Example #1
0
        private void ProcessInputPrepareTarget()
        {
            // Cannot start a next movement if still moving
            if (Moving || _gameManager.Acting)
            {
                return;
            }

            var horizontal = Input.GetAxis("Horizontal");
            var vertical   = Input.GetAxis("Vertical");
            var targetRow  = Row;
            var targetCol  = Col;
            var move       = false;

            if (horizontal < 0)
            {
                targetRow--;
                move = true;
                Transform.Find("Mesh").localRotation = Quaternion.Euler(new Vector3(0, 270, 0));
            }
            else if (horizontal > 0)
            {
                targetRow++;
                move = true;
                Transform.Find("Mesh").localRotation = Quaternion.Euler(new Vector3(0, 90, 0));
            }
            else if (vertical < 0)
            {
                targetCol--;
                move = true;
                Transform.Find("Mesh").localRotation = Quaternion.Euler(new Vector3(0, 180, 0));
            }
            else if (vertical > 0)
            {
                targetCol++;
                move = true;
                Transform.Find("Mesh").localRotation = Quaternion.Euler(new Vector3(0, 0, 0));
            }

            if (move)
            {
                // Handle wrong target and cancel the movement
                if (TileManager.GetTile(targetRow, targetCol) == null ||
                    TileManager.GetTile(targetRow, targetCol).Component.transform.lossyScale.y > 1.25f
                    )
                {
                    Debug.Log("Player's movement target to " + targetRow + ":" + targetCol + " unavailable");
                    return;
                }

                // Start the movement
                PositionSupport.SetGoal(targetRow, targetCol);

                PositionSupport.OnGoalFinish += () =>
                {
                    // Start a next acting round
                    _gameManager.ActActors();
                    return(true);
                };
            }
        }