Ejemplo n.º 1
0
 public double GetHorizontalDistance(Combatant target) =>
 (double)Math.Sqrt(
     Math.Pow(this.PosX - target.PosX, 2) +
     Math.Pow(this.PosY - target.PosY, 2));
Ejemplo n.º 2
0
        public void RefreshCombatantList()
        {
            if (!this.IsAvalable)
            {
#if DEBUG
                lock (this.combatantListLock)
                {
                    foreach (var entity in this.DummyCombatants)
                    {
                        entity.SetName(entity.Name);
                    }

                    this.combatantList       = this.DummyCombatants;
                    this.combatantDictionary = this.DummyCombatants.ToDictionary(x => x.ID);
                }
#endif

                return;
            }

            dynamic list  = this.pluginScancombat.GetCombatantList();
            var     count = (int)list.Count;

            var newList       = new List <Combatant>(count);
            var newDictionary = new Dictionary <uint, Combatant>(count);

            foreach (dynamic item in list.ToArray())
            {
                if (item == null)
                {
                    continue;
                }

                var combatant = new Combatant();

                combatant.ID        = (uint)item.ID;
                combatant.OwnerID   = (uint)item.OwnerID;
                combatant.Job       = (int)item.Job;
                combatant.type      = (byte)item.type;
                combatant.Level     = (int)item.Level;
                combatant.CurrentHP = (int)item.CurrentHP;
                combatant.MaxHP     = (int)item.MaxHP;
                combatant.CurrentMP = (int)item.CurrentMP;
                combatant.MaxMP     = (int)item.MaxMP;
                combatant.CurrentTP = (int)item.CurrentTP;

                var name = (string)item.Name;

                // 名前を登録する
                // TYPEによって分岐するため先にTYPEを設定しておくこと
                combatant.SetName(name);

                newList.Add(combatant);
                newDictionary.Add(combatant.ID, combatant);
            }

            lock (this.combatantListLock)
            {
                this.combatantList       = null;
                this.combatantDictionary = null;

                this.combatantList       = newList;
                this.combatantDictionary = newDictionary;
            }
        }