當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。