本文整理汇总了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";
}
示例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;
}