Example #1
0
        internal bool CanStartUpgrading(Combat_Item data)
        {
            var result = false;

            if (Unit == null)
            {
                if (Parent.ClassId == 0)
                {
                    var b  = (Building)Parent;
                    var ca = Parent.Level.Avatar;
                    var cm = Parent.Level.GetComponentManager();
                    var maxProductionBuildingLevel = data.GetCombatItemType() == 1
                        ? cm.GetMaxSpellForgeLevel()
                        : cm.GetMaxBarrackLevel();
                    if (ca.GetUnitUpgradeLevel(data) < data.GetUpgradeLevelCount() - 1)
                    {
                        if (maxProductionBuildingLevel >= data.GetRequiredProductionHouseLevel() - 1)
                        {
                            result = b.GetUpgradeLevel >=
                                     data.GetRequiredLaboratoryLevel(ca.GetUnitUpgradeLevel(data) + 1) - 1;
                        }
                    }
                }
                else if (Parent.ClassId == 7)
                {
                    var b  = (Builder_Building)Parent;
                    var ca = Parent.Level.Avatar;
                    var cm = Parent.Level.GetComponentManager();
                    var maxProductionBuildingLevel = data.GetCombatItemType() == 1
                        ? cm.GetMaxSpellForgeLevel()
                        : cm.GetMaxBarrackLevel();
                    if (ca.GetUnitUpgradeLevel(data) < data.GetUpgradeLevelCount() - 1)
                    {
                        if (maxProductionBuildingLevel >= data.GetRequiredProductionHouseLevel() - 1)
                        {
                            result = b.GetUpgradeLevel >=
                                     data.GetRequiredLaboratoryLevel(ca.GetUnitUpgradeLevel(data) + 1) - 1;
                        }
                    }
                }
            }
            return(result);
        }
Example #2
0
        public void SetUnitUpgradeLevel(Combat_Item cd, int level)
        {
            switch (cd.GetCombatItemType())
            {
            case 2:
            {
                int index = GetDataIndex(this.Heroes_Upgrades, cd);
                if (index != -1)
                {
                    this.Heroes_Upgrades[index].Count = level;
                }
                else
                {
                    Slot ds = new Slot(cd.GetGlobalID(), level);
                    this.Heroes_Upgrades.Add(ds);
                }
                break;
            }

            case 1:
            {
                int index = GetDataIndex(this.Spell_Upgrades, cd);
                if (index != -1)
                {
                    this.Spell_Upgrades[index].Count = level;
                }
                else
                {
                    Slot ds = new Slot(cd.GetGlobalID(), level);
                    this.Spell_Upgrades.Add(ds);
                }
                break;
            }

            default:
            {
                int index = GetDataIndex(this.Unit_Upgrades, cd);
                if (index != -1)
                {
                    this.Unit_Upgrades[index].Count = level;
                }
                else
                {
                    Slot ds = new Slot(cd.GetGlobalID(), level);
                    this.Unit_Upgrades.Add(ds);
                }
                break;
            }
            }
        }
Example #3
0
        public override JObject Save(JObject jsonObject)
        {
            if (Unit != null)
            {
                var unitUpgradeObject = new JObject
                {
                    { "unit_type", Unit.GetCombatItemType() },
                    { "t", Timer.GetRemainingSeconds(Parent.Level.Avatar.LastTick) },
                    { "t_end", Timer.EndTime },
                    { "id", Unit.GetGlobalId() }
                };

                jsonObject.Add("unit_upg", unitUpgradeObject);
            }
            return(jsonObject);
        }
Example #4
0
        public int GetUnitUpgradeLevel(Combat_Item cd)
        {
            int result = 0;

            switch (cd.GetCombatItemType())
            {
            case 2:
            {
                int index = GetDataIndex(this.Heroes_Upgrades, cd);
                if (index != -1)
                {
                    result = this.Heroes_Upgrades[index].Count;
                }
                break;
            }

            case 1:
            {
                int index = GetDataIndex(this.Spell_Upgrades, cd);
                if (index != -1)
                {
                    result = this.Spell_Upgrades[index].Count;
                }
                break;
            }

            default:
            {
                int index = GetDataIndex(this.Unit_Upgrades, cd);
                if (index != -1)
                {
                    result = this.Unit_Upgrades[index].Count;
                }
                break;
            }
            }
            return(result);
        }