本文整理汇总了C#中TDTK.UnitTower.GetRange方法的典型用法代码示例。如果您正苦于以下问题:C# UnitTower.GetRange方法的具体用法?C# UnitTower.GetRange怎么用?C# UnitTower.GetRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDTK.UnitTower
的用法示例。
在下文中一共展示了UnitTower.GetRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildTower
//called by any external component to build tower, uses buildInfo
public static string BuildTower(UnitTower tower)
{
if (buildInfo == null) return "Select a Build Point First";
UnitTower sampleTower = GetSampleTower(tower);
/***/
// check if there's energy reciving tower
if (tower.electricityNeeded && !tower.electricityReciever && !tower.electricityFacility)
{
LayerMask maskTarget = 1 << LayerManager.LayerTower();
Collider[] cols = Physics.OverlapSphere(buildInfo.position, 1000 /*GetRange()*/, maskTarget);
if (cols.Length > 0)
{
tower.electicitySources.Clear();
// find all electric facility
for (int i = 0; i < cols.Length; i++)
{
// if it's not electric reciever skip
if (!cols[i].gameObject.GetComponent<UnitTower>().electricityReciever)
continue;
//float test = cols[i].gameObject.GetComponent<UnitTower>().GetRange();
//float test2 = Vector3.Distance(cols[i].gameObject.GetComponent<UnitTower>().transform.position, buildInfo.position);
// if this tower is in range of electricityReciever
if (Vector3.Distance(cols[i].gameObject.GetComponent<UnitTower>().transform.position, buildInfo.position) <= cols[i].gameObject.GetComponent<UnitTower>().GetRange())
{
tower.electicitySources.Add(cols[i].gameObject.GetComponent<UnitTower>());
}
}
if (tower.electicitySources.Count == 0)
{
// set electricity source for tower weapon
return "There is not enough electricity";
}
}
else
return "There is not enough electricity";
}
/***/
//check if there are sufficient resource
List<int> cost = sampleTower.GetCost();
int suffCost = ResourceManager.HasSufficientResource(cost);
if (suffCost == -1)
{
ResourceManager.SpendResource(cost);
GameObject towerObj = (GameObject)Instantiate(tower.gameObject, buildInfo.position, buildInfo.platform.thisT.rotation);
UnitTower towerInstance = towerObj.GetComponent<UnitTower>();
towerInstance.InitTower(instance.towerCount += 1, buildInfo.platform);
towerInstance.Build();
// if new electricity reciver is placed search for all towers in it's range and add itself as electricity source
if (tower.electricityReciever)
{
LayerMask maskTarget = 1 << LayerManager.LayerTower();
Collider[] cols = Physics.OverlapSphere(buildInfo.position, tower.GetRange(), maskTarget);
if (cols.Length > 0)
{
UnitTower tmp_tow;
for (int i = 0; i < cols.Length; i++)
{
tmp_tow = cols[i].gameObject.GetComponent<UnitTower>();
if (tmp_tow.electricityReciever || tmp_tow.electricityFacility)
continue;
tmp_tow.electicitySources.Add(towerInstance);
}
}
}
//clear the build info and indicator for build manager
ClearBuildPoint();
return "";
}
return "Insufficient Resource";
}
示例2: _SelectTower
public void _SelectTower(UnitTower tower)
{
_ClearSelectedTower();
selectedTower=tower;
float range=tower.GetRange();
Transform indicatorT=rangeIndicator;
if(indicatorT!=null){
indicatorT.parent=tower.thisT;
indicatorT.position=tower.thisT.position;
indicatorT.localScale=new Vector3(2*range, 1, 2*range);
indicatorT.gameObject.SetActive(true);
}
}
示例3: _SelectTower
public void _SelectTower(UnitTower tower){
_ClearSelectedTower();
selectedTower=tower;
if(tower.type==_TowerType.Block || tower.type==_TowerType.Resource) return;
float range=tower.GetRange();
Transform indicatorT=!tower.directionalTargeting ? rangeIndicator : rangeIndicatorCone;
if(indicatorT!=null){
indicatorT.parent=tower.thisT;
indicatorT.position=tower.thisT.position;
indicatorT.localScale=new Vector3(2*range, 1, 2*range);
if(tower.directionalTargeting) indicatorT.localRotation=Quaternion.identity*Quaternion.Euler(0, tower.dirScanAngle, 0);
indicatorT.gameObject.SetActive(true);
}
}