void RemoveBonus() { int idx = -1; foreach (Bonus b in bonusList) { if (b.isDisappear == true) { idx = bonusList.IndexOf(b); Destroy(b.gameObject); score += 10; } } if (idx >= 0) { bonusList.RemoveAt(idx); //cdBaseCoolTimer = cdBaseCool; CoolDownTimer cdt = Instantiate(coolDownTimer); cdt.coolDown = CDBONUS; cdt.t = 1; //cdt.t = "base"; //cdt.coolDownTimer = 20.0f; cdt.StartCD(); //cdt.type = "base"; cdTimerList.Add(cdt); } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Zombie" && attackTimer.coolDownTimer.Equals(0)) { isAttacked = true; Debug.Log("Ontriggerenter:" + isAttacked); attackTimer.StartCD(); } }
// Update is called once per frame void Update() { //if (isPaused == false) //{ CheckLive(); SpawnZombie(); SpawnNewBase(); RemoveBonus(); SpawnNewBonus(); TimeUp(); UpdateUI(); if (CD_score.coolDownTimer.Equals(0)) { score += delta_score; CD_score.StartCD(); } if (CD_deltaScore.coolDownTimer.Equals(0)) { delta_score *= 2; CD_deltaScore.StartCD(); } if (Input.GetKeyDown(KeyCode.R)) { Debug.Log("R"); RestartCurrentScene(); } //Pause(); //} //if (Input.GetKeyDown(KeyCode.Space)) }
// Start is called before the first frame update void Start() { //Time.timeScale = 1; //player = transform.Find("Player").gameObject; Vector3 pos = new Vector3(100, 0, 100); initialZombie.transform.position = pos; Instantiate(initialZombie); zombieList.Add(initialZombie); SpawnBonus(); SpawnBase(); CD_deltaScore = Instantiate(coolDownTimer); CD_deltaScore.coolDown = DOUBLETIME; CD_deltaScore.StartCD(); CD_score = Instantiate(coolDownTimer); CD_score.coolDown = SCORETIME; CD_score.StartCD(); MSG = transform.Find("Canvas/MSG") as RectTransform; //MSG.gameObject.SetActive(false); text_fail = transform.Find("Canvas/MSG/Text").GetComponent <Text>(); text_lives = transform.Find("Canvas/HUD/Left/Text").GetComponent <Text>(); text_scores = transform.Find("Canvas/HUD/Center/Text").GetComponent <Text>(); text_enemies = transform.Find("Canvas/HUD/Right/Text").GetComponent <Text>(); text_time = transform.Find("Canvas/HUD/LeftColumn/Timer/Text").GetComponent <Text>(); }
void SpawnZombie() { int idx = -1; foreach (LatentCreature c in latentCreatureList) { GameObject cube = c.transform.Find("Cube").gameObject; if (c.spawnCreature == true) { Zombie z = Instantiate(initialZombie); z.transform.position = c.transform.position; zombieList.Add(z); c.spawnCreature = false; idx = latentCreatureList.IndexOf(c); Destroy(c.gameObject); } } if (idx >= 0) { latentCreatureList.RemoveAt(idx); CoolDownTimer cdt = Instantiate(coolDownTimer); cdt.coolDown = CDBASE; cdt.t = 0; cdt.StartCD(); cdTimerList.Add(cdt); } }