//This method starts running the lobby and blocks until the lobby ends public void Run() { //Start the client listener in its own thread //This thread allows clients to asynchronously join the lobby Thread clientListenerThread = new Thread(new ThreadStart(ClientListener)); clientListenerThread.Start(); //wait to start MessageBox.Show("Enter to start", NetUtils.GetLocalIP()); //lock client list clientsMutex.WaitOne(); clientsLocked = true; clientsMutex.ReleaseMutex(); // Start up the game. Game1 game = new ServerGame(this); game.Run(); //the game has finished foreach (Player c in clients) { c.Disconnect(); } //this.prelimListener.Stop(); UdpTcpPair.StopListener(); clientListenerThread.Join(); }
public void Update(ServerGame game, Lobby lobby) { foreach (BigShip ship in aiBigShips.ToArray()) { if (ship.IsDestroyed) { aiBigShips.Remove(ship); } } while (game.GameObjectCollection.GetMasterList().GetList<SmallShip>().Count < 20) { SmallShip.SmallShipFactory(game); } while (game.GameObjectCollection.GetMasterList().GetList<BigShip>().Count < 5) { aiBigShips.Add(BigShip.BigShipFactory(game)); } ControllerFocusObject controllerFocusObject = game.GameObjectCollection.GetMasterList().GetList<ControllerFocusObject>()[0]; foreach (Player player in lobby.Clients) { if (controllerFocusObject.GetFocus(player.Id) == null || controllerFocusObject.GetFocus(player.Id).IsDestroyed) { BigShip playerShip = BigShip.BigShipFactory(game, player); CircleBigShips(playerShip.Position); } } }
public static void SmallShipFactory(ServerGame game, Player player) { SmallShip ship = new SmallShip(game); SmallShip.ServerInitialize(ship, game.WorldSize / 2, new Vector2(0, 0), player.Controller, player.Controller); ControllerFocusObject controllerFocusObject = game.GameObjectCollection.GetMasterList().GetList<ControllerFocusObject>()[0]; controllerFocusObject.SetFocus(player, ship); game.GameObjectCollection.Add(ship); }
public static void TowerFactory(ServerGame game) { Tower t = new Tower(game); Tower.ServerInitialize(t, RandomUtils.RandomVector2(new Rectangle(0, 0, 5000, 5000)) + game.WorldSize / 2, (float)(RandomUtils.random.NextDouble() * Math.PI * 2)); game.GameObjectCollection.Add(t); }
public static void SmallShipFactory(ServerGame game) { Rectangle spawnRect = new Rectangle((int)(game.WorldSize.X - 1000), 0, 1000, (int)(game.WorldSize.Y)); EvilAI c = new EvilAI(game); SmallShip ship3 = new SmallShip(game); SmallShip.ServerInitialize(ship3, Utils.RandomUtils.RandomVector2(spawnRect), new Vector2(0, 0), c, c); c.Focus = ship3; game.GameObjectCollection.Add(ship3); }
public ServerLogic(ServerGame game, Lobby lobby, Vector2 worldSize) { ControllerFocusObject controllerFocusObject = new ControllerFocusObject(game); ControllerFocusObject.ServerInitialize(controllerFocusObject, lobby.Clients.Count); game.GameObjectCollection.Add(controllerFocusObject); for (int j = 0; j < 4; j++) { Tower.TowerFactory(game); } }
public static BigShip BigShipFactory(ServerGame game) { GoodAI controller1 = new GoodAI(game); GoodGunnerAI controller2 = new GoodGunnerAI(game); GoodGunnerAI controller3 = new GoodGunnerAI(game); GoodGunnerAI controller4 = new GoodGunnerAI(game); BigShip ship = new BigShip(game); BigShip.ServerInitialize(ship, Utils.RandomUtils.RandomVector2(new Vector2(500))+game.WorldSize / 2, new Vector2(0, 0), controller1, controller2, controller3, controller4); game.GameObjectCollection.Add(ship); controller1.Focus = ship; controller1.TargetPosition = ship.Position; controller2.Focus = ship; controller3.Focus = ship; controller4.Focus = ship; return ship; }
public GoodAI(ServerGame game) : base(game) { this.game = game; }
public AbstractAIController(ServerGame game) { game.AIManager.AddController(this); }
public EvilAI(ServerGame game) : base(game) { this.game = game; }