public void UpdateWith(UpdateUserBattleStatus u) { if (u != null) { if (u.Name != Name) { throw new Exception(string.Format("Applying update of {0} to user {1}", u.Name, Name)); } if (u.AllyNumber.HasValue) { AllyNumber = u.AllyNumber.Value; } if (u.IsSpectator.HasValue) { IsSpectator = u.IsSpectator.Value; } if (u.Sync.HasValue) { SyncStatus = u.Sync.Value; } if (u.JoinTime.HasValue) { JoinTime = u.JoinTime.Value; } } }
public void UpdateWith(UpdateUserBattleStatus u) { if (u != null) { if (u.Name != Name) throw new Exception(string.Format("Applying update of {0} to user {1}", u.Name, Name)); if (u.AllyNumber.HasValue) AllyNumber = u.AllyNumber.Value; if (u.IsSpectator.HasValue) IsSpectator = u.IsSpectator.Value; if (u.Sync.HasValue) SyncStatus = u.Sync.Value; } }
public async Task ForceSpectator(string username, bool spectatorState = true) { if ((MyBattle != null) && MyBattle.Users.ContainsKey(username)) { var ubs = new UpdateUserBattleStatus() { Name = username, IsSpectator = spectatorState }; await SendCommand(ubs); } }
public async Task ForceAlly(string username, int ally) { if ((MyBattle != null) && MyBattle.Users.ContainsKey(username)) { var ubs = new UpdateUserBattleStatus() { Name = username, AllyNumber = ally }; await SendCommand(ubs); } }
public async Task ForceTeam(string username, int team) { if (MyBattle != null && MyBattle.Users.ContainsKey(username)) { var ubs = new UpdateUserBattleStatus() { Name = username, TeamNumber = team }; await SendCommand(ubs); } }
public async Task ChangeMyBattleStatus(bool?spectate = null, SyncStatuses?syncStatus = null, int?ally = null) { var ubs = MyBattleStatus; if (ubs != null) { var status = new UpdateUserBattleStatus() { IsSpectator = spectate, Sync = syncStatus, AllyNumber = ally, Name = UserName }; await SendCommand(status); } }
private async Task Process(UpdateUserBattleStatus status) { var bat = MyBattle; if (bat != null) { UserBattleStatus ubs; bat.Users.TryGetValue(status.Name, out ubs); if (ubs != null) { ubs.UpdateWith(status); if (status.Name == UserName) { BattleMyUserStatusChanged(this, ubs); } BattleUserStatusChanged(this, ubs); } } }