// Update is called once per frame void Update() { if (GetComponent <Renderer>().isVisible&& Input.GetMouseButton(0)) { Vector3 camPos = Camera.main.WorldToScreenPoint(transform.position); camPos.y = CameraOperator.InvertMouseY(camPos.y); selected = CameraOperator.selection.Contains(camPos); if (selected) { GetComponent <Renderer>().material.color = Color.red; } else { GetComponent <Renderer>().material.color = Color.white; } } if (selected && Input.GetMouseButtonUp(1)) { Vector3 destination = CameraOperator.GetDestination(); if (destination != Vector3.zero) { moveToDest = destination; moveToDest.y += floorOffset; } } UpdateMove(); }
void Update() { if (Input.GetMouseButtonDown(1)) //Move click effect { Instantiate(moveEffectObject, CameraOperator.GetDestination(), moveEffectObject.transform.rotation); } //Debug.Log(targets.Length); }
void Update() { Renderer tmpRender = transform.GetComponentsInChildren <MeshRenderer>()[0].GetComponent <Renderer>(); if (tmpRender.isVisible && Input.GetMouseButton(0)) { if (!selectedByClick) { Vector3 campPos = Camera.main.WorldToScreenPoint(transform.position); campPos.y = CameraOperator.InvertScreenY(campPos.y); selected = CameraOperator.selection.Contains(campPos); } } if (selected && Input.GetMouseButtonUp(1)) { Vector3 destination = CameraOperator.GetDestination(); if (destination != Vector3.zero) { MoveTo(destination); } } }
public void DestOffset() //Formation movement { Vector3 destination = CameraOperator.GetDestination(); float averageX = 0, averageZ = 0; for (int x = 0; x < selectedUnits.Count; x++) { averageX += selectedUnits[x].transform.position.x; averageZ += selectedUnits[x].transform.position.z; } averageX /= selectedUnits.Count; averageZ /= selectedUnits.Count; for (int x = 0; x < selectedUnits.Count; x++) { Vector3 Temp = destination; if (selectedUnits[x].transform.position.x <= averageX) { Temp.x -= averageX - selectedUnits[x].transform.position.x; } else { Temp.x += selectedUnits[x].transform.position.x - averageX; } if (selectedUnits[x].transform.position.z <= averageZ) { Temp.z -= averageZ - selectedUnits[x].transform.position.z; } else { Temp.z += selectedUnits[x].transform.position.z - averageZ; } selectedUnits[x].SendMessage("SetDest", Temp); } }