/// <summary>
        /// Method is used to deserialize based on GUID.
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public GameObject GetGameObjectByGUID(Guid guid)
        {
            if (guid == Guid.Empty)
            {
                return(null);
            }

            GameObject obj = Level.Find(o => o.GUID == guid);

            return(obj);
        }
        public void SetupLevel(int levelIndex)
        {
            //Make the level.
            level = new Level(levelIndex);

            //Create a player for each connected client.
            for (int i = 0; i < Clients.Count; i++)
            {
                Client c      = Clients[i];
                Player player = new Player(c.ClientName, Level.Layer, c.playerType);

                //Put the player on a startTile.
                (Level.Find("StartTile" + (i + 1)) as Tile).PutOnTile(player);
                player.ComputeVisibility();
            }

            InitLivingObjects();
            SendOutUpdatedLevel(true);
        }
Ejemplo n.º 3
0
        public override bool OnServerReceive(LocalServer server)
        {
            NonAnimationSoundEvent nextLevelSound = new NonAnimationSoundEvent("Sounds/wooden-stairs-1");

            LocalServer.SendToClients(nextLevelSound);
            Level             level      = new Level(server.LevelIndex + 1);
            List <GameObject> playerlist = server.Level.FindAll(obj => obj is Player);

            for (int p = 1; p <= playerlist.Count; p++)
            {
                Player player = playerlist[p - 1] as Player;
                (level.Find("StartTile" + p) as Tile).PutOnTile(player);
                player.ActionPoints = Player.MaxActionPoints;
            }
            foreach (Player p in playerlist)
            {
                p.ComputeVisibility();
            }

            server.Level = level;

            LocalServer.SendToClients(new LevelUpdatedEvent(level));
            return(true);
        }