public void DisableSelfAndPlanDestroy() { //Emit particles GetComponent <ParticlesDamageRock>().EmitDamageParticles(7, Vector3.zero, transform.position, true); //Disable self GetComponent <SphereCollider>().enabled = false; //Disable waypoint trigger rb.detectCollisions = false; model.SetActive(false); transform.Find("Map Model").gameObject.SetActive(false); //Disable Station if (hasStation) { Destroy(instancedStation, 0f); } //Gravitate toward centre star only (so that the lack of the hitbox doesn't cause it to accelerate to infinity) GetComponent <Gravity>().gravitateTowardCentreStarOnly = true; //Spawn regular asteroids byte type = CBodyAsteroid.GetRandomType(); for (int i = 0; i < 7; i++) { //Spawn GameObject asteroid = control.generation.SpawnAsteroidManually( transform.position, rb.velocity, CBodyAsteroid.GetRandomSize(), type, CBodyAsteroid.HEALTH_MAX ); //Spread out asteroid.transform.position += 16f * new Vector3(Random.value, Random.value, Random.value); } //Play sound GetComponent <AudioSource>().Play(); //Remember is disabled disabled = true; }
private void Update() { //DEBUG //--------------------------------------------------- //Free money if (binds.GetInputDown(binds.bindCheat1)) { currency += 1000; control.ui.UpdateAllPlayerResourcesUI(); control.ui.SetTip("Show me the money."); } //Add ore water /* * if (binds.GetInputDown(binds.bindThrustVectorDecrease)) * { * ore[ORE_WATER] += 1.0; * control.ui.UpdateAllPlayerResourcesUI(); * } */ //Teleport forward /* * if (binds.GetInputDown(binds.bindThrustVectorIncrease)) * { * transform.position += transform.forward * 1e4f; * Debug.Log("Teleported forward: distance to star " + (control.generation.instanceCentreStar.transform.position - transform.position).magnitude); * } */ //Spawn if (binds.GetInputDown(binds.bindCheat2)) { control.generation.SpawnAsteroidManually( transform.position + transform.forward * 3f, rb.velocity, CBodyAsteroid.GetRandomSize(), CBodyAsteroid.GetRandomType(), CBodyAsteroid.HEALTH_MAX ); control.ui.SetTip("Spawned one asteroid."); upgradeLevels[control.commerce.UPGRADE_SEISMIC_CHARGES] = 1; control.ui.SetTip("Seismic charges unlocked."); } /* * if (binds.GetInputDown(binds.bindThrustVectorDecrease)) * { * control.SpawnPlanetoidManually(transform.position + transform.forward * 20f, rb.velocity, null); * Debug.Log("Spawned one planetoid"); * } */ //Slow motion /* * if (binds.GetInput(binds.bindPrimaryFire)) * { * Time.timeScale = 0.01f; * } * else if (!Menu.menuOpenAndGamePaused) * { * Time.timeScale = 1f; * } */ //--------------------------------------------------- //Slow update if (Time.frameCount % 3 == 0) { SlowUpdate(); } //Have the position mount follow the player position positionMount.transform.position = transform.position; //Setup the camera if (!fovSet) { SetCameraSettings(); } //AUDIO UpdateAudio(); //Don't run if paused if (!Menu.menuOpenAndGamePaused) { UpdateGetIfMoving(); //Check if moving at all so that it only has to be checked once per update UpdatePlayerWeapons(); //Shoot stuff UpdatePlayerEngineEffect(); //Set engine glow relative to movement //Fuel decrement if (canAndIsMoving) { vitalsFuel = Math.Max(0.0, vitalsFuel - ((vitalsFuelConsumptionRate / (1 + upgradeLevels[control.commerce.UPGRADE_FUEL_EFFICIENCY])) * Time.deltaTime)); } //Fuel increment (in-situ refinery) bool missingEnoughFuel = vitalsFuel < vitalsFuelMax - REFINERY_FUEL_OUT_RATE; bool hasUpgrade = upgradeLevels[control.commerce.UPGRADE_IN_SITU_FUEL_REFINERY] >= 1; bool hasEnoughOre = ore[ORE_WATER] > REFINERY_ORE_WATER_IN_RATE; bool enoughTimeHasPassed = Time.time > refineryTimeAtLastRefine + REFINERY_TIME_BETWEEN_REFINES; if (missingEnoughFuel && hasUpgrade && hasEnoughOre && enoughTimeHasPassed && control.settings.refine) { ore[ORE_WATER] -= REFINERY_ORE_WATER_IN_RATE; vitalsFuel += REFINERY_FUEL_OUT_RATE; control.ui.UpdatePlayerOreWaterText(); refineryTimeAtLastRefine = Time.time; } //Warn on loop if out of fuel if (vitalsFuel <= 0d && warningUIFlashTime <= 0f) { FlashWarning("Fuel reserves empty"); //Loop smoothly and indefinitely warningUIFlashTime = warningUIFlashTotalDuration * 100f; } //Without this it would be possible for the out of fuel warning to flash indefinitely if you ran out of fuel right as you entered a station if (vitalsFuel > 0d && warningUIText.text == "Fuel reserves empty") { warningUIFlashTime = 0f; warningUIFlashPosition = 1f; } //Update map player ship position transform.parent.Find("Ship Map Model").position = transform.position; /* * transform.parent.Find("Ship Map Model").position.Set( * transform.position.x, * 1000f, * transform.position.z * ); */ } }