/// <summary> /// Thực hiện khi người chơi chọn vào một vũ khí nào đó /// </summary> public void UsePick(int index) { GameObject[] arrPickOld = GameObject.FindGameObjectsWithTag("Pick"); for (int i = 0; i < arrPickOld.Length; i++) { Pick_ShieldControler pick = arrPickOld[i].GetComponent <Pick_ShieldControler>(); Pick_MineControler pickMine = arrPickOld[i].GetComponent <Pick_MineControler>(); if (pick == null && pickMine == null) { Destroy(arrPickOld[i]); } if (pickMine != null) { if (!pickMine._IsInit) { Destroy(arrPickOld[i]); } } } GameObject[] arrBullet = GameObject.FindGameObjectsWithTag("Bullet"); for (int i = 0; i < arrBullet.Length; i++) { Destroy(arrBullet[i]); } GameObject dart = GameObject.FindGameObjectWithTag("Dart"); if (dart != null) { Destroy(dart); } //====================== Player player = new Player(); Object obj = new Object(); _GameControler._Pick = _ListPick[index]; player = _GameControler._GameObj.GetComponent <Player>(); if (index == 3 || index == 9 || index == 14 || index == 15) { obj = Instantiate(_ListPick[18], _GameControler._GameObj.transform.position, Quaternion.identity); AirCallControler air = ((GameObject)obj).GetComponent <AirCallControler>(); switch (index) { case 3: air._Type = "Pick_Bomb"; break; case 9: air._Type = "Pick_Teleport"; break; case 14: air._Type = "Pick_Health"; break; case 15: air._Type = "Pick_Swap"; break; } } else { FindObjectOfType <CameraControler>()._IsMove = false; FindObjectOfType <MapControler>()._IsMove = false; obj = Instantiate(_ListPick[index], _GameControler._GameObj.transform.position, Quaternion.identity); } if (player._Dir == Player.Dir.right) { ((GameObject)obj).transform.localScale = new Vector3(1, 1, 1); } else { ((GameObject)obj).transform.localScale = new Vector3(-1, 1, 1); } ((GameObject)obj).transform.parent = _GameControler._GameObj.transform; //Hiển thị súng }
IEnumerator WaitForChangeTurn() { yield return(new WaitForSeconds(2f)); Player[] arrPlayer = FindObjectsOfType <Player>(); for (int i = 0; i < arrPlayer.Length; i++) { if (arrPlayer[i]._IsPoison) { if (arrPlayer[i]._Health > 10) { arrPlayer[i]._Health -= 10; } else { arrPlayer[i]._Health = 1; } NumberText textHealth = arrPlayer[i].gameObject.GetComponentInChildren <NumberText>(); textHealth.SetNumberText(arrPlayer[i]._Health); } } _UIManager.SetImgButtonChoosePick(); _numberText.SetNumText2(30, _ListImageTimer); int checkOver = CheckGameOver(); if (checkOver != -1) { _UIManager.ShowPanelGameOver(checkOver); } else { GameObject[] arrPickOld = GameObject.FindGameObjectsWithTag("Pick"); for (int i = 0; i < arrPickOld.Length; i++) { Pick_ShieldControler pick = arrPickOld[i].GetComponent <Pick_ShieldControler>(); Pick_MineControler pickMine = arrPickOld[i].GetComponent <Pick_MineControler>(); if (pickMine != null) { pickMine.ActivePick_Mine(); } if (pick == null && pickMine == null) { Destroy(arrPickOld[i]); } } GameObject[] bullet = GameObject.FindGameObjectsWithTag("Bullet"); for (int i = 0; i < bullet.Length; i++) { Destroy(bullet[i]); } GameObject dart = GameObject.FindGameObjectWithTag("Dart"); if (dart != null) { Destroy(dart); } GameObject[] line = GameObject.FindGameObjectsWithTag("Dot"); for (int i = 0; i < line.Length; i++) { Destroy(line[i]); } //====================== if (_GameState._IsPlayer)//Chuyển sang Enemy { _GameState._IsPlayer = false; _UIManager.ShowPopupTurnBlue(); } else//Chuyển sang Player { _GameState._IsPlayer = true; _UIManager.ShowPopopTurnGreen(); } } }