// Initialization. void Start() { // Get animator. this.anim=this.GetComponent<Animator>(); // Get attacker. this.attacker=this.GetComponent<AttackerManager>(); } // End of Start
} // End of Update // Return information if is time to spawn passed attacker. private bool IsTimeToSpawn(AttackerManager attacker) { // Compute spawns per second. float spawns_per_second=1/attacker.seconds_to_spawn; // Time.deltaTime guarantee that when FPS will drop down then propability // of launching projectile will go up. Calculation is dividied by 5 becouse there is // 5 lanes of attackers. return (Random.value < ((Time.deltaTime*spawns_per_second*this.spawn_rate + (PlayerPrefsManager.DifficultyGet()/10)) / 5)); } // End of IsTimeToSpawn
void Awake() { location = this.gameObject.transform; charMan = this.gameObject.GetComponent <AttackerManager>(); velocity = charMan.Speed; }