// Start is called before the first frame update void Start() { playerStat = GetComponent <VRPlayerIndicator>(); workerList = new List <WorkerUnit>(); armyList = new List <UnitGroupSystem>(); etherClose = new List <EtherDeposit>(); }
void TrainingUnit() { if (isTraining) { cancelUI.gameObject.SetActive(true); barUI.gameObject.SetActive(true); if (cancelUI.CheckClick()) { cancelUI.SetClick(false); isTraining = false; } if (trainTimeNow >= trainTimeMax) { isTraining = false; GameObject unit = Instantiate(unitTrainNow, spawnPoint.transform.position, spawnPoint.transform.rotation) as GameObject; UnitGroupSystem group = unit.GetComponent <UnitGroupSystem>(); if (group != null) { group.SetOwner(build.GetOwner()); } WorkerUnit worker = unit.GetComponent <WorkerUnit>(); if (worker != null) { worker.SetOwner(this.build.GetOwner()); } } trainTimeNow += Time.deltaTime; barUI.SetProgress(trainTimeNow / trainTimeMax); } else { cancelUI.gameObject.SetActive(false); barUI.gameObject.SetActive(false); VRPlayerIndicator player = null; foreach (GameObject plays in GameObject.FindGameObjectsWithTag("Player")) { VRPlayerIndicator ind = plays.GetComponent <VRPlayerIndicator>(); if (ind.GetPlayerNumber() == stat.GetOwner()) { player = ind; } } for (int i = 0; i < trainUI.Length; i++) { if (trainUI[i].CheckClick() && player.GetEther() >= trainCost[i]) { isTraining = true; unitTrainNow = trainUnit[i]; trainTimeMax = trainTime[i]; trainTimeNow = 0; player.ChangeEther(-trainCost[i]); barUI.SetProgress(0); trainUI[i].SetClick(false); Debug.Log("Start Training!!!"); } } } }
public void CancelBuild() { VRPlayerIndicator player = null; foreach (GameObject plays in GameObject.FindGameObjectsWithTag("Player")) { VRPlayerIndicator ind = plays.GetComponent <VRPlayerIndicator>(); if (ind.GetPlayerNumber() == thisOwner) { player = ind; } } player.ChangeEther(cost); }
// Update is called once per frame void Update() { stat = GetComponent <UnitStatSystem>(); VRPlayerIndicator player = null; foreach (GameObject plays in GameObject.FindGameObjectsWithTag("Player")) { VRPlayerIndicator ind = plays.GetComponent <VRPlayerIndicator>(); if (ind.GetPlayerNumber() == stat.GetOwner()) { player = ind; } } etherText.text = "Ether : " + player.GetEther(); }
// Update is called once per frame void Update() { if (!conditionDummy && !haveChecked) { SkirmishStartSystem skir = FindObjectOfType <SkirmishStartSystem>(); if (skir.GetDefeated() || skir.GetVictory()) { conditionDummy = Instantiate(ConditionPrefab) as ConditionMenu; conditionDummy.GetConText().text = skir.GetVictory() ? "Victory!" : "Defeat!"; VRPlayerIndicator player = null; foreach (GameObject plays in GameObject.FindGameObjectsWithTag("Player")) { VRPlayerIndicator ind = plays.GetComponent <VRPlayerIndicator>(); if (ind.GetPlayerNumber() == 1) { player = ind; } } if (skir.GetVictory()) { Instantiate(victorySound, player.transform.position, player.transform.rotation); } else { Instantiate(defeatSound, player.transform.position, player.transform.rotation); } haveChecked = true; } } else { if (timePassed >= 10) { SceneManager.LoadScene("MainMenu"); } timePassed += Time.deltaTime; VRPlayerIndicator player = null; foreach (GameObject plays in GameObject.FindGameObjectsWithTag("Player")) { VRPlayerIndicator ind = plays.GetComponent <VRPlayerIndicator>(); if (ind.GetPlayerNumber() == 1) { player = ind; } } conditionDummy.transform.position = player.gameObject.transform.position + (player.transform.forward * 50) + (player.transform.up * 20); } }
// Update is called once per frame void Update() { constructEff.SetActive(!buildingFinished); foreach (Transform child in constructEff.transform) { child.gameObject.SetActive(!buildingFinished); } stat.SetSelected(isSelected); if (isSelected) { selectorCircle.SetActive(true); baseUI.SetActive(true); VRPlayerIndicator player = null; foreach (GameObject plays in GameObject.FindGameObjectsWithTag("Player")) { VRPlayerIndicator ind = plays.GetComponent <VRPlayerIndicator>(); if (ind.GetPlayerNumber() == stat.GetOwner()) { player = ind; } } VRHeadTracking head = player.GetComponent <VRHeadTracking>(); baseUI.transform.LookAt(head.GetHead().transform); if (!buildingFinished) { cancelUI.gameObject.SetActive(true); barUI.gameObject.SetActive(true); } else { cancelUI.gameObject.SetActive(false); barUI.gameObject.SetActive(false); } } else { selectorCircle.SetActive(false); baseUI.gameObject.SetActive(false); } if (cancelUI.CheckClick()) { cancelUI.SetClick(false); Destroy(this.gameObject); } }
public void StartDummy(GameObject mod, BuildingSystem bui, int owner, int cos) { buildingCon = bui; thisOwner = owner; cost = cos; VRPlayerIndicator player = null; foreach (GameObject plays in GameObject.FindGameObjectsWithTag("Player")) { VRPlayerIndicator ind = plays.GetComponent <VRPlayerIndicator>(); if (ind.GetPlayerNumber() == thisOwner) { player = ind; } } player.ChangeEther(-cost); models = Instantiate(mod, this.transform) as GameObject; }
public void TrainOrder(int selec) { VRPlayerIndicator player = null; foreach (GameObject plays in GameObject.FindGameObjectsWithTag("Player")) { VRPlayerIndicator ind = plays.GetComponent <VRPlayerIndicator>(); if (ind.GetPlayerNumber() == stat.GetOwner()) { player = ind; } } if (!isTraining && player.GetEther() >= trainCost[selec]) { isTraining = true; unitTrainNow = trainUnit[selec]; trainTimeMax = trainTime[selec]; trainTimeNow = 0; player.ChangeEther(-trainCost[selec]); barUI.SetProgress(0); trainUI[selec].SetClick(false); Debug.Log("Start Training!!!"); } }
public void Update() { if (GetAlive()) { healthBar.SetHealthPercent((healthNow * 100 / maxHealth)); healthBar.gameObject.SetActive(isSelected); VRPlayerIndicator player = null; foreach (GameObject plays in GameObject.FindGameObjectsWithTag("Player")) { VRPlayerIndicator ind = plays.GetComponent <VRPlayerIndicator>(); if (ind.GetPlayerNumber() == GetOwner()) { player = ind; } } VRHeadTracking head = player.GetComponent <VRHeadTracking>(); healthBar.transform.LookAt(head.GetHead().transform); } else { healthBar.gameObject.SetActive(false); StartCoroutine(Dies()); } }
void Construction() { VRPlayerIndicator player = null; foreach (GameObject plays in GameObject.FindGameObjectsWithTag("Player")) { VRPlayerIndicator ind = plays.GetComponent <VRPlayerIndicator>(); if (ind.GetPlayerNumber() == stat.GetOwner()) { player = ind; } } for (int i = 0; i < buildUI.Length; i++) { if (buildUI[i].CheckClick() && player.GetEther() >= buildCost[i]) { InGameFirstHand hand = buildUI[i].GetHandClicked(); ConstructDummy dumNow = Instantiate(dummy[i], this.transform.position, this.transform.rotation) as ConstructDummy; dumNow.StartDummy(buildUnit[i].GetModel(), buildUnit[i], stat.GetOwner(), buildCost[i]); hand.SelectConstruction(dumNow); buildUI[i].SetClick(false); } } }
// Use this for initialization void Start() { SkirmishDataTransfer data = FindObjectOfType <SkirmishDataTransfer>(); if (data != null) { maxPlayer = data.GetMaxPlayer(); playerActive = data.GetAssignPlayer(); factions = data.GetFaction(); playerTeam = data.GetTeam(); //Spawn Player for (int i = 0; i < maxPlayer; i++) { if (playerActive[i]) { if (i >= 1) { GameObject aiOBJ = Instantiate(AIDummy, transform.position, transform.rotation) as GameObject; VRPlayerIndicator ai = aiOBJ.gameObject.GetComponent <VRPlayerIndicator>(); ai.SetPlayerNum(i + 1); } VRPlayerIndicator player = null; foreach (GameObject plays in GameObject.FindGameObjectsWithTag("Player")) { VRPlayerIndicator ind = plays.GetComponent <VRPlayerIndicator>(); if (ind.GetPlayerNumber() == i + 1) { player = ind; } } player.SetEther(1500); player.transform.position = startPosition[i].transform.position - (Vector3.forward * 20); if (factions[i] == SkirmishScreenSelection.FactionType.Chaiya) { BuildingSystem strong = Instantiate(chaiyaStrong, startPosition[i].transform.position, startPosition[i].transform.rotation) as BuildingSystem; strong.StartToBuild(i + 1); } if (factions[i] == SkirmishScreenSelection.FactionType.Ulepia) { BuildingSystem strong = Instantiate(ulepiaStrong, startPosition[i].transform.position, startPosition[i].transform.rotation) as BuildingSystem; strong.StartToBuild(i + 1); } if (factions[i] == SkirmishScreenSelection.FactionType.Shin) { BuildingSystem strong = Instantiate(shinStrong, startPosition[i].transform.position, startPosition[i].transform.rotation) as BuildingSystem; strong.StartToBuild(i + 1); } } } //Ally Set for (int i = 0; i < maxPlayer; i++) { for (int j = 0; j < maxPlayer; j++) { if (i != j && playerTeam[i] == playerTeam[j]) { AllianceSystem.SetAlly(i + 1, j + 1, true); } } } data.SetTransfered(true); } else { } }
// Update is called once per frame void Update() { stat.SetSelected(isSelected); if (isSelected) { selectorCircle.SetActive(true); } else { selectorCircle.SetActive(false); } etherModel.SetActive(etherHarvested > 0); harvestCool -= Time.deltaTime; if (stat.GetAlive() && etherTarget != null) { if (etherHarvested < 100) { UnitMove mover = GetComponent <UnitMove>(); if (Vector3.Distance(this.transform.position, etherTarget.transform.position) <= 5) { mover.StopMove(); this.transform.LookAt(etherTarget.transform); this.transform.rotation = Quaternion.Euler(0, this.transform.eulerAngles.y, 0); if (harvestCool <= 0) { harvestCool = timePerHarvest; StartCoroutine(Harvest()); } } else { mover.OrderMove(etherTarget.transform.position); } } else { if (returnBuild == null) { float returnRange = 999999999999f; foreach (ResourceReturnPoint ret in GameObject.FindObjectsOfType <ResourceReturnPoint>()) { UnitStatSystem retSta = ret.GetComponent <UnitStatSystem>(); if (stat.GetOwner() == retSta.GetOwner() && Vector3.Distance(this.transform.position, ret.transform.position) <= returnRange) { returnRange = Vector3.Distance(this.transform.position, ret.transform.position); returnBuild = ret; } } } else { UnitMove mover = GetComponent <UnitMove>(); mover.OrderMove(returnBuild.transform.position); } } } if (stat.GetAlive() && returnBuild != null && Vector3.Distance(this.transform.position, returnBuild.transform.position) <= returnBuild.GetReturnRange()) { VRPlayerIndicator player = null; foreach (GameObject plays in GameObject.FindGameObjectsWithTag("Player")) { VRPlayerIndicator ind = plays.GetComponent <VRPlayerIndicator>(); if (ind.GetPlayerNumber() == stat.GetOwner()) { player = ind; } } player.ChangeEther(etherHarvested); etherHarvested = 0; } }