Ejemplo n.º 1
0
        private async Task Process(JoinBattleSuccess bat)
        {
            Battle battle;

            ExistingBattles.TryGetValue(bat.BattleID, out battle);
            if (battle != null)
            {
                battle.Users.Clear();
                foreach (var battleStatusUpdate in bat.Players)
                {
                    var ubs = new UserBattleStatus(battleStatusUpdate.Name, ExistingUsers.Get(battleStatusUpdate.Name));
                    ubs.UpdateWith(battleStatusUpdate);
                    battle.Users[battleStatusUpdate.Name] = ubs;
                }

                battle.Bots.Clear();
                foreach (var botStatusUpdate in bat.Bots)
                {
                    var ubs = new BotBattleStatus(botStatusUpdate.Name, botStatusUpdate.Owner, botStatusUpdate.AiLib);
                    ubs.UpdateWith(botStatusUpdate);
                    battle.Bots[botStatusUpdate.Name] = ubs;
                    BattleBotAdded(this, ubs);
                }

                MyBattle = battle;
                if (battle.FounderName == UserName)
                {
                    BattleOpened(this, battle);
                }
                BattleJoinSuccess(this, MyBattle);
            }
        }
Ejemplo n.º 2
0
        public async Task Process(UpdateBotStatus status)
        {
            var bat = MyBattle;

            if (bat != null)
            {
                BotBattleStatus ubs;
                bat.Bots.TryGetValue(status.Name, out ubs);
                if (ubs != null)
                {
                    ubs.UpdateWith(status);
                    BattleBotUpdated(this, ubs);
                }
                else
                {
                    var nubs = new BotBattleStatus(status.Name, status.Owner, status.AiLib);
                    nubs.UpdateWith(status);
                    bat.Bots[status.Name] = nubs;
                    BattleBotAdded(this, nubs);
                }
            }
        }