Пример #1
0
        public static IElementType GetTypeObject(Type ressType)
        {
            IElementType result = null;

            switch (ressType)
            {
            case Type.RESSOURCE_FOREST:
                result = new ForestElementType();
                break;

            case Type.RESSOURCE_STONE:
                result = new StoneElementType();
                break;

            case Type.RESSOURCE_IRON:
                result = new IronElementType();
                break;

            case Type.RESSOURCE_WATER:
                result = new LakeElementType();
                break;

            case Type.RESSOURCE_FIELDS:
                result = new FieldsElementType();
                break;
            }
            return(result);
        }
Пример #2
0
        public static IElementType GetElementFromType(string elementType)
        {
            IElementType newElement = null;

            switch (elementType)
            {
            case "RESSOURCE_FOREST":
                newElement = new ForestElementType();
                break;

            case "RESSOURCE_STONE":
                newElement = new StoneElementType();
                break;

            case "RESSOURCE_IRON":
                newElement = new IronElementType();
                break;

            case "RESSOURCE_WATER":
                newElement = new LakeElementType();
                break;

            case "RESSOURCE_FIELDS":
                newElement = new FieldsElementType();
                break;

            case "BUILDING_WOODCUTTER":
                newElement = new WoodcutterElementType();
                break;

            case "BUILDING_SAWMILL":
                newElement = new SawmillElementType();
                break;

            case "BUILDING_QUARRY":
                newElement = new QuarryElementType();
                break;

            case "BUILDING_STONEMASON":
                newElement = new StoneMasonElementType();
                break;

            case "BUILDING_IRONMINE":
                newElement = new IronMineElementType();
                break;

            case "BUILDING_FOUNDRY":
                newElement = new FoundryElementType();
                break;

            case "BUILDING_TOWNHALL":
                newElement = new TownHallElementType();
                break;

            case "BUILDING_FARM":
                newElement = new FarmElementType();
                break;

            case "BUILDING_MILL":
                newElement = new MillElementType();
                break;

            case "BUILDING_TOWNHOUSE":
                newElement = new TownhouseElementType();
                break;

            case "BUILDING_MARKETPLACE":
                newElement = new MarketplaceElementType();
                break;

            case "BUILDING_RESEARCH_CENTER":
                newElement = new ResearchCenterElementType();
                break;

            case "BUILDING_WAREHOUSE":
                newElement = new WarehouseElementType();
                break;

            case "BUILDING_BARRACK":
                newElement = new BarrackBuilding();
                break;

            case "BUILDING_CITYGUARD_HOUSE":
                newElement = new CityguardBuilding();
                break;

            case "BUILDING_TRAINING_GROUND":
                newElement = new TrainingGroundBuilding();
                break;

            case "BUILDING_STABLE":
                newElement = new StableBuilding();
                break;

            case "BUILDING_MOONGLOW_TOWER":
                newElement = new MoonglowTowerBuilding();
                break;
            }

            return(newElement);
        }
Пример #3
0
 public static IElementType GetTypeObject(Type ressType)
 {
     IElementType result = null;
     switch (ressType)
     {
         case Type.RESSOURCE_FOREST:
             result = new ForestElementType();
             break;
         case Type.RESSOURCE_STONE:
             result = new StoneElementType();
             break;
         case Type.RESSOURCE_IRON:
             result = new IronElementType();
             break;
         case Type.RESSOURCE_WATER:
             result = new LakeElementType();
             break;
         case Type.RESSOURCE_FIELDS:
             result = new FieldsElementType();
             break;
     }
     return result;
 }
