Пример #1
0
        public void MarkValidTargets(ConvoyPlayerContext context)
        {
            ClearSelections();
            int moveRange = 0;
            if (playedPiece.name.Contains("1"))
                moveRange = 1;
            if (playedPiece.name.Contains("2"))
                moveRange = 2;
            if (playedPiece.name.Contains("3"))
                moveRange = 3;

            board[selectX][selectY].selectable = true;

            PathfindingHelper(selectX, selectY - 1, moveRange-1, board[selectX][selectY].unit.name == "Gunship", context.side);
            PathfindingHelper(selectX, selectY + 1, moveRange - 1, board[selectX][selectY].unit.name == "Gunship", context.side);
            PathfindingHelper(selectX - 1, selectY, moveRange - 1, board[selectX][selectY].unit.name == "Gunship", context.side);
            PathfindingHelper(selectX + 1, selectY, moveRange - 1, board[selectX][selectY].unit.name == "Gunship", context.side);
        }
Пример #2
0
        public void InitializeState(List<Seat> seats)
        {
            tableId = seats[0].TableId;
            playerContexts = new List<ConvoyPlayerContext>();
            foreach (Seat seat in seats)
            {
                ConvoyPlayerContext playerContext = new ConvoyPlayerContext();
                playerContext.playerId = seat.PlayerId;
                playerContext.name = seat.Player.Name;
                playerContexts.Add(playerContext);
                playerContext.hand = new List<ConvoyPiece>();
                playerContext.draftHand = new List<ConvoyPiece>();
            }
            playerContexts[0].side = "Left";
            playerContexts[1].side = "Right";
            activePlayerIndex = 0;
            activePlayerId = playerContexts[activePlayerIndex].playerId;

            logs = new List<string>();
            logs.Add("Convoy Canyon Initialized at table " + tableId);
            logs.Add(playerContexts[0].name + " vs " + playerContexts[1].name);

            primaryPlayerId = activePlayerId;

            #region intialize_board
            ConvoyPiece rock = new ConvoyPiece { name = "Rock", url = "/content/images/canyon/unit_rock.png" };
            board = new List<List<ConvoyTile>>();
            for (int x = 0; x < 11; x++)
            {
                board.Add(new List<ConvoyTile>());
                for (int y = 0; y < 12; y++)
                {
                    if(x == 4)
                        board[x].Add(new ConvoyTile { type = "Canyon", url = "/content/images/canyon/tile_leftedge.png", unit = null });
                    else if(x == 6)
                        board[x].Add(new ConvoyTile { type = "Canyon", url = "/content/images/canyon/tile_rightedge.png", unit = null });
                    else if(x == 5)
                        board[x].Add(new ConvoyTile { type = "Canyon", url = "/content/images/canyon/tile_canyon.png", unit = null });
                    else if (x == 0)
                        board[x].Add(new ConvoyTile { type = "Canyon", url = "/content/images/canyon/tile_leftcliff.png", unit = null });
                    else if (x == 10)
                        board[x].Add(new ConvoyTile { type = "Canyon", url = "/content/images/canyon/tile_rightcliff.png", unit = null });
                    else if (x < 4)
                    {
                        if(y<=1)
                        {
                            board[x].Add(new ConvoyTile { type = "Start-Left", url = "/content/images/canyon/tile_bluesrc.png", unit = null });
                        }
                        else if (y >= 10)
                        {
                            board[x].Add(new ConvoyTile { type = "End-Left", url = "/content/images/canyon/tile_bluedest.png", unit = null });
                        }
                        else
                        {
                            board[x].Add(new ConvoyTile { type = "Left", url = "/content/images/canyon/tile_path.png", unit = null });
                        }
                    }
                    else if (x > 6)
                    {
                        if (y <= 1)
                        {
                            board[x].Add(new ConvoyTile { type = "End-Right", url = "/content/images/canyon/tile_reddest.png", unit = null });
                        }
                        else if (y >= 10)
                        {
                            board[x].Add(new ConvoyTile { type = "Start-Right", url = "/content/images/canyon/tile_redsrc.png", unit = null });
                        }
                        else
                        {
                            board[x].Add(new ConvoyTile { type = "Right", url = "/content/images/canyon/tile_path.png", unit = null });
                        }
                    }
                }
            }
            board[1][3].unit = rock;
            board[2][7].unit = rock;
            board[3][5].unit = rock;
            board[9][8].unit = rock;
            board[8][4].unit = rock;
            board[7][6].unit = rock;
            #endregion

            #region initialize_deck
            int move_one_count = 8;
            int move_two_count = 10;
            int move_three_count = 8;
            int fire_one_count = 4;
            int fire_all_count = 4;
            int movefire_one_count = 6;
            int movefire_two_count = 4;
            int armoredconvoy_one_count = 3;
            int armoredconvoy_three_count = 2;
            int artillery_count = 2;
            int convoy_one_count = 3;
            int convoy_three_count = 2;
            int tank_count = 4;
            int convoy_five_count = 1;
            int gunship_count = 2;
            int heavytank_count = 0;
            int landmines_count = 2;
            int missileLauncher_count = 2;
            int railgun_count = 2;

            deck = new List<ConvoyPiece>();
            discard = new List<ConvoyPiece>();
            ConvoyPiece move_one = new ConvoyPiece { name = "Move 1", url = "/content/images/canyon/move_one.png", targetType = "Unit-Tile" };
            for (int i = 0; i < move_one_count; i++) deck.Add(move_one);
            ConvoyPiece move_two = new ConvoyPiece { name = "Move 2", url = "/content/images/canyon/move_two.png", targetType = "Unit-Tile" };
            for (int i = 0; i < move_two_count; i++) deck.Add(move_two);
            ConvoyPiece move_three = new ConvoyPiece { name = "Move 3", url = "/content/images/canyon/move_three.png", targetType = "Unit-Tile" };
            for (int i = 0; i < move_three_count; i++) deck.Add(move_three);
            ConvoyPiece fire_one = new ConvoyPiece { name = "Fire 1", url = "/content/images/canyon/fire_one.png", targetType = "Unit" };
            for (int i = 0; i < fire_one_count; i++) deck.Add(fire_one);
            ConvoyPiece fire_all = new ConvoyPiece { name = "Fire All", url = "/content/images/canyon/fire_all.png", targetType = "None" };
            for (int i = 0; i < fire_all_count; i++) deck.Add(fire_all);
            ConvoyPiece movefire_one = new ConvoyPiece { name = "Move Fire 1", url = "/content/images/canyon/movefire_one.png", targetType = "Unit-Tile" };
            for (int i = 0; i < movefire_one_count; i++) deck.Add(movefire_one);
            ConvoyPiece movefire_two = new ConvoyPiece { name = "Move Fire 2", url = "/content/images/canyon/movefire_two.png", targetType = "Unit-Tile" };
            for (int i = 0; i < movefire_two_count; i++) deck.Add(movefire_two);
            ConvoyPiece armoredconvoy_one = new ConvoyPiece { name = "Armored Convoy 1", url = "/content/images/canyon/unit_armoredconvoy1.png", targetType = "Tile" };
            for (int i = 0; i < armoredconvoy_one_count; i++) deck.Add(armoredconvoy_one);
            ConvoyPiece armoredconvoy_three = new ConvoyPiece { name = "Armored Convoy 3", url = "/content/images/canyon/unit_armoredconvoy3.png", targetType = "Tile" };
            for (int i = 0; i < armoredconvoy_three_count; i++) deck.Add(armoredconvoy_three);
            ConvoyPiece artillery = new ConvoyPiece { name = "Artillery", url = "/content/images/canyon/unit_artillery.png", targetType = "Tile" };
            for (int i = 0; i < artillery_count; i++) deck.Add(artillery);
            ConvoyPiece convoy_one = new ConvoyPiece { name = "Convoy 1", url = "/content/images/canyon/unit_convoy1.png", targetType = "Tile" };
            for (int i = 0; i < convoy_one_count; i++) deck.Add(convoy_one);
            ConvoyPiece convoy_three = new ConvoyPiece { name = "Convoy 3", url = "/content/images/canyon/unit_convoy3.png", targetType = "Tile" };
            for (int i = 0; i < convoy_three_count; i++) deck.Add(convoy_three);
            ConvoyPiece convoy_five = new ConvoyPiece { name = "Convoy 5", url = "/content/images/canyon/unit_convoy5.png", targetType = "Tile" };
            for (int i = 0; i < convoy_five_count; i++) deck.Add(convoy_five);
            ConvoyPiece gunship = new ConvoyPiece { name = "Gunship", url = "/content/images/canyon/unit_gunship.png", targetType = "Tile" };
            for (int i = 0; i < gunship_count; i++) deck.Add(gunship);
            ConvoyPiece heavytank = new ConvoyPiece { name = "Heavy Tank", url = "/content/images/canyon/unit_heavytank.png", targetType = "Tile" };
            for (int i = 0; i < heavytank_count; i++) deck.Add(heavytank);
            ConvoyPiece landmines = new ConvoyPiece { name = "Land Mines", url = "/content/images/canyon/unit_mines.png", targetType = "Tile" };
            for (int i = 0; i < landmines_count; i++) deck.Add(landmines);
            ConvoyPiece missileLauncher = new ConvoyPiece { name = "Missile Launcher", url = "/content/images/canyon/unit_missilelauncher.png", targetType = "Tile" };
            for (int i = 0; i < missileLauncher_count; i++) deck.Add(missileLauncher);
            ConvoyPiece railgun = new ConvoyPiece { name = "Rail Gun", url = "/content/images/canyon/unit_railgun.png", targetType = "Tile" };
            for (int i = 0; i < railgun_count; i++) deck.Add(railgun);
            ConvoyPiece tank = new ConvoyPiece { name = "Tank", url = "/content/images/canyon/unit_tank.png", targetType = "Tile" };
            for (int i = 0; i < tank_count; i++) deck.Add(tank);
            #endregion

            DraftDraw();
            state = "Draft";
        }
