当前位置: 首页>>代码示例>>C#>>正文


C# Element.GetElementType方法代码示例

本文整理汇总了C#中Element.GetElementType方法的典型用法代码示例。如果您正苦于以下问题:C# Element.GetElementType方法的具体用法?C# Element.GetElementType怎么用?C# Element.GetElementType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Element的用法示例。


在下文中一共展示了Element.GetElementType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateVisibility

        public void UpdateVisibility(Element element)
        {
            var mainWindow = MainWindow.MIns;
            if (mainWindow == null)
                return;

            if (element?.GetElementType() == null)
                return;

            switch (element.GetElementType().GetElementType())
            {
                case ElementType.Type.BUILDING_CITYGUARD_HOUSE:
                    EnableCanvas(mainWindow.recruit_cityguard);
                    break;

                case ElementType.Type.BUILDING_MOONGLOW_TOWER:
                    EnableCanvas(mainWindow.recruit_mage);
                    EnableCanvas(mainWindow.recruit_warlock);
                    break;

                case ElementType.Type.BUILDING_STABLE:
                    EnableCanvas(mainWindow.recruit_crossbow);
                    EnableCanvas(mainWindow.recruit_knight);
                    EnableCanvas(mainWindow.recruit_paladin);
                    break;

                case ElementType.Type.BUILDING_TRAINING_GROUND:
                    EnableCanvas(mainWindow.recruit_berserker);
                    EnableCanvas(mainWindow.recruit_guardian);
                    EnableCanvas(mainWindow.recruit_ranger);
                    EnableCanvas(mainWindow.recruit_templar);
                    break;
            }
        }
开发者ID:FelixLeChat,项目名称:LordOfUltima,代码行数:34,代码来源:UnitRecruitmentVisibility.cs

示例2: Buy

        public bool Buy(Element element)
        {
            if (element == null)
                return false;

            int elementLevel = element.Level;
            if (elementLevel < 0 || elementLevel >= 10)
                return false;

            if (element.GetElementType() == null)
                return false;

            ElementCost elementCost = element.GetElementType().GetElementCost(elementLevel + 1);

            if (elementCost == null)
                return false;

            return CheckRessourcesAvailability(elementCost);
        }
开发者ID:FelixLeChat,项目名称:LordOfUltima,代码行数:19,代码来源:BuyElement.cs

示例3: CheckFieldsCount

        public void CheckFieldsCount(Element element)
        {
            if (element == null || !element.HasElement || element.GetElementType() == null)
                return;

            if (element.GetElementType().GetElementType() != ElementType.Type.BUILDING_FARM)
                return;

            Element[,] map = _gameboard.GetMap();
            int frameCount = _gameboard.GetFrameCount;
            int x = element.PositionX;
            int y = element.PositionY;
            int fieldsCount = 0;

            #region Fields count
            if (y > 0)
            {
                if (x > 0)
                {
                    if (!map[x - 1, y - 1].HasElement)
                    {
                        fieldsCount++;
                    }
                }
                if (!map[x, y - 1].HasElement)
                {
                    fieldsCount++;
                }

                if (x < frameCount - 1)
                {
                    if (!map[x + 1, y - 1].HasElement)
                    {
                        fieldsCount++;
                    }
                }

            }
            if (y < frameCount - 1)
            {
                if (x > 0)
                {
                    if (!map[x - 1, y + 1].HasElement)
                    {
                        fieldsCount++;
                    }
                }

                if (!map[x, y + 1].HasElement)
                {
                    fieldsCount++;
                }

                if (x < frameCount - 1)
                {
                    if (!map[x + 1, y + 1].HasElement)
                    {
                        fieldsCount++;
                    }
                }
            }

            if (x > 0)
            {
                if (!map[x - 1, y].HasElement)
                {
                    fieldsCount++;
                }
            }
            if (x < frameCount - 1)
            {
                if (!map[x + 1, y].HasElement)
                {
                    fieldsCount++;
                }
            }
            #endregion

            element.FieldsCount = fieldsCount;
        }
开发者ID:FelixLeChat,项目名称:LordOfUltima,代码行数:80,代码来源:RessourcesBuildingCheck.cs

