Example #1
0
        public Fighter GetNextPlayer()
        {
            if (Fighters.Count == 0 || Fighters.All(entry => !entry.CanPlay()))
            {
                return(null);
            }

            int counter = 0;
            int index   = (Index + 1) < Fighters.Count ? Index + 1 : 0;

            while (!Fighters[index].CanPlay() && counter < Fighters.Count)
            {
                index = (index + 1) < Fighters.Count ? index + 1 : 0;

                counter++;
            }

            if (!Fighters[index].CanPlay()) // no fighter can play
            {
                Index = -1;
                return(null);
            }

            return(Fighters[index]);
        }
Example #2
0
        public static Fighter GetOrCreateFighter(string fullName)
        {
            if (fullName.Equals("Unknown") || fullName.Equals("Uknown"))
            {
                return(null);
            }

            var index = fullName.LastIndexOf(' ');

            if (index < 0)
            {
                return(null);
            }

            var firstname = fullName.Substring(0, index);
            var lastname  = fullName.Substring(index + 1);

            var fighter
                = Fighters
                  .FirstOrDefault(f => f.LastName.Equals(lastname) && (f.FirstName.Contains(firstname) || firstname.Contains(f.FirstName)));

            if (fighter == null)
            {
                fighter = new Fighter(NextFighterId++, firstname, lastname, null);
                Fighters.Add(fighter);
            }

            return(fighter);
        }
Example #3
0
        public virtual void BeginSequence(Mobile from)
        {
            if (Peerless == null)
            {
                // spawn boss
                Peerless = Boss;

                if (Peerless == null)
                {
                    return;
                }

                Peerless.Home      = BossLocation;
                Peerless.RangeHome = 12;
                Peerless.MoveToWorld(BossLocation, Map);
                Peerless.Altar = this;

                StartSlayTimer();
            }

            // teleport fighters
            Fighters.ForEach(x =>
            {
                int counter = 0;

                if (x.InRange(from.Location, 15) && CanEnter(x))
                {
                    Timer.DelayCall(TimeSpan.FromSeconds(counter++), () => { Enter(x); });
                }
            });
        }
Example #4
0
        public virtual void DeadlineCheck()
        {
            if (DateTime.UtcNow > Deadline)
            {
                SendMessage(1072258); // You failed to complete an objective in time!
                FinishSequence();
                return;
            }

            TimeSpan timeLeft = Deadline - DateTime.UtcNow;

            if (timeLeft < TimeSpan.FromMinutes(30))
            {
                SendMessage(1075611, timeLeft.TotalSeconds);
            }

            Fighters.ForEach(x =>
            {
                if (x is PlayerMobile)
                {
                    PlayerMobile player = (PlayerMobile)x;

                    if (player.NetState == null)
                    {
                        TimeSpan offline = DateTime.UtcNow - player.LastOnline;

                        if (offline > TimeSpan.FromMinutes(10))
                        {
                            Exit(player);
                        }
                    }
                }
            });
        }
Example #5
0
        public CharacterFeatures GetEnemy(CharacterFeatures fighter)
        {
            CharacterFeatures enemy;

            if (fighter is Pretre)
            {
                enemy = Fighters.FirstOrDefault(x => x.IsUndead);

                if (enemy != null)
                {
                    return(enemy);
                }
            }

            do
            {
                var otherFighters = Fighters
                                    .Where(x => x.Id != fighter.Id && !x.IsDead() && x.CurrentLife > 0 && !x.IsHide).ToList();

                //AfficherListeEnnemi(otherFighters);

                if (otherFighters.Count == 0)
                {
                    otherFighters = Fighters
                                    .Where(x => x.Id != fighter.Id && !x.IsDead() && x.CurrentLife > 0 && x.IsHide).ToList();
                }

                var randomEnemy = Random.Next(otherFighters.Count(f => f.Id != fighter.Id && !f.IsDead()));

                enemy = otherFighters[randomEnemy];
            } while (enemy.Id == fighter.Id);

            return(enemy);
        }
Example #6
0
 public virtual void AddFighter(Mobile fighter)
 {
     if (!Fighters.Contains(fighter))
     {
         Fighters.Add(fighter);
     }
 }
Example #7
0
        public List <int> GetAllPlayerIds()
        {
            var ids = new List <int>();

            ids.AddRange(Fighters.Select(x => x.Id));
            return(ids);
        }
Example #8
0
        public bool RemoveFighter(FightActor fighter)
        {
            if (!Fighters.Contains(fighter))
            {
                return(false);
            }

            var index = Fighters.IndexOf(fighter);

            Fighters.Remove(fighter);

            if (index > Index)
            {
                return(true);
            }

            if (index > 0)
            {
                Index--;
            }
            else
            {
                Index = Fighters.Count - 1;
            }

            return(true);
        }
