本文整理汇总了C#中UnityEngine.Collider2D.GetComponentInParent方法的典型用法代码示例。如果您正苦于以下问题:C# Collider2D.GetComponentInParent方法的具体用法?C# Collider2D.GetComponentInParent怎么用?C# Collider2D.GetComponentInParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Collider2D
的用法示例。
在下文中一共展示了Collider2D.GetComponentInParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if (other.GetComponentInParent<PlayerController>())
{
other.GetComponentInParent<PlayerController>().respawnPoint = transform;
}
}
示例2: OnTriggerEnter2D
//public int bottomDamage;
void OnTriggerEnter2D(Collider2D other)
{
if(other.name == "EnemyBody"){
other.GetComponentInParent<EnemyHealthManager>().HurtEnemy(bodyDamage);//GetComponenetInParent grabs the actual enemy game object rather than the individual hit boxes
other.GetComponentInParent<EnemyHealthManager>().knockBackEnemySides(other, gameObject.transform);
//GetComponent<AudioSource>().Play ();
PlayerHealthManager.BouncePlayer(this.GetComponent<Collider2D>(), other.gameObject);
//Debug.Log("Enemy Body");
}
else if(other.name == "EnemyHead"){
other.GetComponentInParent<EnemyHealthManager>().HurtEnemy(headDamage);
other.GetComponentInParent<EnemyHealthManager>().knockBackEnemySides(other, gameObject.transform);
//GetComponent<AudioSource>().Play ();
PlayerHealthManager.BouncePlayer(this.GetComponent<Collider2D>(), other.gameObject);
//Debug.Log("Enemy Head");
}
// else if(other.name == "EnemyBottom"){
// other.GetComponentInParent<EnemyHealthManager>().HurtEnemy(bottomDamage);
// other.GetComponentInParent<EnemyHealthManager>().knockBackEnemySides(other, gameObject.transform);
// GetComponent<AudioSource>().Play ();
// //Debug.Log ("Enemy Bottom");
// }
else if(other.name == "EnemyLance"){
//bounce back happens here
other.GetComponentInParent<EnemyHealthManager>().knockBackEnemySides(other, gameObject.transform);
GetComponent<AudioSource>().Play ();
}
}
示例3: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D col)
{
if(col.tag == "LightDamaging")
{
lightDamage(1);
}
else if(col.tag == "Waterfall")
{
lightDamage(2);
}
else if(col.tag == "Lamp")
{
if(col.GetComponentInParent<LampCollision>().NotLit)
{
if(currentLight < 8)
{
currentLight += 1;
lightSource.intensity +=1f;
lightSource.range +=1f;
}
player.GetComponent<PlayerController>().PlayerDamage(-25);
}
col.GetComponentInParent<LampCollision>().lightUp();
}
else if(col.tag == "TrickDamaging")
{
if(currentLight > 3)
{
Destroy (col.gameObject);
}
}
}
示例4: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D collider)
{
if (collider.gameObject.layer == _enemyLayer)
{
if (_owner.myTeam == WeaponHolder.Team.ENEMY)
return;
Enemy enemy = collider.GetComponentInParent<Enemy>();
if (enemy != null)
{
_owner.weapon.ApplyKnockback(enemy.mover, rigidBody.velocity);
enemy.LoseHealth(_owner.weapon.strength);
ownerFiringSystem.DestroyObject(gameObject);
}
}
else if (collider.gameObject.layer == _sceneryLayer)
{
ownerFiringSystem.DestroyObject(gameObject);
}
else if (collider.gameObject.layer == _playerLayer)
{
PlayerController player = collider.GetComponentInParent<PlayerController>();
if (player != null)
{
_owner.weapon.ApplyKnockback(player.mover, rigidBody.velocity);
player.GetHit();
ownerFiringSystem.DestroyObject(gameObject);
}
}
//ownerFiringSystem.DestroyObject(gameObject);
}
示例5: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D coll) {
if (coll.GetComponentInParent<Umbrella>() != null) {
Umbrella u = coll.GetComponentInParent<Umbrella>();
u.CollideWithBird(this);
toDestroy = true;
}
}
示例6: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D collider)
{
if (spawnID == collider.GetComponentInParent<Movement>().GetID() && collider.GetComponentInParent<Movement>().GetEggs() != 0)//If player of correct ID collides with me and they're carrying eggs then bank their eggs
{
Debug.Log("Player" + collider.GetComponentInParent<Movement>().GetID() + " Banked " + collider.GetComponentInParent<Movement>().GetEggs() + " Eggs");
collider.GetComponentInParent<Movement>().BankEggs();
}
}
示例7: OnTriggerEnter2D
private void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Ball") {
other.transform.position = ballSpawn.position;
// Reset velocity
other.GetComponentInParent<Rigidbody2D> ().isKinematic = true;
other.GetComponentInParent<Rigidbody2D> ().isKinematic = false;
}
}
示例8: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if(other.name == "EnemyHead"){
other.GetComponentInParent<EnemyHealthManager>().HurtEnemy(1);
other.GetComponentInParent<EnemyHealthManager>().knockBackEnemySides(other, gameObject.transform);
PlayerHealthManager.BouncePlayer(this.GetComponent<Collider2D>(), other.gameObject);
//Debug.Log ("worked");
}
}
示例9: OnTriggerExit2D
void OnTriggerExit2D(Collider2D col)
{
if(col.GetComponent<SpriteObject>())
{
col.GetComponent<SpriteObject>().FellOffEdge();
}
else if (col.GetComponentInParent<SpriteObject>())
{
col.GetComponentInParent<SpriteObject>().FellOffEdge();
}
}
示例10: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D collider)
{
if (isSpawned)
{
if (collider.GetComponentInParent<Movement>().GetTag() == "Player" && !collider.GetComponentInParent<Movement>().CheckEggs())
{
collider.GetComponentInParent<Movement>().AddEgg();
DeSpawn();
}
}
}
示例11: OnTriggerEnter2D
// for interaction if it is an object
void OnTriggerEnter2D(Collider2D collider)
{
if (isObject&&collider.CompareTag ("Player")) {
master = collider.GetComponentInParent<MasterPlayer>();
master.elements[currentColour] = true;
collider.GetComponentInParent<ModeChange>().currentColour = currentColour;
// get the master player
// get the current colour this sphere is possessing
// set the element to true so that the player can access it
Destroy(transform.gameObject); // destroy this object after using it
}
}
示例12: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Enemy"){
other.GetComponentInParent<EnemyHealthManager>().HurtEnemy(thisBulletDamage);
other.GetComponentInParent<EnemyHealthManager>().knockBackEnemySides(other, playerPosition);
Destroy (gameObject);
}
if(other.tag == "TopWall"){
Destroy (gameObject);
}
}
示例13: OnTriggerEnter2D
// Update is called once per frame
void OnTriggerEnter2D (Collider2D other) {
if(other.CompareTag(Tags.player))
{
if (other.GetComponentInParent<Stats>().side != _side)
{
InputToAction otherController = other.GetComponentInParent<InputToAction>();
if (!modifiers.ContainsKey(otherController))
{
modifiers[otherController] = otherController.maxSpeedTracker.addModifier(speedNerf);
}
}
}
}
示例14: OnTriggerEnter2D
private void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player") {
if (doFriendlyFire) return;
if (!immuneToShipCollision) OnHit(false);
if (!doesntKill) other.GetComponentInParent<PlayerLife>().OnHit();
} else if (other.tag == "PlayerShield") {
OnHit(true);
other.transform.parent.GetComponentInChildren<PlayerShield>().OnHit();
} else if (doFriendlyFire && ((other.tag == "Enemy") || (other.tag == "EnemyAttachment"))) {
if (!immuneToShipCollision) OnHit(true);
other.GetComponentInParent<EnemyLife>().OnHit(true);
}
}
示例15: OnTriggerStay2D
void OnTriggerStay2D(Collider2D collider)
{
if (collider.tag == "Player" && isBombExploded)
{
collider.GetComponentInParent<Movement>().ReSpawn();
Destroy(gameObject);
Debug.Log("Player " + collider.tag + "hit by bomb");
}
if (collider.tag == "Egg" && isBombExploded)
{
collider.GetComponentInParent<Egg>().DeSpawn();
Destroy(gameObject);
Debug.Log("Player " + collider.tag + "hit by bomb");
}
}