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


C# Building.GetType方法代码示例

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


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

示例1: addBuilding

    // adds a building to the appropriate dictionary
    public void addBuilding(Tuple t, Building b)
    {
        if (b.GetType() == typeof(HeadQuarterBuilding)) {
            HeadQuarterBuilding head = (HeadQuarterBuilding) b ;
            hq = head;
            hqLocation.x = t.x;
            hqLocation.y = t.y;

        }
        else if (b.GetType() == typeof(DecorativeBuilding)) {
            DecorativeBuilding decBuilding = (DecorativeBuilding)b;
            decorativeBuildings.Add (t, decBuilding);

        } else if (b.GetType() == typeof(ResourceBuilding)) {
            ResourceBuilding resBuilding = (ResourceBuilding)b;
            resourceBuildings.Add (t, resBuilding);

        } else if (b.GetType() == typeof(ResidenceBuilding)) {
            ResidenceBuilding resBuilding = (ResidenceBuilding)b;
            residenceBuildings.Add (t, resBuilding);
        }
    }
开发者ID:,项目名称:,代码行数:23,代码来源:

示例2: SpawnBuilding

    private void SpawnBuilding(Building building)
    {
        GameObject prefab;
        if (building is HouseBuilding)
            prefab = houseBuildingPrefab;
        else if (building is VillaBuilding)
            prefab = villaBuildingPrefab;
        else if (building is ClubBuilding)
            prefab = clubBuildingPrefab;
        else if (building is KebabBuilding)
            prefab = kebabBuildingPrefab;
        else if (building is PoliceBuilding)
            prefab = policeBuildingPrefab;
        else
            throw new Exception("Not supporting building type " + building.GetType());

        GameObject buildingGameObject = SpawnObject(prefab, building.ToString(), building.tile.x, building.tile.z, buildingContainer);
        BuildingController buildingController = buildingGameObject.GetComponent<BuildingController>();
        buildingController.SetBuilding(building);
    }
开发者ID:bjorntore,项目名称:KebabOslo,代码行数:20,代码来源:WorldController.cs

示例3: setSelected

    public void setSelected(Building selectedB)
    {
        //If building is already selected, don't change selection
        if (selectedB != this.selectedB) {
            cancel (true);
            //The menus are already created but we need to activate them in order to use.
            //We do this by acsessing them in the beginning of the selection to hide

            //Activate the required panel

            //Update its prices time,queue and avaliablity accordingly according to type

            //Testing the barracks first
            if (selectedB.GetType ().ToString () == "Barracks"){
                panelIndex = 0;
                panels [panelIndex].SetActive (true);

                //Might be necesseary
                panels [panelIndex].transform.GetChild (6).GetComponent<Button>().interactable = true;
                panels [panelIndex].transform.GetChild (7).GetComponent<Button>().interactable = true;
                panels [panelIndex].transform.GetChild (2).GetComponent<Button>().interactable = true;

                //Arrange queue number
                panels [panelIndex].transform.GetChild (5).GetComponent<Text>().text = ((Barracks)selectedB).Soldiers.Count.ToString();

                //The progress will be arranged by barracks itself

                //Arrange armor,attack and upgrade options
                if(!((Barracks)selectedB).ArmorAval)
                    panels [panelIndex].transform.GetChild (6).GetComponent<Button>().interactable = false;
                if(!((Barracks)selectedB).AttackAval)
                    panels [panelIndex].transform.GetChild (7).GetComponent<Button>().interactable = false;
                if(!((Barracks)selectedB).UpgradeAval)
                    panels [panelIndex].transform.GetChild (2).GetComponent<Button>().interactable = false;

            }
            else if (selectedB.GetType ().ToString () == "Archery")
                panelIndex = 1;
            else if (selectedB.GetType ().ToString () == "ResearchBuilding")
                panelIndex = 2;
            else if (selectedB.GetType ().ToString () == "Tower")
                panelIndex = 3;
            //else if (selectedB.GetType ().ToString () == "QuestionBuilding")
            //	panelIndex = 5;
            panels [panelIndex].SetActive (true);

            this.selectedB = selectedB;
        }
    }
开发者ID:Rakosi,项目名称:CodeNConquer,代码行数:49,代码来源:SelectionManager.cs


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