private void SetEnemies(JSON_MapEnemyUnit[] json)
        {
            for (int index = 0; index < this.UnknownEnemyList.Count; ++index)
            {
                ((Component)this.UnknownEnemyList[index]).get_gameObject().SetActive(false);
            }
            List <JSON_MapEnemyUnit> list            = ((IEnumerable <JSON_MapEnemyUnit>)json).ToList <JSON_MapEnemyUnit>();
            TowerResuponse           towerResuponse  = MonoSingleton <GameManager> .Instance.TowerResuponse;
            TowerFloorParam          towerFloorParam = (TowerFloorParam)null;

            if (towerResuponse != null)
            {
                towerFloorParam = towerResuponse.GetCurrentFloor();
            }
            this.EnemyUnits.Clear();
            int index1 = 0;

            for (int index2 = 0; index2 < list.Count; ++index2)
            {
                NPCSetting npcSetting = new NPCSetting(list[index2]);
                Unit       data       = new Unit();
                data.Setup((UnitData)null, (UnitSetting)npcSetting, (Unit.DropItem)null, (Unit.DropItem)null);
                if (!data.IsGimmick)
                {
                    TowerEnemyListItem towerEnemyListItem;
                    if (this.EnemyList.Count <= index1)
                    {
                        towerEnemyListItem = (TowerEnemyListItem)((GameObject)Object.Instantiate <GameObject>((M0)this.EnemyTemplate)).GetComponent <TowerEnemyListItem>();
                        ((Component)towerEnemyListItem).get_transform().SetParent(this.EnemiesRoot.get_transform(), false);
                        this.EnemyList.Add(towerEnemyListItem);
                    }
                    else
                    {
                        towerEnemyListItem = this.EnemyList[index1];
                    }
                    if (towerFloorParam != null && towerFloorParam.iname == GlobalVars.SelectedQuestID && MonoSingleton <GameManager> .Instance.TowerEnemyUnit != null)
                    {
                        TowerResuponse.EnemyUnit enemyUnit = MonoSingleton <GameManager> .Instance.TowerEnemyUnit[index2];
                        data.Damage((int)data.MaximumStatus.param.hp - enemyUnit.hp, false);
                    }
                    DataSource.Bind <Unit>(((Component)towerEnemyListItem).get_gameObject(), data);
                    this.EnemyUnits.Add(data);
                    ++index1;
                }
            }
            for (int index2 = 0; index2 < this.EnemyList.Count; ++index2)
            {
                bool flag = index2 < list.Count && index2 < 10;
                ((Component)this.EnemyList[index2]).get_gameObject().SetActive(flag);
                this.EnemyList[index2].UpdateValue();
            }
        }
 public void CalcDamage(List <Unit> player)
 {
     if (this.pdeck == null)
     {
         return;
     }
     for (int i = 0; i < this.pdeck.Count; ++i)
     {
         Unit unit = player.Find((Predicate <Unit>)(x => x.UnitParam.iname == this.pdeck[i].unitname));
         if (unit != null)
         {
             int num = Mathf.Min(this.pdeck[i].dmg, (int)unit.MaximumStatus.param.hp - 1);
             unit.Damage(num, false);
         }
     }
 }
Exemple #3
0
        private bool actionDamage(Unit target, LogMapTrick.TargetInfo log_mt_ti)
        {
            int num = this.calcDamage(target);

            if (num <= 0)
            {
                return(false);
            }
            target.Damage(num, true);
            if (log_mt_ti != null)
            {
                log_mt_ti.IsEffective = true;
                log_mt_ti.Damage      = num;
            }
            return(true);
        }
        public void CalcEnemyDamage(List <Unit> enemy, bool is_menu = false)
        {
            if (this.edeck == null)
            {
                return;
            }
            List <Unit> unitList = new List <Unit>();

            for (int index1 = 0; index1 < this.edeck.Count; ++index1)
            {
                int index2 = int.Parse(this.edeck[index1].eid);
                if (index2 >= 0 && enemy.Count > index2)
                {
                    Unit unit = enemy[index2];
                    if (unit != null && (!is_menu || !unit.IsGimmick))
                    {
                        if (unit.IsGimmick && this.edeck[index1].hp == 0)
                        {
                            unitList.Add(unit);
                        }
                        else
                        {
                            unit.Damage((int)unit.MaximumStatus.param.hp - this.edeck[index1].hp, false);
                            unit.Gems                = this.edeck[index1].jewel;
                            this.edeck[index1].id    = unit.UnitData.UniqueID;
                            this.edeck[index1].iname = unit.UnitParam.iname;
                        }
                    }
                }
            }
            enemy.RemoveAll((Predicate <Unit>)(x =>
            {
                if (!x.IsGimmick)
                {
                    return((int)x.CurrentStatus.param.hp <= 0);
                }
                return(false);
            }));
            for (int index = 0; index < unitList.Count; ++index)
            {
                if (unitList[index] != null)
                {
                    enemy.Remove(unitList[index]);
                }
            }
        }
Exemple #5
0
 public void CalcEnemyDamage(List <Unit> enemy)
 {
     if (this.edeck == null)
     {
         return;
     }
     for (int index1 = 0; index1 < this.edeck.Count; ++index1)
     {
         int index2 = int.Parse(this.edeck[index1].eid);
         if (index2 >= 0 && enemy.Count > index2)
         {
             Unit unit = enemy[index2];
             if (unit != null)
             {
                 unit.Damage((int)unit.MaximumStatus.param.hp - this.edeck[index1].hp);
                 unit.Gems                = this.edeck[index1].jewel;
                 this.edeck[index1].id    = unit.UnitData.UniqueID;
                 this.edeck[index1].iname = unit.UnitParam.iname;
             }
         }
     }
     enemy.RemoveAll((Predicate <Unit>)(x => (int)x.CurrentStatus.param.hp <= 0));
 }