void unitCommand() { playerControl.setIsGuarding(false); playerControl.setIsMoving(false); playerControl.setIsAttacking(false); if (Input.GetKeyDown(KeyCode.J)) // Move { cursorMovement.setPauseCursor(false); playerControl.setIsMoving(true); // Choose destination -> moving -> set false } else if (Input.GetKeyDown(KeyCode.O)) // Attacc { playerControl.setIsAttacking(true); selectPlayer.setIsSelected(false); Animator animator = PlayerUnit.GetComponent <Animator>(); animator.Play("attack"); // Choose enemy -> do attack animation -> set false } else if (Input.GetKeyDown(KeyCode.L)) // Open Skill Window { // Same as attack } else if (Input.GetKeyDown(KeyCode.I)) // Guard Mode { playerControl.setIsGuarding(true); selectPlayer.setIsSelected(false); // guard for one turn -> next turn set false } else if (Input.GetKeyDown(KeyCode.Space)) // Cancel { selectPlayer.setIsSelected(false); } }
// 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(); } }