Exemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     try
     {
         habilidadCombustible = GetComponent(combustibles[0].ToString()) as HabilidadCombustible;
         combustibleActivo    = 0;
     }
     catch
     {
         throw new Exception("Fallo al cargar habilidad de combustible");
     }
 }
Exemplo n.º 2
0
 private void AsignarCombustibleInicial()
 {
     //asignar el combustible que elija el jugador
     try
     {
         //habrá que cambiarlo para poner el combustible que elija el jugador
         habilidadCombustible = GetComponent(combustibles[0].ToString()) as HabilidadCombustible;
         combustibleActivo    = 0;
     }
     catch
     {
         throw new Exception("Fallo al cargar habilidad de combustible");
     }
 }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        //código cutre para pruebas

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            try
            {
                combustibleActivo -= 1;
                if (combustibleActivo < 0) //comprueba que no se salga del límite del array
                {
                    combustibleActivo = combustibles.Count - 1;
                }
                habilidadCombustible = GetComponent(combustibles[combustibleActivo].ToString()) as HabilidadCombustible;
            }
            catch
            {
                throw new Exception("Fallo al cambiar habilidad de combustible");
            }
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            try
            {
                combustibleActivo += 1;
                Debug.Log(combustibles.Count);
                if (combustibleActivo >= combustibles.Count) //comprueba que no se salga del límite del array
                {
                    combustibleActivo = 0;
                }
                habilidadCombustible = GetComponent(combustibles[combustibleActivo].ToString()) as HabilidadCombustible;
            }
            catch
            {
                throw new Exception("Fallo al cambiar habilidad de combustible");
            }
        }
        else if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            habilidadCombustible.Use();
        }
    }
Exemplo n.º 4
0
    private void FuelManager()
    {
        if (PauseManager.inPause)
        {
            return;
        }

        combustible = habilidadCombustible.combustible;
        Vector3 locVel = GetComponent <NaveController>().modelTransform.InverseTransformDirection(rb.velocity);

        if (locVel.z <= 2)
        {
            trail.enabled = false;
        }
        else
        {
            trail.enabled = true;
        }

        if (trail.enabled)
        {
            trail.material.color = habilidadCombustible.combustible.color;
        }

        Direction fuelSide = ChangeFuelManager();

        //cambiar entre los distintos combustibles
        if (fuelSide == Direction.Left)
        {
            try
            {
                combustibleActivo -= 1;
                if (combustibleActivo < 0) //comprueba que no se salga del límite del array
                {
                    combustibleActivo = combustibles.Count - 1;
                }
                habilidadCombustible = GetComponent(combustibles[combustibleActivo].ToString()) as HabilidadCombustible;
            }
            catch
            {
                throw new Exception("Fallo al cambiar habilidad de combustible");
            }
        }
        if (fuelSide == Direction.Right || combustible.currentAmmount <= 0)
        {
            //print("entra en right");
            try
            {
                combustibleActivo += 1;
                if (combustibleActivo >= combustibles.Count) //comprueba que no se salga del límite del array
                {
                    combustibleActivo = 0;
                }
                habilidadCombustible = GetComponent(combustibles[combustibleActivo].ToString()) as HabilidadCombustible;
            }
            catch
            {
                throw new Exception("Fallo al cambiar habilidad de combustible");
            }
        }
        if (inputManager.UseFuel())
        {
            habilidadCombustible.Use();
        }
    }