本文整理汇总了C#中Unit.GetComponentInParent方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.GetComponentInParent方法的具体用法?C# Unit.GetComponentInParent怎么用?C# Unit.GetComponentInParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.GetComponentInParent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Use
public override void Use(Unit self, Vector3 position)
{
var parentTcp = self.GetComponentInParent<TrolleyChargeProjectile>();
if (parentTcp)
{
self.switchOff = false;
self.transform.SetParent(parentTcp.oldParent);
self.GetComponent<NavMeshAgent>().enabled = true;
self.GetComponent<Collider>().enabled = true;
GameObject.Destroy(parentTcp.gameObject);
return;
}
self.switchOff = true;
var trolley = self.transform.Find("Babywka").Find("Trolley");
var trolleyChargeInst = GameObject.Instantiate(trolleyCharge).transform;
var projectile = trolleyChargeInst.GetComponent<TrolleyChargeProjectile>();
projectile.oldParent = self.transform.parent;
var selfPos = self.transform.position;
selfPos.y = 0;
position.y = 0;
self.transform.rotation = Quaternion.LookRotation(position - selfPos);
trolleyChargeInst.position = trolley.position;
trolleyChargeInst.rotation = trolley.rotation;
self.transform.SetParent(trolleyChargeInst);
self.GetComponent<NavMeshAgent>().enabled = false;
self.GetComponent<Collider>().enabled = false;
}
示例2: CheckForUpgrade
public void CheckForUpgrade (Unit unit, Village v)
{
home = v;
currentUnit = unit;
currentTile = currentUnit.GetComponentInParent<Tile>();
int target = (int)currentUnit.rank;
if (home.Gold >= 10 && currentUnit.rank != Unit.UnitRank.Knight)
Upgrade(target);
else
Debug.Log ("Cannot upgrade: not enough gold or already at max rank (knight).");
}
示例3: CheckForMerge
public void CheckForMerge (Unit unit1, Unit unit2, Village v)
{
home = v;
currentUnit = unit1;
currentTile = currentUnit.GetComponentInParent<Tile>();
targetUnit = unit2;
targetTile = targetUnit.GetComponentInParent<Tile>();
Debug.Log ("Current unit is: " + currentUnit + " and it's on tile " + currentTile);
Debug.Log ("Target unit is: " + targetUnit + " and it's on tile " + targetTile);
int result = (int)currentUnit.rank + (int)targetUnit.rank;
if (result <= (int)home.ThisRank + 1)
Merge (result);
else
Debug.Log ("Cannot merge because this village does not have the required rank.");
}
示例4: GetEvade
int GetEvade(Unit target)
{
Stats s = target.GetComponentInParent<Stats> ();
return Mathf.Clamp (s [StatTypes.EVD], 0, 100);
}