protected Cloud(World world, float vapor, IGraphicManager graphicsHandler, ShapeType shapeType) { this.world = world; this.vapor = vapor; this.graphicsHandler = graphicsHandler; velocity = new Vector(); position = new Vector(); shape = graphicsHandler.InsertShape(shapeType); random = new Random(DateTime.UtcNow.Millisecond); }
public static string Create(Thunderstorm player, World world, int ticks) { StringBuilder builder = new StringBuilder(); builder.AppendLine(beginStateLine(ticks)); builder.AppendLine(youIndexLine(world, player)); foreach (Thunderstorm cloud in world.Thunderstorms) { builder.AppendLine(cloudLine("THUNDERSTORM", cloud)); } foreach (RainCloud cloud in world.RainClouds) { builder.AppendLine(cloudLine("RAINCLOUD", cloud)); } builder.AppendLine(endStateLine()); return builder.ToString(); }
public void Start() { hasClosed = false; gameLoop = new DispatcherTimerGameLoop(1000 / 100); gameLoop.Update += Update; gameWindow = new GameWindow(settings); gameWindow.Closed += (sender, args) => Stop(); SocketFactory socketGame = new SocketFactory(settings); socketGame.Cancel += Stop; socketManager = socketGame.CreateSocketManager(); GraphicManager graphicManager = new GraphicManager(gameWindow.Canvas); InputFactory inputFactory = new InputFactory(gameWindow.Canvas, socketManager); if (hasClosed) return; world = new World(settings, inputFactory, graphicManager); CompositionTarget.Rendering += (sender, args) => world.Draw(); world.Start(); gameWindow.Show(); gameLoop.Start(); }
public void Update(Thunderstorm thunderstorm, World world, int iteration) { if (thunderstorm.IsDead() || !IsConnected()) { Dispose(); return; } thunderstorm.Name = playerName; state = new { player = thunderstorm, world, iteration }; while (commandQueue.Any()) { ParseMessage(commandQueue.Dequeue(), thunderstorm); } }
public Thunderstorm(World world, float vapor, IGraphicManager graphicsHandler, ShapeType shapeType, IInputHandler inputHandler) : base(world, vapor, graphicsHandler, shapeType) { this.inputHandler = inputHandler; }
public RainCloud(World world, float vapor, IGraphicManager graphicsHandler, ShapeType shapeType) : base(world, vapor, graphicsHandler, shapeType) { }
private static string youIndexLine(World world, Thunderstorm player) { return "YOU {0}".Format(world.Thunderstorms.IndexOf(player)); }