Пример #3
0
 public void MarkValidSelections(ConvoyPlayerContext context)
 {
     ClearSelections();
     if(playedPiece.name == "Land Mines")
     {
         // Empty spaces on opponent side
         for (int x = 1; x < 10; x++)
         {
             for (int y = 1; y < 11; y++)
             {
                 if (!board[x][y].type.Contains(context.side) && board[x][y].type != "Canyon")
                 {
                     if (board[x][y].unit == null)
                     {
                         board[x][y].selectable = true;
                     }
                 }
             }
         }
     }
     if(playedPiece.targetType.Contains("Unit"))
     {
         // Any friendly piece except land mines
         for (int x = 1; x < 10; x++)
         {
             for (int y = 0; y < 12; y++)
             {
                 if (board[x][y].unit != null && board[x][y].unit.side == context.side && board[x][y].unit.name != "Land Mines")
                 {
                     if (playedPiece.name.Contains("Fire") && (board[x][y].unit.name.Contains("Convoy") || board[x][y].unit.name == "Heavy Tank"))
                         continue;
                     board[x][y].selectable = true;
                 }
             }
         }
     }
     if (playedPiece.targetType == "Tile")
     {
         // Start tile on friendly side
         for (int x = 1; x < 10; x++)
         {
             for (int y = 0; y < 12; y++)
             {
                 if (board[x][y].type.Contains("Start") && board[x][y].type.Contains(context.side) && board[x][y].unit == null)
                 {
                     board[x][y].selectable = true;
                 }
             }
         }
     }
 }
