Ejemplo n.º 1
0
        public ClientDispatcher(NetworkedScene n)
        {
            this.networkedScene = n;
            this.networkService = networkedScene.networkService;

            playerInfo = new List <PlayerInfo>();
        }
Ejemplo n.º 2
0
 public ServerDispatcher(NetworkedScene n)
 {
     this.networkedScene = n;
     this.networkService = networkedScene.networkService;
     ids          = new List <string>();
     names        = new List <string>();
     chosenColors = new HashSet <int>();
 }
Ejemplo n.º 3
0
        /**
         * <summary>
         * Sets the camera according to the initial position of the player
         * </summary>
         */
        public void SetCameraPosition(int number, int max, NetworkedScene ns)
        {
            PopulateInitialPosition init = PopulateInitialPosition.GetPlayerPosition(number, max, width, height, castleWidth, castleHeight);
            LayerTile tile = Map.map.GetTileByMapCoordinates(init.x + castleWidth / 2, init.y + castleHeight / 2);

            if (tile != null)
            {
                Vector2 pos = tile.LocalPosition + WorldObjectData.center;
                ns.RenderManager.ActiveCamera2D.Transform.Position = pos;
            }
        }
Ejemplo n.º 4
0
        /**
         * <summary>
         * Loads the map from the TiledMap into the arrays
         * </summary>
         */
        public void SetMap()
        {
            networkedScene = (Owner.Scene as NetworkedScene);

            IEnumerator <string> keys = tiledMap.TileLayers.Keys.GetEnumerator();

            if (keys.MoveNext())
            {
                string layer = keys.Current;

                occupied = new bool[width, height];

                mobiles = new WorldObject[width, height];
                objects = new WorldObject[width, height];

                if (layer != null)
                {
                    mapLayer = tiledMap.TileLayers[layer];
                    foreach (LayerTile tile in mapLayer.Tiles)
                    {
                        if (InBounds(tile.X, tile.Y))
                        {
                            occupied[tile.X, tile.Y] = false;
                            mobiles[tile.X, tile.Y]  = null;
                            objects[tile.X, tile.Y]  = null;
                        }
                    }
                }
            }

            Color back = RenderManager.ActiveCamera2D.BackgroundColor;

            //Hide non-playable map
            if (height != tiledMap.Height)
            {
                Entity quad = new Entity()
                              .AddComponent(new Transform2D()
                {
                    Position = new Vector2(width * tiledMap.TileWidth, 0),

                    Scale = new Vector2((tiledMap.Width - width), tiledMap.Height)
                })

                              .AddComponent(new Sprite(WaveContent.Assets.Blank_png)
                {
                    TintColor = back
                })
                              .AddComponent(new SpriteRenderer());
                EntityManager.Add(quad);
            }
            if (width != tiledMap.Width)
            {
                Entity quad = new Entity()
                              .AddComponent(new Transform2D()
                {
                    Position = new Vector2(0, height * tiledMap.TileHeight),
                    Scale    = new Vector2(tiledMap.Width, (tiledMap.Height - height))
                })

                              .AddComponent(new Sprite(WaveContent.Assets.Blank_png)
                {
                    TintColor = back
                })
                              .AddComponent(new SpriteRenderer());
                EntityManager.Add(quad);
            }
        }