public bool CanStartUpgrading(CombatItemData cid)
 {
     bool result = false;
     if (m_vCurrentlyUpgradedUnit == null)
     {
         Building b = (Building)GetParent();
         ClientAvatar ca = GetParent().GetLevel().GetHomeOwnerAvatar();
         ComponentManager cm = GetParent().GetLevel().GetComponentManager();
         int maxProductionBuildingLevel;
         if(cid.GetCombatItemType() == 1)
             maxProductionBuildingLevel = cm.GetMaxSpellForgeLevel();
         else
             maxProductionBuildingLevel = cm.GetMaxBarrackLevel();
         if (ca.GetUnitUpgradeLevel(cid) < cid.GetUpgradeLevelCount() - 1)
         {
             if(maxProductionBuildingLevel >= cid.GetRequiredProductionHouseLevel() - 1)
             {
                 result = (b.GetUpgradeLevel() >= (cid.GetRequiredLaboratoryLevel(ca.GetUnitUpgradeLevel(cid) + 1)) - 1);
             }
         }
     }
     return result;
 }
예제 #2
0
 public void SetUnitUpgradeLevel(CombatItemData cd, int level)
 {
     switch(cd.GetCombatItemType())
     {
         case 2:
             {
                 int index = GetDataIndex(m_vHeroUpgradeLevel, cd);
                 if (index != -1)
                     m_vHeroUpgradeLevel[index].Value = level;
                 else
                 {
                     DataSlot ds = new DataSlot(cd, level);
                     m_vHeroUpgradeLevel.Add(ds);
                 }
                 break;
             }
         case 1:
             {
                 int index = GetDataIndex(m_vSpellUpgradeLevel, cd);
                 if (index != -1)
                     m_vSpellUpgradeLevel[index].Value = level;
                 else
                 {
                     DataSlot ds = new DataSlot(cd, level);
                     m_vSpellUpgradeLevel.Add(ds);
                 }
                 break;
             }
         default:
             {
                 int index = GetDataIndex(m_vUnitUpgradeLevel, cd);
                 if (index != -1)
                     m_vUnitUpgradeLevel[index].Value = level;
                 else
                 {
                     DataSlot ds = new DataSlot(cd, level);
                     m_vUnitUpgradeLevel.Add(ds);
                 }
                 break;
             }
     }
 }
예제 #3
0
 public void SetUnitCount(CombatItemData cd, int count)
 {
     switch (cd.GetCombatItemType())
     {
         case 1:
             {
                 int index = GetDataIndex(m_vSpellCount, cd);
                 if (index != -1)
                     m_vSpellCount[index].Value = count;
                 else
                 {
                     DataSlot ds = new DataSlot(cd, count);
                     m_vSpellCount.Add(ds);
                 }
                 break;
             }
         default:
             {
                 int index = GetDataIndex(m_vUnitCount, cd);
                 if (index != -1)
                     m_vUnitCount[index].Value = count;
                 else
                 {
                     DataSlot ds = new DataSlot(cd, count);
                     m_vUnitCount.Add(ds);
                 }
                 break;
             }
     }
 }
예제 #4
0
        public int GetUnitUpgradeLevel(CombatItemData cd)
        {
            int result = 0;
            switch(cd.GetCombatItemType())
            {
                case 2:
                    {
                        int index = GetDataIndex(m_vHeroUpgradeLevel, cd);
                        if (index != -1)
                            result = m_vHeroUpgradeLevel[index].Value;
                        break;
                    }
                case 1:
                    {
                        int index = GetDataIndex(m_vSpellUpgradeLevel, cd);
                        if (index != -1)
                            result = m_vSpellUpgradeLevel[index].Value;
                        break;
                    }

                default:
                    {
                        int index = GetDataIndex(m_vUnitUpgradeLevel, cd);
                        if (index != -1)
                            result = m_vUnitUpgradeLevel[index].Value;
                        break;
                    }
            }
            return result;
        }
예제 #5
0
 public int GetUnitCount(CombatItemData cd)
 {
     int result = 0;
     if(cd.GetCombatItemType() == 1)
     {
         int index = GetDataIndex(m_vSpellCount, cd);
         if (index != -1)
             result = m_vSpellCount[index].Value;
     }
     else
     {
         int index = GetDataIndex(m_vUnitCount, cd);
         if (index != -1)
             result = m_vUnitCount[index].Value;
     }
     return result;
 }