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


C# Collider.GetComponentInParent方法代码示例

本文整理汇总了C#中Collider.GetComponentInParent方法的典型用法代码示例。如果您正苦于以下问题:C# Collider.GetComponentInParent方法的具体用法?C# Collider.GetComponentInParent怎么用?C# Collider.GetComponentInParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Collider的用法示例。


在下文中一共展示了Collider.GetComponentInParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnTriggerStay

    //Check if you're intersecting something
    void OnTriggerStay(Collider other)
    {
        //Check if you're actually swinging - people just walking into weapons and dying would be bad
        if (charWepCtrl.GetIsSwinging()) {

            //Make sure it's not a child of yourself
            if (!other.transform.IsChildOf (transform)) {

                //Check if it's supposed to take damage
                if (other.tag.Equals ("AI")) {

                    //Check if it's in the list of stuff you've hit during this swing
                    //If it is, skip it
                    if (!hitTrans.Contains (other.transform)) {

                        //Add it to the list of things hit during this swing
                        hitTrans.Add(other.transform);
                        //Deal the damage
                        other.GetComponentInParent<CharacterHealthMana>().ModHealth (-1 * charWepCtrl.GetDamage ());
                        //Do knockback
                        Vector3 force = KNOCKBACK_OFFSET + other.transform.root.position - transform.root.position;
                        force.Normalize ();
                        force *= charWepCtrl.GetKnockback ();
                        other.GetComponentInParent<CharacterMove>().AddKnockback(force);
                    }
                }
            }
        }
    }
开发者ID:type1ninja,项目名称:Dwarfnarok,代码行数:30,代码来源:DamageDealer.cs

示例2: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if (taken)
            return;

        PlayerPickupHitbox hitbox = other.GetComponent<PlayerPickupHitbox>();

        if (hitbox != null && !hitbox.GetComponentInParent<ShipAttributesOnline>().IsDead && other.GetComponentInParent<CustomOnlinePlayer>() != owner)
        {
            if (repairPotential > 0f)
            {
                float rnd = Random.Range(0, 3);

                if (rnd == 0 || rnd == 1)
                {
                    other.GetComponentInParent<HullOnline>().Repair(repairPotential);
                    OnPickup(hitbox.GetComponentInParent<CustomOnlinePlayer>(), "Hull");
                }
                else
                {
                    other.GetComponentInParent<ShipAttributesOnline>().RepairAllSails(repairPotential);
                    OnPickup(hitbox.GetComponentInParent<CustomOnlinePlayer>(), "Sails");
                }
            }
            else
            {
                OnPickup(hitbox.GetComponentInParent<CustomOnlinePlayer>());
            }

            taken = true;
            NetworkServer.Destroy(this.gameObject);
        }
    }
开发者ID:alextalvan,项目名称:Ships2,代码行数:33,代码来源:Pickup.cs

示例3: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.name == "Shield")
     {
     }
     if (other.tag == "Damage")
     {
         switch (other.name)
         {
             case "Canon dmg":
                 transform.parent.GetComponent<enemyHealth>().playerHealth -= 20;
                 break;
             case "Mage dmg":
                 transform.parent.GetComponent<enemyHealth>().playerHealth -= 10;
                 break;
             case "Player dmg":
                 if (other.GetComponentInParent<Buffer>().buffed)
                     buff = 2;
                 transform.parent.GetComponent<enemyHealth>().playerHealth -= (20 * buff);
                 buff = 1;
                 break;
             case "Player dmg(Build)":
                 if (other.GetComponentInParent<attackPlayerCaster>().player.GetComponent<Buffer>().buffed)
                     buff = 2;
                 transform.parent.GetComponent<enemyHealth>().playerHealth -= (20 * buff);
                 buff = 1;
                 break;
             case "Frozen dmg":
                 transform.parent.GetComponent<enemyHealth>().playerHealth -= 3;
                 GetComponent<FollowPath>().buff = 0.5f;
                 break;
         }
     }
 }
开发者ID:ridsar,项目名称:FARY,代码行数:34,代码来源:shieldFade.cs

