Ejemplo n.º 1
0
        private void gameStartBtn_Click(object sender, EventArgs e)
        {
            // Check that we have the required amount of players to begin a
            // game.
            if (game.Players.Count >= Constants.MinimumPlayers)
            {
                #region enable/disable
                this.gameStartBtn.Enabled = false;
                #endregion

                _setGameMonitorState(_GameMonitorState.Online);

                // TODO: Uncomment this.
                game.Start();
            }
            else
            {
                // If we don't show the server administrator an error message.
                MessageBox.Show(
                    this,
                    String.Format(
                        "There must be at least {0} players connected before a game can begin.",
                        Constants.MinimumPlayers
                        ),
                    "Insufficient players.",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation
                    );
            }
        }
Ejemplo n.º 2
0
        /*
         * public GameForm(Game.Game G)
         * {
         *  context = SynchronizationContext.Current;
         *
         *  InitializeComponent();
         *  FormBorderStyle = FormBorderStyle.None;
         *  WindowState = FormWindowState.Maximized;
         *
         *  RunningGame = G;
         *  RunningGame.Render.ImageUpdated += Render_ImageUpdated;
         *  RunningGame.Width = Screen.PrimaryScreen.WorkingArea.Width;
         *  RunningGame.Height = Screen.PrimaryScreen.WorkingArea.Height;
         *
         *  //Player 1
         *  Player Player1 = new Player(30, 30, 'M' , RunningGame.Teams[0],true, RunningGame);
         *  Player1.KeyBindings.Add(Keys.W, new MoveState(Player1, Direction.Up));
         *  Player1.KeyBindings.Add(Keys.A, new MoveState(Player1, Direction.Left));
         *  Player1.KeyBindings.Add(Keys.S, new MoveState(Player1, Direction.Down));
         *  Player1.KeyBindings.Add(Keys.D, new MoveState(Player1, Direction.Right));
         *  AddPlayerToGame(Player1);
         *
         *  //Player 2
         *  Player Player2 = new Player(RunningGame.Width - 40, RunningGame.Height - 40, 'C', RunningGame.Teams[1],  true, RunningGame);
         *  Player2.KeyBindings.Add(Keys.Up, new MoveState(Player2, Direction.Up));
         *  Player2.KeyBindings.Add(Keys.Left, new MoveState(Player2, Direction.Left));
         *  Player2.KeyBindings.Add(Keys.Down, new MoveState(Player2, Direction.Down));
         *  Player2.KeyBindings.Add(Keys.Right, new MoveState(Player2, Direction.Right));
         *  AddPlayerToGame(Player2);
         *
         *
         *
         * }*/

        public GameForm(Game.Game G, List <Player> Players, List <Fighter> Bots)
        {
            context = SynchronizationContext.Current;

            InitializeComponent();
            FormBorderStyle = FormBorderStyle.None;
            WindowState     = FormWindowState.Maximized;

            RunningGame = G;
            RunningGame.Render.ImageUpdated += Render_ImageUpdated;
            RunningGame.Width  = Screen.PrimaryScreen.WorkingArea.Width;
            RunningGame.Height = Screen.PrimaryScreen.WorkingArea.Height;

            foreach (Player p in Players)
            {
                AddPlayerToGame(p);
            }

            foreach (Fighter Bot in Bots)
            {
                RunningGame.InitialBots.Add(Bot);
            }

            RunningGame.Start();
        }
Ejemplo n.º 3
0
        private void GamePage_OnLoaded(object sender, RoutedEventArgs e)
        {
            Application.Current.MainWindow.KeyDown     += GamePage_OnKeyDown;
            Application.Current.MainWindow.SizeChanged += MainWindowOnSizeChanged;
            _game = new Game.Game(_size, GameCanvas, _updateAfterMoveDelegate);
            _game.PlayWithComputer(_withComputer);
            _game.Start();

            ResultMessage.Visibility = Visibility.Collapsed;
        }
Ejemplo n.º 4
0
 private void Start()
 {
     if (Level == Level.UNKHOWN || Player == UnitType.UNKNOWN)
     {
         return;
     }
     Game = new Game.Game(Level, Player);
     Game.Start();
     GameBoard       = Game.GameBoard;
     IsStarted       = true;
     _timer          = new DispatcherTimer();
     _timer.Tick    += new EventHandler(GameStep);
     _timer.Interval = new TimeSpan(0, 0, 1);
     _timer.Start();
 }
Ejemplo n.º 5
0
        public override void HandlePackage()
        {
            Random random = new Random();
            int    n      = random.Next(7, 13);
            Room   room   = new Room
            {
                Width  = n,
                Height = n,
                Units  = new Unit[random.Next(1, 6)]
            };

            List <Position> startPositions = new List <Position>();

            while (startPositions.Count < room.Units.Length)
            {
                var position = new Position(random.Next(0, n), random.Next(0, n));
                if (startPositions.Any(p => p.X == position.X && p.Y == position.Y))
                {
                    continue;
                }

                startPositions.Add(position);
            }

            for (int i = 0; i < room.Units.Length; i++)
            {
                room.Units[i] = new Unit
                {
                    Id             = i + 1,
                    Position       = startPositions[i],
                    State          = States.Stay,
                    TargetPosition = startPositions[i]
                };
            }

            Client.SendPackage(new SetRoomPackage
            {
                Room = room
            });

            Game.Game game = new Game.Game(room, Client.ClientId);
            Client.SetGame(game);
            game.Start();
        }
Ejemplo n.º 6
0
        private void Window_Loaded(object sender, EventArgs e)
        {
            ResizeUI();
            this.SizeChanged  += (a, b) => ResizeUI();
            this.StateChanged += (a, b) => {
                System.Timers.Timer t = new System.Timers.Timer {
                    Interval  = 100,
                    AutoReset = false,
                    Enabled   = false,
                };
                t.Elapsed += (c, d) => { ResizeUI(); t.Enabled = false; };
                t.Enabled  = true;
            };

            this.BattleIconAttack.Source = new BitmapImage(new Uri(Environment.CurrentDirectory + @"\img\icons\attack.png", UriKind.Absolute));
            this.BattleIconArmor.Source  = new BitmapImage(new Uri(Environment.CurrentDirectory + @"\img\icons\armor.png", UriKind.Absolute));

            this.GlobalMapGridBackground.ImageSource = new BitmapImage(new Uri(Environment.CurrentDirectory + @"\img\globalMap\map.png", UriKind.Absolute));
            this.PlayerMarker.Source = new BitmapImage(new Uri(Environment.CurrentDirectory + @"\img\globalMap\playerMarker.png", UriKind.Absolute));

            Game.Game game = new Game.Game(this);
            game.Start(this);
        }
Ejemplo n.º 7
0
 public void Execute()
 {
     _game.Start();
 }
Ejemplo n.º 8
0
 static void Main(string[] args)
 {
     Game.Game g = new Game.Game();
     g.Start();
 }