Example #1
0
 private void OnWinnersDetermined(Fight fight, FightTeam winners, FightTeam losers, bool draw)
 {
     fight.WinnersDetermined -= new Fight.FightWinnersDelegate(this.OnWinnersDetermined);
     if (!draw && (winners is FightPlayerTeam && losers is FightMonsterTeam))
     {
         MonsterGroup group = ((MonsterFighter)losers.Leader).Monster.Group;
         if (!this.m_groupsSpawn.ContainsKey(group))
         {
             DungeonSpawningPool.logger.Error <int, int>("Group {0} (Map {1}) has ended his fight but is not register in the pool", group.Id, base.Map.Id);
         }
         else
         {
             MonsterDungeonSpawn monsterDungeonSpawn = this.m_groupsSpawn[group];
             if (monsterDungeonSpawn.TeleportEvent)
             {
                 ObjectPosition teleportPosition = monsterDungeonSpawn.GetTeleportPosition();
                 foreach (CharacterFighter current in winners.GetAllFighters <CharacterFighter>())
                 {
                     current.Character.NextMap   = teleportPosition.Map;
                     current.Character.Cell      = teleportPosition.Cell;
                     current.Character.Direction = teleportPosition.Direction;
                     this.m_groupsSpawn.Remove(group);
                 }
             }
         }
     }
 }
Example #2
0
        protected override System.Collections.Generic.IEnumerable <IFightResult> GenerateResults()
        {
            System.Collections.Generic.List <IFightResult> list = new System.Collections.Generic.List <IFightResult>();

            list.AddRange(
                from entry in base.GetFightersAndLeavers()
                where !(entry is SummonedFighter)
                select entry.GetFightResult());

            if (base.Map.TaxCollector != null && base.Map.TaxCollector.CanGatherLoots())
            {
                list.Add(new TaxCollectorFightResult(base.Map.TaxCollector, this));
            }

            FightTeam[] teams = this.m_teams;
            for (int i = 0; i < teams.Length; i++)
            {
                FightTeam team = teams[i];
                System.Collections.Generic.IEnumerable <FightActor> enumerable = ((team == base.RedTeam) ? base.BlueTeam : base.RedTeam).GetAllFighters((FightActor entry) => entry.IsDead()).ToList <FightActor>();

                IOrderedEnumerable <IFightResult> orderedEnumerable =
                    from x in list
                    where x.CanLoot(team)
                    select x into entry
                    orderby(entry is TaxCollectorFightResult) ? -1 : entry.Prospecting descending
                    select entry;

                int  teamPP       = team.GetAllFighters().Sum((FightActor entry) => entry.Stats[PlayerFields.Prospecting].Total);
                int  challengeSum = base.m_challenges.Sum((entry => entry.GetChallengeBonus()));
                long baseKamas    = enumerable.Sum((FightActor entry) => (long)((ulong)entry.GetDroppedKamas()));

                using (System.Collections.Generic.IEnumerator <IFightResult> enumerator = orderedEnumerable.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        IFightResult looter = enumerator.Current;

                        looter.Loot.Kamas = FightFormulas.AdjustDroppedKamas(looter, teamPP, baseKamas);
                        System.Collections.Generic.IEnumerable <FightActor> arg_1F0_0 = enumerable;
                        Func <FightActor, System.Collections.Generic.IEnumerable <DroppedItem> > selector = (FightActor dropper) => dropper.RollLoot(looter, challengeSum);
                        foreach (DroppedItem current in arg_1F0_0.SelectMany(selector))
                        {
                            looter.Loot.AddItem(current);
                        }

                        if (looter is IExperienceResult)
                        {
                            (looter as IExperienceResult).AddEarnedExperience(FightFormulas.CalculateWinExp(looter, team.GetAllFighters(), enumerable));
                        }
                    }
                }
            }
            return(list);
        }
Example #3
0
        private void OnWinnersDetermined(IFight fight, FightTeam winners, FightTeam losers, bool draw)
        {
            fight.WinnersDetermined -= OnWinnersDetermined;

            if (draw)
            {
                return;
            }

            // if players didn't win they don't get teleported
            if (!(winners is FightPlayerTeam) || !(losers is FightMonsterTeam))
            {
                return;
            }

            var group = ((MonsterFighter)losers.Leader).Monster.Group;

            if (!m_groupsSpawn.ContainsKey(@group))
            {
                logger.Error("Group {0} (Map {1}) has ended his fight but is not register in the pool", @group.Id, Map.Id);
                return;
            }

            var spawn = m_groupsSpawn[@group];

            if (!spawn.TeleportEvent)
            {
                return;
            }

            var pos = spawn.GetTeleportPosition();

            foreach (var fighter in winners.GetAllFighters <CharacterFighter>())
            {
                fighter.Character.NextMap   = pos.Map;
                fighter.Character.Cell      = pos.Cell;
                fighter.Character.Direction = pos.Direction;


                m_groupsSpawn.Remove(group);
            }
        }
Example #4
0
 public override bool IsEligible() => m_team.GetAllFighters().Count() > 1;