public void SelectConstruction(ConstructDummy dum) { UnselectBuilding(); UnselectUnit(); UnselectWorker(); selectedConstruct = dum; }
public void UnselectConstruction() { if (selectedConstruct != null) { selectedConstruct.CancelBuild(); Destroy(selectedConstruct.gameObject); } selectedConstruct = null; }
public override void OnIndexTriggered() { base.OnIndexTriggered(); if (!startSelected) { startSelected = true; Debug.Log("Raycast Initated"); RaycastHit hit; GameObject hitObject = null; if (Physics.Raycast(pointer.transform.position, pointer.transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity)) { hitObject = InitRayCast(hit); } if (selectedConstruct != null) { if (selectedConstruct.IsBuildable()) { selectedConstruct.ConfirmBuild(); selectedConstruct = null; } } else { CheckUnitOBJ(hitObject); CheckUIOBJ(hitObject); } EtherDeposit eth = hitObject.GetComponent <EtherDeposit>(); if (selectedWorker != null && eth != null) { selectedWorker.GoHarvest(eth); } if (hitObject.tag == "Terrain" && (selectedUnit != null || selectedWorker != null)) { UnitMove mover = null; if (selectedUnit != null) { mover = selectedUnit.GetComponent <UnitMove>(); selectedUnit.SetAutoAttaack(false); selectedUnit.SetTarget(null); } else if (selectedWorker != null) { mover = selectedWorker.GetComponent <UnitMove>(); selectedWorker.GoHarvest(null); } mover.OrderMove(hit.point); StartCoroutine(MovePointIndicator(hit.point)); } } }
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); } } }