void Awake() { _instance = this; _maxEnergyValue = 620; _newEnergyLevel = 0; _isIncreasingEnergy = false; }
public void ResetEnergy() { _instance = this; _maxEnergyValue = 620; _newEnergyLevel = 0; _isIncreasingEnergy = false; }
// Use this for initialization private void Start() { //Getting the reference to the health and armor component for our player switch (this.playerID) { case Players.P1: this.ourEnergy = PlayerShipController.p1ShipRef.ourEnergy; break; case Players.P2: this.ourEnergy = PlayerShipController.p2ShipRef.ourEnergy; break; default: this.ourEnergy = PlayerShipController.p1ShipRef.ourEnergy; break; } //Looping through all of our energy sliders to make sure they show the correct max value foreach (Slider energySlider in this.energySliders) { energySlider.maxValue = this.ourEnergy.maxEnergy; } }
//Function called when this object is created private void Awake() { //Getting the movement component references this.ourFreeMovement = this.GetComponent <FreeMovementFlight>(); this.ourRailMovement = this.GetComponent <RailMovementFlight>(); //Getting our controller input based on which player this is switch (this.playerController) { case Players.P1: //Making sure there's not already a static reference to the p1 ship if (p1ShipRef == null) { p1ShipRef = this; this.ourController = ControllerInputManager.P1Controller; this.ourCustomInputs = CustomInputSettings.globalReference.p1Inputs; } //If there's already a static reference for the p1 ship and not one for the p2 ship else if (p2ShipRef == null) { this.playerController = Players.P2; p2ShipRef = this; this.ourController = ControllerInputManager.P2Controller; this.ourCustomInputs = CustomInputSettings.globalReference.p2Inputs; } //If there are already static references to both ships, we disable this object { this.gameObject.SetActive(false); } break; case Players.P2: //Making sure there's not already a static reference to the p2 ship if (p2ShipRef == null) { p2ShipRef = this; this.ourController = ControllerInputManager.P2Controller; this.ourCustomInputs = CustomInputSettings.globalReference.p2Inputs; } //If there's already a static reference for the p2 ship, we disable this object else { this.gameObject.SetActive(false); } break; default: //Making sure there's not already a static reference to the p1 ship if (p1ShipRef == null) { p1ShipRef = this; this.ourController = ControllerInputManager.P1Controller; this.ourCustomInputs = CustomInputSettings.globalReference.p1Inputs; } //If there's already a static reference for the p1 ship and not one for the p2 ship else if (p2ShipRef == null) { this.playerController = Players.P2; p2ShipRef = this; this.ourController = ControllerInputManager.P2Controller; this.ourCustomInputs = CustomInputSettings.globalReference.p2Inputs; } //If there are already static references to both ships, we disable this object { this.gameObject.SetActive(false); } break; } //Passing our controller input to our movement mechanic scripts this.ourFreeMovement.ourShip = this; this.ourRailMovement.ourShip = this; //Getting our health and armor component reference this.ourHealth = this.GetComponent <HealthAndArmor>(); //Getting our energy component reference this.ourEnergy = this.GetComponent <ShipEnergy>(); //Looping through all of our weapons, wings and engines to tell them what player ID we are if (this.playerController == Players.P1) { this.mainWeapon.objectIDType = AttackerID.Player1; this.secondaryWeapon.objectIDType = AttackerID.Player1; this.shipCockpit.objectIDType = AttackerID.Player1; } else { this.mainWeapon.objectIDType = AttackerID.Player2; this.secondaryWeapon.objectIDType = AttackerID.Player2; this.shipCockpit.objectIDType = AttackerID.Player2; } foreach (ShipWingLogic wing in this.shipWings) { if (this.playerController == Players.P1) { wing.objectIDType = AttackerID.Player1; } else if (this.playerController == Players.P2) { wing.objectIDType = AttackerID.Player2; } } foreach (ShipEngineLogic engine in this.shipEngines) { if (this.playerController == Players.P1) { engine.objectIDType = AttackerID.Player1; } else if (this.playerController == Players.P2) { engine.objectIDType = AttackerID.Player2; } } //Getting the default pitch for the engine sound effect this.defaultPitch = this.engineSoundEmitter.ownerAudio.pitch; }