Example #9
0
        protected IFighter GetFighter(double fighterId)
        {
            lock (CheckLock)
            {
                //Logger.Default.Log($"Looking for id [{fighterId}]");

                //foreach (var monster in Account.Character.Map.Monsters)
                //    Logger.Default.Log($"[Monster]{monster.GroupName} has id {monster.Id} and level [{monster.GroupLevel}]");
                //foreach (var fighter in Fighters)
                //    Logger.Default.Log($"[Fighter]Fighter on {fighter.CellId} has id {fighter.Id}");
                //foreach (var companion in Companions)
                //    Logger.Default.Log($"[Companion]{companion.Name} has id {companion.Id}");

                if (Monsters.Find(x => x.Id == fighterId) != null)
                {
                    return(Monsters.FirstOrDefault(m => m.Id == fighterId));
                }
                //else if (Companions.Find(x => x.Id == fighterId) != null)
                //    return Companions.FirstOrDefault(c => c.Id == fighterId);
                else
                {
                    return(Fighters.FirstOrDefault(f => f.Id == fighterId));
                }
            }
        }
Example #10
0
        private List <Fight> ScheduleFights(WeightClass wc)
        {
            List <Fighter> fighters = Fighters.AllFighters().Where(fighter => fighter.Weight == wc.Weight).ToList();
            List <Fight>   schedule = new List <Fight>();

            //Sort in reverse order
            fighters.Sort((f1, f2) => Rating.Rating(f2).CompareTo(Rating.Rating(f1)));

            while (fighters.Count > 1)
            {
                int f1 = 0, f2 = 1;
                for (; f2 < fighters.Count - 1; ++f2)
                {
                    if (MathUtils.RangeUniform(0, 1) < 0.05)
                    {
                        break;
                    }
                }

                var judges = Agents.RandomBunch(PersonType.JUDGE, 3).Select(j => (Judge)j).ToArray();
                schedule.Add(new Fight(fighters[f1], fighters[f2], 12, judges));
                fighters.RemoveAt(f1); fighters.RemoveAt(f2 - 1);
            }

            return(schedule);
        }
Example #11
0
        private void Awake()
        {
            // Setup dictionary from ScriptableObject data
            foreach (FighterData data in FighterDataList)
            {
                data.SetupDictionary();
            }

            Fighter1 = new Fighter();
            Fighter2 = new Fighter();

            Fighters.Add(Fighter1);
            Fighters.Add(Fighter2);

            debugP2Attack = false;
            debugP2Guard  = false;

            if (roundUI != null)
            {
                RoundUIAnimator = roundUI.GetComponent <Animator>();
            }

            stateMachine = new StateMachine();
            stateMachine.AddState(new StopState(this));
            stateMachine.AddState(new IntroState(this));

            FightState fightState = new FightState(this);

            fightState.DamageOccurred += (damaged, damagePos, damageResult) => DamageOccurred?.Invoke(damaged, damagePos, damageResult);             // TODO refactor this
            stateMachine.AddState(new FightState(this));
            stateMachine.AddState(new KOState(this));
            stateMachine.AddState(new EndState(this));

            stateMachine.SetState <StopState>();
        }
Example #12
0
 public FighterEntry GetFighterInCell(short cell)
 {
     if (PlayedFighter?.CellId == cell)
     {
         return(PlayedFighter);
     }
     return(Fighters.FirstOrDefault(f => f.Alive && f.CellId == cell));
 }
Example #13
0
 protected IFighter GetFighter(double fighterId)
 {
     return(Monsters.Find(x => x.Id == fighterId) != null
         ? Monsters.FirstOrDefault(m => m.Id == fighterId)
         : (Companions.Find(x => x.Id == fighterId) != null
             ? Companions.FirstOrDefault(c => c.Id == fighterId)
             : Fighters.FirstOrDefault(f => f.Id == fighterId)));
 }
Example #14
0
 /// <summary>
 /// Initializes a new instance of the FighterViewModel class.
 /// </summary>
 public FighterViewModel()
 {
     if (!IsInDesignModeStatic)
     {
         Helpers.Shared.Entities.Fighters.Load();
         this.SelectedFighter = Fighters.First(f => f.Name == "Test B 0001");
     }
 }
Example #15
0
 protected void RemoveFighter(double Id)
 {
     lock (CheckLock)
     {
         Fighters.Remove(Fighters.Find(f => f.Id == Id));
         Monsters.Remove(Monsters.Find(m => m.Id == Id));
     }
 }
