public void Start() { var players = _playerProvider.GetCurrentPlayers(); var notificators = GameObject.FindObjectsOfType <PlayerCountChanger>() .Select(x => x.GetComponent <IPlayerChangeNotificator>()); players.ForEach(CreatePlayer); notificators.Select(x => x.ChangePlayerCountAsObservable()) .Merge() .Subscribe(x => { if (x == 1) { _playerManager.AddPlayer(); } else { _playerManager.RemoveLastPlayer(); } }).AddTo(_disposable); _playerManager.AddPlayerAsObservable() .Subscribe(CreatePlayer) .AddTo(_disposable); _playerManager.RemovePlayerAsObservable() .Subscribe(RemovePlayer) .AddTo(_disposable); }
private void SetupGame() { //on setup, reset all variables to their defaults _boardState = new BoardStateManager(_locationManager); _infectionDeckManager = new InfectionDeckManager(_locationManager); _cureDeckManager = new CureDeckManager(_locationManager); _infectionDrawCount = Properties.Settings.Default.DEFAULT_INFECTION_DRAW; DifficultyLevel diffLevel = GetDifficulty(); _epidemicCards = (int)diffLevel; int playerCount = GetPlayerCount(); for (int index = 1; index <= playerCount; index++) { _interactionManager.OutputContent(String.Format("CHARACTER CREATION FOR PLAYER {0}", index)); _playerManager.AddPlayer(GetPlayerRole()); } _interactionManager.OutputContent(String.Format("Epidemic Card Count for {0} is {1}", diffLevel.ToString(), _epidemicCards)); _interactionManager.OutputContent(String.Format("Press any key to start game...")); _interactionManager.Pause(); _interactionManager.ClearOutput(); }
public bool AttachPlayersToSession(SessionToken session, Guid[] characterIds) { var s = gameData.GetSession(session.SessionId); if (s != null) { var chars = gameData.GetSessionCharacters(s); foreach (var c in chars) { c.UserIdLock = null; } } var result = false; foreach (var id in characterIds) { var c = gameData.GetCharacter(id); //if (c == null || (c.UserIdLock != null && c.UserIdLock != session)) result = playerManager.AddPlayer(session, id) != null || result; } return(result); }
private bool OnLogin(ZoneClient client, ZI_LOGON packet) { Logger.Debug($"ZSRV({client.Sid}) ZI_LOGON AID={packet.AID} AccountName={packet.AccountName} GID={packet.GID}, CharacterName={packet.CharacterName}, MapName {packet.MapName}"); var myPlayers = _playerManager.FindPlayersByAID(packet.AID); if (myPlayers.Any()) { client.EnqueuePacket(new IZ_DISCONNECT_CHARACTER { AID = packet.AID }); return ExitPlayer(client, packet.GID, packet.AID); } // create the player trying to log in var myPlayer = new Player() { AID = packet.AID, GID = packet.GID, AccountName = packet.AccountName, CharacterName = packet.CharacterName, Head = packet.Head, HeadPalette = packet.HeadPalette, Level = packet.Level, Sex = (short)packet.Sex, Job = packet.Job, MapName = packet.MapName, ZSID = client.Sid, Status = 1 }; _playerManager.AddPlayer(myPlayer); var gdid = _guildManager.GetGDIDByGID(packet.GID); if (gdid.HasValue) { // if user has a guild myPlayer.GDID = gdid.Value; // GuildInfo var g = _guildManager.GetGuild(gdid.Value); var gi = g.GuildInfo; client.EnqueuePacket(new IZ_GUILDINFO_TOD { AID = 0, GDID = gdid.Value, Data = new GUILDINFO(gi.GDID, gi.Level, gi.Name, gi.MName, gi.MaxUserNum, gi.UserNum, gi.Honor, gi.Virtue, gi.Type, gi.Class, gi.Money, gi.ArenaWin, gi.ArenaLose, gi.ArenaDrawn, gi.ManageLand, gi.Exp, gi.EmblemVersion, gi.Point, gi.Desc) }); // GuildNotice client.EnqueuePacket(new IZ_GUILD_NOTICE { GDID = gdid.Value, Notice = g.GuildNotice.Notice, Subject = g.GuildNotice.Subject }); // GuildMemberInfo var gmi = g.GuildMInfo.ToArray(); foreach (var player in gmi) { var pc = _playerManager.FindPlayerByGID(player.GID); if (pc == null) continue; player.Status = pc.Status; player.Sex = pc.Sex; player.Job = pc.Job; player.Head = pc.Head; player.HeadPalette = pc.HeadPalette; } client.EnqueuePacket(new IZ_GUILD_MEMBERINFO_TOD { AID = 0, GDID = gdid.Value, GuildMInfo = gmi.Select(x => new GUILDMINFO(x.GID, x.CharName, x.AccountName, x.Level, x.Memo, x.Service, x.MemberExp, x.GDID, x.AID, x.PositionID, x.Head, x.HeadPalette, x.Sex, x.Job, x.Status)).ToArray() }); // GuildAllyInfo client.EnqueuePacket(new IZ_GUILD_ALLYINFO_TOD { AID = 0, GDID = gdid.Value, GuildAllyInfo = g.GuildAllyInfo.Select(x => new GUILDALLYINFO(x.GDID, x.OpponentGDID, x.GuildName, x.Relation)).ToArray() }); // GuildBanishInfo client.EnqueuePacket(new IZ_GUILD_BANISHINFO_TOD { AID = 0, GDID = gdid.Value, GuildBanishInfo = g.GuildBanishInfo.Select(x => new GUILDBANISHINFO(x.GDID, x.MemberName, string.Empty, x.Reason, x.GID, x.AID)).ToArray() }); // GuildMPosition client.EnqueuePacket(new IZ_GUILD_MPOSITION_TOD { AID = 0, GDID = gdid.Value, GuildMPosition = g.GuildMPosition.Select(x => new GUILDMPOSITION(x.GDID, x.Grade, x.PosName, x.JoinRight, x.PenaltyRight, x.PositionID, x.Service)).ToArray() }); // GuildSkill client.EnqueuePacket(new IZ_GUILD_NOTIFYSKILLDATA { IsForceSend = 1, SkillPoint = g.GuildSkill.Point, GuildSkill = g.GuildSkill.Skills.Select(x => new GUILDSKILL(x.SkillId, x.Level)).ToArray(), GDID = gdid.Value, }); BroadcastPacket(new IZ_UPDATE_CHARSTAT { GDID = gdid.Value, GID = packet.GID, AID = packet.AID, Status = myPlayer.Status, Sex = myPlayer.Sex, Head = myPlayer.Head, HeadPalette = myPlayer.HeadPalette, Job = (short)myPlayer.Job, Level = myPlayer.Level }); client.EnqueuePacket(new IZ_UPDATE_CHARGDID { Type = 2, GDID = gdid.Value, EmblemVer = gi.EmblemVersion, InterSID = 701348095, GID = packet.GID, AID = packet.AID, Right = 17, IsMaster = gi.MName == myPlayer.CharacterName, GuildName = gi.Name }); } client.EnqueuePacket(new IZ_ACK_LOGON { AID = packet.AID, GID = packet.GID, Type = 0 }); // finished guild, group coming next var grid = _groupManager.GetMember(packet.GID); if (grid.HasValue) { var charinfo = new List<CHARINFO_IN_GROUP>(); var g = _groupManager.GetGroup(grid.Value); foreach (var m in g.GroupMember) { var p = _playerManager.FindPlayerByGID(m.GID); if (p != null && p.Status == 1) { ZonePacket(p.ZSID, new IZ_ADD_MEMBER_TO_GROUP2 { ReceiverAID = m.AID, AID = packet.AID, Role = 0, State = 0, GroupName = g.GroupInfo.GroupName, CharacterName = packet.CharacterName, MapName = packet.MapName, ItemPickupRule = g.GroupInfo.ItemPickupRule, ItemDivisionRule = g.GroupInfo.ItemDivisionRule }); client.EnqueuePacket(new IZ_ADD_MEMBER_TO_GROUP2 { ReceiverAID = packet.AID, AID = m.AID, Role = 0, State = (byte)(p?.Status ?? 1), GroupName = g.GroupInfo.GroupName, CharacterName = m.CharName, MapName = p?.MapName, ItemPickupRule = g.GroupInfo.ItemPickupRule, ItemDivisionRule = g.GroupInfo.ItemDivisionRule }); } byte status; if (p == null || p.Status == 0) { status = 1; } else { status = 0; } Logger.Debug($"CHARINFO {m.CharName}, Status {status}"); charinfo.Add(new CHARINFO_IN_GROUP(m.AID, m.CharName, p?.MapName, (byte)m.Role, status)); } client.EnqueuePacket(new IZ_GROUP_LIST { AID = packet.AID, ExpOption = g.GroupInfo.ExpOption, GroupName = g.GroupInfo.GroupName, CharinfoInGroup = charinfo.ToArray() }); client.EnqueuePacket(new ZI_GRID_UPDATE { AID = packet.AID, ExpOption = g.GroupInfo.ExpOption, GRID = grid.Value }); } //var friends = _friendManager.GetFriends(packet.GID); return true; }
public void Initialize() { _playerManager.AddPlayer(); }
//[MethodDescriptor(Name = "Add Player to Game Session", Description = "Adds the target player to the ongoing session. This will lock the target player to the session and then return the player data.", RequiresSession = true)] public Player PlayerJoin(string userId, Single <string> username) { return(playerManager.AddPlayer(AssertGetSessionToken(), userId, username.Value)); }
public int AddPlayer(ulong clientId, PlayerController player) { return(mImpl.AddPlayer(clientId, player, this)); }