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


C# Collider类代码示例

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


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

示例1: OnTriggerEnter

    public void OnTriggerEnter(Collider other)
    {
        if(other.gameObject.tag == Tags.PLAYER)
        {
            PlayerMechanic player = other.gameObject.GetComponent<PlayerMechanic>();

            switch(playerState)
            {
                case PlayerState.ScaryDogMode:
                rigidbody.AddForce(xJumpForce * 2, yJumpForce, 0);
                death = true;
                AudioPlayer.Play(AudioPlayer.PLAYER_WOOF);
                break;

                case PlayerState.BoostMode:
                rigidbody.AddForce(xJumpForce * 2, yJumpForce, 0);
                death = true;
                AudioPlayer.Play(AudioPlayer.CAT_DAMAGED);
                break;

                case PlayerState.Normal:
                player.GameOver();
                break;

                case PlayerState.LaserMode:
                if(!zonzo)
                    player.GameOver();
                break;
            }
        }
    }
开发者ID:JulienLeal,项目名称:nave-1-jam-mil-gatos-pronomes,代码行数:31,代码来源:Cat.cs

示例2: OnTriggerExit

 void OnTriggerExit(Collider OtherCollider)
 {
     //StartCoroutine(MoveFromTo(Door1, Door1.position - new Vector3(0,0,2), moveTime));
     //StartCoroutine(MoveFromTo(Door2, Door2.position + new Vector3(0,0,2), moveTime));
     moving = true;
     open = false;
 }
开发者ID:Kharaz,项目名称:UnityStuff,代码行数:7,代码来源:DoorScript.cs

示例3: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if(other.tag == "Player")
     {
         Destroy(gameObject);
     }
 }
开发者ID:dimmondslice,项目名称:CAVE_DodgeGame,代码行数:7,代码来源:Bullet.cs

示例4: OnTriggerEnter

    public void OnTriggerEnter(Collider c)
    {
        var g = c.gameObject;
        if( g == null) return;

        if( g.CompareTag("Enemy") ) {
            var roman = g.GetComponent<RomanMovement>();
            var pickup = g.GetComponent<Pickup>();

            if( roman != null ) {
                var collision = RomanCollision(this, this.pickup_, roman, pickup) ||
                RomanCollision(roman, pickup, this, this.pickup_);
                if( collision ) {
                    this.audio_.PlayOneShot(this.SndCollision);
                }
            }
        }
        else if( g.CompareTag("Player") ) {
            if( this.pickup_.IsBeingThrown ) return;
            if( this.pickup_.IsPickedUp ) return;
            // Debug.Log ("Player died");
            this.audio_.PlayOneShot(this.SndPlayerDeath);
            Destroy(g);
        }
    }
开发者ID:madeso,项目名称:protect-my-circles,代码行数:25,代码来源:RomanMovement.cs

示例5: OnTriggerEnter

	void OnTriggerEnter(Collider other) 
	{
		
		if (other.gameObject.CompareTag ("box")) {
			moveGate = true;
		}
	}
开发者ID:jsngai,项目名称:deepsquid,代码行数:7,代码来源:KrakenSwitch.cs

示例6: Pegarse

 public override void Pegarse(Collider other)
 {
     SoundManager.soundManagerRef.audioCoger.Play();
     transform.forward = other.transform.position - transform.position;
     transform.parent = other.transform;
     //transform.localPosition = Vector3.zero;
 }
开发者ID:ConstantinoCallado,项目名称:GameJamUA-2015,代码行数:7,代码来源:Chincheta.cs

示例7: OnTriggerExit

 void OnTriggerExit(Collider other)
 {
     // If the player leaves the trigger zone...
     if (other.gameObject == player)
         // ... the player is not in sight.
         playerInSight = false;
 }
开发者ID:Defsv,项目名称:UJelly-ProtoType1,代码行数:7,代码来源:EnemySight.cs

示例8: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.name == "NecroHalo")
     {
         isBuffed = true;
     }
 }
开发者ID:ridsar,项目名称:FARY,代码行数:7,代码来源:NecroBuffRes.cs

示例9: OnTriggerExit

 void OnTriggerExit(Collider other)
 {
     if (other.name == "NecroHalo")
     {
         isBuffed = false;
     }
 }
开发者ID:ridsar,项目名称:FARY,代码行数:7,代码来源:NecroBuffRes.cs

示例10: OnTriggerEnter

	void OnTriggerEnter(Collider other)
	{
		if (tag == "" || other.gameObject.CompareTag(tag))
		{
			NextLevel();
		}
	}
开发者ID:hecki97,项目名称:2DPlatformer-2.0,代码行数:7,代码来源:NextLevelCollider.cs

示例11: OnTriggerEnter

 void OnTriggerEnter(Collider c)
 {
     if (c.tag == "Ground") {
         // Set rigidbody of shells to sleep when they touch the ground, so the shells will stop wobbling around at eat the performance.
         GetComponent<Rigidbody>().Sleep();
     }
 }
开发者ID:Jellezilla,项目名称:IsometricSpace,代码行数:7,代码来源:Shell(old).cs

示例12: OnTriggerEnter

    void OnTriggerEnter(Collider objC)
    {
        switch (ZoneType)
        {
            case ZoneType.DeathZone:

                if (objC.CompareTag("Sphere"))
                {
                    objC.transform.parent.GetComponent<Sphere>().YouDeadBro();
                }
                else if (string.Equals(objC.gameObject.name, "ZoneCollider"))
                {
                    objC.transform.parent.gameObject.GetComponent<Box>().YouDeadBro();
                    ZoneType = ZoneType.Walkable;
                }
                break;

            case ZoneType.Walkable:

                break;

            default:
                throw new ArgumentOutOfRangeException();
        }
    }
开发者ID:FeedFestival,项目名称:VisualHack,代码行数:25,代码来源:Zone.cs

示例13: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if(other.tag == "Player")
     {
         StartCoroutine(FadeOnTp(other.gameObject, GameObject.Find("Main Camera")));
     }
 }
开发者ID:MrMesk,项目名称:OnAir,代码行数:7,代码来源:GoToBoss.cs

示例14: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("PickUp")) {
         other.gameObject.SetActive(false);
         setCount(count += 1);
     }
 }
开发者ID:Jonicon,项目名称:Unity,代码行数:7,代码来源:PlayerController.cs

示例15: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if (damagingTags.IndexOf (other.tag) >= 0) {
            addHitPoints (-other.gameObject.GetComponent<Damaging> ().damage);

            if (explosion) {
                Instantiate (explosion, transform.position + new Vector3 (0, 0, 1), transform.rotation);
            }

            if (sound) {
                AudioSource.PlayClipAtPoint (sound, transform.position);
            }

            if (hitPoints.Value <= 0) {
                BroadcastMessage ("DoKill", null, SendMessageOptions.DontRequireReceiver);
            }

            if (damageIndicator) {
                Color cl = damageIndicator.color;
                damageIndicator.color = new Color (cl.r, cl.g, cl.b, 1.0f);
            }
        } else if (pickupTags.IndexOf (other.tag) >= 0) {
        //			other.GetComponent<PickUp> ().apply (this);
            Debug.Log ("PickUp: " + other.tag);
        }
    }
开发者ID:Im0rtality,项目名称:space-invaders-2k,代码行数:26,代码来源:Player.cs


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