Example #16
0
        public void Remove(IFighter fighter)
        {
            Fighters.Remove(fighter);

            fighter.SetTeam(null);

            SetupDisplayNames();
        }
Example #17
0
    public StationData(StationDesignData data)
    {
        designData  = data;
        DisplayName = designData.Design.Name;

        //Add Fighters
        foreach (KeyValuePair <FighterDefinition, int> keyVal in designData.Fighters)
        {
            Fighters.Add(new FighterComplement(keyVal.Key, keyVal.Value));
        }
        foreach (KeyValuePair <FighterDefinition, int> keyVal in designData.HeavyFighters)
        {
            HeavyFighters.Add(new FighterComplement(keyVal.Key, keyVal.Value));
        }
        foreach (KeyValuePair <FighterDefinition, int> keyVal in designData.AssaultPods)
        {
            AssaultPods.Add(new FighterComplement(keyVal.Key, keyVal.Value));
        }

        ammo            = designData.Ammo;
        ammoMax         = designData.Ammo;
        power           = designData.PowerStorage;
        powerMax        = designData.PowerStorage;
        crew            = designData.Crew;
        crewMax         = designData.Crew;
        troops          = designData.Troops;
        troopsMax       = designData.Troops;
        powerGenerated  = designData.PowerGenerated;
        research        = designData.Research;
        mining          = designData.Mining;
        repair          = designData.Repair;
        ammoGenerated   = designData.AmmoGenerated;
        transporter     = designData.Transporter;
        medical         = designData.Medical;
        boardingDefense = designData.BoardingDefense;
        diplomacy       = designData.Diplomacy;
        sensor          = designData.Sensor;
        longRangeSensor = designData.LongRangeSensor;
        advancedSensor  = designData.AdvancedSensor;

        health              = designData.Health;
        healthMax           = designData.Health;
        armorHealth         = designData.ArmorHealth;
        armorHealthMax      = designData.ArmorHealth;
        armorRating         = designData.ArmorRating;
        shieldHealth        = designData.ShieldHealth;
        shieldHealthMax     = designData.ShieldHealth;
        shieldRating        = designData.ShieldRating;
        shieldRechargeRate  = designData.ShieldRechargeRate;
        shieldRechargeDelay = designData.ShieldRechargeDelay;

        SetCrewEffeciency();

        foreach (SavedWeapon savedWeapon in designData.Weapons)
        {
            Weapons.Add(new AttachedWeapon(savedWeapon.weapon));
        }
    }
Example #18
0
        public void AddStatus(Status status)
        {
            IEnumerable <IFighter> aliveFighters = Fighters.Where(f => f.IsAlive());

            foreach (IFighter fighter in aliveFighters)
            {
                fighter.AddStatus(status);
            }
        }
Example #19
0
        protected void Death(CharacterFeatures deadGuy)
        {
            deadGuy.AttackTimer.Stop();
            deadGuy.PowerTimer.Stop();

            if (DeadFighters.All(dead => deadGuy != null && dead.Id != deadGuy.Id))
            {
                DeadFighters.Add(deadGuy);
                Fighters.Remove(deadGuy);
            }
        }
 internal void SetIsEnabled(Fighter swipedFighter)
 {
     if (swipedFighter != null)
     {
         Fighters.Where(o => o.Name != swipedFighter.Name).ForEach(o => o.IsEnabled = false); // I Disable all SwipeViews excepts the one selected
     }
     else
     {
         Fighters.Where(o => o.IsEnabled == false).ForEach(o => o.IsEnabled = true); // I enable all SwipeViews
     }
 }
Example #21
0
 private void HandleGameFightSynchronizeMessage(IAccount account, GameFightSynchronizeMessage message)
 {
     lock (CheckLock)
     {
         Fighters.Clear();
         Monsters.Clear();
         Companions.Clear();
         foreach (var fighter in message.Fighters)
         {
             AddFighter(fighter);
         }
     }
     Account.Character.Status = CharacterStatus.Fighting;
 }
Example #22
0
 private void HandleGameFightJoinMessage(IAccount account, GameFightJoinMessage message)
 {
     lock (CheckLock)
     {
         Fighters.Clear();
         Options.Clear();
         TotalLaunchBySpell.Clear();
         LastTurnLaunchBySpell.Clear();
         TotalLaunchByCellBySpell.Clear();
         DurationByEffect.Clear();
         IsFightStarted = message.IsFightStarted;
         WaitForReady   = !message.IsFightStarted && message.CanSayReady;
     }
 }
