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


C# Collider.GetComponents方法代码示例

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


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

示例1: OnTriggerEnter

	void OnTriggerEnter (Collider other){

        if (other.gameObject.CompareTag("Bean"))
        {
            BonusEffects effects = other.gameObject.GetComponent<BonusEffects>();
            BonusFactorCarrier bonus = other.gameObject.GetComponent<BonusFactorCarrier>();
            if (effects != null)
            {
                if (HyperEffect)
                {
                    bonus.addMultiplierB();
                    effects.HyperEffect.SetActive(true);
                }
                else
                {
                    bonus.addMultiplierA();
                    effects.SuperEffect.SetActive(true);
                }

                AudioSource aus = other.GetComponents<AudioSource>()[0];
                if (aus)
                {
                    aus.Play();
                }
            }
        }
	}
开发者ID:polycular,项目名称:oekogotschi,代码行数:27,代码来源:WallTrigger.cs

示例2: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if(other.name == "Blobb")
     {
         controlScripts = other.GetComponents<Controls>();
         player = other.transform.root.gameObject;
     }
 }
开发者ID:NoDruid,项目名称:Zerblobbung,代码行数:8,代码来源:WaterBeiboot.cs

示例3: ApplyTo

    /// <summary>
    /// Apply damage to collider if it, or its rigidbody, has an IDamagable derived component.
    /// </summary>
    /// <param name="coll"></param>
    /// <param name="amount"></param>
    /// <param name="damageType"></param>
    /// <param name="inflictor"></param>
    public static void ApplyTo(Collider coll, int amount, DamageType damageType, GameObject inflictor)
    {
        IDamagable[] damagables = coll.GetComponents(typeof(IDamagable)).Cast<IDamagable>().ToArray();
        DamageData dm = new DamageData(amount, damageType, inflictor);
        Array.ForEach(damagables, damagable => damagable.TakeDamage(dm));

        // Also apply damage to rigidbody of this collider, but only if they're different gameobjects (otherwise we already did)
        if (coll.attachedRigidbody != null && coll.gameObject != coll.attachedRigidbody.gameObject)
        {
            IDamagable[] rigidBodyDamagables = coll.attachedRigidbody.GetComponents(typeof(IDamagable)).Cast<IDamagable>().ToArray();
            Array.ForEach(rigidBodyDamagables, damagable => damagable.TakeDamage(dm));
        }
    }
开发者ID:Clavus,项目名称:Tank,代码行数:20,代码来源:Damage.cs

示例4: OnTriggerEnter

 private void OnTriggerEnter(Collider other)
 {
     MonoBehaviour[] components = other.GetComponents<MonoBehaviour>();
     foreach (MonoBehaviour component in components)
     {
         ISplitable splitable = component as ISplitable;
         if (splitable != null)
         {
             SplitObject(splitable, other.gameObject);
             break;
         }
     }
 }
开发者ID:ZepLI,项目名称:U3D,代码行数:13,代码来源:Splitter.cs

