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); }
public bool Upgrade() { if (BuyElement.Instance.Buy(_elementToUpgrade)) { _elementToUpgrade.Level = _elementToUpgrade.Level + 1; // Update all map for ressources RessourcesBuildingCheck.Instance.cheakAllNeighbourRessources(); // Update count (Town Hall) BuildingCount.Instance.CountBuildings(); // Update Score int level = _elementToUpgrade.Level; IElementType elementType = _elementToUpgrade.GetElementType(); Score.Score.Instance.ScoreValue += (elementType.GetScoreValue(level) - elementType.GetScoreValue(level - 1)); // Update Storage Storage.Instance.UpdateStorageCapacity(); // Update Unit max count if (_elementToUpgrade.GetElementType() is BarrackBuilding) { UnitManager.Instance.UpdateUnitCount(); } return(true); } ErrorManager.Instance.AddError(new Error.Error() { Description = Error.Error.Type.NOT_ENOUGH_RESSOURCES_UPGRADE }); return(false); }
private void BuildElement(IElementType element) { _buildEvent.SetTypeToBuild(element); if (_buildEvent.BuildElement()) { _buildEvent.SetElementToBuild(null); BuildingMenuVisibility.Instance.HideBuildingMenu(); } }
private ElementSpec(IElementType elementType) { TypeID = (uint)_typeIDs.Count; _typeIDs.Add(TypeID, elementType); ScheduleStyleEvery = (elementType.ScheduleStyle == ElementScheduleStyle.Every); var image = elementType.GetImage(Foo(typeof(TEngine))); TotalSizeInBytes = image.StateSizeInBytes + SizeOfElement + sizeof(uint); StateSizeInBytes = image.StateSizeInBytes; DataSizeInBytes = image.DataSizeInBytes; }
public static ElementSpec <TEngine> GetSpec(IElementType elementType) { ElementSpec <TEngine> spec; if (!_specs.TryGetValue(elementType, out spec)) { _specs.Add(elementType, spec = new ElementSpec <TEngine>(elementType)); } return(spec); }
public bool Buy(IElementType elementType, int level) { if (elementType == null) return false; ElementCost elementCost = elementType.GetElementCost(level); if (elementCost == null) return false; return CheckRessourcesAvailability(elementCost); }
public void SetElementType(IElementType type) { if (type == null) { return; } _elementType = type; // Set new image SetPath(type.GetImagePath()); if (_levelIndicatorVisibility) { ShowLevelIndicator(); } }
public bool Buy(IElementType elementType, int level) { if (elementType == null) { return(false); } ElementCost elementCost = elementType.GetElementCost(level); if (elementCost == null) { return(false); } return(CheckRessourcesAvailability(elementCost)); }
public void Initialise() { HideSelectBorder(); HasElement = false; _elementType = null; _imageBrush = new ImageBrush(); _rectangle.Fill = _imageBrush; _level = 0; // Natural ressources near _neighbourRessources = 0; _fieldsCount = 0; // Initialise bonus building BonusBuilding = null; TotalBonus = 0; }
public CompoundType(IElementType[] types) { Types = types; }
public void SetTypeToBuild(IElementType elementType) { _typeToBuild = elementType; }
public IEnumerable <IModuleDefinitionDetail> GetModulesForElement(IElementType elementType) { throw new NotImplementedException(); }
public void ShowBuildingDetails() { _mainWindow = MainWindow.MIns; if (_mainWindow == null) { return; } // Building menu visibility _mainWindow.building_menu_englob.Height = 400; _mainWindow.building_details.Visibility = Visibility.Visible; // if anything is not defined, return if (_elementMenuDetail == null || _elementMenuDetail.GetElementType() == null) { return; } // Add visual elements ImageBrush image = new ImageBrush { ImageSource = new BitmapImage(new Uri(_elementMenuDetail.GetElementType().GetDetailImagePath(), UriKind.RelativeOrAbsolute)) }; _mainWindow.building_details_img.Fill = image; // set the elementInfo _mainWindow.building_detail_info.Text = _elementMenuDetail.GetElementType().GetElementInfo(); int elementLevel = _elementMenuDetail.Level; if (elementLevel > 0 && elementLevel <= 10) { // hide second ressource delete button _mainWindow.delete_ressource_button.Visibility = Visibility.Hidden; // it's a building, show level info _mainWindow.building_detail_level_info.Visibility = Visibility.Visible; _mainWindow.building_detail_level.Content = _elementMenuDetail.Level; IElementType elementType = _elementMenuDetail.GetElementType(); if (elementType == null) { return; } if (elementLevel < 10) { ElementCost elementCost = elementType.GetElementCost(elementLevel + 1); // Show upgrade button _mainWindow.upgrade_element_button.Visibility = Visibility.Visible; // Show infos _mainWindow.wood_dockpanel.Visibility = Visibility.Visible; _mainWindow.stone_dockpanel.Visibility = Visibility.Visible; _mainWindow.iron_dockpanel.Visibility = Visibility.Visible; // Show cost for upgrade _mainWindow.building_detail_wood_cost.Content = elementCost.Wood; _mainWindow.building_detail_stone_cost.Content = elementCost.Stone; _mainWindow.building_detail_iron_cost.Content = elementCost.Iron; } else { // hide upgrade button _mainWindow.upgrade_element_button.Visibility = Visibility.Hidden; // hide upgrade qty _mainWindow.wood_dockpanel.Visibility = Visibility.Hidden; _mainWindow.stone_dockpanel.Visibility = Visibility.Hidden; _mainWindow.iron_dockpanel.Visibility = Visibility.Hidden; } #region Storage Label handle ElementStorage elementStorage = elementType.GetElementStorage(elementLevel + 1); if (elementStorage != null) { _mainWindow.storage_dockpanel.Visibility = Visibility.Visible; _mainWindow.building_detail_storage_next.Content = elementStorage.BaseStorage; } else { _mainWindow.storage_dockpanel.Visibility = Visibility.Hidden; } elementStorage = elementType.GetElementStorage(elementLevel); if (elementStorage != null && elementType.GetElementType() != ElementType.Type.BUILDING_TOWNHALL) { _mainWindow.building_storage_label.Visibility = Visibility.Visible; _mainWindow.building_detail_storage.Content = elementStorage.BaseStorage; } else { _mainWindow.building_detail_storage.Content = ""; _mainWindow.building_storage_label.Visibility = Visibility.Hidden; } #endregion // Show/Hide production label #region Production Label handle ElementProduction elementProduction = _elementMenuDetail.GetElementType().GetElementProduction(elementLevel); if (elementProduction != null) { _mainWindow.building_production_label.Visibility = Visibility.Visible; _mainWindow.building_detail_production.Content = elementProduction.GetFirstNotNull(); } else { // hide production label _mainWindow.building_detail_production.Content = ""; _mainWindow.building_production_label.Visibility = Visibility.Hidden; } elementProduction = _elementMenuDetail.GetElementType().GetElementProduction(elementLevel + 1); if (elementProduction != null) { _mainWindow.production_dockpanel.Visibility = Visibility.Visible; _mainWindow.building_detail_production_next.Content = elementProduction.GetFirstNotNull(); } else { // hide production label _mainWindow.building_detail_production_next.Content = ""; _mainWindow.production_dockpanel.Visibility = Visibility.Collapsed; } #endregion // Show/Hide Bonus label #region Bonus Label handle _mainWindow.building_units_label.Visibility = Visibility.Hidden; _mainWindow.building_detail_units.Content = ""; ElementProductionBonus elementProductionBonus = _elementMenuDetail.GetElementType().GetElementProductionBonus(elementLevel); if (elementProductionBonus != null) { _mainWindow.building_bonus_label.Visibility = Visibility.Visible; if (!elementProductionBonus.IsRessourcesBonus) { _mainWindow.building_detail_bonus.Content = String.Format("{0}%", elementProductionBonus.GetFirstNotNull()); } } else if (_elementMenuDetail.GetElementType().IsMilitary()) { var militaryElement = (IUnitBuilding)_elementMenuDetail.GetElementType(); if (!militaryElement.IsBarrack()) { _mainWindow.building_bonus_label.Visibility = Visibility.Visible; _mainWindow.building_detail_bonus.Content = String.Format("{0}%", militaryElement.GetUnitBonus(_elementMenuDetail.Level)); } else { _mainWindow.building_units_label.Visibility = Visibility.Visible; _mainWindow.building_detail_units.Content = militaryElement.GetArmySize(_elementMenuDetail.Level); _mainWindow.building_bonus_label.Visibility = Visibility.Hidden; _mainWindow.building_detail_bonus.Content = ""; } } else { _mainWindow.building_bonus_label.Visibility = Visibility.Hidden; _mainWindow.building_detail_bonus.Content = ""; } elementProductionBonus = _elementMenuDetail.GetElementType().GetElementProductionBonus(elementLevel + 1); if (elementProductionBonus != null) { _mainWindow.bonus_dockpanel.Visibility = Visibility.Visible; if (!elementProductionBonus.IsRessourcesBonus) { _mainWindow.building_detail_bonus_next.Content = String.Format("{0}%", elementProductionBonus.GetFirstNotNull()); } } else { _mainWindow.bonus_dockpanel.Visibility = Visibility.Collapsed; _mainWindow.building_detail_bonus_next.Content = ""; } #endregion // Show/Hide # ressources around element #region Label for # ressources around if (_elementMenuDetail.NbRessourcesAround > 0) { _mainWindow.ressources_bonus_dockpanel.Visibility = Visibility.Visible; _mainWindow.building_detail_ressource_bonus.Content = _elementMenuDetail.NbRessourcesAround; } else { _mainWindow.ressources_bonus_dockpanel.Visibility = Visibility.Collapsed; } #endregion // Show/Hide # fields count #region Fields Count if (_elementMenuDetail.FieldsCount > 0) { _mainWindow.fields_count_dockpanel.Visibility = Visibility.Visible; _mainWindow.building_detail_fields_count.Content = _elementMenuDetail.FieldsCount; } else { _mainWindow.fields_count_dockpanel.Visibility = Visibility.Collapsed; } #endregion // Show/Hide total bonus on element #region Total bonus if (_elementMenuDetail.TotalBonus > 100) { _mainWindow.total_bonus_dockpanel.Visibility = Visibility.Visible; _mainWindow.building_detail_total_bonus.Content = (_elementMenuDetail.TotalBonus - 100) + "%"; } else { _mainWindow.total_bonus_dockpanel.Visibility = Visibility.Collapsed; } #endregion // Show/hide delete button _mainWindow.delete_element_button.Visibility = (elementType.GetElementType() == ElementType.Type.BUILDING_TOWNHALL) ? Visibility.Collapsed : Visibility.Visible; } else { // it's not a building (no level) _mainWindow.building_detail_level_info.Visibility = Visibility.Collapsed; if (_elementMenuDetail.GetElementType() != null && _elementMenuDetail.GetElementType().GetElementType() != ElementType.Type.BUILDING_TOWNHALL) { _mainWindow.delete_ressource_button.Visibility = Visibility.Visible; } } }
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); }
protected override void InsertItem(int index, IElementType item) { Console.WriteLine("Managed::InsertItem"); base.InsertItem(index, item); }
protected override void SetItem(int index, IElementType item) { throw new NotSupportedException(); }
public MockElement(IElementType type) { Type = type; }
private void AssignRessources(Element element) { // check the Element Type IElementType elementType = element.GetElementType(); if (elementType.IsRessources()) { return; } // Get the element Level int elementLevel = element.Level; if (elementLevel <= 0) { return; } // Get the base production ElementProduction elementProduction = elementType.GetElementProduction(elementLevel); if (elementProduction == null) { return; } UpdateElementTotalBonus(element); // Get Wood bonus var woodResearch = _researchHandler.WoodResearchType; var woodBonus = 0; if (woodResearch.GetLevel() > 0) { woodBonus = woodResearch.GetResearchBonus(woodResearch.GetLevel()).WoodBonus; } // Get Stone bonus var stoneResearch = _researchHandler.StoneResearchType; var stoneBonus = 0; if (stoneResearch.GetLevel() > 0) { stoneBonus = stoneResearch.GetResearchBonus(stoneResearch.GetLevel()).StoneBonus; } // Get Iron bonus var ironResearch = _researchHandler.IronResearchType; var ironBonus = 0; if (ironResearch.GetLevel() > 0) { ironBonus = ironResearch.GetResearchBonus(ironResearch.GetLevel()).IronBonus; } // Get Food Bonus var foodResearch = _researchHandler.FoodResearchType; var foodBonus = 0; if (foodResearch.GetLevel() > 0) { foodBonus = foodResearch.GetResearchBonus(foodResearch.GetLevel()).FoodBonus; } // Get Gold bonus var goldResearch = _researchHandler.GoldResearchType; var goldBonus = 0; if (goldResearch.GetLevel() > 0) { goldBonus = goldResearch.GetResearchBonus(goldResearch.GetLevel()).GoldBonus; } _ressourcesProduction.WoodQty += CalculateRessource(elementProduction.Wood, element.TotalBonus, woodBonus); _ressourcesProduction.StoneQty += CalculateRessource(elementProduction.Stone, element.TotalBonus, stoneBonus); _ressourcesProduction.IronQty += CalculateRessource(elementProduction.Iron, element.TotalBonus, ironBonus); _ressourcesProduction.FoodQty += CalculateRessource(elementProduction.Food, element.TotalBonus, foodBonus); _ressourcesProduction.GoldQty += CalculateRessource(elementProduction.Gold, element.TotalBonus, goldBonus); _ressourcesProduction.ResearchQty += CalculateRessource(elementProduction.Research, element.TotalBonus); }