Ejemplo n.º 1
0
        public void HostBidReceived(Bid bid)
        {
            if (MainGame.Instance.HostOnly)
            {
                while (bid == null)
                {
                    ;
                }
                debugOut("Bid received");

                clientData.placeBid(bid);

                AudioHelper.play(ContentStore.soundNeutral);
                Console.WriteLine("Bid player ID: " + bid.ID);
                Console.WriteLine(network.Players.GetPlayerByID(bid.ID).Name + " bid to win " + bid.Value);
                MainGame.Instance.GeneralMessageQueue.Enqueue(network.Players.GetPlayerByID(bid.ID).Name + " bid to win " + bid.Value);
                Thread.Sleep(1000);
            }
        }
Ejemplo n.º 2
0
        public override void update(GameTime gameTime)
        {
            base.update(gameTime);
            for (int i = 0; i < 14; i++)
            {
                if (i == index)
                {
                    anchors[i].moveTo(position + Arranger.staticPoint(0.5f, 0.5f), ScaleManager.InterfaceScale);
                }
                else if (i > index)
                {
                    anchors[i].moveTo(position + Arranger.staticPoint(1.5f, 0.5f), ScaleManager.InterfaceScale);
                }
                else if (i < index)
                {
                    anchors[i].moveTo(position + Arranger.staticPoint(-0.5f, 0.5f), ScaleManager.InterfaceScale);
                }
            }

            foreach (GestureSample gesture in GestureManager.Gestures)
            {
                if (gesture.GestureType == GestureType.Tap)
                {
                    if (navigateBack.checkForHit(gesture.Position))
                    {
                        if (index != 0)
                        {
                            AudioHelper.play(ContentStore.soundRoll);
                            index--;
                        }
                    }
                    if (navigateForward.checkForHit(gesture.Position))
                    {
                        if (index != 13)
                        {
                            AudioHelper.play(ContentStore.soundRoll);
                            index++;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public PageMainMenu(MainGame mainGame) : base(mainGame)
        {
            Arranger arranger = new Arranger(true, 1, 'C', ScaleManager.InterfaceScale * 2);

            spacer = new Arranger.ArrangerSpacer(128 * ScaleManager.InterfaceScale, 64 * ScaleManager.InterfaceScale, false);
            addMovable(spacer);
            arranger.addObject(spacer, 0);

            PatchButton joinButton = new PatchButton(10, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, "Join Game", () => {
                AudioHelper.play(ContentStore.soundPop);
                mainGame.menuController.changeActivePage(mainGame.joinMenu);
            });

            addButton(joinButton);
            arranger.addObject(joinButton, 0);

            PatchButton hostButton = new PatchButton(10, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, "Host Game", () => {
                AudioHelper.play(ContentStore.soundPop);
                mainGame.menuController.changeActivePage(mainGame.preHostGame);
            });

            addButton(hostButton);
            arranger.addObject(hostButton, 0);

            PatchButton settingsButton = new PatchButton(10, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, "Settings", () => {
                AudioHelper.play(ContentStore.soundPop);
                mainGame.menuController.changeActivePage(mainGame.settingsMenu);
            });

            addButton(settingsButton);
            arranger.addObject(settingsButton, 0);

            PatchButton helpButton = new PatchButton(10, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, "Help", () => {
                AudioHelper.play(ContentStore.soundPop);
                mainGame.menuController.changeActivePage(mainGame.tutorialPage);
            });

            addButton(helpButton);
            arranger.addObject(helpButton, 0);

            arranger.performArrangements();
        }
Ejemplo n.º 4
0
        public void CardReceived(RawCard card)
        {
            debugOut("Card received");
            if (card == lastReceivedCard)
            {
                return;
            }

            if (card.Player != -1)
            {
                client.playCard(card);
                clientData.cardPlayed(card, card.Player);
            }
            else
            {
                client.dealtCard(card);
            }

            lastReceivedCard = card;

            AudioHelper.play(ContentStore.soundSlide);
        }
Ejemplo n.º 5
0
        public override void update(GameTime gameTime)
        {
            base.update(gameTime);
            foreach (GestureSample gesture in GestureManager.Gestures)
            {
                if (gesture.GestureType == GestureType.Tap)
                {
                    if (upButton.checkForHit(gesture.Position))
                    {
                        if (value < rangeHigh)
                        {
                            value++;
                            AudioHelper.play(ContentStore.soundRoll);
                        }
                        else
                        {
                            AudioHelper.play(ContentStore.soundBad);
                        }
                    }
                    if (downButton.checkForHit(gesture.Position))
                    {
                        if (value > rangeLow)
                        {
                            value--;
                            AudioHelper.play(ContentStore.soundRoll);
                        }
                        else
                        {
                            AudioHelper.play(ContentStore.soundBad);
                        }
                    }
                }
            }

            upButton.update(gameTime);
            downButton.update(gameTime);
        }
Ejemplo n.º 6
0
        public void BidReceived(Bid bid)
        {
            while (bid == null)
            {
                ;
            }
            debugOut("Bid received");

            if (bid == lastReceivedBid)
            {
                return;
            }

            if (bid.ID == clientData.CurrentPlayer.ID)
            {
                try {
                    client.frameController.stow(client.frameBid);
                } catch (FrameController.InvalidFrameException) {
                }
            }

            foreach (Player p in network.Players.GetPlayers())
            {
                Console.WriteLine(p.Name + " (" + p.ID + ")");
            }

            clientData.placeBid(bid);

            lastReceivedBid = bid;

            AudioHelper.play(ContentStore.soundNeutral);
            Console.WriteLine("Bid player ID: " + bid.ID);
            Console.WriteLine(network.Players.GetPlayerByID(bid.ID).Name + " bid to win " + bid.Value);
            MainGame.Instance.GeneralMessageQueue.Enqueue(network.Players.GetPlayerByID(bid.ID).Name + " bid to win " + bid.Value);
            Thread.Sleep(1000);
        }
Ejemplo n.º 7
0
        public PageJoinGame(MainGame mainGame) : base(mainGame)
        {
            Arranger arranger = new Arranger(true, 1, 'C', ScaleManager.InterfaceScale * 2);

            nameField = new PatchField(4, 15, Vector2.Zero, ScaleManager.InterfaceScale, "Name", "Enter Name...", "Enter your Name:", true);
            if (UltraClient.Instance.network.GetLastClientName() != null)
            {
                nameField.Text = UltraClient.Instance.network.GetLastClientName();
            }
            addField(nameField);
            arranger.addObject(nameField, 0);

            String lastIP      = UltraClient.Instance.network.GetLastServerIP();
            String convertedIP = "";

            try {
                convertedIP = IPHelper.decToSimple(lastIP + ":60347");
            } catch {
                Console.WriteLine("[IPHelper] Error: Invalid conversion.");
            }

            ipField = new PatchField(4, 15, Vector2.Zero, ScaleManager.InterfaceScale, "IP", (lastIP != null ? convertedIP : "Enter Server..."), "Enter the server's IP:", true);
            addField(ipField);
            arranger.addObject(ipField, 0);

            Arranger.ArrangerSpacer spacer = new Arranger.ArrangerSpacer(128 * ScaleManager.InterfaceScale, 8 * ScaleManager.InterfaceScale, false);
            addMovable(spacer);
            arranger.addObject(spacer, 0);

            scanButton = new PatchButton(15, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, "Scan QR Code", async() => {
                if (!joinAttempted)
                {
                    AudioHelper.play(ContentStore.soundPop);
                    var scanner = new ZXing.Mobile.MobileBarcodeScanner();
                    var result  = await scanner.Scan();
                    if (result != null)
                    {
                        ipField.Text = result.ToString();
                    }
                }
            });
            addButton(scanButton);
            arranger.addObject(scanButton, 0);

            joinButton = new PatchButton(15, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, "Join", () => {
                if (!joinAttempted)
                {
                    joinAttempted   = true;
                    joinButton.Text = "Joining...";
                    AudioHelper.play(ContentStore.soundPop);
                    string standardIP = "";
                    String ip         = "";
                    int port          = 0;

                    try {
                        standardIP = IPHelper.simpleToDec(ipField.Text, true);

                        if (standardIP.StartsWith("IP"))
                        {
                            MainGame.Instance.GeneralMessageQueue.Enqueue(standardIP);
                            joinAttempted = false;
                            SetJoinButtonText("Join");
                            AudioHelper.play(ContentStore.soundBad);
                            return;
                        }

                        ip                = IPHelper.getIP(standardIP);
                        port              = int.Parse(IPHelper.getPort(standardIP));
                        clientTask        = UltraClient.Instance.network.StartClient(ip, port, 0, new Player(nameField.Text, 2));
                        nameField.Enabled = false;
                        ipField.Enabled   = false;
                    } catch (Exception e) {
                        UltraClient.Instance.ClientJoinFailed(null);
                        Console.WriteLine("Error: " + e.Message);
                    }
                }
            });
            addButton(joinButton);
            arranger.addObject(joinButton, 0);

            backButton = new PatchButton(5, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, "Back", () => {
                AudioHelper.play(ContentStore.soundPop);
                if (backButton.Text != "-")
                {
                    AudioHelper.play(ContentStore.soundPop);
//					UltraClient.Instance.network.SendLeaveGameMessage(UltraClient.Instance.network.Me);
//					UltraClient.Instance.network.Me = null;
//					mainGame.GeneralMessageQueue.Enqueue("You left the game!");
//					backButton.Text = "Back";
//					joinButton.Text = "Join";
//					joinAttempted = false;
                    mainGame.menuController.changeActivePage(mainGame.mainMenu);
                }
                else
                {
                    AudioHelper.play(ContentStore.soundBad);
                }
            });
            addButton(backButton);
            arranger.addObject(backButton, 0);

            arranger.performArrangements();
        }
Ejemplo n.º 8
0
        public PageHostGame(MainGame mainGame) : base(mainGame)
        {
            Arranger arranger = new Arranger(true, 2, 'C', ScaleManager.InterfaceScale * 2);

            spacer = new Arranger.ArrangerSpacer(100 * ScaleManager.InterfaceScale, false);
            addMovable(spacer);
            arranger.addObject(spacer, 0);

            ipField = new PatchField(2, 13, Vector2.Zero, ScaleManager.InterfaceScale, "IP", "Starting...", null, false);
            addField(ipField);
            arranger.addObject(ipField, 0);

            backButton = new PatchButton(5, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, "Back", () => {
                AudioHelper.play(ContentStore.soundPop);
                mainGame.menuController.changeActivePage(mainGame.preHostGame);
                UltraServer.Instance.network.CloseServer();
                UltraClient.Instance.network.CloseClient();
                for (int i = 1; i <= 6; i++)
                {
                    NineGridRow row              = joinedGrid.getRow(i.ToString());
                    row.getCell("player").Text   = "...";
                    row.getCell("player").Colour = Color.White;
                }
                ClientDataStore.Instance.resetPlayers();
            });
            addButton(backButton);
            arranger.addObject(backButton, 0);

            joinedGrid = new NineGrid(Vector2.Zero, ScaleManager.InterfaceScale, ScaleManager.LargeFont, new string[] { "player" }, new int[] { 13 });
            NineGridRow header = joinedGrid.addRow("header");

            header.getCell("player").Text      = "Players";
            header.getCell("player").Alignment = 'C';
            for (int i = 1; i <= 6; i++)
            {
                NineGridRow playerRow = joinedGrid.addRow(i.ToString());
                playerRow.getCell("player").Text      = ("...");
                playerRow.getCell("player").Alignment = 'C';
            }
            addMovable(joinedGrid);
            arranger.addObject(joinedGrid, 1);

            beginButton = new PatchButton(13, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, "Begin!", () => {
                AudioHelper.play(ContentStore.soundPop);

                int playerCount = UltraServer.Instance.network.Players.GetPlayers().Count;
                if ((playerCount < 3 && SettingsHelper.Instance.PlayerCountCheck) || (!SettingsHelper.Instance.PlayerCountCheck && playerCount == 0))
                {
                    if (!SettingsHelper.Instance.PlayerCountCheck)
                    {
                        mainGame.GeneralMessageQueue.Enqueue("At least 1 more player must join!");
                        return;
                    }

                    if (3 - playerCount > 1)
                    {
                        mainGame.GeneralMessageQueue.Enqueue("At least " + (3 - playerCount) + " more players must join!");
                    }
                    else
                    {
                        mainGame.GeneralMessageQueue.Enqueue("At least " + (3 - playerCount) + " more player must join!");
                    }

                    return;
                }

                if (mainGame.HostOnly)
                {
                    mainGame.gameIsRunning = true;
                    UltraServer.Instance.network.SendStartGameMessage();
                    GameScheduler.initialise(UltraServer.Instance.network.Players.GetPlayers(), UltraServer.Instance.network, UltraServer.Instance);
                    UltraServer.Instance.HostStarted();
                }
                else
                {
                    UltraServer.Instance.network.SendStartGameMessage();
                    GameScheduler.initialise(UltraServer.Instance.network.Players.GetPlayers(), UltraServer.Instance.network, UltraServer.Instance);
                }

                Thread schedulerThread = new Thread(new ThreadStart(GameScheduler.schedulerThread));
                schedulerThread.Start();
            });
            addButton(beginButton);
            arranger.addObject(beginButton, 1);

            arranger.performArrangements();
        }