Unity Spain

Post Antiguos => General (Antiguo) => Mensaje iniciado por: ramunda en Julio 07, 2015, 11:56:58 PM

Título: Alguien que sen tan amable podría convertir esto?
Publicado por: ramunda en Julio 07, 2015, 11:56:58 PM
Muy buenas a todos , después de varios meses de un proyecto a base de tortas  , me he encontrado que no puedo seguir por cualpa de un script que esta en C# y deberia estar en Java.
 
Si alguien fuese tan amable de convertírmelo en java le estaría eternamente agradecido y seguiria mi proyecto.
 
Dejo el script aqui por si alguien se quiere tomar la molestia...gracias de antemano.

Título: Alguien que sen tan amable podría convertir esto?
Publicado por: GSG3D en Julio 08, 2015, 12:14:01 AM
Digo, eso ya no esta en JavaScript?
Título: Alguien que sen tan amable podría convertir esto?
Publicado por: Howling Wolf en Julio 08, 2015, 12:35:34 AM
Te equivocaste, ese ya está en javascript xD
Título: Alguien que sen tan amable podría convertir esto?
Publicado por: ramunda en Julio 08, 2015, 11:04:14 AM
Lol se me va la perola mogollon ahora pongo el bueno XDDDD

using UnityEngine;
using System.Collections;
public class PlayerInfo : MonoBehaviour {

public GameObject healthBottle;
public GameObject player;
public AudioClip deathClip;
public AudioClip deathClip2;
public float length;
//public AnimationClip Die;
int health = 100;
int damageCount = 0;
int currentHealth;
bool playerFighting;
public GUIText healthbar;
float timer = 0.0f;
float healthTimer = 0.0f;
bool healthShouldRespawn = false;

public bool muerto = false;
public GameObject tuUI;

void Start () {
   currentHealth = health;
   tuUI.SetActive(false);
   }

void Update () {
   Cursor.visible = false;
   print("player in combat? " + playerFighting);
   if(!playerFighting){
      print("player is not fighting");
      if(currentHealth != 100){
         timer += Time.deltaTime;
         print ("timer: " + timer);
         if(timer > 90.0f){
            currentHealth += 10;
            timer = 0.0f;
         }
      }
   }
   else
   {
      if(currentHealth <= 0 && !muerto ){
         muerto = true;
         GetComponent<AudioSource>().PlayOneShot(deathClip);length =7f;
         GetComponent<FPSInputController>().enabled = false;
         GetComponent<CharacterController>().enabled = false;
   
      }
   }
   healthbar.text = "Vida " + currentHealth + " / 100";
   
   if(healthShouldRespawn)
   {
      healthTimer += Time.deltaTime;
      
      if(healthTimer > 5.0f)
      {
         healthBottle.gameObject.SetActive(true);
         healthTimer = 0.0f;
      }
   }
   
   if(muerto){
      //var anim = GetComponent<Animation>();
      //anim.AddClip(Die,"attackbo");
      //anim.Play("attackbo");
      GetComponent<AudioSource>().PlayOneShot(deathClip);length =7f;
      Cursor.visible = false;
      tuUI.SetActive(true);
      if(Input.GetKeyDown(KeyCode.Space)){
         Respawn();
      }
   }
   
}

public void ApplyDamage(int damage){
   damageCount = damageCount + damage;
   if(damageCount == 100){
      if(currentHealth < 0){
         currentHealth = 0;
      }
      currentHealth = currentHealth - 30;
      GetComponent<AudioSource>().PlayOneShot(deathClip);length =7f;
      healthbar.text = "Health " + currentHealth + " / 100";
      damageCount = 0;
   }
   
   print(currentHealth);
}

public void playerInCombat(int combat){
   if(combat == 1){
      playerFighting = true;
   }
   else
   {
      playerFighting = false;
   }
}

public void Respawn(){
   tuUI.SetActive(false);
   muerto = false;
   transform.position = new Vector3(Random.Range(50.0f, 120.0f), 0, Random.Range(10.0f, 200.0f));
   GetComponent<FPSInputController>().enabled = true;
   GetComponent<CharacterController>().enabled = true;
   ///GetComponent<disparosyrecargos>().enabled = true;
   ////GetComponent<MouseLook>().enabled = true;
   currentHealth = 100;
}

void OnTriggerEnter(Collider item){
   if(item.gameObject.tag == "PlayerHealthBottle")
   {
      if(currentHealth < 100)
      {
         currentHealth = currentHealth + 50;
         item.gameObject.SetActive(false);
         healthShouldRespawn = true;
      }
   }
}
}
Título: Alguien que sen tan amable podría convertir esto?
Publicado por: ramunda en Julio 08, 2015, 02:11:19 PM
Cita de: GSG3D date=1436307241Digo, eso ya no esta en JavaScript?
 
Siiii uf se me va el perolo GSG3D , perdon mas abajo puse el bueno