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


C# Collider2D.GetComponentInParent方法代码示例

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

示例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 ();
        }
    }
开发者ID:ToraDota,项目名称:Time-Tilt,代码行数:33,代码来源:PlayerLance.cs

示例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);
            }
        }
    }
开发者ID:MichaelJames16,项目名称:TeamDark3710,代码行数:34,代码来源:LightFollow.cs

示例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);
 }
开发者ID:LGriggles,项目名称:Trout-Run,代码行数:30,代码来源:EnemyCreatorBullet.cs

示例5: OnTriggerEnter2D

	void OnTriggerEnter2D(Collider2D coll) {
		if (coll.GetComponentInParent<Umbrella>() != null) {
			Umbrella u = coll.GetComponentInParent<Umbrella>();
			u.CollideWithBird(this);
			toDestroy = true;
		}
	}
开发者ID:agaubatz,项目名称:ggj16,代码行数:7,代码来源:Bird.cs

示例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();
     }
 }
开发者ID:GREEDYHD,项目名称:Eggscapade,代码行数:8,代码来源:PlayerSpawner.cs

示例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;
			}
		}
开发者ID:karthikb351,项目名称:ggj2016-game,代码行数:10,代码来源:BallRespawner.cs

示例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");
        }
    }
开发者ID:ToraDota,项目名称:Time-Tilt,代码行数:10,代码来源:PlayerStomp.cs

示例9: OnTriggerExit2D

        void OnTriggerExit2D(Collider2D col)
        {
			if(col.GetComponent<SpriteObject>())
            {
                col.GetComponent<SpriteObject>().FellOffEdge();
            }
            else if (col.GetComponentInParent<SpriteObject>())
            {
                col.GetComponentInParent<SpriteObject>().FellOffEdge();
            }
        }
开发者ID:MercilessMinions,项目名称:Gamejam_Ritual,代码行数:11,代码来源:Field.cs

示例10: OnTriggerEnter2D

 void OnTriggerEnter2D(Collider2D collider)
 {
     if (isSpawned)
     {
         if (collider.GetComponentInParent<Movement>().GetTag() == "Player" && !collider.GetComponentInParent<Movement>().CheckEggs())
         {
             collider.GetComponentInParent<Movement>().AddEgg();
             DeSpawn();
         }
     }
 }
开发者ID:GREEDYHD,项目名称:Eggscapade,代码行数:11,代码来源:Egg.cs

示例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
        }
    }
开发者ID:Vylantze,项目名称:Chaos-Children,代码行数:14,代码来源:ModeChange.cs

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

示例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);
                }
            }
        }
	}
开发者ID:AlbearKamoo,项目名称:Witches-vs-Aliens-2015-2016,代码行数:14,代码来源:MeteorCrater.cs

示例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);
     }
 }
开发者ID:Kyte,项目名称:Phoenix-Clone,代码行数:14,代码来源:EnemyLife.cs

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


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