Inheritance: Californium.Entity
        public override void Enter()
        {
            Button button = new Button(new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height - 52.0f - 48.0f), "End Game");
            button.OnClick += Game.Exit;
            Entities.Add(button);

            base.Enter();
        }
Ejemplo n.º 2
0
        public override void Enter()
        {
            Button button = new Button(new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height - 52.0f - 48.0f), "Main Menu");
            button.OnClick += () =>
            {
                //Game.PopState();
                Game.SetState(new MainMenu());
                return true;
            };

            Entities.Add(button);

            base.Enter();
        }
Ejemplo n.º 3
0
        public override void Enter()
        {
            endTurnButton = new Button(new Vector2f(GameOptions.Width - 132.0f, GameOptions.Height - 244.0f), "End Turn");
            endTurnButton.OnClick += () =>
            {
                if (SelectedCards.Count != Client.CurrentBlackCard.Info.PickCount || !Client.InMatch)
                    return false;

                LocalPlayer.Thinking = false;
                Client.InMatch = false;
                Client.SendMessage(new EndTurn(SelectedCards));
                RemoveSelectedWhiteCards();

                return true;
            };

            Entities.Add(endTurnButton);

            base.Enter();
        }
Ejemplo n.º 4
0
        private void AddButton(Vector2f position, string value, Button.OnClickHandler handler)
        {
            Button button = new Button(position, value);
            button.OnClick += handler;

            Entities.Add(button);
        }
Ejemplo n.º 5
0
        public override void Enter()
        {
            Button okButton =
                new Button(new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height * PaddingVertical + GameOptions.Height * (1.0f - PaddingVertical * 2.0f) - 64.0f), "Alright");
            okButton.OnClick += () =>
            {
                Game.PopState();
                return true;
            };

            Entities.Add(okButton);

            base.Enter();
        }
Ejemplo n.º 6
0
        private void InitializeSession(SessionRole role, string ip)
        {
            switch (role)
            {
                case SessionRole.Server:
                    {
                        // Initialize server
                        try
                        {
                            Server.Initialize(Constants.DefaultPort);
                        }
                        catch (Exception)
                        {
                            Timer.NextFrame(() => Game.SetState(new ErrorMessageScreen("You are already hosting in another instance, moron.")));
                            return;
                        }

                        // Initialize client frontend
                        try
                        {
                            Client.Connect("localhost", Constants.DefaultPort);
                        }
                        catch (Exception)
                        {
                            Timer.NextFrame(() => Game.SetState(new ErrorMessageScreen("Cannot connect to host!")));
                            return;
                        }

                        // Add start button
                        Button startButton = new Button(new Vector2f(GameOptions.Width - 222.0f / 2.0f - 8.0f - 64.0f + 8.0f, Button.Height / 2.0f + 8.0f + 32.0f + 8.0f), "Begin Game");
                        startButton.OnClick += () =>
                        {
                            // Do not start unless we have enough players
                            if (Players.Count < Constants.MinimalPlayerCount)
                            {
                                ChatBacklog.Add(String.Format("Cannot begin game with less than {0} people!", Constants.MinimalPlayerCount));
                                return true;
                            }

                            // Load cards if we're the server
                            Server.LoadCards();

                            // Begin game
                            Client.SendMessage(new BeginGame());

                            return true;
                        };

                        Entities.Add(startButton);

                        // Add settings button
                        Button settingsButton = new Button(new Vector2f(GameOptions.Width - Button.Width / 2.0f - 8.0f - 64.0f + 8.0f - Button.Width - 4.0f, Button.Height / 2.0f + 8.0f + 32.0f + 8.0f), "Settings");
                        settingsButton.OnClick += () =>
                        {
                            Game.PushState(new HostSettingsOverlay());
                            return true;
                        };

                        Entities.Add(settingsButton);

                        break;
                    }

                case SessionRole.Client:
                    try
                    {
                        Client.Connect(ip, Constants.DefaultPort);
                    }
                    catch (Exception)
                    {
                        Timer.NextFrame(() => Game.SetState(new ErrorMessageScreen("Cannot connect to host!")));
                    }
                    break;
            }
        }
        public override void Enter()
        {
            Button refreshButton =
                new Button(new Vector2f(GameOptions.Width * (PaddingHorizontal * 2.5f) + Button.Width / 2.0f, GameOptions.Height / 2.0f + GameOptions.Height / 3.0f + 16.0f), "Refresh");
            refreshButton.OnClick += () =>
            {
                RefreshServerList();
                return true;
            };

            Entities.Add(refreshButton);

            Button backButton =
                new Button(new Vector2f(GameOptions.Width - GameOptions.Width * (PaddingHorizontal * 2.5f) - Button.Width / 2.0f, GameOptions.Height / 2.0f + GameOptions.Height / 3.0f + 16.0f), "Back");
            backButton.OnClick += () =>
            {
                Game.PopState();
                return true;
            };

            Entities.Add(backButton);

            Button joinByIpButton =
                new Button(new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height / 2.0f + GameOptions.Height / 3.0f + 16.0f), "Join by IP");
            joinByIpButton.OnClick += () =>
            {
                Game.PushState(new JoinByIpOverlay());
                return true;
            };

            Entities.Add(joinByIpButton);

            base.Enter();
        }
        public override void Enter()
        {
            ipAddressTextbox = new Textbox("")
            {
                Position = new Vector2f(GameOptions.Width * PaddingHorizontal + 32.0f, GameOptions.Height * PaddingVertical + 128.0f),
                Size = new Vector2f(GameOptions.Width * (1.0f - PaddingHorizontal * 2.0f) - 64.0f, 48.0f),
                Selected = true
            };

            Entities.Add(ipAddressTextbox);

            Button okButton =
                new Button(new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height * PaddingVertical + GameOptions.Height * (1.0f - PaddingVertical * 2.0f) - 64.0f), "Alright");
            okButton.OnClick += () =>
            {
                Game.PopState();
                JoinNext(ipAddressTextbox.Value);
                return true;
            };

            Entities.Add(okButton);

            base.Enter();
        }
