// Update is called once per frame void Update() { if (volcStatus == volc.moving && selfGO.transform.position.x > -6) { this.transform.position += Time.deltaTime * new Vector3(-speed, 0f, 0f); } else if (volcStatus == volc.moving && selfGO.transform.position.y <= 0) { GameObject.FindGameObjectWithTag("FlrCeil").GetComponent <FloorScroller>().animated = 2; volcStatus = volc.shooting; startTime = Time.time; delayTime = Time.time; } else if (volcStatus == volc.shooting && (Time.time - startTime) < dwellTime) { if (Time.time - delayTime > timeBtwShots) { foreach (GameObject v in volcs) { if (v.tag == "Volcano") { MountainBehavior vFire = v.GetComponent <MountainBehavior>(); vFire.callFire(); } } delayTime = Time.time; } } else if (volcStatus == volc.shooting && (Time.time - startTime) > dwellTime) { volcStatus = volc.leaving; } else if (volcStatus == volc.leaving) { GameObject.FindGameObjectWithTag("FlrCeil").transform.position += Time.deltaTime * new Vector3(-speed, 0f, 0f); this.transform.position += Time.deltaTime * new Vector3(-speed, 0f, 0f); } }
void Boom() { // Fix our angle and stop moving rigidbody2D.velocity = Vector2.zero; rigidbody2D.fixedAngle = true; rigidbody2D.isKinematic = true; // Explode ourselves animator.SetBool("Exploded", true); // Set spawner to stop spawning GameObject[] spawners = GameObject.FindGameObjectsWithTag("Respawn"); for (int i = 0; i < spawners.Length; i++) { ObstacleSpawner os = spawners[i].GetComponent <ObstacleSpawner>(); if (os != null) { os.IsSpawning = false; } MountainSpawner ms = spawners[i].GetComponent <MountainSpawner>(); if (ms != null) { ms.IsSpawning = false; } } // Stop moving Obstacles GameObject[] Obstacles = GameObject.FindGameObjectsWithTag("Obstacle"); for (int i = 0; i < Obstacles.Length; i++) { ObstacleBehavior ob = Obstacles[i].GetComponent <ObstacleBehavior>(); if (ob != null) { ob.speed = 0; } } // Set ourselves as exploded hasExploded = true; // Stop clouds GameObject particles = GameObject.FindGameObjectWithTag("Particles"); if (particles != null) { particles.GetComponent <ParticleSystem>().Pause(); } // Stop mountains GameObject[] Mountains = GameObject.FindGameObjectsWithTag("Mountains"); for (int i = 0; i < Mountains.Length; i++) { MountainBehavior ob = Mountains[i].GetComponent <MountainBehavior>(); if (ob != null) { ob.BaseSpeed = 0; } } // Stop Music GameObject music = GameObject.FindGameObjectWithTag("Music"); if (music != null) { music.GetComponent <AudioSource>().Stop(); Destroy(music); } // Flash the screen flasher.StartFlash(); // Play Explosion Sound audio.clip = explode; audio.Play(); // Show menu GameObject.FindGameObjectWithTag("RestartMenu").GetComponent <RestartMenu>().Show(); }