// 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(); } }
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(); } }