示例4: checkNeighbourRessources

        private void checkNeighbourRessources(Element element)
        {
            if (element == null || !element.HasElement || element.GetElementType() == null)
                return;

            Element[,] map = _gameboard.GetMap();
            int frameCount = _gameboard.GetFrameCount;
            int x = element.PositionX;
            int y = element.PositionY;
            int ressourceCount = 0;

            ElementType.Type ressourceType = ElementType.GetBonusRessource(element.GetElementType().GetElementType());

            if (ressourceType == ElementType.Type.DEFAULT)
            {
                return;
            }

            if (y > 0)
            {
                if (x > 0)
                {
                    if (map[x - 1, y - 1].HasElement && map[x - 1, y - 1].GetElementType().GetElementType() == ressourceType)
                        ressourceCount++;
                }
                if (map[x, y - 1].HasElement && map[x, y - 1].GetElementType().GetElementType() == ressourceType)
                    ressourceCount++;

                if (x < frameCount - 1)
                {
                    if (map[x + 1, y - 1].HasElement && map[x + 1, y - 1].GetElementType().GetElementType() == ressourceType)
                        ressourceCount++;
                }

            }
            if (y < frameCount - 1)
            {
                if (x > 0)
                {
                    if (map[x - 1, y + 1].HasElement && map[x - 1, y + 1].GetElementType().GetElementType() == ressourceType)
                        ressourceCount++;
                }

                if (map[x, y + 1].HasElement && map[x, y + 1].GetElementType().GetElementType() == ressourceType)
                    ressourceCount++;

                if (x < frameCount - 1)
                {
                    if (map[x + 1, y + 1].HasElement && map[x + 1, y + 1].GetElementType().GetElementType() == ressourceType)
                        ressourceCount++;
                }
            }

            if (x > 0)
            {
                if (map[x - 1, y].HasElement && map[x - 1, y].GetElementType().GetElementType() == ressourceType)
                    ressourceCount++;
            }
            if (x < frameCount - 1)
            {
                if (map[x + 1, y].HasElement && map[x + 1, y].GetElementType().GetElementType() == ressourceType)
                    ressourceCount++;
            }

            element.NbRessourcesAround = ressourceCount;
        }
开发者ID:FelixLeChat,项目名称:LordOfUltima,代码行数:66,代码来源:RessourcesBuildingCheck.cs

示例5: checkNeighbourBonusBuilding

        private void checkNeighbourBonusBuilding(Element element)
        {
            if (element == null || !element.HasElement || element.GetElementType() == null)
                return;

            Element[,] map = _gameboard.GetMap();
            int frameCount = _gameboard.GetFrameCount;
            int x = element.PositionX;
            int y = element.PositionY;
            Element bonusBuilding = null;

            ElementType.Type buildingBonurType =
                ElementType.GetBonusBuilding(element.GetElementType().GetElementType());

            if (buildingBonurType == ElementType.Type.DEFAULT)
            {
                return;
            }

            if (y > 0)
            {
                if (x > 0)
                {
                    if (map[x - 1, y - 1].HasElement &&
                        map[x - 1, y - 1].GetElementType().GetElementType() == buildingBonurType)
                    {
                        bonusBuilding = getBestOne(bonusBuilding, map[x - 1, y - 1]);
                    }

                }
                if (map[x, y - 1].HasElement && map[x, y - 1].GetElementType().GetElementType() == buildingBonurType)
                {
                    bonusBuilding = getBestOne(bonusBuilding, map[x, y - 1]);
                }

                if (x < frameCount - 1)
                {
                    if (map[x + 1, y - 1].HasElement &&
                        map[x + 1, y - 1].GetElementType().GetElementType() == buildingBonurType)
                    {
                        bonusBuilding = getBestOne(bonusBuilding, map[x + 1, y - 1]);
                    }

                }

            }
            if (y < frameCount - 1)
            {
                if (x > 0)
                {
                    if (map[x - 1, y + 1].HasElement &&
                        map[x - 1, y + 1].GetElementType().GetElementType() == buildingBonurType)
                    {
                        bonusBuilding = getBestOne(bonusBuilding, map[x - 1, y + 1]);
                    }

                }

                if (map[x, y + 1].HasElement && map[x, y + 1].GetElementType().GetElementType() == buildingBonurType)
                {
                    bonusBuilding = getBestOne(bonusBuilding, map[x, y + 1]);
                }

                if (x < frameCount - 1)
                {
                    if (map[x + 1, y + 1].HasElement &&
                        map[x + 1, y + 1].GetElementType().GetElementType() == buildingBonurType)
                    {
                        bonusBuilding = getBestOne(bonusBuilding, map[x + 1, y + 1]);
                    }

                }
            }

            if (x > 0)
            {
                if (map[x - 1, y].HasElement && map[x - 1, y].GetElementType().GetElementType() == buildingBonurType)
                {
                    bonusBuilding = getBestOne(bonusBuilding, map[x - 1, y]);
                }

            }
            if (x < frameCount - 1)
            {
                if (map[x + 1, y].HasElement && map[x + 1, y].GetElementType().GetElementType() == buildingBonurType)
                {
                    bonusBuilding = getBestOne(bonusBuilding, map[x + 1, y]);
                }

            }

            element.BonusBuilding = bonusBuilding;
        }