示例4: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if(other.tag == "enemyweapon" && other.GetComponentInParent<LizardAnimationSelector>().attacking){
         hp -= other.GetComponentInParent<LizardController>().damage;
         other.GetComponentInParent<LizardController>().fitness += 10;
     }
 }
开发者ID:rabbort,项目名称:AI-Project,代码行数:7,代码来源:PlayerController.cs

示例5: OnTriggerEnter

 void OnTriggerEnter(Collider col)
 {
     if (col.GetComponentInParent<CarController>())
     {
         col.GetComponentInParent<CarController>().Reposition();
     }
 }
开发者ID:GuillaumeLangis,项目名称:LOG4715,代码行数:7,代码来源:RepositionTrigger.cs

示例6: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if (other.tag != Tags.RideOn)
        {
            return;
        }

        if (other.GetComponentInParent<ColorBlock>() != null)
        {
            if (other.GetComponentInParent<ColorBlock>().isDisappearance)
            {
                // カラーブロックのisTriggerがtrueになったときに入るのでリストから削除
                hitList.RemoveAll((match) => match == other.gameObject);
                if (hitList.Count == 0 && switchState)
                {
                    SwitchOff();
                    switchState = false;
                }
                return;
            }
        }

        if (!switchState)
        {
            SwitchOn();
            switchState = true;
        }

        hitList.Add(other.gameObject);
    }
开发者ID:Kuvo,项目名称:Primary,代码行数:30,代码来源:Switch.cs

