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


C# Collider.CompareTag方法代码示例

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


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

示例1: OnTriggerEnter

	    void OnTriggerEnter(Collider other) 
		{	
			if(!sequenceToPlay)
			{
				Debug.LogWarning("You have triggered a sequence in your scene, however, you didn't assign it a Sequence To Play", gameObject);
				return;
			}
			
			if(sequenceToPlay.IsPlaying)
				return;
			
			if(other.CompareTag("MainCamera") && isMainCameraTrigger)
			{
				sequenceToPlay.Play();
				return;
			}
			
			if(other.CompareTag("Player") && isPlayerTrigger)
			{
				sequenceToPlay.Play();
				return;
			}
			
			if(other.gameObject == triggerObject)
			{
				sequenceToPlay.Play();
				return;
			}
		}
开发者ID:totoro-j,项目名称:BallSpy,代码行数:29,代码来源:SequenceTrigger.cs

示例2: OnTriggerExit

 private void OnTriggerExit(Collider other)
 {
     if (other.CompareTag("Player") && this._hasPlayer)
     {
         this._hasPlayer = false;
         if (this._activeWarmth)
         {
             LocalPlayer.GameObject.SendMessage("LeaveHomeWarmth");
         }
     }
     if (other.CompareTag("FireTrigger") && this._activeWarmth)
     {
         Transform transform = base.GetComponentInParent<PrefabIdentifier>().transform;
         bool activeWarmth = this._activeWarmth;
         this._activeWarmth = false;
         int childCount = transform.childCount;
         for (int i = 0; i < childCount; i++)
         {
             Fire2 componentInChildren = transform.GetChild(i).GetComponentInChildren<Fire2>();
             if (componentInChildren && componentInChildren.Lit && base.GetComponent<Collider>().bounds.Contains(componentInChildren.transform.position))
             {
                 this._activeWarmth = true;
                 break;
             }
         }
         if (this._hasPlayer && activeWarmth != this._activeWarmth)
         {
             LocalPlayer.GameObject.SendMessage((!this._activeWarmth) ? "LeaveHomeWarmth" : "HomeWarmth");
         }
     }
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:31,代码来源:BuildingWarmthArea.cs

示例3: OnTriggerEnter

        // 「Trigger」のコライダー接触時に呼ばれるコールバック
        void OnTriggerEnter(Collider collider)
        {
            if (collider.CompareTag ("Enemy")) {
                animator.SetTrigger ("Dead");
                DoneGameController.Instance.state = DoneGameController.GameState.GameOver;
            }

            if (collider.CompareTag ("Goal")) {
                animator.SetTrigger ("Clear");
                DoneGameController.Instance.state = DoneGameController.GameState.GameClear;
            }
        }
开发者ID:tsubaki,项目名称:UnitychanEscape,代码行数:13,代码来源:DonePlayerController.cs

示例4: OnTriggerEnter

        //check if the character collects the powerups or the snags
        void OnTriggerEnter(Collider other)
        {
            Debug.Log (isGrounded);
            if(other.CompareTag("Powerup") && isGrounded)
            {
                control.PowerupCollected();
            }
            else if(other.CompareTag("Obstacle") && isGrounded)
            {
                control.AlcoholCollected();
            }

            Destroy(other.gameObject);
        }
开发者ID:2dev9,项目名称:RoadRunner,代码行数:15,代码来源:PlayerControl.cs

示例5: OnHit

        private void OnHit(Collider other)
		{
			if (!other.CompareTag(Tags.Monster))
			{
				if (other.CompareTag(Tags.Hero))
				{
					//TODO: Hero bullet attack
					battleProxy.DoAttackHero(AttackContext);
				}
				Script.SetState(BulletState.After);
				Script.CallbackUpdate = null;
			}
			
		}
开发者ID:sigmadruid,项目名称:NewMaze,代码行数:14,代码来源:Bullet.cs

示例6: OnTriggerExit

        void OnTriggerExit(Collider other)
        {
            if (other.CompareTag("Player1_") || other.CompareTag("Player2_") || other.CompareTag("Player3_") || other.CompareTag("Player4_"))
            {
                if (m_childStatic.isPlaying)
                {
                    m_childStatic.Stop();
                }

                if (m_childParticles.isPlaying)
                {
                    m_childParticles.Stop();
                }
            }
        }
开发者ID:patferguson,项目名称:Storms-Project,代码行数:15,代码来源:HealPointBehaviour.cs

示例7: OnTriggerEnter

        void OnTriggerEnter(Collider other)
        {

            if (other.CompareTag("Player"))
                return;

            if (Time.time < timer)
            {
                if (!targetsAlreadyTouched.Contains(other.gameObject.GetInstanceID()))
                {
                    IDamageable damageable = other.GetComponent(typeof(IDamageable)) as IDamageable;

                    if (damageable == null)
                    {
                        return;
                    }
                    targetsAlreadyTouched.Add(other.gameObject.GetInstanceID());
                    damageable.TakeDirectDamage(DoDamage());

                    //Target spreading.
                    if (damageable is AlienBase)
                    {
                        AlienBase alien = damageable as AlienBase;
                        alien.SetTarget(damageSource.transform);
                    }

                    if (damageable is CocoonSpawner)
                        (damageable as CocoonSpawner).TriggerSpawning(damageSource.transform);
                }
            }
        }
开发者ID:S4D3H,项目名称:ProjectJanitor,代码行数:31,代码来源:GrenadeExplosion.cs

示例8: OnTriggerEnter

 // OnTriggerEnter is called when the Collider other enters the trigger
 public void OnTriggerEnter(Collider other)
 {
     int objLayer = 1 << other.gameObject.layer;
     if (other.isTrigger && ignoreTriggers || other.CompareTag(playerTag) || (layersToFade & objLayer) != objLayer)
         return;
     // Retrieve all the renderers
     Renderer[] rendererWeHit = other.gameObject.GetComponentsInChildren<Renderer>();
     // Loop through the renderers
     for (int idx = 0; idx < rendererWeHit.Length; idx++)
     {
         if (rendererWeHit[idx] != null) // just to be on the safe side :)
         {
             // If we changed this already we skip it, otherwise we proceed with the change
             if (!modifiedShaders.ContainsKey(rendererWeHit[idx].GetInstanceID()))
             {
                 ShaderData shaderData = new ShaderData();
                 shaderData.renderer = rendererWeHit[idx];
                 shaderData.shader = new Shader[rendererWeHit[idx].materials.Length];
                 shaderData.color = new Color[rendererWeHit[idx].materials.Length];
                 for (int j = 0; j < rendererWeHit[idx].materials.Length; j++)
                 {
                     shaderData.shader[j] = rendererWeHit[idx].materials[j].shader;
                     if (rendererWeHit[idx].materials[j].HasProperty("_Color"))
                         shaderData.color[j] = rendererWeHit[idx].materials[j].color;
                     rendererWeHit[idx].materials[j].shader = transparentShader;
                     rendererWeHit[idx].materials[j].color = fadingColorToUse;
                 }
                 // Add the shader to the list of those that have been changed
                 modifiedShaders.Add(rendererWeHit[idx].GetInstanceID(), shaderData);
             }
         }
     }
 }
开发者ID:ninfea79,项目名称:ClassPrjUnit4-5,代码行数:34,代码来源:FadeObstructorsVolumetric.cs

示例9: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         GameController.NotifyPlayer("Don't forget to save, janitor !", Color.red, 3);
     }
 }
