示例#1
0
        public void PlayerTurn(List <Piece> playerPieces)
        {
            foreach (var piece in playerPieces)
            {
                Coordinates location    = piece.CurrentLocation;
                BoardSpace  space       = Board.Spaces[location.Section][location.Row][location.Position];
                int         amountMined = 0;

                Console.WriteLine("Piece: " + location.ToString());
                Console.WriteLine("Move Forward, Left, or Right? (F,L,R) or Mine? (M)");

                var response = Console.ReadLine();
                switch (response)
                {
                case ("F"):
                    piece.Move(space.AdjacentSpaces[0]);
                    break;

                case ("L"):
                    piece.Move(space.AdjacentSpaces[1]);
                    break;

                case ("R"):
                    piece.Move(space.AdjacentSpaces[2]);
                    break;

                case ("M"):
                    if (space.asteroid != null)
                    {
                        amountMined = space.asteroid.Mine(1);
                        Console.WriteLine(amountMined + " mineral successfully mined!");
                    }
                    else
                    {
                        Console.WriteLine("No asteroid at this location");
                    }

                    break;
                }

                Console.WriteLine("Piece now at " + piece.CurrentLocation.ToString() + "\n");

                piece.CollectGold(amountMined);

                Coordinates newLocation = piece.CurrentLocation;
                BoardSpace  newSpace    = Board.Spaces[newLocation.Section][newLocation.Row][newLocation.Position];
                if (newSpace.asteroid != null)
                {
                    Console.WriteLine("Asteroid Discovered!\n");
                }
                else if (newLocation.Row == 0)
                {
                    CurrentPlayer.Score += piece.DepositGold();
                }
            }
        }
示例#2
0
        public void PieceSelect(GameObject seletedSpace)
        {
            var pieceNumber = (int)Char.GetNumericValue(seletedSpace.name[seletedSpace.name.Length - 1]);
            var piece       = CurrentPlayer == 1 ? Player1Pieces[pieceNumber] : Player2Pieces[pieceNumber];

            Coordinates location     = piece.CurrentLocation;
            BoardSpace  currentSpace = Board.Spaces[location.Section][location.Row][location.Position];

            foreach (var adjacentSpace in currentSpace.AdjacentSpaces)
            {
                var target = GameObject.Find("Space." + adjacentSpace.Section + "." + adjacentSpace.Row + "." + adjacentSpace.Position);
                target.GetComponent <MeshCollider>().enabled = true;
            }
        }