示例5: OnTriggerExit

 /// <summary>
 /// Raises the trigger exit event.
 /// </summary>
 /// <param name="coll">Coll.</param>
 void OnTriggerExit(Collider coll)
 {
     if (coll.gameObject.tag == "player" && coll.gameObject.GetComponent<PlayerStats> ().teamNumber == 1 && this.gameObject.name == "BeaconNorth") {
         Collider[] allCols = coll.GetComponents<Collider> ();
         HashSet<Collider> hashies = new HashSet<Collider> (allCols);
         foreach (Collider col in hashies) {
             if (col.isTrigger && col.GetType () == typeof(CapsuleCollider)) {
                 teamOneCaptureList.Remove (col);
                 Debug.Log ("" + teamOneCaptureList.Count);
             }
         }
     }
     if (coll.gameObject.tag == "player" && coll.gameObject.GetComponent<PlayerStats> ().teamNumber == 2 && this.gameObject.name == "BeaconNorth") {
         Collider[] allCols = coll.GetComponents<Collider> ();
         HashSet<Collider> hashies = new HashSet<Collider> (allCols);
         foreach (Collider col in hashies) {
             if (col.isTrigger && col.GetType () == typeof(CapsuleCollider)) {
                 teamTwoCaptureList.Remove (col);
                 Debug.Log ("" + teamTwoCaptureList.Count);
             }
         }
     }
     if (coll.gameObject.tag == "player" && coll.gameObject.GetComponent<PlayerStats> ().teamNumber == 1 && this.gameObject.name == "BeaconSouth") {
         Collider[] allCols = coll.GetComponents<Collider> ();
         HashSet<Collider> hashies = new HashSet<Collider> (allCols);
         foreach (Collider col in hashies) {
             if (col.isTrigger && col.GetType () == typeof(CapsuleCollider)) {
                 teamOneCaptureList.Remove (col);
                 Debug.Log ("" + teamOneCaptureList.Count);
             }
         }
     }
     if (coll.gameObject.tag == "player" && coll.gameObject.GetComponent<PlayerStats> ().teamNumber == 2 && this.gameObject.name == "BeaconSouth") {
         Collider[] allCols = coll.GetComponents<Collider> ();
         HashSet<Collider> hashies = new HashSet<Collider> (allCols);
         foreach (Collider col in hashies) {
             if (col.isTrigger && col.GetType () == typeof(CapsuleCollider)) {
                 teamTwoCaptureList.Remove (col);
                 Debug.Log ("" + teamTwoCaptureList.Count);
             }
         }
     }
     if (coll.gameObject.tag == "player" && coll.gameObject.GetComponent<PlayerStats> ().teamNumber == 1 && this.gameObject.name == "BeaconWest") {
         Collider[] allCols = coll.GetComponents<Collider> ();
         HashSet<Collider> hashies = new HashSet<Collider> (allCols);
         foreach (Collider col in hashies) {
             if (col.isTrigger && col.GetType () == typeof(CapsuleCollider)) {
                 teamOneCaptureList.Remove (col);
                 Debug.Log ("" + teamOneCaptureList.Count);
             }
         }
     }
     if (coll.gameObject.tag == "player" && coll.gameObject.GetComponent<PlayerStats> ().teamNumber == 2 && this.gameObject.name == "BeaconWest") {
         Collider[] allCols = coll.GetComponents<Collider> ();
         HashSet<Collider> hashies = new HashSet<Collider> (allCols);
         foreach (Collider col in hashies) {
             if (col.isTrigger && col.GetType () == typeof(CapsuleCollider)) {
                 teamTwoCaptureList.Remove (col);
                 Debug.Log ("" + teamTwoCaptureList.Count);
             }
         }
     }
     if (coll.gameObject.tag == "player" && coll.gameObject.GetComponent<PlayerStats> ().teamNumber == 1 && this.gameObject.name == "BeaconEast") {
         Collider[] allCols = coll.GetComponents<Collider> ();
         HashSet<Collider> hashies = new HashSet<Collider> (allCols);
         foreach (Collider col in hashies) {
             if (col.isTrigger && col.GetType () == typeof(CapsuleCollider)) {
                 teamOneCaptureList.Remove (col);
                 Debug.Log ("" + teamOneCaptureList.Count);
             }
         }
     }
     if (coll.gameObject.tag == "player" && coll.gameObject.GetComponent<PlayerStats> ().teamNumber == 2 && this.gameObject.name == "BeaconEast") {
         Collider[] allCols = coll.GetComponents<Collider> ();
         HashSet<Collider> hashies = new HashSet<Collider> (allCols);
         foreach (Collider col in hashies) {
             if (col.isTrigger && col.GetType () == typeof(CapsuleCollider)) {
                 teamTwoCaptureList.Remove (col);
                 Debug.Log ("" + teamTwoCaptureList.Count);
             }
         }
     }
 }
开发者ID:PeWiNi,项目名称:gamedev15,代码行数:87,代码来源:BeaconCaptureScript.cs

示例6: OnTriggerStay

    void OnTriggerStay(Collider other)
    {
        if (grabbedObject != null)
        {
            return;
        }

        // hitListに何か含まれていればreturn。(拾えるもの優先)
        foreach (GraspItem listItem in hitList)
        {
            ColorObjectBase colorObject = listItem.GetComponent<ColorObjectBase>();
            if (colorObject != null)
            {
                if (!colorObject.isDisappearance)
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }

        // 目の前の物を調べる
        // 調べられるもの全てを配列として取得
        Component[] checkComponents = other.GetComponents(typeof(ICheckEvent));
        if (checkComponents == null)
        {
            return;
        }

        ExamineIconManager.HideIcon();
        if ((Input.GetKeyDown(KeyCode.E) || Input.GetMouseButtonDown(1)) && !player.isIrradiation)
        {
            foreach (ICheckEvent component in checkComponents)
            {
                component.Check();
            }
        }
    }
开发者ID:Kuvo,项目名称:Primary,代码行数:41,代码来源:Examine.cs


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