Ejemplo n.º 1
0
        public override void update(GameTime gameTime)
        {
            base.update(gameTime);

            foreach (GestureSample gesture in GestureManager.Gestures)
            {
                if (gesture.GestureType == GestureType.Tap)
                {
                    PatchButton hitButton = buttons.FindLast(x => x.checkForHit(gesture.Position));
                    if (hitButton != null)
                    {
                        hitButton.doAction();
                    }
                    PatchField hitField = fields.FindLast(x => x.checkForHit(gesture.Position));
                    if (hitField != null)
                    {
                        hitField.getInput();
                    }
                }
            }

            foreach (Movable movable in movables)
            {
                movable.update(gameTime);
            }
        }
Ejemplo n.º 2
0
 public void addButton(PatchButton button)
 {
     if (buttons.Contains(button))
     {
         buttons.Remove(button);
     }
     buttons.Add(button);
 }
Ejemplo n.º 3
0
        public PageSettings(MainGame mainGame) : base(mainGame)
        {
            Arranger arranger = new Arranger(true, 1, 'C', ScaleManager.InterfaceScale * 2);

            muteButton = new PatchButton(15, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, SettingsHelper.Instance.Mute ? "Un-mute Sounds" : "Mute Sounds", () => {
                SettingsHelper.Instance.Mute = !SettingsHelper.Instance.Mute;
                AudioHelper.play(ContentStore.soundPop);
                muteButton.Text = SettingsHelper.Instance.Mute ? "Un-mute Sounds" : "Mute Sounds";
            });
            addButton(muteButton);
            arranger.addObject(muteButton, 0);

            toggleUsernamesButton = new PatchButton(15, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, SettingsHelper.Instance.ShowNameplates ? "Hide Usernames" : "Show Usernames", () => {
                SettingsHelper.Instance.ShowNameplates = !SettingsHelper.Instance.ShowNameplates;
                AudioHelper.play(ContentStore.soundPop);
                toggleUsernamesButton.Text = SettingsHelper.Instance.ShowNameplates ? "Hide Usernames" : "Show Usernames";
            });
            addButton(toggleUsernamesButton);
            arranger.addObject(toggleUsernamesButton, 0);

            playerCountCheckButton = new PatchButton(15, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, SettingsHelper.Instance.PlayerCountCheck ? "Min. Players: 3" : "Min. Players: 1", () => {
                SettingsHelper.Instance.PlayerCountCheck = !SettingsHelper.Instance.PlayerCountCheck;
                AudioHelper.play(ContentStore.soundPop);
                playerCountCheckButton.Text = SettingsHelper.Instance.PlayerCountCheck ? "Min. Players: 3" : "Min. Players: 1";
            });
            addButton(playerCountCheckButton);
            arranger.addObject(playerCountCheckButton, 0);

            demoModeButton = new PatchButton(15, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, SettingsHelper.Instance.DemoMode ? "Demo Mode: ON" : "Demo Mode: OFF", () => {
                SettingsHelper.Instance.DemoMode = !SettingsHelper.Instance.DemoMode;
                AudioHelper.play(ContentStore.soundPop);
                demoModeButton.Text = SettingsHelper.Instance.DemoMode ? "Demo Mode: ON" : "Demo Mode: OFF";
            });
            addButton(demoModeButton);
            arranger.addObject(demoModeButton, 0);

            resetFirstRunButton = new PatchButton(15, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, SettingsHelper.Instance.FirstRun ? "Have fun!" : "Clear Saved Data", () => {
                if (!SettingsHelper.Instance.FirstRun)
                {
                    SettingsHelper.Instance.ResetFirstRun();
                    AudioHelper.play(ContentStore.soundPop);
                }

                resetFirstRunButton.Text = SettingsHelper.Instance.FirstRun ? "Have fun!" : "Reset First Run";
            });
            addButton(resetFirstRunButton);
            arranger.addObject(resetFirstRunButton, 0);

            PatchButton backButton = new PatchButton(5, Vector2.Zero, buttonPatch, ScaleManager.InterfaceScale, "Back", () => {
                AudioHelper.play(ContentStore.soundPop);
                mainGame.menuController.changeActivePage(mainGame.mainMenu);
            });

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

            arranger.performArrangements();
        }
