Example #1
0
 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);
 }
Example #2
0
 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();
 }
Example #3
0
        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();
        }
Example #4
0
        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);
            }
        }
Example #5
0
 public Thunderstorm(World world, float vapor, IGraphicManager graphicsHandler, ShapeType shapeType,
                     IInputHandler inputHandler)
     : base(world, vapor, graphicsHandler, shapeType)
 {
     this.inputHandler = inputHandler;
 }
Example #6
0
 public RainCloud(World world, float vapor, IGraphicManager graphicsHandler, ShapeType shapeType)
     : base(world, vapor, graphicsHandler, shapeType)
 {
 }
Example #7
0
 private static string youIndexLine(World world, Thunderstorm player)
 {
     return "YOU {0}".Format(world.Thunderstorms.IndexOf(player));
 }