开发者ID:FelixLeChat,项目名称:LordOfUltima,代码行数:93,代码来源:RessourcesBuildingCheck.cs

示例6: SpawnFields

        public void SpawnFields(Element element)
        {
            if (element == null || !element.HasElement || element.GetElementType() == null)
                return;

            Element[,] map = _gameboard.GetMap();
            int frameCount = _gameboard.GetFrameCount;
            int x = element.PositionX;
            int y = element.PositionY;

            if (y > 0)
            {
                if (x > 0)
                {
                    if (!map[x - 1, y - 1].HasElement)
                    {
                        buildFields((x - 1), (y - 1));
                    }
                }
                if (!map[x, y - 1].HasElement)
                {
                    buildFields(x, y - 1);
                }

                if (x < frameCount - 1)
                {
                    if (!map[x + 1, y - 1].HasElement)
                    {
                        buildFields(x + 1, y - 1);
                    }
                }

            }
            if (y < frameCount - 1)
            {
                if (x > 0)
                {
                    if (!map[x - 1, y + 1].HasElement)
                    {
                        buildFields(x - 1, y + 1);
                    }
                }

                if (!map[x, y + 1].HasElement)
                {
                    buildFields(x, y + 1);
                }

                if (x < frameCount - 1)
                {
                    if (!map[x + 1, y + 1].HasElement)
                    {
                        buildFields(x + 1, y + 1);
                    }
                }
            }

            if (x > 0)
            {
                if (!map[x - 1, y].HasElement)
                {
                    buildFields(x - 1, y);
                }
            }
            if (x < frameCount - 1)
            {
                if (!map[x + 1, y].HasElement)
                {
                    buildFields(x + 1, y);
                }
            }
        }
开发者ID:FelixLeChat,项目名称:LordOfUltima,代码行数:72,代码来源:RessourcesBuildingCheck.cs

示例7: AssignRessources

        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);
        }
开发者ID:FelixLeChat,项目名称:LordOfUltima,代码行数:57,代码来源:RessourcesManager.cs

示例8: UpdateElementTotalBonus

        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;
        }
开发者ID:FelixLeChat,项目名称:LordOfUltima,代码行数:59,代码来源:RessourcesManager.cs