示例7: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     //Debug.Log("A");
     //Debug.Log(other.name);
     if (other.GetComponent<CharacterStats>())
     {
         //  Debug.Log("B");
         CharacterInTrigger = true;
         if (!Owner)
         {
             ///    Debug.Log("C");
             Owner = other.gameObject;
         }
     }//Debug.Log("END");
     if (other.GetComponentInParent<CharacterStats>())
     {
         // Debug.Log("E");
         CharacterInTrigger = true;
         if (!Owner)
         {
             //   Debug.Log("C");
             Owner = other.GetComponentInParent<CharacterStats>().gameObject;
         }
     }
 }/*
开发者ID:theawless,项目名称:Core-Attack,代码行数:25,代码来源:PickableItem.cs

示例8: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent<CharacterStats>())
     {
        // Debug.Log("1");
         if (other.GetComponent<CharacterStats>().Id != charStat.Id)
         {
         //    Debug.Log("2");
             if (!enAi.Enemies.Contains(other.gameObject))
             {
                 enAi.Enemies.Add(other.gameObject);
             }
         }
     }
     if (other.GetComponentInParent<CharacterStats>())
     {
        // Debug.Log("10");
         if (other.GetComponentInParent<CharacterStats>().Id != charStat.Id)
         {
         //    Debug.Log("20");
             if (!enAi.Enemies.Contains(other.GetComponentInParent<CharacterStats>().gameObject))
             {
                 enAi.Enemies.Add(other.GetComponentInParent<CharacterStats>().gameObject);
             }
         }
     }
 }
开发者ID:theawless,项目名称:Core-Attack,代码行数:27,代码来源:Sight.cs

示例9: OnTriggerStay

 void OnTriggerStay(Collider other)
 {
     //Get the players colliding with the trigger...
     if (other.GetComponentInParent<Actor>())
     {
         other.GetComponentInParent<Actor>().m_Statistics.CalculateHealth(gameObject, TriggerDamagePerSecond * Time.deltaTime);
     }
 }
开发者ID:WEASEL4994,项目名称:GameJam2016,代码行数:8,代码来源:DamageVolume.cs

示例10: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if (other.name.Equals("MagnetingSphere") && silverCoin)
        {
            this.GetComponent<Rigidbody>().velocity = (other.GetComponentInParent<Transform>().position - transform.position) * 40 * Time.deltaTime;

            float distance = (other.GetComponentInParent<Transform>().position - transform.position).magnitude;
            other.GetComponentInParent<MagnetController>().setStartingDistance(distance);
        }

        if (other.tag.Equals("Player") && !isCollected)
        {
            isCollected = true;

            if (bomb)
                other.GetComponent<BombController>().AddBomb(value);
            else if (shield)
                other.GetComponent<ShieldController>().ActiveShield(value);                      // get refenence to shield Controller and active player shield
            else if (star)
                GameMaster.instance.AddStars(value);                                             // increase player score and add star
            else if (bulletTime)
                GameMaster.instance.BulletTimeOn();                                              // change timeScale to achive bullettime effect
            else if (silverCoin)
                GameMaster.instance.IncreaseScore(1);
            else if (stamina)
                other.GetComponent<StaminaController>().IncreaseStamina(value);
            else if (magnet)
                other.GetComponent<MagnetController>().UseMagnet();
            else
            {
                PlayerController playerController = other.GetComponent<PlayerController>();          // Get reference to player controller

                if (recoveryPackage)
                    playerController.IncreaseHealth(value);
                else if (fuel)
                    playerController.Refuel(value);
                else if (ammo)
                    playerController.AddAmmo(value);
                else if (fireRate)
                    playerController.ChangeFireRate(value, activeTime);
                else if (speed)
                    playerController.ChangeSpeed(value, activeTime);
                else if (gun)                                                                        // if there is any gun attached
                {
                    playerController.ChangeWeapons(ref gun);                                         // change player weapon
                    playerController.AddAmmo(value);                                                 // add aditional ammo
                }
            }

            if (audioSource)                                                                     // if there is sound attacheds
                audioSource.Play();

            animator.SetTrigger(collected);

            StartCoroutine(DestroyAfterFinishAnimation());
        }
    }
开发者ID:darthachill,项目名称:SpaceShooter,代码行数:57,代码来源:PickUpsController.cs

示例11: OnTriggerStay

	void OnTriggerStay(Collider other)
	{
		if ((this.gameObject.tag.Equals("Player") && other.GetComponentInParent<Player>() == null)
		    || (this.gameObject.tag.Equals("Enemy") && other.GetComponentInParent<Enemy>() == null) || (this.gameObject.tag.Equals("EnemyScared") && other.GetComponentInParent<Enemy>() == null))
		{
			Vector3 distVec = (other.transform.position - transform.position);
			print("working");
		}
	}
开发者ID:keyward,项目名称:Zombie-Prototype,代码行数:9,代码来源:Avoid.cs

示例12: OnTriggerExit

 void OnTriggerExit(Collider other)
 {
     if (other.tag == "PlayerCollider")
     {
         if (other.GetComponentInParent<PlayerController>().currTile == parentTile)
         {
             other.GetComponentInParent<PlayerController>().currTile = null;
         }
     }
 }
开发者ID:icicle-tricycle,项目名称:NitrosIdea,代码行数:10,代码来源:TileTriggerCode.cs

示例13: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if ((this.gameObject.tag.Equals("Player") && other.GetComponentInParent<Player>() == null)
         || (this.gameObject.tag.Equals("Enemy") && other.GetComponentInParent<Enemy>() == null))
     {
         Vector3 distVec = (other.transform.position - transform.position);
         this.batwolf.Seek(distVec * -1, true);
         print("working");
     }
 }
开发者ID:Reckofm,项目名称:Zombie-Prototype,代码行数:10,代码来源:Avoid.cs

示例14: OnTriggerEnter

    //Call Caught command when player collides
    protected virtual void OnTriggerEnter(Collider collider)
    {
        if (collider.GetComponentInParent<Transform>().tag == "Player") {
            isTouch = true;
            colliderId = collider.GetComponentInParent<PlayerIdentity>();

            //Let's test this badboy out
            /*Application.LoadLevel (Application.loadedLevel);
            Debug.Log("Reloaded");*/
        }
    }
开发者ID:Adderbane,项目名称:OVWS-Scavenger-Hunt,代码行数:12,代码来源:ChaseTarget.cs

示例15: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.GetComponentInParent<HexTileInformation>() != null)
     {
         DestroySelf();
     }
     else if (other.GetComponentInParent<PlayerInformation>() != null)
     {
         other.GetComponentInParent<PlayerInformation>().CharacterState = CharacterState.Dead;
         DestroySelf();
     }
 }
开发者ID:MelonStudios,项目名称:bacongamejam2016,代码行数:12,代码来源:BulletBehaviour.cs


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