Beispiel #1
0
        private void AddTroops(List <UXElement> list)
        {
            TroopUpgradeCatalog troopUpgradeCatalog = Service.TroopUpgradeCatalog;

            foreach (KeyValuePair <string, int> current in this.cp.Prizes.Troops)
            {
                if (current.Value > 0)
                {
                    PrizeType   prizeType = PrizeType.Infantry;
                    TroopTypeVO minLevel  = troopUpgradeCatalog.GetMinLevel(current.Key);
                    TroopType   type      = minLevel.Type;
                    if (type != TroopType.Vehicle)
                    {
                        if (type != TroopType.Mercenary)
                        {
                            if (type == TroopType.Hero)
                            {
                                prizeType = PrizeType.Hero;
                            }
                        }
                        else
                        {
                            prizeType = PrizeType.Mercenary;
                        }
                    }
                    else
                    {
                        prizeType = PrizeType.Vehicle;
                    }
                    UXElement item = this.CreateTileWithPrizeInfo(current.Key, current.Value, prizeType);
                    list.Add(item);
                }
            }
            foreach (KeyValuePair <string, int> current2 in this.cp.Prizes.SpecialAttacks)
            {
                if (current2.Value > 0)
                {
                    UXElement item2 = this.CreateTileWithPrizeInfo(current2.Key, current2.Value, PrizeType.SpecialAttack);
                    list.Add(item2);
                }
            }
        }
        private void AddTroops(List <UXElement> list)
        {
            TroopUpgradeCatalog troopUpgradeCatalog = Service.Get <TroopUpgradeCatalog>();

            foreach (KeyValuePair <string, int> current in this.cp.Prizes.Troops)
            {
                if (current.get_Value() > 0)
                {
                    PrizeType   prizeType = PrizeType.Infantry;
                    TroopTypeVO minLevel  = troopUpgradeCatalog.GetMinLevel(current.get_Key());
                    switch (minLevel.Type)
                    {
                    case TroopType.Vehicle:
                        prizeType = PrizeType.Vehicle;
                        break;

                    case TroopType.Mercenary:
                        prizeType = PrizeType.Mercenary;
                        break;

                    case TroopType.Hero:
                        prizeType = PrizeType.Hero;
                        break;
                    }
                    UXElement item = this.CreateTileWithPrizeInfo(current.get_Key(), current.get_Value(), prizeType);
                    list.Add(item);
                }
            }
            foreach (KeyValuePair <string, int> current2 in this.cp.Prizes.SpecialAttacks)
            {
                if (current2.get_Value() > 0)
                {
                    UXElement item2 = this.CreateTileWithPrizeInfo(current2.get_Key(), current2.get_Value(), PrizeType.SpecialAttack);
                    list.Add(item2);
                }
            }
        }
        public bool IsEquipmentValidForTab(EquipmentVO vo, EquipmentTab selectedTab)
        {
            if (selectedTab == EquipmentTab.All)
            {
                return(true);
            }
            TroopUpgradeCatalog troopUpgradeCatalog = Service.Get <TroopUpgradeCatalog>();
            IDataController     dataController      = Service.Get <IDataController>();

            if (vo.EffectUids == null)
            {
                return(false);
            }
            int i   = 0;
            int num = vo.EffectUids.Length;

            while (i < num)
            {
                EquipmentEffectVO optional = dataController.GetOptional <EquipmentEffectVO>(vo.EffectUids[i]);
                if (optional == null)
                {
                    Service.Get <StaRTSLogger>().Error("CMS Error: EffectUids is empty for EquipmentEffectVO " + optional.Uid);
                    return(false);
                }
                switch (selectedTab)
                {
                case EquipmentTab.Troops:
                    if (optional.AffectedTroopIds != null && optional.AffectedTroopIds.Length != 0)
                    {
                        int j    = 0;
                        int num2 = optional.AffectedTroopIds.Length;
                        while (j < num2)
                        {
                            if (troopUpgradeCatalog.GetMinLevel(optional.AffectedTroopIds[j]).Type != TroopType.Hero)
                            {
                                return(true);
                            }
                            j++;
                        }
                    }
                    break;

                case EquipmentTab.Heroes:
                    if (optional.AffectedTroopIds != null && optional.AffectedTroopIds.Length != 0)
                    {
                        int k    = 0;
                        int num3 = optional.AffectedTroopIds.Length;
                        while (k < num3)
                        {
                            if (troopUpgradeCatalog.GetMinLevel(optional.AffectedTroopIds[k]).Type == TroopType.Hero)
                            {
                                return(true);
                            }
                            k++;
                        }
                    }
                    break;

                case EquipmentTab.Structures:
                    if (optional.AffectedBuildingIds != null && optional.AffectedBuildingIds.Length != 0)
                    {
                        return(true);
                    }
                    break;
                }
                i++;
            }
            return(false);
        }
Beispiel #4
0
        public bool IsEquipmentValidForTab(EquipmentVO vo, EquipmentTab selectedTab)
        {
            if (selectedTab == EquipmentTab.All)
            {
                return(true);
            }
            TroopUpgradeCatalog  troopUpgradeCatalog  = Service.TroopUpgradeCatalog;
            StaticDataController staticDataController = Service.StaticDataController;

            if (vo.EffectUids == null)
            {
                return(false);
            }
            int i   = 0;
            int num = vo.EffectUids.Length;

            while (i < num)
            {
                EquipmentEffectVO optional = staticDataController.GetOptional <EquipmentEffectVO>(vo.EffectUids[i]);
                if (optional == null)
                {
                    Service.Logger.Error("CMS Error: EffectUids is empty for EquipmentEffectVO " + optional.Uid);
                    return(false);
                }
                if (selectedTab != EquipmentTab.Structures)
                {
                    if (selectedTab != EquipmentTab.Troops)
                    {
                        if (selectedTab == EquipmentTab.Heroes)
                        {
                            if (optional.AffectedTroopIds != null && optional.AffectedTroopIds.Length > 0)
                            {
                                int j    = 0;
                                int num2 = optional.AffectedTroopIds.Length;
                                while (j < num2)
                                {
                                    if (troopUpgradeCatalog.GetMinLevel(optional.AffectedTroopIds[j]).Type == TroopType.Hero)
                                    {
                                        return(true);
                                    }
                                    j++;
                                }
                            }
                        }
                    }
                    else if (optional.AffectedTroopIds != null && optional.AffectedTroopIds.Length > 0)
                    {
                        int k    = 0;
                        int num3 = optional.AffectedTroopIds.Length;
                        while (k < num3)
                        {
                            if (troopUpgradeCatalog.GetMinLevel(optional.AffectedTroopIds[k]).Type != TroopType.Hero)
                            {
                                return(true);
                            }
                            k++;
                        }
                    }
                }
                else if (optional.AffectedBuildingIds != null && optional.AffectedBuildingIds.Length > 0)
                {
                    return(true);
                }
                i++;
            }
            return(false);
        }