示例9: MoveElementAtGridPos

	public bool MoveElementAtGridPos(Element newElem, int i, int j) {
		if (!grid.InGrid(i, j))
			return false;

		if (grid.Get(i, j) != null) {
			Element currentElem = grid.Get(i, j);
			switch (currentElem.GetElementType()) {
			case ElementType.Fire:
				switch (newElem.GetElementType()) {
				case ElementType.Water:
					Destroy(currentElem.gameObject);
					Destroy(newElem.gameObject);
					grid.Set(i, j, null);
					break;
				case ElementType.Stone:
					SetElementAtGridPos(newElem, i, j);
					break;
				case ElementType.Ice:
					Destroy(currentElem.gameObject);
					Destroy(newElem.gameObject);
					CreateElementAtGridPos(ElementType.Water, i, j);
					break;
				default : 
					Destroy(newElem.gameObject);
					break;
				}
				return true;
			case ElementType.Water:
				switch (newElem.GetElementType()) {
				case ElementType.Fire:
					Destroy(currentElem.gameObject);
					Destroy(newElem.gameObject);
					grid.Set(i, j, null);
					break;
				case ElementType.Water:
					Destroy(newElem.gameObject);
					break;
				case ElementType.Stone:
					SetElementAtGridPos(newElem, i, j);
					break;
				case ElementType.Plant:
					SetElementAtGridPos(newElem, i, j);
					break;
				case ElementType.Soul:
					Destroy(currentElem.gameObject);
					Destroy(newElem.gameObject);
					CreatePoolOfElement(ElementType.Ice, i, j, 3, true);
					break;
				}
				return true;
			case ElementType.Ice:
				switch (newElem.GetElementType()) {
				case ElementType.Fire:
					Destroy(currentElem.gameObject);
					Destroy(newElem.gameObject);
					CreateElementAtGridPos(ElementType.Water, i, j);
					break;
				case ElementType.Water:
					Destroy(newElem.gameObject);
					break;
				case ElementType.Stone:
					Destroy(currentElem.gameObject);
					break;
				case ElementType.Plant:
					Destroy(newElem.gameObject);
					break;
				case ElementType.Ice:
					Destroy(newElem.gameObject);
					break;
				}
				return true;
			case ElementType.Plant:
				switch (newElem.GetElementType()) {
				case ElementType.Water:
					Destroy(newElem.gameObject);
					return true;
				case ElementType.Fire:
					SetElementAtGridPos(newElem, i, j);
					return true;
				case ElementType.Stone:
					SetElementAtGridPos(newElem, i, j);
					return true;
				case ElementType.Plant:
					return false;
				case ElementType.Soul:
					Destroy(currentElem.gameObject);
					Destroy(newElem.gameObject);
					CreateElementAtGridPos(ElementType.Life, i, j);
					return true;
				}
				break;
			case ElementType.Stone:
				switch (newElem.GetElementType()) {
				case ElementType.Fire:
					Destroy(newElem.gameObject);
					return true;
				case ElementType.Water:
					Destroy(newElem.gameObject);
					return true;
				case ElementType.Stone:
//.........这里部分代码省略.........
开发者ID:Nunsense,项目名称:ElementDungeon,代码行数:101,代码来源:WorldManager.cs

示例10: assingStorage

        private void assingStorage(Element element)
        {
            if (element.GetElementType() != null)
            {
                ElementStorage elementStorage = element.GetElementType().GetElementStorage(element.Level);

                if (elementStorage != null)
                {
                    AddToStorage(elementStorage);
                }
            }
        }
开发者ID:FelixLeChat,项目名称:LordOfUltima,代码行数:12,代码来源:Storage.cs

示例11: resetElementNear

        private void resetElementNear(Element element)
        {
            if (element == null || !element.HasElement || element.GetElementType() == null)
                return;

            Element[,] map = Gameboard.Instance.GetMap();
            int frameCount = Gameboard.Instance.GetFrameCount;
            int x = element.PositionX;
            int y = element.PositionY;

            if (y > 0)
            {
                if (x > 0)
                {
                    if (!map[x - 1, y - 1].HasElement)
                    {
                        deleteElement((x - 1), (y - 1));
                    }
                }
                if (!map[x, y - 1].HasElement)
                {
                    deleteElement(x, y - 1);
                }

                if (x < frameCount - 1)
                {
                    if (!map[x + 1, y - 1].HasElement)
                    {
                        deleteElement(x + 1, y - 1);
                    }
                }

            }
            if (y < frameCount - 1)
            {
                if (x > 0)
                {
                    if (!map[x - 1, y + 1].HasElement)
                    {
                        deleteElement(x - 1, y + 1);
                    }
                }

                if (!map[x, y + 1].HasElement)
                {
                    deleteElement(x, y + 1);
                }

                if (x < frameCount - 1)
                {
                    if (!map[x + 1, y + 1].HasElement)
                    {
                        deleteElement(x + 1, y + 1);
                    }
                }
            }

            if (x > 0)
            {
                if (!map[x - 1, y].HasElement)
                {
                    deleteElement(x - 1, y);
                }
            }
            if (x < frameCount - 1)
            {
                if (!map[x + 1, y].HasElement)
                {
                    deleteElement(x + 1, y);
                }
            }
        }
开发者ID:FelixLeChat,项目名称:LordOfUltima,代码行数:72,代码来源:DeleteElement.cs


注:本文中的Element.GetElementType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。