本文整理汇总了C#中UnityEngine.Collider2D.GetComponentsInParent方法的典型用法代码示例。如果您正苦于以下问题:C# Collider2D.GetComponentsInParent方法的具体用法?C# Collider2D.GetComponentsInParent怎么用?C# Collider2D.GetComponentsInParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Collider2D
的用法示例。
在下文中一共展示了Collider2D.GetComponentsInParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ActionCheck
public override void ActionCheck(Collider2D c)
{
base.ActionCheck(c);
if (IsPreformingAction && AttackEffectTags.Contains(c.gameObject.tag) && AttactkCollider2D.enabled)
{
if (c.gameObject.tag == "Enemy")
{
//var enemies = c.GetComponentsInParent<Damagable>();
var enemies = c.GetComponents<Damagable>();
for (var i = 0; i < enemies.Count(); i++)
{
enemies[i].TakeDamage("Player", DamageAmt);
//todo: figure out the angle of approach and bounce enemy\player off when damaged
//c.GetComponentsInParent( )
////c.OverlapPoint()
//enemies[i].transform.Move();
}
}
if (c.gameObject.tag == "Player")
{
var player = c.GetComponentsInParent<Damagable>();
for (var i = 0; i < player.Count(); i++)
{
player[i].TakeDamage("Enemy", DamageAmt);
//todo: figure out the angle of approach and bounce enemy\player off when damaged
//c.GetComponentsInParent( )
////c.OverlapPoint()
//enemies[i].transform.Move();
}
}
}
}
示例2: ActionCheck
public override void ActionCheck(Collider2D c)
{
base.ActionCheck(c);
if (AttackEffectTags.Contains(c.gameObject.tag) && this.DamageAreaCollider2D.enabled)
{
if (AttackEffectTags.Contains(c.gameObject.tag))
{
var enemies = c.GetComponentsInParent<Damagable>();
for (int i = 0; i < enemies.Count(); i++)
{
enemies[i].TakeDamage("Obstacle", DamageAmt);
}
}
}
}
示例3: OnTriggerExit2D
void OnTriggerExit2D(Collider2D other)
{
if (other.tag == "PlayerObject" && opened) {
other.GetComponentsInParent<Score_Counter> ()[0].in_portal = false;
}
}