Ejemplo n.º 1
0
 public Broadcaster(IPlayerColliser colliser, IShapesColliser shapeColliser, Player player, Position mousePosition)
 {
     this.shapesCollsier = shapeColliser;
     this.colliser       = colliser;
     this.MousePosition  = mousePosition;
     this.player         = player;
     this.ts             = new CancellationTokenSource();
     this.ct             = ts.Token;
     context             = GlobalHost.ConnectionManager.GetHubContext <PlayerHub>();
     Task.Run(() => UpdatePlayer(), ct);
 }
Ejemplo n.º 2
0
        public void SpawnPlayer()
        {
            Player player = GameEngine.Instance.CreatePlayer(Context.ConnectionId);

            player.ConnectionId = Context.ConnectionId;
            Clients.AllExcept(Context.ConnectionId).spawnNewPlayer(player);
            Clients.Caller.spawnCurrentPlayer(player);
            Clients.Caller.spawnAllShapes(GameEngine.Instance.ShapesGenerator.GetAllShapes());
            var otherPlayers = GameEngine.Instance.GetOtherPlayers(player.Id);

            Clients.Caller.spawnOtherPlayers(otherPlayers);

            IPlayerColliser colliser       = NinjectObjectFactory.GetObject <IPlayerColliser>();
            IShapesColliser shapesColliser = NinjectObjectFactory.GetObject <IShapesColliser>();

            PlayerHub.broadcasters.Add(player.Id, new Broadcaster(colliser, shapesColliser, player, new Position(0, 0)));
        }