开发者ID:S4D3H,项目名称:ProjectJanitor,代码行数:7,代码来源:SaveNotificationToPlayer.cs

示例10: OnSceneObjectHit

 protected override void OnSceneObjectHit(Collider collider)
 {
     if(collider.CompareTag(Tags.GameObstacle))
     {
         OnCollisionEventStart(Tags.GameObstacleAway);
     }
 }
开发者ID:Ladano,项目名称:Runner,代码行数:7,代码来源:PlayerObstacleAway.cs

示例11: OnTriggerEnter

		public void OnTriggerEnter(Collider other) {
			if (other.CompareTag("Player")) {
				string savegame = PixelCrushers.DialogueSystem.PersistentDataManager.GetSaveData();
				Debug.Log ("Recording: " + savegame);
				Application.LoadLevel(newLevelName);
			}
		}
开发者ID:HaoYunSun,项目名称:TEMPORAIRE,代码行数:7,代码来源:ChangeLevelTrigger.cs

示例12: OnTriggerExit

 private void OnTriggerExit(Collider otherCollider) {
     // Making sure the object we have left is DynamicWater
     if (_water != null && otherCollider.CompareTag(FluidVolume.DynamicWaterTagName) &&
         otherCollider == _water.Collider) {
         _water = null;
     }
 }
开发者ID:cschladetsch,项目名称:UnityTemplate,代码行数:7,代码来源:WaterDetector.cs

示例13: OnTriggerExit

 void OnTriggerExit(Collider other)
 {
     if (String.IsNullOrEmpty(CollisionTag) || other.CompareTag(CollisionTag))
     {
         HandleGameEvent(EmitterGameEvent.TriggerExit);
     }
 }
开发者ID:mutatis,项目名称:WereWolfTheApocalipse,代码行数:7,代码来源:StudioEventEmitter.cs

示例14: OnTriggerEnter

 private void OnTriggerEnter(Collider col)
 {
     if (String.IsNullOrEmpty(CollisionTag) || col.CompareTag(CollisionTag))
     {
         _collisionCount++;
         this.enabled = true;
     }
 }
开发者ID:cupsster,项目名称:ExtremeBusiness,代码行数:8,代码来源:GlueEdgeOnFracture.cs

示例15: SetGrounded

        void SetGrounded(bool value, Collider other) {
            if (Character == null || other == null)
                return;

            if (other.CompareTag("Platform")) {
                Character.IsGrounded = value;   
            }
        }
开发者ID:juliosueiras,项目名称:GensoShojokosen,代码行数:8,代码来源:GroundCheck.cs


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