// Use this for initialization void Start() { aliveZombies = 0; aliveCivilians = 0; aliveCops = 0; for (int i = 0; i < startingZombies; i++) { Vector3 pos = Random.insideUnitSphere; pos.y = 0; pos = pos.normalized * Random.value * 20; Instantiate(ZombieTemplate, pos, Quaternion.identity); Map.Instance.aliveZombies++; } for (int i = 0; i < startingCivilians; i++) { Civilian.Spawn(); } }
public override void Update() { if (liberated) { return; } if (attacker == null) { collisionCount = 0; } if (collisionCount >= minZombieCollisions) { if (Health < 1) { int index = Random.Range(0, 5); Material mat = renderer.material; switch (index) { case 0: mat.color = capColor0; break; case 1: mat.color = capColor1; break; case 2: mat.color = capColor2; break; case 3: mat.color = capColor3; break; case 4: mat.color = capColor4; break; default: mat.color = capColor0; break; } for (int i = 0; i < captureReward; i++) { Bounds b = new Bounds(transform.position, new Vector3(5, 0, 5)); Civilian.Spawn(b); } collisionCount = 0; liberated = true; collider.enabled = false; return; } else if (Mathf.RoundToInt(Health) % 25 == 0) { Bounds b = new Bounds(transform.position, new Vector3(5, 0, 5)); Civilian.Spawn(b); Health -= collisionCount / minZombieCollisions; } else { Health -= collisionCount / minZombieCollisions; } } }