Пример #4
0
        public static IElementType GetElementFromType(string elementType)
        {
            IElementType newElement = null;
            switch(elementType)
            {
                case "RESSOURCE_FOREST":
                    newElement = new ForestElementType();
                    break;
                case "RESSOURCE_STONE":
                    newElement = new StoneElementType();
                    break;
                case "RESSOURCE_IRON":
                    newElement = new IronElementType();
                    break;
                case "RESSOURCE_WATER":
                    newElement = new LakeElementType();
                    break;
                case "RESSOURCE_FIELDS":
                    newElement = new FieldsElementType();
                    break;
                case "BUILDING_WOODCUTTER":
                    newElement = new WoodcutterElementType();
                    break;
                case "BUILDING_SAWMILL":
                    newElement = new SawmillElementType();
                    break;
                case "BUILDING_QUARRY":
                    newElement = new QuarryElementType();
                    break;
                case "BUILDING_STONEMASON":
                    newElement = new StoneMasonElementType();
                    break;
                case "BUILDING_IRONMINE":
                    newElement = new IronMineElementType();
                    break;
                case "BUILDING_FOUNDRY":
                    newElement = new FoundryElementType();
                    break;
                case "BUILDING_TOWNHALL":
                    newElement = new TownHallElementType();
                    break;
                case "BUILDING_FARM":
                    newElement = new FarmElementType();
                    break;
                case "BUILDING_MILL":
                    newElement = new MillElementType();
                    break;
                case "BUILDING_TOWNHOUSE":
                    newElement = new TownhouseElementType();
                    break;
                case "BUILDING_MARKETPLACE":
                    newElement = new MarketplaceElementType();
                    break;
                case "BUILDING_RESEARCH_CENTER":
                    newElement = new ResearchCenterElementType();
                    break;
                case "BUILDING_WAREHOUSE":
                    newElement = new WarehouseElementType();
                    break;
                case "BUILDING_BARRACK":
                    newElement = new BarrackBuilding();
                    break;
                case "BUILDING_CITYGUARD_HOUSE":
                    newElement = new CityguardBuilding();
                    break;
                case "BUILDING_TRAINING_GROUND":
                    newElement = new TrainingGroundBuilding();
                    break;
                case "BUILDING_STABLE":
                    newElement = new StableBuilding();
                    break;
                case "BUILDING_MOONGLOW_TOWER":
                    newElement = new MoonglowTowerBuilding();
                    break;
            }

            return newElement;
        }
        private static void UpdateElementTotalBonus(Element element)
        {
            var elementType = element.GetElementType();

            // Get number of natural ressources around
            var nbNaturalRessources = element.NbRessourcesAround;

            var firstBonus     = 0;
            var secondBonus    = 0;
            var bonusRessource = ElementType.GetTypeObject(ElementType.GetBonusRessource(elementType.GetElementType()));

            if (bonusRessource != null)
            {
                firstBonus  = bonusRessource.GetElementProductionBonus(0).FirstBonus;
                secondBonus = bonusRessource.GetElementProductionBonus(0).SecondBonus;
            }

            var buildingBonus = 0;
            var bonusElement  = element.BonusBuilding;

            if (bonusElement?.GetElementType() != null)
            {
                var elementProductionBonus =
                    bonusElement.GetElementType().GetElementProductionBonus(bonusElement.Level);
                if (elementProductionBonus != null)
                {
                    buildingBonus = elementProductionBonus.GetFirstNotNull();
                }
            }

            var fieldsCount = element.FieldsCount;
            var fieldBonus  = new FieldsElementType().GetElementProductionBonus(0);


            var bonus = 100;

            // Natural ressources bonus
            if (nbNaturalRessources > 0)
            {
                bonus += firstBonus;
                if (nbNaturalRessources > 1)
                {
                    bonus += (nbNaturalRessources - 1) * secondBonus;
                }
            }
            // Production increase building bonus
            bonus += buildingBonus;

            // Fields bonus
            if (fieldsCount > 0)
            {
                bonus += fieldBonus.FirstBonus;
                if (fieldsCount > 1)
                {
                    bonus += (fieldsCount - 1) * fieldBonus.SecondBonus;
                }
            }

            // total bonus

            element.TotalBonus = bonus;
        }