protected virtual void SpawnOrbs() { int topNum, botNum; // Number spawning from top/bottom topNum = mSpawnNum / 2; botNum = mSpawnNum - topNum; WorldBehavior world = GetComponent <WorldBehavior>(); for (int i = 0; i < topNum; ++i) { Vector2 spawnPoint = new Vector2(Random.Range(-mSpawnSpread, mSpawnSpread), world.WorldMax.y + (i + 1) * mSpawnStagger); Vector2 spawnDir = new Vector2(Random.Range(-mSpawnSpread / 2f, mSpawnSpread / 2f), -mSpawnSpeed); float spawnMass = Random.Range(mSpawnMinSize, mSpawnMaxSize); ThrowOrb(spawnPoint, spawnDir, spawnMass); } for (int i = 0; i < botNum; ++i) { Vector2 spawnPoint = new Vector2(Random.Range(-mSpawnSpread, mSpawnSpread), world.WorldMin.y - (i + 1) * mSpawnStagger); Vector2 spawnDir = new Vector2(Random.Range(-mSpawnSpread / 2f, mSpawnSpread / 2f), mSpawnSpeed); float spawnMass = Random.Range(mSpawnMinSize, mSpawnMaxSize); ThrowOrb(spawnPoint, spawnDir, spawnMass); } //Added }
void OnMouseUp() { //GlobalBehavior glob = GameObject.Find ("GameStateManager").GetComponent<GlobalBehavior>(); //glob.SetCurrentLevel("Dual Level"); WorldBehavior world = GameObject.Find("GameManager").GetComponent <WorldBehavior>(); world.mode = lvlNum; Active = true; tm.fontSize = 70; renderer.material.color = new Color(95, 153, 207, 255); }
void OnMouseUp() { //GlobalBehavior glob = GameObject.Find ("GameStateManager").GetComponent<GlobalBehavior>(); //glob.SetCurrentLevel("Dual Level"); WorldBehavior world = GameObject.Find("GameManager").GetComponent <WorldBehavior>(); world.resetScore(); int mode = world.mode; Application.LoadLevel(mode); }
IEnumerator WinScreen() { WorldBehavior world = GameObject.Find("GameManager").GetComponent <WorldBehavior>(); if (gameObject.name == "OrangeCity") { GameObject e = (GameObject)Instantiate(blueRoundWin); e.transform.position = new Vector3(0, -50); if (world.blueScore() == 0) { e.GetComponent <RoundCounterBehavior>().mTargetPos = BluePoint1; } else if (world.blueScore() == 1) { e.GetComponent <RoundCounterBehavior>().mTargetPos = BluePoint2; } else { e.GetComponent <RoundCounterBehavior>().mTargetPos = BluePoint3; } } else { GameObject e = (GameObject)Instantiate(orangeRoundWin); e.transform.position = new Vector3(0, -50); if (world.orangeScore() == 0) { e.GetComponent <RoundCounterBehavior>().mTargetPos = OrangePoint1; } else if (world.orangeScore() == 1) { e.GetComponent <RoundCounterBehavior>().mTargetPos = OrangePoint2; } else { e.GetComponent <RoundCounterBehavior>().mTargetPos = OrangePoint3; } } yield return(new WaitForSeconds(4.5f)); if (gameObject.name == "OrangeCity") { world.RoundEnd(2); } // If Blue base destroyed, load Level 3 if (gameObject.name == "BlueCity") { world.RoundEnd(3); } }
void Start() { mHover = (AudioClip)Resources.Load("Sounds/DaikoSingle"); tm = GetComponent <TextMesh>(); // Set Mode: 1 vs 1 & Best of: 1 Round to active WorldBehavior world = GameObject.Find("GameManager").GetComponent <WorldBehavior>(); if (lvlNum == world.mode) { Active = true; tm.fontSize = 70; renderer.material.color = new Color(95, 153, 207, 255); } }
// Use this for initialization void Start() { if (world == null) { world = GameObject.Find("GameManager").GetComponent <WorldBehavior>(); } // Associates sound clips mHover = (AudioClip)Resources.Load("Sounds/DaikoSingle"); // Associates text mesh component tm = GetComponent <TextMesh>(); if (world.isKeyboard(player)) { tm.text = "Keyboard"; } }
void OnMouseUp() { // For button up controls based on the "text" of the button // Main menu - Controls - Credits - Instructions buttons if (GetComponent <TextMesh>().text == "Controls") { Camera.main.transform.position = Controls; } if (GetComponent <TextMesh>().text == "Credits") { Camera.main.transform.position = Credits; } if (GetComponent <TextMesh>().text == "Instructions") { Camera.main.transform.position = Instructions; } if (GetComponent <TextMesh>().text == "Main Menu") { Camera.main.transform.position = MainMenu; } if (GetComponent <TextMesh>().text == "Exit") { Application.Quit(); } if (GetComponent <TextMesh>().text == "Start") { Camera.main.transform.position = Setup; //Application.LoadLevel(1); // Level 1 } // Pause menu buttons if (GetComponent <TextMesh>().text == "Resume") { //resume.Pause(); } if (GetComponent <TextMesh>().text == "Reset") { WorldBehavior world = GameObject.Find("GameManager").GetComponent <WorldBehavior>(); Application.LoadLevel(world.mode); // Level 1 } if (GetComponent <TextMesh>().text == "Quit") { Time.timeScale = 1f; Application.LoadLevel(0); // Menu } }
// Use this for initialization void Start() { if (world == null) { world = GameObject.Find("GameManager").GetComponent <WorldBehavior>(); } // Associates sound clips mHover = (AudioClip)Resources.Load("Sounds/DaikoSingle"); // Associates text mesh component tm = GetComponent <TextMesh>(); buttonNumber = tm.text[0]; // Set Mode: 1 vs 1 & Best of: 1 Round to active if (gameObject.name == "Setup-Rounds1Button") { world.setRounds(buttonNumber); Active = true; tm.fontSize = 70; renderer.material.color = new Color(95, 153, 207, 255); } }
void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.name == "Orb1(Clone)" || other.gameObject.name == "Orb(Clone)" || other.gameObject.name == "Orb2(Clone)" || other.gameObject.name == "Orb3(Clone)" || other.gameObject.name == "Orb4(Clone)" && !isInvulnerable) { WorldBehavior bounds = GameObject.Find("GameManager").GetComponent <WorldBehavior>(); currentHealth -= ((other.gameObject.rigidbody2D.velocity.magnitude * other.gameObject.rigidbody2D.mass) / 100.0f); // Experimental audio play //GameObject go = new GameObject("Audio: " + mBaseHit.name); //AudioSource source = go.AddComponent<AudioSource>(); //source.volume = 1; //source.Play(); //Destroy(go, mBaseHit.length); Play(mBaseHit, 1f, 1); Destroy(other.gameObject); AsteroidSpawner spawner = GameObject.Find("GameManager").GetComponent <AsteroidSpawner>(); spawner.Orbs--; FireControl(); } }
/*private AudioClip mHitLowMid; * private AudioClip mHitMid; * private AudioClip mHitMidHigh;*/ #endregion void Start() { // Get Prefab WorldBehavior world = GameObject.Find("GameManager").GetComponent <WorldBehavior>(); if (world.mode == 1) { powerUpDroprate = 0.13f; } else if (world.mode == 2) { powerUpDroprate = 0.09f; } else if (world.mode == 3) { powerUpDroprate = 0.10f; } if (mWorld == null) { mWorld = GameObject.Find("GameManager").GetComponent <AsteroidSpawner>(); } if (mPowerUp == null) { mPowerUp = (GameObject)Resources.Load("Prefabs/PowerUp"); } if (mSpeedUp == null) { mSpeedUp = (GameObject)Resources.Load("Prefabs/SpeedUp"); } if (mGrowUp == null) { mGrowUp = (GameObject)Resources.Load("Prefabs/GrowUp"); } if (mSpikeUp == null) { mSpikeUp = (GameObject)Resources.Load("Prefabs/SpikeUp"); } // Set mass and adjust the scale to match float mass = rigidbody2D.mass; float diameter = Mathf.Sqrt(mass) * kScale; transform.localScale = new Vector3(diameter, diameter); mWorld.Orbs++; mInvul = true; mSpawnTime = Time.realtimeSinceStartup; // Orb collide sounds //mHit = (AudioClip)Resources.Load("Sounds/OrbCollide"); // Orb colliding sound (original) mHitLow = (AudioClip)Resources.Load("Sounds/energy orb low"); // Orb colliding sound (Low) /*mHitLowMid = (AudioClip)Resources.Load("Sounds/energy orb low mid"); // Orb colliding sound (Low-Mid) * mHitMid = (AudioClip)Resources.Load("Sounds/energy orb mid"); // Orb colliding sound (Mid) * mHitMidHigh = (AudioClip)Resources.Load("Sounds/energy orb mid high"); // Orb colliding sound (Mid-High) * * explosion = Resources.Load("Prefabs/OrbExplosion") as GameObject;*/ if (explosion == null) { explosion = Resources.Load("Prefabs/OrbExplosion") as GameObject; } }
void Update() { if (pause.GameIsPaused()) { kSpeedBegin += Time.time; kGrowBegin += Time.time; mWaveBlastChargeTime += Time.time; } if (mSpeedUp == true) { if (speedupParticle != null) { speedupParticle.transform.position = transform.position; } if (Time.realtimeSinceStartup - kSpeedBegin > kSpeedEnd) { mSpeedUp = false; kHeroSpeed = kDefaultHeroSpeed; rigidbody2D.mass = kDefaultMass; kShotgunBlastSpawnInterval = kShotgunBlastDefaultSpawnInterval; kWaveBlastSpawnInterval = kWaveBlastDefaultSpawnInterval; Destroy(speedupParticle); } } if (mGrowUp == true) { if (growupParticle != null) { growupParticle.transform.position = transform.position; } if (Time.realtimeSinceStartup - kGrowBegin > kGrowEnd) { mGrowUp = false; kHeroSpeed = kDefaultHeroSpeed; transform.localScale -= new Vector3(mGrowScale, mGrowScale, 0.0f); Destroy(growupParticle); rigidbody2D.mass = kDefaultMass; } } if (mSpikeUp == true) { if (spikeupParticle != null) { spikeupParticle.transform.position = transform.position; } if (Time.realtimeSinceStartup - kSpikeBegin > kSpikeEnd) { mSpikeUp = false; } } //No longer necessary. Maybe. //DieCheck(); // Check if ship is dead WorldBehavior WorldBehavior = GameObject.Find("GameManager").GetComponent <WorldBehavior>(); WorldBehavior.ClampAtWorldBounds(this.gameObject, this.renderer.bounds); if (isController == false && !respawn.GameIsPaused() && !count.GetIsCounting()) { // Ship mouse aim mousedir = WorldBehavior.mMainCamera.ScreenToWorldPoint(Input.mousePosition) - transform.position; mousedir.Normalize(); transform.up = mousedir; if (Input.GetAxisRaw("Horizontal") > 0f || Input.GetAxisRaw("Horizontal") < 0f || Input.GetAxisRaw("Vertical") > 0f || Input.GetAxisRaw("Vertical") < 0f) { Vector2 move = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); rigidbody2D.AddForce(move.normalized * kHeroSpeed); } // Wave Blast single click if (Input.GetButtonDown("Fire1")) { StartWaveBlast(); StartCoroutine("WaveBlastChargeCoroutine"); mWaveBlastChargeTime = Time.realtimeSinceStartup; } // Wave Blast Charge fire if (Input.GetButtonUp("Fire1")) { StopCoroutine("WaveBlastChargeCoroutine"); StopChargeParticle(); FireChargedWaveBlast(); } // Shotgun Blast single click if (Input.GetButtonDown("Fire2")) { StartShotgunBlast(); StartCoroutine("ShotgunBlastChargeCoroutine"); } // Shotgun Blast charge control if (Input.GetButtonUp("Fire2")) { StopCoroutine("ShotgunBlastChargeCoroutine"); StopChargeParticle(); FireChargedShotgunBlast(); } } else if (isController == true && !respawn.GameIsPaused() && !count.GetIsCounting()) { // Player movement //Vector2 move = new Vector2(Input.GetAxis(controller + "Horizontal"), Input.GetAxis(controller + "Vertical")); Vector2 move = new Vector2(Input.GetAxisRaw(controller + "Horizontal"), Input.GetAxisRaw(controller + "Vertical")); rigidbody2D.AddForce(move.normalized * kHeroSpeed); // Right Stick Aimto transform.up += new Vector3(Input.GetAxis(controller + "RHorz"), Input.GetAxis(controller + "RVert"), 0) * Time.smoothDeltaTime * 15f; // Wave blast single click if (Input.GetButtonDown(controller + "Fire1")) { StartWaveBlast(); StartCoroutine("WaveBlastChargeCoroutine"); mWaveBlastChargeTime = Time.realtimeSinceStartup; } // Wave blast charge if (Input.GetButtonUp(controller + "Fire1")) { StopCoroutine("WaveBlastChargeCoroutine"); StopChargeParticle(); FireChargedWaveBlast(); } // Shotgun single click if (Input.GetButtonDown(controller + "Fire2")) // this is Right-Control { StartShotgunBlast(); StartCoroutine("ShotgunBlastChargeCoroutine"); } // Shotgun charge if (Input.GetButtonUp(controller + "Fire2")) { StopCoroutine("ShotgunBlastChargeCoroutine"); StopChargeParticle(); FireChargedShotgunBlast(); } } }