public VisibleSectorsStrategyRadius(SectorManagerUnity sectorManagerUnity, SectorManager sectorManager, Player player, PlayerUnity playerUnity)
 {
     this.sectorManager = sectorManager;
     this.player = player;
     this.playerUnity = playerUnity;
     this.sectorManagerUnity = sectorManagerUnity;
 }
Beispiel #2
0
        public Avatar CreateAvatar(AvatarDefinition avatarDefinition, int objectId, Vector3 pos, bool dispatchWorldListener)
        {
            Avatar avatar;

            if (avatarDefinition.id == "player")
            {
                avatar = new Player(world, avatarDefinition, objectId);
                this.player = avatar as Player;
            }
            else if (avatarDefinition.id == "player_remote")
            {
                avatar = new Player(world, avatarDefinition, objectId);
            }
            else
            {
                avatar = new Avatar(world, avatarDefinition, objectId);
                avatar.AddComponent(new AvatarComponentIA());
            }

            avatar.position = pos;

            avatars.Add(avatar);

            if (dispatchWorldListener)
                world.cwListener.CreateObject(avatar);

            return avatar;
        }
Beispiel #3
0
		public void Clear()
		{
			foreach(Avatar avatar in avatars)
				avatar.Clear();
			avatars.Clear();
			
			player = null;
		}
 private byte[] GetInitialData(MultiplayerClient client, Player player)
 {
     return world.SaveMultiplayer(player);
 }
Beispiel #5
0
        public byte[] SaveMultiplayer(Player player)
        {
            //Save world to memory
            MemoryStream bytesStream = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(bytesStream);

            //Basic world info
            SaveMultiplayer(bw);

            //Managers
            tileManager.Save(bw);
            itemManager.Save(bw);
            sectorManager.Save(bw);
            dayCycleManager.Save(bw);

            //Player avatar
            bw.Write(player.objectId);
            player.Save(bw);

            bw.Flush();

            byte[] bytes = bytesStream.ToArray();

            //Write header
            MemoryStream bytesStreamFinal = new MemoryStream();
            BinaryWriter bwFinal = new BinaryWriter(bytesStreamFinal);

            bwFinal.Write(bytes.Length);
            bwFinal.Flush();

            //Compress and write world
            GZipStream gzipStream = new GZipStream(bytesStreamFinal, CompressionMode.Compress, CompressionLevel.BestSpeed, true);
            gzipStream.Write(bytes, 0, bytes.Length);
            gzipStream.Close();

            return bytesStreamFinal.ToArray();
        }