Example #1
0
        public void SpawnBoosts()
        {
            Obstacle obs = new Powerup(0, 0, 0, 0, 0);

            if (rnd.Next(2) == 0)
            {
                return;
            }

            int powerUpType = rnd.Next(3);

            ObstacleFactory.boostPrototypes.TryGetValue((Powerup.PowerUpType)powerUpType, out obs);
            Obstacle pwrUp = obs.Clone();

            pwrUp.SetPosition(new System.Drawing.Point(rnd.Next(720), rnd.Next(280)));
            ((Powerup)pwrUp).SetTime(rnd.Next(3, 8));
            foreach (Game game in Program.Games)
            {
                foreach (Player player in game.Players)
                {
                    hubContext.Clients.Clients(GameHub.GetConnectionId(player.id.ToString())).SendAsync("Boost",
                                                                                                        ((Powerup)pwrUp).id,
                                                                                                        ((Powerup)pwrUp).type,
                                                                                                        ((Powerup)pwrUp).value,
                                                                                                        ((Powerup)pwrUp).x,
                                                                                                        ((Powerup)pwrUp).y,
                                                                                                        ((Powerup)pwrUp).time
                                                                                                        );
                }
            }
        }