Esempio n. 1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game game = new Game())
     {
         game.Run();
     }
 }
Esempio n. 2
0
 public Game()
 {
     this._players = new Player[4];
     this._mapIndex = -1;
     this._defaultHealth = 100;
     MainGame = this;
     this.Won = this.InCutSchene = this.CustomGame = false;
 }
Esempio n. 3
0
 public Lobby(Game game)
 {
     _game = game;
     _players = new Label[] { new Label("<empty slot> "), new Label("<empty slot>"), new Label("<empty slot>"), new Label("<empty slot>") };
     _chat = new Label[] { new Label(), new Label(), new Label(), new Label(), new Label() };
     _mainMenu = new Menu("Chat", _chat);
     _menuSettings = new Menu("Game Settings", new OptionNumeric("Health", _game.DefaultHealth, 10, 1000, 10), new OptionValue("  Map", "<none>", 0), new Option("-"), new Option("-", 1));
     _menuPlayers = new Menu("Lobby", _players);
     _menuSettings.MakeTight = _menuPlayers.MakeTight = true;
     _menuSettings.MaxLength = 51;
 }
Esempio n. 4
0
        public Shop(Game game, int playerIndex)
        {
            _guns = new List<Gun>();
            _guns.Add(new Pistol());
            _guns.Add(new MachineGun());
            _game = game;
            _playerSelection = new int[] { -1, -1 };
            if (_playerIndex < 4)
                _playerIndex = playerIndex;
            else
                _playerIndex = 0;

            if (Game.Network != null)
            {
                Game.Network.RegisterEvent((int)PacketCode.PlayerDisconnected, PlayerDisconnected);
                Game.Network.RegisterEvent((int)PacketCode.PlayerSelectionChanged, PlayerSelectionChanged);
                Game.Network.RegisterEvent((int)PacketCode.PlayerShopBuys, PlayerNetworkBuys);
            }
        }
Esempio n. 5
0
 public GameScreen(Game game)
 {
     _game = game;
 }
Esempio n. 6
0
        public static IScreen StartNewGame(bool story, int players, Map map)
        {
            OptionTextbox[] textboxes = new OptionTextbox[players];
            for (int i = 0; i < players; i++)
                textboxes[i] = new OptionTextbox("Player " + (i + 1), 12);

            Menu m = new Menu(new Option("-"), new Option("Start Game", 0), new Option("Back", 1));
            m.Options.InsertRange(0, textboxes);
            switch (m.Start(35, 7))
            {
                case 0:
                    for (int i = 0; i < players; i++)
                        if (string.IsNullOrEmpty(textboxes[i].Text))
                        {
                            m.Clear();
                            Menu msub = new Menu(Label.CreateLabelArrayFromText(
            "\nYou have to specify a name in\norder to start a new game."));
                            msub.Start(-1, 20);
                            msub.Clear();
                            return StartNewGame(story, players, map);
                        }
                    Game g = new Game();
                    for (int i = 0; i < players; i++)
                    {
                        Player p = new Player(i);
                        p.Name = textboxes[i].Text;
                        g.Players[i] = p;
                    }
                    for (int i = players; i < 4; i++)
                        g.Players[i] = null;

                    if (story)
                        g.LoadStoryMode();
                    else
                        g.Map = map;
                    g.CustomGame = !story;

                    if (Game.Network != null)
                    {
                        Game.Network.Dispose();
                        Game.Network = null;
                    }

                    return new Shop(g);

            }
            m.Clear();
            return null;
        }
Esempio n. 7
0
 public Shop(Game game)
     : this(game, 0)
 {
 }
Esempio n. 8
0
 public Board(Game game, Map map)
     : this(game)
 {
     _map = map;
 }
Esempio n. 9
0
 public Board(Game game)
     : this()
 {
     _game = game;
 }
Esempio n. 10
0
 public XmlManager(Game game)
 {
     _game = game;
 }
Esempio n. 11
0
        protected IScreen RegisterDefault(bool host)
        {
            Game.Network.NetworkDataHandler.RegisterTypeFromAssembly(System.Reflection.Assembly.GetCallingAssembly());
            Menu m;
            if (host)
            {
                m = new Menu(Label.CreateLabelArrayFromText("Registering default types and initialising lobby."));
                m.Start(-1, 3, false);
                Game game = new Game();
                Player p = new Player(0);
                p.Name = _name;
                game.Players[0] = p;
                game.CurrentPlayer = p;
                Game.Network.NetworkDataHandler.RegisterRecursive(game);
                m.Clear();
                return new Lobby(game);
            }
            else
            {
                m = new Menu(Label.CreateLabelArrayFromText("Connected to host. retreaving game data and initialising lobby."));
                m.Start(-1, 3, false)
                    ;
                Game game = Game.Network.NetworkDataHandler.RequestInstance<Game>();
                m.Clear();
                int index = 0;
                for (; index < game.Players.Length; index++)
                {
                    if (game.Players[index] == null)
                        break;
                }

                if (index == 4)
                    throw new Exception("Connection was allowed but the game was full");
                Player p = new Player(index);
                p.Controls = new PlayerControls(0);
                p.Name = _name;
                game.Players[index] = p;
                game.CurrentPlayer = p;
                Game.Network.NetworkDataHandler.RegisterRecursive(p);
                Game.Network.SendEvent((int)PacketCode.NewPlayer, p);
                return new Lobby(game);
            }
        }