• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Collider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: OnTriggerEnter

	void OnTriggerEnter(Collider collision)
	{
		//如果碰到player
		if (collision.tag == "Player" && HitPlayer == false && Player)
		{
			Debug.Log("OnTriggerEnter");
			HitPlayer = true; //置为true,目的是为了一个障碍物只与player碰撞一次,
			
//			if (isRunWithPlayer == false) audio.PlayOneShot(HitSound); //如果不是依附性障碍物,则只播放一次音效,
//			else audio.Play(); //如果是依附性障碍物,则循环 播放音效,for example :碰到饮料瓶 ,持续播放吹风机短路的声音,
			
			Player.GetComponent<playerManager>().Speed *= SpeedChange; //改变player速度,
			Player.GetComponent<playerManager>().HitAnimation = PlayerHitAnimation; //设置player碰撞时的动画,
			Player.GetComponent<playerManager>().HitAnimationTime = PlayerHitAnimationTime; //设置player碰撞动画的时间,
			if(AffectSightOfPlayer)
				Player.GetComponent<playerManager>().AffectSightOfPlayer = AffectSightOfPlayer; //设置是否影响player视野,
			if(AffectDirectionOfPlayer)
				Player.GetComponent<playerManager>().AffectDirectionOfPlayer = AffectDirectionOfPlayer; //设置是否让palyer的方向混乱,

			
			if (isRunWithPlayer == true)
			{
				isStickingPlayer = true;
				transform.parent = Player.transform.parent; //让依附性障碍依附于plaer上,
			}
			
			if (AnimateObstacle == true)
			{
				transform.animation.Play(); //播放障碍物的动画,
			}
		}
	}
开发者ID:trananh1992,项目名称:ParkOurGame,代码行数:32,代码来源:Obstacle.cs


示例17: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         Application.LoadLevel(levelName);
     }
 }
开发者ID:DeepPhaseLabs,项目名称:PlantCellTour,代码行数:7,代码来源:LoadLevelOnTrigger.cs


示例18: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag(ColliderTag))
     {
         Hit(other);
     }
 }
开发者ID:StepanoidTeam,项目名称:RetroShooter,代码行数:7,代码来源:Destroyable.cs


示例19: OnTriggerEnter

	void OnTriggerEnter(Collider other){
		if(other.gameObject.CompareTag("Enemy")){
            other.gameObject.GetComponent<Health>().health -= 10;
			//Destroy (other.gameObject, 0.1f);
			Destroy (gameObject);
		}
	}
开发者ID:Flave229,项目名称:Jampire-Knights-Game-Jam-2016,代码行数:7,代码来源:ProjectileMover.cs


示例20: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Ball"))
     {
         npc.AI.Mind.AI.WorkingMemory.SetItem<bool>("stun", true);
     }
 }
开发者ID:TeamBuzzinga,项目名称:AlphaDemo,代码行数:7,代码来源:AudioNpcTakeDamage.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Collision类代码示例发布时间:2022-05-24
下一篇:
C# CollegeERPDBEntities类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap