// Update is called once per frame void Update() { // nameDisplay.text = objectName cameraMovement = CameraController.GetComponent <CameraMovement>(); cursorMovement = PointerMove.GetComponent <CursorMovement>(); isHover = cursorMovement.getIsOverPlayer(); selectPlayer = Pointer.GetComponent <SelectPlayer>(); isSelected = selectPlayer.getIsSelected(); if (isSelected) { PlayerUnit = selectPlayer.GetSelectedObject(); playerControl = PlayerUnit.GetComponent <PlayerController>(); isMoving = playerControl.getIsMoving(); } showUnitInfo(isSelected, isHover); showUnitCommand(isSelected, isMoving); if (isSelected && !isMoving) { unitCommand(); } }
// Update is called once per frame void Update() { if (objectSelected) { if (playerControl.getIsMoving()) { CursorMovement cursorMovement = PointerMove.GetComponent <CursorMovement>(); if (!cursorMovement.getIsOverPlayer()) { if (Input.GetKeyDown(KeyCode.Space)) { destination = Pointer.transform.position - new Vector3(0, 2.95001f, 0); float m = Mathf.Abs(destination.x - transform.position.x), n = Mathf.Abs(destination.z - transform.position.z); switch ((int)(m + n) <= 3) { case true: transform.position = destination; objectSelected = false; SelectPlayer sp = Pointer.GetComponent <SelectPlayer>(); sp.setIsSelected(false); playerControl.setIsMoving(false); break; case false: showUnitWarning(); break; } } } } } if (Input.GetKeyDown(KeyCode.Escape)) { UnitWarning(); } }