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


C# Platform.Build方法代码示例

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


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

示例1: BuildTowerPointNBuild

    //called by any external component to build tower
    public static string BuildTowerPointNBuild(UnitTower tower, Vector3 pos, Platform platform)
    {
        //dont allow building of resource tower before game started
        if(tower.type==_TowerType.ResourceTower && GameControl.gameState==_GameState.Idle){
            //GameMessage.DisplayMessage("Cant Build Tower before spawn start");
            return "Cant Build Tower before spawn start";
        }

        bool matched=false;
        foreach(_TowerType type in platform.buildableType){
            if(tower.type==type){
                matched=true;
                break;
            }
        }
        if(!matched) return "Invalid Tower Type";

        //check if there are sufficient resource
        int[] cost=tower.GetCost();
        if(GameControl.HaveSufficientResource(cost)){
            GameControl.SpendResource(cost);

            GameObject towerObj=(GameObject)Instantiate(tower.thisObj, pos, platform.thisT.rotation);
            UnitTower towerCom=towerObj.GetComponent<UnitTower>();
            towerCom.InitTower(towerCount+=1);

            //register the tower to the platform
            if(platform!=null) platform.Build(pos, towerCom);

            if(tower.type!=_TowerType.Mine)
                currentBuildInfo.platform.Build(currentBuildInfo.position, tower);

            //clear the build info and indicator for build manager
            ClearBuildPoint();

            return "";
        }

        //GameMessage.DisplayMessage("Insufficient Resource");
        return "Insufficient Resource";
    }
开发者ID:wdj294,项目名称:tdtk,代码行数:42,代码来源:BuildManager.cs

示例2: BuildTowerPointNBuild

    //called by any external component to build tower
    public static UnitTower BuildTowerPointNBuild(UnitTower tower, Vector3 pos, Platform platform)
    {
        //dont allow building of resource tower before game started
        if(tower.type==_TowerType.ResourceTower && GameControl.gameState==_GameState.Idle){
            GameMessage.DisplayMessage("Cant Build Tower before spawn start");
            return null;
        }

        //check if there are sufficient resource
        int[] cost=tower.GetCost();
        if(GameControl.HaveSufficientResource(cost)){
            GameControl.SpendResource(cost);

            GameObject towerObj=(GameObject)Instantiate(tower.thisObj, pos, Quaternion.identity);
            UnitTower towerCom=towerObj.GetComponent<UnitTower>();
            towerCom.InitTower(towerCount+=1);

            //register the tower to the platform
            if(platform!=null) platform.Build(pos, towerCom);

            //clear the build info and indicator for build manager
            ClearBuildPoint();

            return towerCom;
        }

        GameMessage.DisplayMessage("Insufficient Resource");
        return null;
    }
开发者ID:inkgamestudios,项目名称:Prime_HDP,代码行数:30,代码来源:BuildManager.cs


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