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


C# Unit.GetComponentInParent方法代码示例

本文整理汇总了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;
    }
开发者ID:Awpteamoose,项目名称:Batya-RTS,代码行数:32,代码来源:TrolleyCharge.cs

示例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).");
	}
开发者ID:EmilioF,项目名称:UnityProjects,代码行数:13,代码来源:UpgradeUnit.cs

示例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.");
	}
开发者ID:EmilioF,项目名称:UnityProjects,代码行数:20,代码来源:MergeUnits.cs

示例4: GetEvade

 int GetEvade(Unit target)
 {
     Stats s = target.GetComponentInParent<Stats> ();
     return Mathf.Clamp (s [StatTypes.EVD], 0, 100);
 }
开发者ID:arthurwoo,项目名称:TaticsHero,代码行数:5,代码来源:ATypeHitRate.cs


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