Ejemplo n.º 9
0
        public override void Enter()
        {
            endTurnButton = new Button(new Vector2f(GameOptions.Width - 132.0f, GameOptions.Height - 244.0f), "End Turn");
            endTurnButton.OnClick += () =>
            {
                if (Client.InMatch && SelectedCards.Count != Client.CurrentBlackCard.Info.PickCount)
                {
                    string errorMessage = String.Format("Select {0} {1} before ending turn, moron.",
                                                        Client.CurrentBlackCard.Info.PickCount,
                                                        Client.CurrentBlackCard.Info.PickCount == 1 ? "card" : "cards");

                    Game.PushState(new PopupOverlay(errorMessage));

                    return false;
                }

                if (!Client.InMatch)
                    return false;

                LocalPlayer.Thinking = false;
                Client.InMatch = false;
                Client.SendMessage(new EndTurn(SelectedCards));
                RemoveSelectedWhiteCards();

                return true;
            };

            Entities.Add(endTurnButton);

            base.Enter();
        }
        public override void Enter()
        {
            float boundingY = GameOptions.Height * (PaddingVertical * 3.0f) + 80.0f;
            float boundingX = GameOptions.Width * (PaddingHorizontal * 2.5f);

            Numberbox numberSecondsPerTurn = new Numberbox("Seconds Per Turn", 180)
            {
                Position = new Vector2f(boundingX, boundingY),
                Value = Server.SecondsPerTurn,
                MinimumValue = 30
            };

            Numberbox numberboxPointCap = new Numberbox("Point Cap", 99)
            {
                Position = new Vector2f(GameOptions.Width - boundingX, boundingY),
                Value = Server.PointCap
            };

            Entities.Add(numberboxPointCap);

            numberboxPointCap.Position.X -= numberboxPointCap.Width;

            Entities.Add(numberSecondsPerTurn);

            List<Checkbox> decks = new List<Checkbox>();
            for (int i = 0; i < CardLoader.Decks.Count; i++)
            {
                CardLoader.CardDeck deck = CardLoader.Decks[i];

                Checkbox checkboxDeck = new Checkbox(deck.Name, deck.Include)
                {
                    Position = new Vector2f(boundingX + (i / 4 * 128), boundingY + 64.0f + 80.0f + ((i % 4) * 64.0f))
                };

                decks.Add(checkboxDeck);
                Entities.Add(checkboxDeck);
            }

            Button applyButton =
                new Button(new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height / 2.0f + GameOptions.Height / 3.0f + 16.0f), "Apply");
            applyButton.OnClick += () =>
            {
                Apply(decks, numberboxPointCap, numberSecondsPerTurn);
                return true;
            };

            Entities.Add(applyButton);

            base.Enter();
        }