public void AddUnitImpl(CombatItemData cd, int level)
 {
     if(CanAddUnit(cd))
     {
         int unitIndex = GetUnitTypeIndex(cd, level);
         if(unitIndex == -1)
         {
             UnitSlot us = new UnitSlot(cd, level, 1);
             m_vUnits.Add(us);
         }
         else
         {
             m_vUnits[unitIndex].Count++;
         }
         ClientAvatar ca = GetParent().GetLevel().GetPlayerAvatar();
         int unitCount = ca.GetUnitCount(cd);
         ca.SetUnitCount(cd, unitCount + 1);
     }
 }
Exemplo n.º 2
0
 public void AddUnitImpl(CombatItemData cd, int level)
 {
     if (CanAddUnit(cd))
     {
         var unitIndex = GetUnitTypeIndex(cd, level);
         if (unitIndex == -1)
         {
             var us = new UnitSlot(cd, level, 1);
             m_vUnits.Add(us);
         }
         else
         {
             m_vUnits[unitIndex].Count++;
         }
         var ca        = GetParent().GetLevel().GetPlayerAvatar();
         var unitCount = ca.GetUnitCount(cd);
         ca.SetUnitCount(cd, unitCount + 1);
     }
 }
Exemplo n.º 3
0
        public void RemoveUnitsImpl(CombatItemData cd, int level, int count)
        {
            int unitIndex = GetUnitTypeIndex(cd, level);

            if (unitIndex == -1)
            {
                //Do nothing, should be empty yet
            }
            else
            {
                UnitSlot us = m_vUnits[unitIndex];
                if (us.Count <= count)
                {
                    m_vUnits.Remove(us);
                }
                else
                {
                    us.Count -= count;
                }
                ClientAvatar ca        = GetParent().GetLevel().GetPlayerAvatar();
                int          unitCount = ca.GetUnitCount(cd);
                ca.SetUnitCount(cd, unitCount - count);
            }
        }