コード例 #1
0
        public void Choose(GameBoardEntityDirection direction)
        {
            if (movingSum > 0)
            {
                GameBoardManager manager = GetComponentInParent <GameBoardManager>();
                GameBoardPlayer  player  = GetComponentInParent <GameBoardPlayer>();
                movingSum = manager.TryMove(player.GetComponent <GameBoardEntity>(), movingSum, direction);

                if (movingSum <= 0)
                {
                    manager.AmbiguousDirectionSolvedEvent.Invoke();

                    Destroy(this.gameObject);
                }
                else
                {
                    GetComponentInParent <GameBoardManager>()?.AmbiguousDirectionEvent?.Invoke();
                }
            }
            else
            {
                GetComponentInParent <GameBoardManager>()?.AmbiguousDirectionSolvedEvent.Invoke();
                Destroy(this.gameObject);
            }
        }
コード例 #2
0
        public static GameBoardEntityDirection Left(this GameBoardEntityDirection dir)
        {
            switch (dir)
            {
            case GameBoardEntityDirection.NORTH:
                return(GameBoardEntityDirection.WEST);

            case GameBoardEntityDirection.SOUTH:
                return(GameBoardEntityDirection.EAST);

            case GameBoardEntityDirection.EAST:
                return(GameBoardEntityDirection.NORTH);

            case GameBoardEntityDirection.WEST:
                return(GameBoardEntityDirection.SOUTH);

            default:
                return(GameBoardEntityDirection.SOUTH);
            }
        }
コード例 #3
0
        public static Vector3Int NextTile(this Vector3Int coordinates, GameBoardEntityDirection dir)
        {
            switch (dir)
            {
            case GameBoardEntityDirection.NORTH:
                return(new Vector3Int(coordinates.x, coordinates.y, coordinates.z + 1));

            case GameBoardEntityDirection.SOUTH:
                return(new Vector3Int(coordinates.x, coordinates.y, coordinates.z - 1));

            case GameBoardEntityDirection.EAST:
                return(new Vector3Int(coordinates.x + 1, coordinates.y, coordinates.z));

            case GameBoardEntityDirection.WEST:
                return(new Vector3Int(coordinates.x - 1, coordinates.y, coordinates.z));

            default:
                return(coordinates);
            }
        }