Example #23
0
        public CharacterFeatures GetDeadEnemy(CharacterFeatures fighter)
        {
            CharacterFeatures enemy;

            do
            {
                var otherFighters = Fighters.Where(x => x.Id != fighter.Id && x.IsDead() && !x.IsDevoured).ToList();

                var randomEnemy = Random.Next(otherFighters.Count(f => f.Id != fighter.Id));

                enemy = otherFighters[randomEnemy];
            } while (enemy.Id == fighter.Id);

            return(enemy);
        }
Example #24
0
        public virtual void BeginSequence(Mobile from)
        {
            SpawnBoss();

            // teleport fighters
            Fighters.ForEach(x =>
            {
                int counter = 0;

                if (x.InRange(from.Location, 15) && CanEnter(x))
                {
                    Timer.DelayCall(TimeSpan.FromSeconds(counter++), () => { Enter(x); });
                }
            });
        }
Example #25
0
        public void InitialSetup(Fighter firstFighter, Fighter secondFighter)
        {
            Fighters.Clear();
            Fighters.Add(firstFighter);
            Fighters.Add(secondFighter);

            PickInitialActor();
            WindowController.Hit.Add("Game started!");
            WindowController.Hit.Add("FIGHTING STAGE: " + Stage + " - " + GetActor().Name + " goes first!");
            OutputFighterStatus(); // Creates the fighter status blocks (HP/Mana/Stamina)
            OutputFighterStats();  // Creates the fighter stat blocks (STR/DEX/END/INT/WIL)
            WindowController.Info.Add("[url=http://www.f-list.net/c/rendezvous%20fight/]Visit this page for game information[/url]");
            IsActive = true;
            WindowController.UpdateOutput(this);
        }
Example #26
0
 protected bool IsCellWalkable(int cellId)
 {
     lock (CheckLock)
     {
         var mapData = (API.Gamedata.D2p.Map)Account.Character.Map.Data;
         if (!Account.Character.Map.Data.IsWalkable(cellId))
         {
             return(false);
         }
         var selectedFighter =
             Fighters.FirstOrDefault(f => f.CellId == cellId ||
                                     mapData.Cells[cellId].NonWalkableDuringFight);
         return(selectedFighter == null);
     }
 }
Example #27
0
        public bool InsertFighter(FightActor fighter, int index)
        {
            if (index > Fighters.Count)
            {
                return(false);
            }

            Fighters.Insert(index, fighter);

            if (index <= Index)
            {
                Index++;
            }

            return(true);
        }
Example #28
0
        private void HandleGameFightEndMessage(IAccount account, GameFightEndMessage message)
        {
            Fighters.Clear();
            Options.Clear();
            TotalLaunchBySpell.Clear();
            LastTurnLaunchBySpell.Clear();
            TotalLaunchByCellBySpell.Clear();
            DurationByEffect.Clear();

            WaitForReady   = false;
            IsFighterTurn  = false;
            IsFightStarted = false;
            FightEnded?.Invoke(message);

            Account.Character.Status = CharacterStatus.None;
        }
Example #29
0
        public virtual void FinishSequence()
        {
            StopTimers();

            if (Owner != null)
            {
                Owner = null;
            }

            // delete peerless
            if (Peerless != null)
            {
                if (Peerless.Corpse != null && !Peerless.Corpse.Deleted)
                {
                    Peerless.Corpse.Delete();
                }

                if (!Peerless.Deleted)
                {
                    Peerless.Delete();
                }
            }

            // teleport party to exit if not already there
            Fighters.ForEach(x => Exit(x));

            // delete master keys
            MasterKeys.ForEach(x => x.Delete());

            if (MasterKeys != null)
            {
                MasterKeys.Clear();
            }

            if (Fighters != null)
            {
                Fighters.Clear();
            }

            // delete any remaining helpers
            CleanupHelpers();

            // reset summoner, boss
            Peerless = null;

            Deadline = DateTime.MinValue;
        }
Example #30
0
        public override FighterRefusedReasonEnum CanJoin(Character character)
        {
            if (IsRestrictedToParty)
            {
                if (!Leader.Character.IsInParty(PartyTypeEnum.PARTY_TYPE_CLASSICAL) || !Leader.Character.Party.IsInGroup(character))
                {
                    return(FighterRefusedReasonEnum.TEAM_LIMITED_BY_MAINCHARACTER);
                }
            }

            if (Fight.IsMultiAccountRestricted && Fighters.Where(x => x is CharacterFighter).Any(x => (x as CharacterFighter).Character.Client.IP == character.Client.IP))
            {
                return(FighterRefusedReasonEnum.MULTIACCOUNT_NOT_ALLOWED);
            }

            return(base.CanJoin(character));
        }