void OnDeath() { playerControllerScript.addScore(10 + zombieSpawnerScript.getCurrentRound() * 2); //Increase Current Score int randomObject = (int)Random.Range(0f, 8f); //Random Number to Determine if and what you get if (randomObject == 0) { pS.InstantiateAPS("HealthPack", transform.position, transform.rotation); } else if (randomObject == 1) { pS.InstantiateAPS("ScrapsPack", transform.position, transform.rotation); } else if (randomObject == 2) { pS.InstantiateAPS("AmmoPack", transform.position, transform.rotation); } //circleCollider.enabled = false; //body.isKinematic = true;//Set to Kinematic so no collisions of any kind occur //dead = false; int bloodPoolChance = (int)Random.Range(0f, 10f); //Random Number to Determine blood pool gets spawned if (bloodPoolChance >= 0 && bloodPoolChance <= 2) { pS.InstantiateAPS("BloodPool", transform.position, transform.rotation); } //playerControllerScript.addScraps(10+zombieSpawnerScript.getCurrentRound()*2); playerControllerScript.addScraps(10 + zombieSpawnerScript.getCurrentRound()); playerControllerScript.killedZombie(); //Add one to total zombies killed in whole play time zombieSpawnerScript.deadZombie(); // Add one to total zombies killed this round gameObject.DestroyAPS(); //spawnAI.Remove();//Destroy (this.gameObject);//Replace with DeSpawn }
public void flood() { if (zombieSpawnerScript.getCurrentRound() % 2 == 0) { spawnPool(); } if (zombieSpawnerScript.getCurrentRound() % 3 == 0) { spawnPool(); } }
public void displaySecondaryButtons() { drawEquipedSquare(); //---------------------------------------Secondaries Start //if(secondariesPage == 1){ /// Barricade Section Start /*if(survivorButtonsController.getEngineerSurvivors() > 0){ * if(spawnerScript.currentRound >= 2){ * if(barricadePurchased == 1){ * if (GUI.Button (new Rect (65, yOne, 120, 30), "Equip Barricade")){ * secondaryController.equipSecondary(0); * } * if(secondaryController.getStock(0) == 0){ * if (playerScript.getCurrentScraps() < 100) { * GUI.enabled = false;//Grey out GUI * if (GUI.Button (new Rect (55, yOne+35, 135, 20), "Not Enough Scrap")) {} * } else if (GUI.Button (new Rect (55, yOne+35, 135, 20), "Buy More: 100 scrap")) { * if (playerScript.getCurrentScraps() >= 100) { * playerScript.subtractScraps(100); * secondaryController.addStock(0,1); * } * } * }else { * GUI.enabled = false;//Grey out GUI * if (GUI.Button (new Rect (55, yOne+35, 135, 20), "Max Carrying")) {} * } * GUI.enabled = true; * }else { * if (playerScript.getCurrentScraps() < 500) { * GUI.enabled = false; * if (GUI.Button (new Rect (65, yOne, 120, 30), "Not Enough Scrap\n500 Scrap")) {} * } else { * if (GUI.Button (new Rect (65, yOne, 120, 30), "Unlock Barricade\n500 Scrap")) { * playerScript.subtractScraps(500); * barricadePurchased = 1; * } * } * } * }else { * GUI.enabled = false; * if (GUI.Button (new Rect (65, yOne, 120, 20), "Not Round 2")){}//Button for Round * } * }else { * GUI.enabled = false; * if (GUI.Button (new Rect (65, yOne, 120, 20), survivorButtonsController.getEngineerSurvivors() + "/1 Engineers")){}//Button for engineer surivors * } * GUI.enabled = true; * /// Barricade Section End */ /// Land Mine Section Start if (survivorButtonsController.getEngineerSurvivors() > 1) { if (zombieSpawnerScript.getCurrentRound() >= 2) { if (landMinePurchased == 1) { if (secondaryController.getCurrentlyEquipedSecondary() == 1) { GUI.enabled = false; } if (GUI.Button(new Rect(65, yTwo, 120, 30), "Equip LandMine")) { secondaryController.equipSecondary(1); soundControllerScript.playSFX("gunCock"); } GUI.enabled = true; if (playerScript.getCurrentScraps() < 249) { GUI.enabled = false; //Grey out GUI if (GUI.Button(new Rect(55, yTwo + 35, 135, 20), "Not Enough Scrap")) { } } else if (GUI.Button(new Rect(55, yTwo + 35, 135, 20), "Buy More: 250 scrap")) { playerScript.subtractScraps(250); secondaryController.addStock(1, 1); soundControllerScript.playSFX("buy"); } GUI.enabled = true; } else { if (playerScript.getCurrentScraps() < 499) { GUI.enabled = false; if (GUI.Button(new Rect(65, yTwo, 120, 30), "Not Enough Scrap\n500 Scrap")) { } } else { if (GUI.Button(new Rect(65, yTwo, 120, 30), "Unlock LandMine\n500 Scrap")) { playerScript.subtractScraps(500); landMinePurchased = 1; soundControllerScript.playSFX("buy"); secondaryController.equipSecondary(1); soundControllerScript.playSFX("gunCock"); } } } } else { GUI.enabled = false; if (GUI.Button(new Rect(65, yTwo, 120, 20), "Not Round 2")) { } //Button for Round } } else { GUI.enabled = false; if (GUI.Button(new Rect(65, yTwo, 120, 20), survivorButtonsController.getEngineerSurvivors() + "/2 Engineers")) { } //Button for engineer surivors } GUI.enabled = true; /// Land Mine Section End /// Bio-Bomb if (survivorButtonsController.getEngineerSurvivors() > 3) { if (zombieSpawnerScript.getCurrentRound() >= 2) { if (bioBombPurchased == 1) { if (secondaryController.getCurrentlyEquipedSecondary() == 2) { GUI.enabled = false; } if (GUI.Button(new Rect(65, yThree, 120, 30), "Equip Bomb")) { secondaryController.equipSecondary(2); soundControllerScript.playSFX("gunCock"); } GUI.enabled = true; //if(secondaryController.getStock(2) == 0){ if (playerScript.getCurrentScraps() < 549) { GUI.enabled = false; //Grey out GUI if (GUI.Button(new Rect(55, yThree + 32, 135, 20), "Not Enough Scrap")) { } } else if (GUI.Button(new Rect(55, yThree + 35, 135, 20), "Buy More: 550 scrap")) { //if (playerScript.getCurrentScraps() >= 549){ playerScript.subtractScraps(550); secondaryController.addStock(2, 1); soundControllerScript.playSFX("buy"); //} } //}else { // GUI.enabled = false;//Grey out GUI // if (GUI.Button (new Rect (55, yThree+35, 135, 20), "Max Carrying")) {} //} GUI.enabled = true; } else { if (playerScript.getCurrentScraps() < 599) { GUI.enabled = false; if (GUI.Button(new Rect(65, yThree, 120, 30), "Not Enough Scrap\n600 Scrap")) { } } else { if (GUI.Button(new Rect(65, yThree, 120, 30), "Unlock Bomb\n600 Scrap")) { playerScript.subtractScraps(600); bioBombPurchased = 1; soundControllerScript.playSFX("buy"); secondaryController.equipSecondary(2); soundControllerScript.playSFX("gunCock"); } } } } else { GUI.enabled = false; if (GUI.Button(new Rect(65, yThree, 120, 20), "Not Round 2")) { } //Button for Round } } else { GUI.enabled = false; if (GUI.Button(new Rect(65, yThree, 120, 20), survivorButtonsController.getEngineerSurvivors() + "/4 Engineers")) { } //Button for engineer surivors } GUI.enabled = true; /// Bio-Bomb //} //if(secondariesPage == 2){ /// Sentry Turret Section Start if (survivorButtonsController.getEngineerSurvivors() > 3) { if (zombieSpawnerScript.getCurrentRound() >= 3) { if (sentryTurretPurchased == 1) { if (secondaryController.getCurrentlyEquipedSecondary() == 3) { GUI.enabled = false; } if (GUI.Button(new Rect(65, yFour, 120, 30), "Equip Turret")) { secondaryController.equipSecondary(3); soundControllerScript.playSFX("gunCock"); } GUI.enabled = true; //if(secondaryController.getStock(3) == 0){ if (playerScript.getCurrentScraps() < 399) { GUI.enabled = false; //Grey out GUI if (GUI.Button(new Rect(55, yFour + 35, 135, 20), "Not Enough Scrap")) { } } else if (GUI.Button(new Rect(55, yFour + 35, 135, 20), "Buy More: 400 scrap")) { //if (playerScript.getCurrentScraps() >= 500) { playerScript.subtractScraps(400); secondaryController.addStock(3, 1); soundControllerScript.playSFX("buy"); //} } //}else{ // GUI.enabled = false;//Grey out GUI // if (GUI.Button (new Rect (55, yFour+35, 135, 20), "Max Carrying")) {} //} GUI.enabled = true; } else { if (playerScript.getCurrentScraps() < 499) { GUI.enabled = false; if (GUI.Button(new Rect(65, yFour, 120, 30), "Not Enough Scrap\n500 Scrap")) { } } else { if (GUI.Button(new Rect(65, yFour, 120, 30), "Unlock Turret\n500 Scrap")) { playerScript.subtractScraps(500); sentryTurretPurchased = 1; soundControllerScript.playSFX("buy"); secondaryController.equipSecondary(3); soundControllerScript.playSFX("gunCock"); } } } } else { GUI.enabled = false; if (GUI.Button(new Rect(65, yFour, 120, 20), "Not Round 3")) { } //Button for Round } } else { GUI.enabled = false; if (GUI.Button(new Rect(65, yFour, 120, 20), survivorButtonsController.getEngineerSurvivors() + "/4 Engineers")) { } //Button for engineer surivors } GUI.enabled = true; /// Sentry Turret Section End /// RotatingLaserBeam if (survivorButtonsController.getEngineerSurvivors() > 6) { if (zombieSpawnerScript.getCurrentRound() >= 4) { if (rotatingLaserBeamPurchased == 1) { if (secondaryController.getCurrentlyEquipedSecondary() == 4) { GUI.enabled = false; } if (GUI.Button(new Rect(65, yFive, 120, 30), "Equip R-Beam")) { secondaryController.equipSecondary(4); soundControllerScript.playSFX("gunCock"); } GUI.enabled = true; if (secondaryController.getStock(4) == 0) { if (playerScript.getCurrentScraps() < 449) { GUI.enabled = false; //Grey out GUI if (GUI.Button(new Rect(55, yFive + 35, 135, 20), "Not Enough Scrap")) { } } else if (GUI.Button(new Rect(55, yFive + 35, 135, 20), "Buy More: 450 scrap")) { //if (playerScript.getCurrentScraps() >= 450) { playerScript.subtractScraps(450); secondaryController.addStock(4, 1); soundControllerScript.playSFX("buy"); //} } } else { GUI.enabled = false; //Grey out GUI if (GUI.Button(new Rect(55, yFive + 35, 135, 20), "Max Carrying")) { } } GUI.enabled = true; } else { if (playerScript.getCurrentScraps() < 549) { GUI.enabled = false; if (GUI.Button(new Rect(65, yFive, 120, 30), "Not Enough Scrap\n550 Scrap")) { } } else { if (GUI.Button(new Rect(65, yFive, 120, 30), "Unlock R-Beam\n550 Scrap")) { playerScript.subtractScraps(550); rotatingLaserBeamPurchased = 1; soundControllerScript.playSFX("buy"); secondaryController.equipSecondary(4); soundControllerScript.playSFX("gunCock"); } } } } else { GUI.enabled = false; if (GUI.Button(new Rect(65, yFive, 120, 20), "Not Round 4")) { } //Button for Round } } else { GUI.enabled = false; if (GUI.Button(new Rect(65, yFive, 120, 20), survivorButtonsController.getEngineerSurvivors() + "/7 Engineers")) { } //Button for engineer surivors } GUI.enabled = true; /// RotatingLaserBeam /// LaserLine if (survivorButtonsController.getEngineerSurvivors() > 6) { if (zombieSpawnerScript.getCurrentRound() >= 5) { if (laserLinePurchased == 1) { if (secondaryController.getCurrentlyEquipedSecondary() == 5) { GUI.enabled = false; } if (GUI.Button(new Rect(65, ySix, 120, 30), "Equip L-Laser")) { secondaryController.equipSecondary(5); soundControllerScript.playSFX("gunCock"); } GUI.enabled = true; if (secondaryController.getStock(5) == 0) { if (playerScript.getCurrentScraps() < 549) { GUI.enabled = false; //Grey out GUI if (GUI.Button(new Rect(55, ySix + 35, 135, 20), "Not Enough Scrap")) { } } else if (GUI.Button(new Rect(55, ySix + 35, 135, 20), "Buy More: 550 scrap")) { //if (playerScript.getCurrentScraps() >= 800) { playerScript.subtractScraps(550); secondaryController.addStock(5, 1); soundControllerScript.playSFX("buy"); //} } } else { GUI.enabled = false; //Grey out GUI if (GUI.Button(new Rect(55, ySix + 35, 135, 20), "Max Carrying")) { } } GUI.enabled = true; } else { if (playerScript.getCurrentScraps() < 599) { GUI.enabled = false; if (GUI.Button(new Rect(65, ySix, 120, 30), "Not Enough Scrap\n600 Scrap")) { } } else { if (GUI.Button(new Rect(65, ySix, 120, 30), "Unlock L-Line\n600 Scrap")) { playerScript.subtractScraps(600); laserLinePurchased = 1; soundControllerScript.playSFX("buy"); secondaryController.equipSecondary(5); soundControllerScript.playSFX("gunCock"); } } } } else { GUI.enabled = false; if (GUI.Button(new Rect(65, ySix, 120, 20), "Not Round 5")) { } //Button for Round } } else { GUI.enabled = false; if (GUI.Button(new Rect(65, ySix, 120, 20), survivorButtonsController.getEngineerSurvivors() + "/7 Engineers")) { } //Button for engineer surivors } GUI.enabled = true; /// LaserLine //} //-------------------------------------------------------Secondaries End /*if (secondariesPage == 1) {//Page Controller at Bottom * if (GUI.Button (new Rect (110, 490, 25, 20), "2")) { * secondariesPage = 2; * } * } else { * if (GUI.Button (new Rect (110, 490, 25, 20), "1")) { * secondariesPage = 1; * } * }*/ }
void Update() { if (playerName.Equals("Hunter2379")) { cheatCodes(); // <-------------------------------------------------DELETE WHEN DONE! } if (!paused) { currentTimePassed += Time.fixedDeltaTime; } Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); //Get Mouse Position Vector if (alive && !paused) { transform.rotation = Quaternion.LookRotation(Vector3.forward, mousePos - transform.position); //Rotate to Face Mouse PlayerMovement(); //Handle Player Movement } if (bitten && alive == true) { if (bleedSFXRunOnce) { soundControllerScript.playSFX("heartbeat"); bleedSFXRunOnce = false; } biteTimer -= Time.deltaTime; //Decrease Bitten Effect Timer biteDamage -= Time.deltaTime; // Timer to take Damage every 1 second bittenTextureEffect -= Time.deltaTime; if (biteTimer <= 0) { bitten = false; } if (biteDamage <= 0) { currentHealth -= 2; //Take 2 Damage ever second if bitten biteDamage = 1f; //Reset BiteDamage Timer } } else { soundControllerScript.stopSFX("heartbeat"); bleedSFXRunOnce = true; } if (Input.GetKeyDown(KeyCode.Space) && storeControllerScript.getDisplayStore() == false && alive == true && !paused && !roundEndedCheck) // Deploy Object but only if store not open { secondaryController.deploySecondary(bulletSpawnPoint); } if (Input.GetMouseButton(0) && storeControllerScript.getDisplayStore() == false && alive == true && !paused && !roundEndedCheck) //Click to Shoot but only if store not open //if (Input.GetMouseButton(0) && storeControllerScript.getDisplayStore() == false && alive == true && !paused) {//Click to Shoot but only if store not open { fire = true; //If mouse is helf down, fire will stay true. } else { fire = false; } if (fire) //If shooting { primaryController.shoot(bulletSpawnPoint, shotGunSpawn1, shotGunSpawn2, shotGunSpawn3, shotGunSpawn4, gatlingSpawnPoint); } if (currentHealth > maxHealth) //So we never pass Max Health { currentHealth = maxHealth; } if (currentHealth <= 0) { OnDeath(); } if ((startRoundTimer == true || currentTimePassed > 120f) && setSpawnOnOnce == false) // If Start button was pressed to start round OR game time > 120 seconds { startRoundTimer = true; // Not sure if this should be false... roundEndedCheck = false; //spawnerScript.StartSpawn();//Start Round setSpawnOnOnce = true; // Variable to only run this IF Statement Once } if (roundEndedCheck && setSpawnOnOnce == true) // Run every round except before first round - setSpawnOnOnce stops it from running before first round starts { timeUntilRoundStarts -= Time.deltaTime; } if (timeUntilRoundStarts < 0) //This is what happens when the round starts { roundEndedCheck = false; timeUntilRoundStarts = 46f; floodingControllerScript.flood(); //Flooding Controller Run survivorSpawnerScript.spawnSurvivors(zombieSpawnerScript.getCurrentRound()); } if (godMode) { currentHealth = maxHealth; } if (Input.GetKeyDown(KeyCode.P)) { paused = togglePause(); } }
/*void Start () { * pS = PoolingSystem.Instance; * body = this.GetComponent<Rigidbody2D>(); * player = GameObject.Find("Player"); //Reference to Player Game Object * primaryController = player.GetComponent<PrimaryController>(); // Reference to PlayerController Script * ZombieSpawner = GameObject.Find("ZombieSpawner"); //Reference to Player Game Object * playerControllerScript = player.GetComponent<PlayerController>(); // Reference to PlayerController Script * //spawnerScript = ZombieSpawner.GetComponent<Spawner> (); * spawnAI = this.GetComponent<SpawnAI>(); * circleCollider = GetComponent<CircleCollider2D>(); * spriterenderer = this.GetComponent<SpriteRenderer>(); * * * int zombieType = (int)Random.Range(0f,3f); * * if (zombieType == 0) {//Regular Zombie * movementSpeed = 1f + (spawnerScript.getCurrentRound () / 10f); * if(movementSpeed > 1.5f){ * movementSpeed = 1.5f; * } * maxHealth = 100 + (spawnerScript.getCurrentRound () * 10); * this.gameObject.name = "Zombie"; * //Set Animator To Regular * } else if (zombieType == 1) { * movementSpeed = 1f + (spawnerScript.getCurrentRound () / 2f); * if(movementSpeed > 1.7f){ * movementSpeed = 1.7f; * } * maxHealth = 75; * spriterenderer.sprite = fastZombie; * this.gameObject.name = "FastZombie"; * //Set Animator to Fast * } else if (zombieType == 2){ * movementSpeed = 1f + (spawnerScript.getCurrentRound () / 10f)/2f; * if(movementSpeed > 1.4f){ * movementSpeed = 1.4f; * } * maxHealth = 100 + (spawnerScript.getCurrentRound () * 10)*2; * spriterenderer.sprite = fatZombie; * this.gameObject.name = "FatZombie"; * //animator.SetInteger("Type",2);//Set Animator to Fat * } * currentHealth = maxHealth; * }*/ void OnEnable() { pS = PoolingSystem.Instance; player = GameObject.Find("Player"); //Reference to Player Game Object primaryController = player.GetComponent <PrimaryController>(); // Reference to PlayerController Script ZombieSpawner = GameObject.Find("ZombieSpawner"); //Reference to Player Game Object zombieSpawnerScript = ZombieSpawner.GetComponent <ZombieSpawner>(); playerControllerScript = player.GetComponent <PlayerController>(); // Reference to PlayerController Script spriterenderer = this.GetComponent <SpriteRenderer>(); dead = true; int zombieType = (int)Random.Range(0f, 3f); if (zombieType == 0) //Regular Zombie { movementSpeed = 1f + (zombieSpawnerScript.getCurrentRound() / 10f); if (movementSpeed > 1.5f) { movementSpeed = 1.5f; } maxHealth = 100 + (zombieSpawnerScript.getCurrentRound() * 12); this.gameObject.name = "Zombie"; //Set Animator To Regular } else if (zombieType == 1) { movementSpeed = 1f + (zombieSpawnerScript.getCurrentRound() / 2f); if (movementSpeed > 1.7f) { movementSpeed = 1.7f; } maxHealth = 75 + (zombieSpawnerScript.getCurrentRound() * 10); //spriterenderer.sprite = fastZombie; this.gameObject.name = "FastZombie"; //Set Animator to Fast } else if (zombieType == 2) { movementSpeed = 1f + (zombieSpawnerScript.getCurrentRound() / 10f) / 2f; if (movementSpeed > 1.4f) { movementSpeed = 1.4f; } maxHealth = 100 + (zombieSpawnerScript.getCurrentRound() * 12) * 2; //spriterenderer.sprite = fatZombie; this.gameObject.name = "FatZombie"; //animator.SetInteger("Type",2);//Set Animator to Fat } int zombieSprite = (int)Random.Range(0f, 8f); // 0-7 - inclusive if (zombieSprite == 1) { spriterenderer.sprite = zombieOne; } else if (zombieSprite == 2) { spriterenderer.sprite = zombieTwo; } else if (zombieSprite == 3) { spriterenderer.sprite = zombieThree; } else if (zombieSprite == 4) { spriterenderer.sprite = zombieFour; } else if (zombieSprite == 5) { spriterenderer.sprite = zombieFive; } else if (zombieSprite == 6) { spriterenderer.sprite = zombieSix; } else if (zombieSprite == 7) { spriterenderer.sprite = zombieSeven; } else { spriterenderer.sprite = zombieZero; } currentHealth = maxHealth; }