//Update is called once per frame void Update() { //Only checks activation if deactive, it will keep trying to chase the player forever. if (!isActive) { isActive = ControllerMob.ActivationCheck(gameObject); } else { //Updates movement if Skitter returns true, enabling the bursts of skittering movement. UpdateMovement(UpdateSkitter()); } }
//UpdateSpawn //Spawning is switched on and off with canSpawn //Currently the code assumes the Spawner can only create Seeker Bugs. //Spawns (Speed) creatures per second at spawnSpeed 100 //MobController handles the spawning //bool canSpawn Switches spawning on and off //float speed How quickly mobs spawn. Multiplies the effect of spawnSpeed. //flaot spawnSpeed How quickly mobs spawn. 1 per second at 100 - 1 per 100 seconds at 1. //float spanwTimer How long remaining until a new mob is spawned private void UpdateSpawn() { if (canSpawn == true) { spawnTimer -= speed * (.01f * spawnSpeed) * Time.deltaTime; if (spawnTimer <= 0) { spawnTimer = 1; ControllerMob.AddSeeker(spawn, gameObject, minimumSpawns); minimumSpawns--; } } }
//Update is divided into private methods //Most methods depend on current pause state. void Update() { //Checks for activation each tick (So that it does not keep spawning deactivated enemies when the player walks away) isActive = ControllerMob.ActivationCheck(gameObject); UpdateIsolation(); if ((isActive) && (!ControllerGame.IsPaused)) { if (isIsolated == false) { UpdateRotation(); UpdateSpawn(); } } }
//Used by ControllerMob to track the number of Seekers in play private void OnDestroy() { ControllerMob.RemoveSeeker(); }