public SystemData LoadSystemData(string target) { WipeCurrentSystem(); TextAsset systemText = Resources.Load <TextAsset>("SystemData/" + target); SystemData data = JsonUtility.FromJson <SystemData>(systemText.text); SetSystemManager(data); for (var x = 0; x < data.planets.Count; x++) { TextAsset newPlanetText = Resources.Load <TextAsset>("PlanetData/" + data.systemName + "/" + data.planets[x]); Planet newPlanet = JsonUtility.FromJson <Planet>(newPlanetText.text); planetList.Add(newPlanet); planetManager.BuildPlanet(newPlanet); } InitializeOtherShips(); _guiBehaviour.ReceiveMessage("Entered system: " + systemName, false); _guiBehaviour.ReceiveMessage("System owner: " + systemOwner, false); Invoke("CheckArea", 0.75f); return(data); }
void AddMission(string missionPath) { Mission loadedMission = Resources.Load(missionPath) as Mission; newMission = Instantiate(loadedMission); missions.Add(newMission); _guiBehaviour.ReceiveMessage("MISSION: " + newMission.description, true); }
public void TakeDamage(int damage, GameObject damageSource) { if (!invincibilityFramesOn) { InvincibilityOn(); Invoke("InvincibilityOff", invincibilityFramesTime); if (shipShieldCurrent > damage) { shipShieldCurrent -= damage; } else if (shipShieldCurrent < damage) { shipHullCurrent -= (damage - shipShieldCurrent); shipShieldCurrent = 0; } else if (shipShieldCurrent <= 0) { shipHullCurrent -= damage; } if (_guiManager != null) { _guiManager.SetBarAmount("hull", (shipHullCurrent / shipHullMax)); _guiManager.SetBarAmount("shield", (shipShieldCurrent / shipShieldMax)); } if (shipHullCurrent <= 0) { _guiBehaviour.ReceiveMessage(this.name + " has been destroyed.", true); _localShipsManager.ShipWasKilled(this.gameObject, damageSource); Death(); } } if (_ai != null) { _ai.IWasHit(damageSource); _localShipsManager.AllAggroTarget(damageSource, this.gameObject.tag); } }
// Update is called once per frame void Update() { if (_gameStateManager.currentMode != GameMode.Menu && _gameStateManager.currentMode != GameMode.Hyperspace) { if (Input.GetButtonDown("Jump")) { //Cancel hyperspace jump. } if (_gameStateManager.currentMode != GameMode.Menu && _gameStateManager.currentMode != GameMode.Hyperspace) { /* Hyperspace Jump */ if (Input.GetButtonDown("Jump") && _gameStateManager.currentMode != GameMode.Hyperspace && (Mathf.Abs(playerShip.transform.position.x) + Mathf.Abs(playerShip.transform.position.y) > validJumpDistance)) { if (_gameStateManager.targetSystem != null) { _gameStateManager.currentMode = GameMode.Hyperspace; //shipState.AddState("Hyperspace Jump", 3f); _gameStateManager.Invoke("HyperspaceJump", 1.8f); _cameraBehaviour.StartCoroutine("BackdropFadeOut"); } else { _guiBehaviour.ReceiveMessage("Invalid hyperspace target.", false); } } else if (Input.GetButtonDown("Jump")) { _guiBehaviour.ReceiveMessage("Too close to system center.", false); } } /*Movement while Defenses are active*/ if (Input.GetAxis("Horizontal") <= -defenseActivationThreshold) { shipChassis.shipDefenses[0].DefenseRotateLeft(); shipChassis.shipDefenses[1].DefenseRotateLeft(); } else if (Input.GetAxis("Horizontal") >= defenseActivationThreshold) { shipChassis.shipDefenses[0].DefenseRotateRight(); shipChassis.shipDefenses[1].DefenseRotateRight(); } /*Thrust and Brakes*/ if (Input.GetAxis("Vertical") > 0) { shipChassis.thrustersOn = true; shipChassis.brakesOn = false; } else if (Input.GetAxis("Vertical") < 0) { shipChassis.thrustersOn = false; shipChassis.brakesOn = true; } else { shipChassis.thrustersOn = shipChassis.brakesOn = false; } /*Activating/Deactivating Defenses L R*/ if (shipState.GetTopState().canDefend == true) { if (Input.GetButtonDown("DefenseL")) { shipChassis.FireDefense(0); } if (Input.GetButtonDown("DefenseR")) { shipChassis.FireDefense(1); } } /* Releasing our buttons is outside the canDefend so they don't get stuck * down */ if (Input.GetButtonUp("DefenseL")) { shipChassis.ReleaseDefense(0); } if (Input.GetButtonUp("DefenseR")) { shipChassis.ReleaseDefense(1); } /*Rotation*/ //Kept separate from defenses below in order to ensure rotates cut off when //axis input is zero. shipChassis.horizontalInput = -Input.GetAxis("Horizontal"); /* Firing Weapons */ if (Input.GetButtonDown("Fire1")) { shipChassis.FireWeapon(0); } if (Input.GetButtonUp("Fire1")) { shipChassis.ReleaseWeapon(0); } if (Input.GetButtonDown("Fire2")) { shipChassis.shipWeapons[1].FireButtonPressed(); } if (Input.GetButtonUp("Fire2")) { shipChassis.shipWeapons[1].FireButtonReleased(); } if (Input.GetButtonDown("Fire3")) { shipChassis.shipWeapons[2].FireButtonPressed(); } if (Input.GetButtonUp("Fire3")) { shipChassis.shipWeapons[2].FireButtonReleased(); } /* GUI controls */ if (Input.GetButtonDown("MoveLogs") && _guiManager != null) { _guiManager.MoveLogs(); } /* Camera Control */ if (Input.GetKey("+") || (Input.GetKey("="))) { _cameraBehaviour.ZoomIn(); } if (Input.GetKey("-")) { _cameraBehaviour.ZoomOut(); } } }