Пример #4
0
 public ConvoyState GetClientState(int playerId)
 {
     this.sourcePlayerId = playerId;
     ConvoyState clientState = new ConvoyState();
     clientState.board = this.board;
     clientState.activePlayerId = this.activePlayerId;
     clientState.activePlayerIndex = this.activePlayerIndex;
     clientState.deck = null;
     clientState.discard = null;
     clientState.dudPiece = false;
     clientState.gameOver = this.gameOver;
     clientState.playedPiece = this.playedPiece;
     clientState.primaryPlayerId = this.primaryPlayerId;
     clientState.selectX = this.selectX;
     clientState.selectY = this.selectY;
     clientState.state = this.state;
     clientState.tableId = this.tableId;
     clientState.sourcePlayerId = playerId;
     clientState.targetX = this.targetX;
     clientState.targetY = this.targetY;
     clientState.playerContexts = new List<ConvoyPlayerContext>();
     clientState.logs = this.logs;
     foreach (ConvoyPlayerContext context in playerContexts)
     {
         ConvoyPlayerContext clientContext = new ConvoyPlayerContext();
         clientContext.score = context.score;
         clientContext.playerId = context.playerId;
         clientContext.name = context.name;
         clientContext.side = context.side;
         if (clientContext.playerId == playerId)
         {
             clientContext.hand = context.hand;
             clientContext.draftIndex = context.draftIndex;
             clientContext.draftHand = context.draftHand;
             clientContext.draftReady = context.draftReady;
         }
         clientState.playerContexts.Add(clientContext);
     }
     return clientState;
 }