Exemple #1
0
 public static int createMarker(Point topLeft, int p, SpriteBatch s)
 {
     MarkerButton markerB;
     markerB = new MarkerButton(markerTexture[p - 1], GameBoard.Game.getPlayers()[p - 1], s, 30, 30, topLeft.X + 25, topLeft.Y + 5);
     marker.Add(markerB);
     markerB.setIsSet(true);
     KNT_Game.me.placeMarker(markerB.getButtonID());
     return markerB.getButtonID();
 }
Exemple #2
0
        protected override void isClicked()
        {
            if ((IsInsideTriangle(topleft, midleft, botleft, new Point(mouse.X, mouse.Y)) ||
                 middle.Contains(new Point(mouse.X, mouse.Y)) ||
                 IsInsideTriangle(topright, midright, botright, new Point(mouse.X, mouse.Y)))) //HEX TILES
            {
                Thread.Sleep(1);
                switch (GameBoard.Game.getCurrentPhase().getName())
                {
                    case "Setup":
                        if ((marker = KNT_Game.getMyMarker()) != null)
                        {
                            if (marker.getMarkerSelected() && (this.hex.getStart() || this.hex.getPlayerAble() == KNT_Game.me) &&
                                (this.hex.getPlayerAble() == null || this.hex.getPlayerAble() == KNT_Game.me) &&
                                this.hex.getPlayer() == null && this.hex.adjacencyRule(KNT_Game.me) &&
                                this.hex.getType() != "Sea")
                            {
                                this.hex.selectedAsStarting(KNT_Game.me);
                                KNT_Game.me.addOwnedTile(hex);
                                currentMarkerID = marker.getButtonID();
                                marker.setIsSet(true);
                                marker.setMarkerSelected(false);
                                marker.Location(25 + topleft.X, 5 + topleft.Y);
                                KNT_Game.me.placeMarker(marker.getButtonID());
                                KNT_Game.me.setCurrentMarker(marker.getButtonID());
                                KNT_Game.me.setHandsFull();
                            }
                        }
                        else if (((SetupPhase)GameBoard.Game.getCurrentPhase()).getTowerPlacementPhase() && this.hex.getPlayerControlBool())
                        {
                            if (this.hex.getPlayer() == KNT_Game.me)
                            {
                                KNT_Game.me.towerPlaced = 1;
                                this.hex.upgradeFort();
                            }
                        }
                        break;

                    case "Recruit Things":
                        if(KNT_Game.getButtonInHand() != null)
                        {
                            if(hex.doesPlayerHaveStack(KNT_Game.me.getPlayerNumber()))
                            {
                                if (stacks[KNT_Game.me.getPlayerNumber()].canAddToStack())
                                {
                                    ((ThingButton)KNT_Game.getButtonInHand()).putInPlay();
                                    hex.addToPlayerStack(KNT_Game.me.getPlayerNumber(), ((ThingButton)KNT_Game.getButtonInHand()).getThing());
                                    stacks[KNT_Game.me.getPlayerNumber()].addThings(((ThingButton)KNT_Game.getButtonInHand()).getThing());
                                    KNT_Game.buttonInHand = null;
                                }
                            }
                            else
                            {
                                if (hex.getPlayer() != null && hex.getPlayer().getName() == KNT_Game.me.getName())
                                {
                                    stacks[KNT_Game.me.getPlayerNumber()] = KNT_Game.createStack(hex,
                                            ((ThingButton)KNT_Game.getButtonInHand()).getThing(), spriteB);

                                    if (stacks[KNT_Game.me.getPlayerNumber()].canAddToStack())
                                    {
                                        ((ThingButton)KNT_Game.getButtonInHand()).putInPlay();
                                        hex.addToPlayerStack(KNT_Game.me.getPlayerNumber(), ((ThingButton)KNT_Game.getButtonInHand()).getThing());
                                        KNT_Game.buttonInHand = null;
                                    }

                                    if (KNT_Game.me.getPlayerNumber() == 1)
                                        stacks[1].Location(0 + topleft.X, 35 + topleft.Y);
                                    if (KNT_Game.me.getPlayerNumber() == 2)
                                        stacks[2].Location(25 + topleft.X, 35 + topleft.Y);
                                    if (KNT_Game.me.getPlayerNumber() == 3)
                                        stacks[3].Location(0 + topleft.X, 65 + topleft.Y);
                                    if (KNT_Game.me.getPlayerNumber() == 4)
                                        stacks[4].Location(25 + topleft.X, 65 + topleft.Y);
                                }

                            }
                        }
                        break;

                    case "Movement":
                        if (hex.doesPlayerHaveStack(KNT_Game.me.getPlayerNumber()) && !KNT_Game.me.handsFull() && hex.movePossible[KNT_Game.me.getPlayerNumber()])
                        {
                            foreach(Tile t in GameBoard.Game.getMap().getHexList())
                                t.resetMovementLogic();
                            ((MovementPhase)GameBoard.Game.getCurrentPhase()).checkMovement(hexNumber, 4);
                            KNT_Game.putStackInHand(stacks[KNT_Game.me.getPlayerNumber()].getList());
                            KNT_Game.removeStack(stacks[KNT_Game.me.getPlayerNumber()]);
                            hex.clearPlayerStack(KNT_Game.me.getPlayerNumber());
                            stacks[KNT_Game.me.getPlayerNumber()] = null;
                        }
                        else if (hex.traversed && KNT_Game.me.handsFull() && !hex.doesPlayerHaveStack(KNT_Game.me.getPlayerNumber()))
                        {
                            stacks[KNT_Game.me.getPlayerNumber()] = KNT_Game.createStack(hex, KNT_Game.getStackInHand(), spriteB);
                            hex.movePossible[KNT_Game.me.getPlayerNumber()] = false;
                            foreach (Thing aThing in stacks[KNT_Game.me.getPlayerNumber()].getList())
                                hex.addToPlayerStack(KNT_Game.me.getPlayerNumber(), aThing);
                            if (KNT_Game.me.getPlayerNumber() == 1)
                                stacks[1].Location(0 + topleft.X, 35 + topleft.Y);
                            if (KNT_Game.me.getPlayerNumber() == 2)
                                stacks[2].Location(25 + topleft.X, 35 + topleft.Y);
                            if (KNT_Game.me.getPlayerNumber() == 3)
                                stacks[3].Location(0 + topleft.X, 65 + topleft.Y);
                            if (KNT_Game.me.getPlayerNumber() == 4)
                                stacks[4].Location(25 + topleft.X, 65 + topleft.Y);
                            foreach (Tile t in GameBoard.Game.getMap().getHexList())
                                t.resetMovementLogic();
                            if (this.hex.getPlayerControlBool() == false)
                            {
                                KNT_Game.deleteMarker(currentMarkerID);
                                this.hex.setPlayerControl(KNT_Game.me);
                                this.hex.setPlayerControlBool(true);
                                KNT_Game.me.addOwnedTile(this.hex);
                                currentMarkerID = KNT_Game.createMarker(topleft, KNT_Game.me.getPlayerNumber(), spriteB);
                            }
                            else if (this.hex.getPlayerControlBool() && this.hex.getPlayer() != KNT_Game.me)
                            {
                                if (stacks[this.hex.getPlayer().getPlayerNumber()] == null)
                                {
                                    KNT_Game.deleteMarker(currentMarkerID);
                                    this.hex.getPlayer().removeOwnedTile(this.hex);
                                    this.hex.setPlayerControl(KNT_Game.me);
                                    this.hex.setPlayerControlBool(true);
                                    KNT_Game.me.addOwnedTile(this.hex);
                                    currentMarkerID = KNT_Game.createMarker(topleft, KNT_Game.me.getPlayerNumber(), spriteB);
                                }
                            }
                        }
                        else if (hex.traversed && KNT_Game.me.handsFull() && hex.doesPlayerHaveStack(KNT_Game.me.getPlayerNumber()))
                        {
                            List<Thing> temp = new List<Thing>();
                            temp = KNT_Game.getStackInHand();
                            foreach (Thing aThing in temp)
                                hex.addToPlayerStack(KNT_Game.me.getPlayerNumber(), aThing);

                            KNT_Game.removeStack(stacks[KNT_Game.me.getPlayerNumber()]);
                            stacks[KNT_Game.me.getPlayerNumber()] = KNT_Game.createStack(hex, hex.getPlayerStack(KNT_Game.me.getPlayerNumber()), spriteB);
                            hex.movePossible[KNT_Game.me.getPlayerNumber()] = false;
                            if (KNT_Game.me.getPlayerNumber() == 1)
                                stacks[1].Location(0 + topleft.X, 35 + topleft.Y);
                            if (KNT_Game.me.getPlayerNumber() == 2)
                                stacks[2].Location(25 + topleft.X, 35 + topleft.Y);
                            if (KNT_Game.me.getPlayerNumber() == 3)
                                stacks[3].Location(0 + topleft.X, 65 + topleft.Y);
                            if (KNT_Game.me.getPlayerNumber() == 4)
                                stacks[4].Location(25 + topleft.X, 65 + topleft.Y);

                            foreach (Tile t in GameBoard.Game.getMap().getHexList())
                                t.resetMovementLogic();
                        }

                        break;

                    case "Combat":
                        if (this.hex.getCFlag())
                        {
                            if (this.hex.doesPlayerHaveStack(KNT_Game.me.getPlayerNumber()))
                            {
                                Thread.Sleep(1);
                                resolveCombat(this.hex);
                            }
                        }
                        break;

                    case "Construction":
                        if (this.hex.getPlayer() == KNT_Game.me)
                        {
                            if (this.hex.getFort() < 3 && KNT_Game.me.getPlayerGold() >= 5)
                            {
                                KNT_Game.me.takePlayerGold(5);
                                this.hex.upgradeFort();
                            }
                            if (this.hex.getFort() == 3 )
                            {
                                bool haveCitadel = false;
                                //check income > 15
                                int g = 0;
                                foreach (Tile t in KNT_Game.me.getOwnedTiles())
                                {
                                    g++;
                                    g = g + t.getFort();
                                    if (t.getFort() == 4)
                                        haveCitadel = true;
                                }
                                //if so, upgrade Fort
                                if (!haveCitadel && g >=15)
                                {
                                    this.hex.upgradeFort();
                                    ((ConstructionPhase)GameBoard.Game.getCurrentPhase()).citadelBuilt();
                                }
                            }
                        }
                        break;
                }
            }
        }