コード例 #1
0
    public void ReloadNewMercenaryProduct(List <MercenaryType> newProducts)
    {
        this.m_Data.ProduceMercenary.ReloadNewProduct(newProducts);

        List <MercenaryType> deletedTypes = new List <MercenaryType>();

        foreach (MercenaryType mercenaryType in m_MercenaryComponents.Keys)
        {
            if (!this.m_Data.ProduceMercenary.Products.ContainsKey(mercenaryType))
            {
                deletedTypes.Add(mercenaryType);
            }
        }
        foreach (MercenaryType type in deletedTypes)
        {
            this.RemoveComponent(this.m_MercenaryComponents[type]);
            this.m_MercenaryComponents.Remove(type);
        }

        foreach (MercenaryType type in this.m_Data.ProduceMercenary.Products.Keys)
        {
            if (!this.m_MercenaryComponents.ContainsKey(type))
            {
                MercenaryProduceComponent comp = new MercenaryProduceComponent(type);
                this.InitialComponent(comp);
                this.m_MercenaryComponents.Add(type, comp);
            }
        }
    }
コード例 #2
0
    private void AddComponentAccordingToConfigData(BuildingConfigData configData, int functionMask)
    {
        if (configData.CanProduceArmy && (functionMask & ((int)BuildingFunction.ProduceArmy)) != 0 &&
            this.m_ArmyProduceComponent == null)
        {
            ArmyProduceComponent comp = new ArmyProduceComponent();
            this.InitialComponent(comp);
            comp.ProduceFinished       += this.ArmyProduced;
            this.m_ArmyProduceComponent = comp;
        }
        if (configData.CanProduceItem && (functionMask & ((int)BuildingFunction.ProduceItem)) != 0 &&
            this.m_ItemProduceComponent == null)
        {
            ItemProduceComponent comp = new ItemProduceComponent();
            this.InitialComponent(comp);
            comp.ProduceFinished       += this.ItemProduced;
            this.m_ItemProduceComponent = comp;
        }

        if (configData.CanUpgradeArmy && (functionMask & ((int)BuildingFunction.UpgradeArmy)) != 0 &&
            this.m_ArmyUpgradeComponent == null)
        {
            ArmyUpgradeComponent comp = new ArmyUpgradeComponent();
            this.InitialComponent(comp);
            comp.ProduceFinished       += this.ArmyUpgraded;
            this.m_ArmyUpgradeComponent = comp;
        }
        if (configData.CanUpgradeItem && (functionMask & ((int)BuildingFunction.UpgradeItem)) != 0 &&
            this.m_ItemUpgradeComponent == null)
        {
            ItemUpgradeComponent comp = new ItemUpgradeComponent();
            this.InitialComponent(comp);
            comp.ProduceFinished       += this.ItemUpgraded;
            this.m_ItemUpgradeComponent = comp;
        }
        if (this.m_Data.ProduceMercenary != null && (functionMask & ((int)BuildingFunction.ProduceMercenary)) != 0 &&
            this.m_MercenaryComponents == null)
        {
            this.m_MercenaryComponents = new Dictionary <MercenaryType, MercenaryProduceComponent>();
            foreach (MercenaryType type in this.m_Data.ProduceMercenary.Products.Keys)
            {
                MercenaryProduceComponent comp = new MercenaryProduceComponent(type);
                this.InitialComponent(comp);
                this.m_MercenaryComponents.Add(type, comp);
            }
        }
    }