public void Update() { if (Input.GetKeyDown(KeyCode.Return)) { if (newGame) { sceneToLoad = "TitlePage" + GGS.SCENESUFFIX; } else { sceneToLoad = "SampleScene" + GGS.SCENESUFFIX; GGS.NewLevel(); } SceneManager.LoadScene(sceneToLoad); } if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } if (Input.GetKeyDown(KeyCode.F10)) { GGS.newScore = LevelThreshold(GGS.levelNumber); GGS.capsuleLaunched = true; GGS.capsuleSurvived = true; GenerateText(); } if (Input.GetKeyDown(KeyCode.F1)) { DoDebug(); } }
// Update is called once per frame void Update() { for (int _count = 0; _count < ovals; _count++) { // each frame, we pick two pixels from each oval... GameObject _thisPixel = oval[_count][processed]; _thisPixel.transform.position = Helper.rotateVec2(_thisPixel.transform.position - transform.position, processedAngle) + (Vector2)transform.position; _thisPixel = oval[_count][(pointsPerOval - processed) - 1]; _thisPixel.transform.position = Helper.rotateVec2(_thisPixel.transform.position - transform.position, processedAngle) + (Vector2)transform.position; } processed++; if (processed >= (pointsPerOval / 2)) { processed = 0; } if (Input.GetKeyDown(KeyCode.Return)) { GGS.NewGame(); Application.targetFrameRate = 60; SceneManager.LoadScene("SampleScene" + GGS.SCENESUFFIX); } if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } }
public void OnTriggerEnter2D(Collider2D collision) { if (destroyed) { return; } GameObject _other = collision.gameObject; string _otherTag = _other.tag; if (_otherTag == "EnemyShip") { enemyExplodeSound.Play(); // add the score manually, as the energy code only does it on 'natural' object destruction; GGS.AddScore(2); // ship collision with shields off is a bad thing. energy.DoDamage(150, 0, true); GameObject _explo = Instantiate(enemyExplosion, _other.transform.position, _other.transform.rotation); Rigidbody2D _explorb = _explo.GetComponent <Rigidbody2D>(); ManagedMob _enemyManager = _other.GetComponent <ManagedMob>(); _explorb.velocity = _enemyManager.velocity(); Destroy(_other); } if (_otherTag == "EnemyBullet") { hitSound.Play(); energy.DoDamage(_other.GetComponent <bullet>().payloadEnergy, 0, true); Instantiate(bulletDeath, _other.transform.position, _other.transform.rotation); Destroy(_other); } }
public void DoDamage(float damage, int score, bool critical = false) { // Some damage will *really* hurt us, regardless of shielding // (not incremental, so if we're already damaged, we stop checking) // (Do this first - if the damage wounds us, we want the effect to start NOW) if (critical) { if ((Random.Range(0, 100) < damageChance) && (!damaged)) { // set us as damaged, and find out how long Scotty's going to take to fix it. damaged = true; damageRepair = Time.time + Random.Range(5, 10); } } // if we've got a shield... if (shield != null) { //... and it's switched on, and we're not hurt if ((shield.shieldEnabled) && (!damaged)) { // ameliorate some of the damage; damage *= shield.shieldReducer; } } energy -= damage; if (energy <= 0) { GGS.AddScore(score); } }