示例#1
0
        public bool CanAddUnit(LogicCombatItemData data)
        {
            LogicAvatar homeOwnerAvatar = this.m_parent.GetLevel().GetHomeOwnerAvatar();

            if (!homeOwnerAvatar.IsNpcAvatar())
            {
                if (this.GetComponentType() != 0)
                {
                    if (this.m_storageType == data.GetCombatItemType())
                    {
                        return(this.m_maxCapacity >= data.GetHousingSpace() + this.GetUsedCapacity());
                    }
                }
                else
                {
                    LogicComponentManager componentManager = this.m_parent.GetComponentManager();

                    int totalUsedHousing = componentManager.GetTotalUsedHousing(this.m_storageType);
                    int totalMaxHousing  = componentManager.GetTotalMaxHousing(this.m_storageType);

                    if (data.GetCombatItemType() == this.m_storageType)
                    {
                        if (this.GetUsedCapacity() < this.m_maxCapacity)
                        {
                            return(totalMaxHousing >= totalUsedHousing + data.GetHousingSpace());
                        }
                    }
                }

                return(false);
            }

            return(true);
        }
示例#2
0
        public bool CanStartUpgrading(LogicCombatItemData data)
        {
            if (data != null && this.m_unit == null)
            {
                if (this.m_parent.GetLevel().GetGameMode().GetCalendar().IsProductionEnabled(data))
                {
                    if (data.GetCombatItemType() != LogicCombatItemData.COMBAT_ITEM_TYPE_HERO)
                    {
                        if (this.m_parent.GetVillageType() == data.GetVillageType())
                        {
                            int upgLevel = this.m_parent.GetLevel().GetHomeOwnerAvatar().GetUnitUpgradeLevel(data);

                            if (data.GetUpgradeLevelCount() - 1 > upgLevel)
                            {
                                int maxProductionHouseLevel;

                                if (data.GetVillageType() == 1)
                                {
                                    maxProductionHouseLevel = this.m_parent.GetComponentManager().GetMaxBarrackLevel();
                                }
                                else
                                {
                                    LogicComponentManager componentManager = this.m_parent.GetComponentManager();

                                    if (data.GetCombatItemType() == LogicCombatItemData.COMBAT_ITEM_TYPE_CHARACTER)
                                    {
                                        maxProductionHouseLevel = data.GetUnitOfType() != 1 ? componentManager.GetMaxDarkBarrackLevel() : componentManager.GetMaxBarrackLevel();
                                    }
                                    else
                                    {
                                        maxProductionHouseLevel =
                                            data.GetUnitOfType() == 1 ? componentManager.GetMaxSpellForgeLevel() : componentManager.GetMaxMiniSpellForgeLevel();
                                    }
                                }

                                if (maxProductionHouseLevel >= data.GetRequiredProductionHouseLevel())
                                {
                                    LogicBuilding building = (LogicBuilding)this.m_parent;

                                    if (!building.IsLocked())
                                    {
                                        return(building.GetUpgradeLevel() >= data.GetRequiredLaboratoryLevel(upgLevel + 1));
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(false);
        }