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]); }
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); }
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); }); } }); }
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); } } } }); }
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); }
public virtual void AddFighter(Mobile fighter) { if (!Fighters.Contains(fighter)) { Fighters.Add(fighter); } }
public List <int> GetAllPlayerIds() { var ids = new List <int>(); ids.AddRange(Fighters.Select(x => x.Id)); return(ids); }
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); }
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)); } } }
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); }
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>(); }
public FighterEntry GetFighterInCell(short cell) { if (PlayedFighter?.CellId == cell) { return(PlayedFighter); } return(Fighters.FirstOrDefault(f => f.Alive && f.CellId == cell)); }
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))); }
/// <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"); } }
protected void RemoveFighter(double Id) { lock (CheckLock) { Fighters.Remove(Fighters.Find(f => f.Id == Id)); Monsters.Remove(Monsters.Find(m => m.Id == Id)); } }
public void Remove(IFighter fighter) { Fighters.Remove(fighter); fighter.SetTeam(null); SetupDisplayNames(); }
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)); } }
public void AddStatus(Status status) { IEnumerable <IFighter> aliveFighters = Fighters.Where(f => f.IsAlive()); foreach (IFighter fighter in aliveFighters) { fighter.AddStatus(status); } }
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 } }
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; }
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; } }
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); }
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); }); } }); }
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); }
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); } }
public bool InsertFighter(FightActor fighter, int index) { if (index > Fighters.Count) { return(false); } Fighters.Insert(index, fighter); if (index <= Index) { Index++; } return(true); }
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; }
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; }
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)); }