// Update is called once per frame void Update() { if (build.CheckFinish() && build.CheckSelect()) { constructUI.gameObject.SetActive(true); } else { constructUI.gameObject.SetActive(false); } if (constructUI.CheckClick()) { constructShow = !constructShow; constructUI.SetClick(false); } if (build.CheckSelect() && build.CheckFinish() && constructShow) { baseUI.SetActive(true); foreach (BuildingUI showUI in buildUI) { showUI.gameObject.SetActive(true); } Construction(); } else { constructShow = false; baseUI.SetActive(false); } }
private void CheckStronghold() { if (aiStronghold.CheckFinish() && workerList.Count < 3 && !aiStronghold.GetComponent <UnitTraining>().IsTraining() && playerStat.GetEther() >= 100) { aiStronghold.GetComponent <UnitTraining>().TrainOrder(0); } if (aiStronghold.CheckFinish() && !aiBarrack && playerStat.GetEther() >= 850) { BuildingSystem barrackDummy = aiStronghold.GetComponent <ConstructSystem>().GetBuildingToConstruct(0); GameObject posDummy = Instantiate(aiPointDummy, aiStronghold.transform.position, aiStronghold.transform.rotation) as GameObject; posDummy.transform.Rotate(new Vector3(0, Random.Range(110f, 150f), 0)); posDummy.transform.position += posDummy.transform.forward * Random.Range(25f, 30f); aiBarrack = Instantiate(barrackDummy, posDummy.transform.position, aiStronghold.transform.rotation) as BuildingSystem; aiBarrack.transform.Rotate(new Vector3(0, 180, 0)); aiBarrack.StartToBuild(playerStat.GetPlayerNumber()); playerStat.SetEther(playerStat.GetEther() - 850); } if (aiStronghold.CheckFinish() && !aiStable && playerStat.GetEther() >= 1000) { BuildingSystem stableDummy = aiStronghold.GetComponent <ConstructSystem>().GetBuildingToConstruct(2); GameObject posDummy = Instantiate(aiPointDummy, aiStronghold.transform.position, aiStronghold.transform.rotation) as GameObject; posDummy.transform.Rotate(new Vector3(0, Random.Range(200f, 240f), 0)); posDummy.transform.position += posDummy.transform.forward * Random.Range(25f, 30f); aiStable = Instantiate(stableDummy, posDummy.transform.position, aiStronghold.transform.rotation) as BuildingSystem; aiStable.transform.Rotate(new Vector3(0, 180, 0)); aiStable.StartToBuild(playerStat.GetPlayerNumber()); playerStat.SetEther(playerStat.GetEther() - 800); } }
// Update is called once per frame void Update() { if (build.CheckSelect()) { if (build.CheckFinish()) { baseUI.SetActive(true); foreach (BuildingUI showUI in trainUI) { showUI.gameObject.SetActive(true); } if (isTraining) { cancelUI.gameObject.SetActive(true); } else { cancelUI.gameObject.SetActive(false); } } else { baseUI.SetActive(false); foreach (BuildingUI showUI in trainUI) { showUI.gameObject.SetActive(false); } } } else { baseUI.SetActive(false); } TrainingUnit(); }
// Update is called once per frame void Update() { coolNow -= Time.deltaTime; if (stat.GetAlive()) { if (isBuilding) { BuildingSystem bui = GetComponent <BuildingSystem>(); if (bui.CheckFinish()) { CheckTarget(); } else { target = null; } } else { CheckTarget(); } } else { target = null; } }
private void CheckStable() { if (aiStable.CheckFinish() && armyList.Count < 6) { UnitTraining stableTrain = aiStable.GetComponent <UnitTraining>(); stableTrain.TrainOrder(0); } }
private void CheckBarrack() { Debug.Log("AI " + playerStat.GetPlayerNumber() + " build barrack."); if (aiBarrack.CheckFinish() && armyList.Count < 6) { UnitTraining barrackTrain = aiBarrack.GetComponent <UnitTraining>(); barrackTrain.TrainOrder(Random.Range(0, 3)); } Debug.Log("AI " + playerStat.GetPlayerNumber() + " find army."); UnitGroupSystem[] groupF = FindObjectsOfType <UnitGroupSystem>(); foreach (UnitGroupSystem groupDum in groupF) { if (groupDum.GetOwner() == playerStat.GetPlayerNumber() && !armyList.Contains(groupDum)) { armyList.Add(groupDum); Debug.Log("AI " + playerStat.GetPlayerNumber() + " add 1 army to group."); } } Debug.Log("AI " + playerStat.GetPlayerNumber() + " have army : " + armyList.Count); }