IEnumerator AITurnTiger() { Debug.Log("AI"); yield return(new WaitForSeconds(2f)); Debug.Log("AIde"); List <int> aiMOve = new List <int> (); aiMOve = Tg_FightAI.instance.GetTigerNextMove(); if (aiMOve [0] >= 0) { // OnInputByUser (aiMOve [0]); InputHandler.instance.OnInputByAI(aiMOve[0]); yield return(new WaitForSeconds(.5f)); //OnInputByUser (aiMOve [1]); InputHandler.instance.OnInputByAI(aiMOve[1]); } else { currWinStatus = eWinStatus.goat; UIManager.instance.OnGameOver(); } gameManager.isTimeUp = false; }
bool SetDataTiger(int pData) { bool correctTile = false; foreach (BranchTGNode item in allTgNodes[selectedGoatIndex].branchTgNodes) { if (item.firstLayerNode.ID == pData + 1 || (item.secondLayerNode != null && item.secondLayerNode.ID == pData + 1 && allTgNodes [item.firstLayerNode.ID - 1].currNodeHolder == eNodeHolder.goat)) { allTgNodes [pData].currNodeHolder = eNodeHolder.tiger; allTgNodes [selectedGoatIndex].currNodeHolder = eNodeHolder.none; // allTgNodes[pData].SetNodeHolderSprint(); allTgNodes [selectedGoatIndex].SetNodeHolderSprint(); selectedGoatIndex = -1; correctTile = true; if (item.secondLayerNode != null && item.secondLayerNode.ID == pData + 1 && allTgNodes [item.firstLayerNode.ID - 1].currNodeHolder == eNodeHolder.goat) { allTgNodes [item.firstLayerNode.ID - 1].currNodeHolder = eNodeHolder.none; // allTgNodes[item.firstLayerNode.ID -1 ].SetNodeHolderSprint(); coutGoatKill++; goatKillTxt.text = coutGoatKill.ToString(); AudioManager.Instance.PlaySound(AudioManager.SoundType.LevelComplete); if (coutGoatKill >= 5) { currWinStatus = eWinStatus.tiger; UIManager.instance.OnGameOver(); } } } } return(correctTile); }
void ResetData() { markerToMove.position = defaultPos.position; noOfGoat = 0; coutGoatKill = 0; usedGoatTxt.text = gameManager.totalNoOfGoat.ToString(); goatKillTxt.text = "0"; foreach (TGNode item in allTgNodes) { item.currNodeHolder = eNodeHolder.none; } if (selectedGoatIndex >= 0) { allTgNodes [selectedGoatIndex].transform.GetChild(0).gameObject.SetActive(false); } selectedGoatIndex = -1; currWinStatus = eWinStatus.none; lstGameTurn = gameManager.currTurnStatus; StopAllCoroutines(); StopCoroutine("AITurnTiger"); StopCoroutine("AITurnGoat"); tigerTimmer.Stop(); goatTimmer.Stop(); }
void FriendMove(int pData, eAnimalType pCurrAnimalType) { pData = pData - 1; if (pCurrAnimalType == eAnimalType.goat) { markerToMove.GetComponent <Image> ().sprite = goatTexture; if (noOfGoat >= gameManager.totalNoOfGoat) { if (allTgNodes [pData].currNodeHolder == eNodeHolder.goat) { selectedGoatIndex = pData; markerToMove.position = allTgNodes [pData].transform.position; MarkerReset(); allTgNodes [selectedGoatIndex].transform.GetChild(0).gameObject.SetActive(true); } else if (selectedGoatIndex >= 0 && allTgNodes [pData].currNodeHolder == eNodeHolder.none) { if (SetDataGoat(pData)) { MarkerReset(); endPos = allTgNodes [pData].transform; isMoveAlow = true; // speed = Vector3.Distance (markerToMove.position,endPos.position) / 5f; markerToMove.gameObject.SetActive(true); if (gameManager.currTurnStatus == eTurnStatus.friend) { gameManager.currTurnStatus = eTurnStatus.my; TurnMsg(true); // turnMsg.text = "You"; } else { gameManager.currTurnStatus = eTurnStatus.friend; TurnMsg(false); turnMsg.text = "Friend"; } if (IsAiEnable(true)) { StartCoroutine("AITurnTiger"); } } } } else { if (allTgNodes [pData].currNodeHolder != eNodeHolder.none) { return; } noOfGoat++; usedGoatTxt.text = (gameManager.totalNoOfGoat - noOfGoat).ToString(); markerToMove.position = defaultPos.position; markerToMove.gameObject.SetActive(true); endPos = allTgNodes [pData].transform; allTgNodes [pData].currNodeHolder = eNodeHolder.goat; isMoveAlow = true; // allTgNodes[pData].SetNodeHolderSprint(); if (gameManager.currTurnStatus == eTurnStatus.friend) { // turnMsg.text = "You"; gameManager.currTurnStatus = eTurnStatus.my; TurnMsg(true); } else { // turnMsg.text = "Friend"; gameManager.currTurnStatus = eTurnStatus.friend; TurnMsg(false); } if (IsAiEnable(true)) { StartCoroutine("AITurnTiger"); } } Debug.Log("Check gamme over for tiger-------------------------->>>>"); if (!IsTigerMoveAlv()) { Debug.Log(" gamme over -----------------------tiger nomove--->>>>"); currWinStatus = eWinStatus.goat; UIManager.instance.OnGameOver(); } } else if (pCurrAnimalType == eAnimalType.tiger) { markerToMove.GetComponent <Image> ().sprite = tigerTexture; if (!IsTigerMoveAlv()) { currWinStatus = eWinStatus.goat; UIManager.instance.OnGameOver(); } if (allTgNodes [pData].currNodeHolder == eNodeHolder.tiger) { selectedGoatIndex = pData; markerToMove.position = allTgNodes [pData].transform.position; MarkerReset(); allTgNodes [selectedGoatIndex].transform.GetChild(0).gameObject.SetActive(true); } else if (selectedGoatIndex >= 0 && allTgNodes [pData].currNodeHolder == eNodeHolder.none) { if (SetDataTiger(pData)) { MarkerReset(); endPos = allTgNodes [pData].transform; isMoveAlow = true; markerToMove.gameObject.SetActive(true); // speed = Vector3.Distance (markerToMove.position,endPos.position) / 5f; if (gameManager.currTurnStatus == eTurnStatus.friend) { // turnMsg.text = "You"; gameManager.currTurnStatus = eTurnStatus.my; TurnMsg(true); } else { gameManager.currTurnStatus = eTurnStatus.friend; TurnMsg(false); // turnMsg.text = "Friend"; } if (IsAiEnable(false)) { StartCoroutine("AITurnGoat"); } } } } }