public PlayerManager(Random rand, PlayerPool pool, MapCore mapCore, ObjectPool <ImageBase> imagesDeath, LevelMode levelMode) { this.pool = pool; this.rand = rand; this.mapCore = mapCore; this.imagesDeath = imagesDeath; this.levelMode = levelMode; models = new List <PlayerModelBase>(); models.AddRange(pool.GetCurrentPlayerModels()); pool.AddedPlayer += model => models.Add(model); pool.RemovePlayer += model => models.Remove(model); }
public void GameInfoPlayersReceive(JToken jToken) { foreach (var player in jToken.Children <JObject>()) { var playerId = player[ServerParams.UserId].ToString(); if (!PlayerPool.ContainsKey(playerId)) { PlayerManager.CreateServerModel(new PlayerCore(player[ServerParams.UserName].ToString(), playerId, Configs.Player["sample"]), Instantiate(prefabServerPlayer)); } } if (!Camera.IsWatcher && PlayerPool.GetCurrentPlayerModels().Any()) { Camera.Watch(PlayerPool.GetCurrentPlayerModels().First().transform); } }