Ejemplo n.º 4
0
        public PageTutorial(MainGame mainGame) : base(mainGame)
        {
            whiteout = new Texture2D(mainGame.GraphicsDevice, 1, 1);
            whiteout.SetData <Color>(new Color[] { Color.White });
            slides  = new Texture2D[14];
            anchors = new SlideAnchor[14];
            for (int i = 1; i <= 14; i++)
            {
                slides[i - 1]  = mainGame.Content.Load <Texture2D>("tutorial\\Tutorial_A" + i.ToString() + ".png");
                anchors[i - 1] = new SlideAnchor(Arranger.staticPoint(0.5f, 0.5f));
                addMovable(anchors[i - 1]);
            }
            leftArrow  = mainGame.Content.Load <Texture2D>("tutorial\\arrowLeft.png");
            rightArrow = mainGame.Content.Load <Texture2D>("tutorial\\arrowRight.png");

            scale     = (float)screenSize.Y / (float)slides[0].Height;
            texCentre = new Vector2(slides[0].Width / 2f, slides[0].Height / 2f);

            Arranger arranger = new Arranger(true, 3, 'R', ScaleManager.InterfaceScale * 2);

            LinePoly backPoly = new LinePoly(
                Vector2.Zero,
                new Vector2(-9.5f, -10f),
                new Vector2(9.5f, -10f),
                new Vector2(9.5f, 10f),
                new Vector2(-9.5f, 10f)
                );

            navigateBack = new PolyButton(Vector2.Zero, backPoly, leftArrow, new Vector2(7.5f, 8f), ScaleManager.CardScale, 0f);
            arranger.addObject(navigateBack, 0);
            addMovable(navigateBack);

            LinePoly fwdPoly = new LinePoly(
                Vector2.Zero,
                new Vector2(-9.5f, -10f),
                new Vector2(9.5f, -10f),
                new Vector2(9.5f, 10f),
                new Vector2(-9.5f, 10f)
                );

            navigateForward = new PolyButton(Vector2.Zero, fwdPoly, rightArrow, new Vector2(7.5f, 8f), ScaleManager.InterfaceScale, 0f);
            arranger.addObject(navigateForward, 2);
            addMovable(navigateForward);

            backButton = new PatchButton(5, Vector2.Zero, ContentStore.standardPatch, ScaleManager.InterfaceScale, "Back", () => {
                AudioHelper.play(ContentStore.soundPop);
                mainGame.menuController.changeActivePage(mainGame.mainMenu);
            });
            addButton(backButton);
            arranger.addObject(backButton, 1);

            arranger.performArrangements();
        }
Ejemplo n.º 5
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.º 6
0
        public FrameBid(Vector2 position) : base(position)
        {
            ticker = new Ticker(new Vector2(screenSize.X * 3f / 5f, screenSize.Y * 1f / 3f), ScaleManager.InterfaceScale);
            ticker.setRange(0, 0);
            button = new PatchButton(9, new Vector2(screenSize.X * 4f / 5f, screenSize.Y * 1f / 3f), ContentStore.standardPatch, ScaleManager.InterfaceScale, "Place Bid", () => {
                UltraClient.Instance.network.SendBid(new Bid(ticker.Value, ClientDataStore.Instance.CurrentPlayer.ID), null);
                Console.WriteLine("SENT BID");
                GameClient.Instance.frameController.stow(this);
            });
            patch = ContentStore.bidPatch;
            int      padding  = ScaleManager.InterfaceScale * 2;
            Arranger arranger = new Arranger(false, 1, 'R', padding);

            arranger.addObject(ticker, 0);
            arranger.addObject(button, 0);
            arranger.performArrangements();
            Point topLeft = new Vector2(ticker.Position.X - ((ticker.Width / 2) + padding), ticker.Position.Y - ((ticker.Height / 2) + padding)).ToPoint();

            patchSize = patch.wrap(new Point(ScaleManager.ScreenSize.X - topLeft.X, ticker.Height + 2 * padding), ScaleManager.InterfaceScale);
            patchPos  = new Point(ScaleManager.ScreenSize.X - patchSize.X, (ScaleManager.ScreenSize.Y - patchSize.Y) / 2);
        }
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();
        }