public bool playNext(Graphics g, int screenWidth, int screenHeight) { try { if (!enabled) { return(false); } DeltaTimeCounter performanceCounter = new DeltaTimeCounter(); long deltaTime = deltaTimeCounter.PrintAndMeasureDelta("Seconds per frame"); GamePrints.Toggle(deltaTime); smallCache.cacheModel(model); largeCache.cacheModel(model); performanceCounter.PrintAndMeasureDelta("Cache drones"); Graphics mainG = Graphics.FromImage(mainImage); GameEvent gameEvent = new GameEvent(this, deltaTime / 100000.0, mainG, screenWidth, screenHeight); foreach (GameController controller in controllers) { controller.execute(gameEvent); performanceCounter.PrintAndMeasureDelta(controller.ToString()); } motionBlurFilter.Draw(gameEvent, g, mainImage); performanceCounter.PrintAndMeasureDelta("Motion blur"); winBanner.Draw(gameEvent, g); performanceCounter.PrintAndMeasureDelta("Win banner"); performanceCounter.PrintAndMeasureDelta("Draw win banner"); return(model.Winner != Team.neutral); } catch (Exception e) { Console.WriteLine(e.ToString()); } return(true); }
public void start(QuantumModel model, int screenWidth, int screenHeight) { motionBlurFilter = new MotionBlurFilter((int)model.mapWidth, (int)model.mapHeight); mainImage = new Bitmap((int)model.mapWidth, (int)model.mapHeight); controllers.Add(new CheckWinCondition()); controllers.Add(new GeneralController(Keys.W, Keys.S, Keys.A, Keys.D, Team.green)); controllers.Add(new GeneralController(Keys.Up, Keys.Down, Keys.Left, Keys.Right, Team.blue)); controllers.Add(new DroneOrderingController(Team.green, Keys.Q, MouseButtons.Left)); controllers.Add(new DroneOrderingController(Team.blue, Keys.ShiftKey, MouseButtons.Right)); controllers.Add(new DroneController()); controllers.Add(new DrownRespawnerController()); controllers.Add(new DronsFighting()); controllers.Add(new OutpostConquestController()); controllers.Add(new GlobalRender()); this.model = model; deltaTimeCounter = new DeltaTimeCounter(); enabled = true; }