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


C# Collider.CompareTag方法代码示例

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


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

示例1: OnTriggerStay

	void OnTriggerStay(Collider other)
	{
		if ((other.CompareTag("Monster") || other.CompareTag("Hero") || other.CompareTag("Boss")) && !other.isTrigger)
		{
			insideThisFrame = true;
		}
	}
开发者ID:stevesolomon,项目名称:MicroDungeonPrototype,代码行数:7,代码来源:SpawnCollider.cs

示例2: OnTriggerEnter

	void OnTriggerEnter(Collider other)
	{
		if(other.CompareTag("Boundary") || other.CompareTag("Enemy") || other.CompareTag("PowerUp"))
		{
			return;
		}
		if(!other.CompareTag("Shield"))
		{
			Destroy(other.gameObject);
		}


		if(Random.Range(0,100) < powerUpDropRate)
		{
			if(powerUps.Length > 0)
			{
				Instantiate(powerUps[Random.Range(0,powerUps.Length)], transform.position, Quaternion.identity);
			}
		}
		Destroy(gameObject);

		if(explosion != null)
		{
			Instantiate(explosion, transform.position, transform.rotation);
		}

		if(other.CompareTag("Player"))
		{
			Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
			gameController.GameOver();
			return;
		}

		gameController.AddScore(scoreValue);
	}
开发者ID:humberto-trujillo,项目名称:GitUnityGames,代码行数:35,代码来源:DestroyByContact.cs

示例3: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player") && isHealthPowerUp)
        {
            player.health++;

            if (player.health > player.maxHealth)
            {
                player.health = player.maxHealth;
            }

        }
        if (other.CompareTag("Player") && isRapidFire)
        {
            player.hasRapidFire = true;
        }
        if (other.CompareTag("Player") && isInfiniteRun)
        {
            player.hasInfiniteRun = true;
        }
        if (other.CompareTag("Player"))
        {
            Destroy(gameObject);
        }
    }
开发者ID:matbecker,项目名称:FirstAssignment,代码行数:25,代码来源:PowerUps.cs

示例4: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if(!active_My)
        {
            if(other.CompareTag("PlacementPlane_Taken"))
            {
                GameInterface gi = (GameInterface)mainCamera.GetComponent("GameInterface");
                gi.canCreate = false;
                a1 = true;
            }
            if(other.CompareTag("PlacementPlane_Open"))
            {
                GameInterface gi = (GameInterface)mainCamera.GetComponent("GameInterface");
                gi.canCreate = true;
                a1 = false;
            }

            if(other.CompareTag("Active"))
            {
                //print("Нельзя сотворить здесь!");
                GameInterface gi = (GameInterface)mainCamera.GetComponent("GameInterface");
                gi.canCreate = false;
                a1 = true;
            }

            if(other.CompareTag("PlacementPlane_Taken"))
            {
                GameInterface gi = (GameInterface)mainCamera.GetComponent("GameInterface");
                gi.canCreate = false;
                a1 = true;
            }
        }
    }
开发者ID:TheSinSay,项目名称:Tanks,代码行数:33,代码来源:Build.cs

示例5: OnTriggerEnter

	void OnTriggerEnter(Collider col)
	{
		Debug.Log ("WOMP");
		if (col.CompareTag ("Jump")) {
			Debug.Log("shitass");
			if(!floating){
						if (Random.value <= chanceToJump) {
								Velocity.y = jumpSpeed;
								floating = true;
						} else
					Velocity.x *= -1;}
				} else if (col.CompareTag ("Bullet")) {
						GameObject bgo = col.gameObject;
						Bullet bill = bgo.GetComponent<Bullet> ();
						if (bill.IsPlayer ()) {
								Destroy (this.gameObject);
				Destroy(bgo);
						}
				} else if (!col.CompareTag ("Villan")) {
			if(floating)
			{
				floating=false;
				Velocity.y=0;
			}
				}
	}
开发者ID:danyaal,项目名称:Contra,代码行数:26,代码来源:Runner.cs

示例6: OnTriggerEnter

    public void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag(Tags.BOUNDARY) == true)
        {
            return;
        }
        if (other.CompareTag(Tags.ENEMY) == true)
        {
            return;
        }

        Debug.Log(string.Format("{0} destroyed by collision with {1}", this.name, other.name));
        if (Explosion != null)
        {
            Instantiate(Explosion, transform.position, transform.rotation);
        }

        Destroy(other.gameObject);
        Destroy(gameObject);

        if (other.CompareTag(Tags.PLAYER) == false)
        {
            //gameManager.AddPointsToScore(pointsValue);
            return;
        }

        Instantiate(PlayerExplosion, other.transform.position, other.transform.rotation);
        gameManager.GameOver();
    }
开发者ID:Blkx-Darkreaper,项目名称:Unity,代码行数:29,代码来源:_DestroyOnContact.cs

示例7: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if(triggerActivated)
            return;

        if (other.CompareTag("Player"))
            _playerCrossed = true;
        else if(other.CompareTag("Moe"))
            _moeCrossed = true;


        


        if (_playerCrossed && _moeCrossed || _playerCrossed && onlyNeedLarry || _moeCrossed && onlyNeedMoe)
        {
            triggerActivated = true;
            _enemyManager.gameObject.SetActive(true);

            Invoke("SpawnEnemies", .5f);

            if (needsToRaiseBarriers)
                StartCoroutine(RaiseBarriers()); 
        }
    }
开发者ID:keyward,项目名称:EnemyOfMyEnemy,代码行数:25,代码来源:LevelTrigger.cs

示例8: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Goal")) {
            other.gameObject.GetComponent<GoalController>().IncrimentScore();
            GameController.Instance.GoalScored();

            Destroy(this.gameObject);
            Instance = null;
        }
        else if (other.CompareTag("Wall"))
            udDirection *= -1;
        else if (other.CompareTag("Player")) {
            bumpCount++;
            if (bumpCount == BumpFrequency) {
                bumpCount = 0;
                currentSpeed *= SpeedBump;
                GameController.Instance.DisplayToast("SPEED UP!");
            }

            var angle = (transform.position - other.transform.position) / other.bounds.size.y;
            udDirection = angle.y;

            lrDirection *= -1;
        }

        rigidBody.velocity = new Vector2(lrDirection, udDirection) * currentSpeed;
    }
开发者ID:nadrees,项目名称:Pong,代码行数:27,代码来源:BallController.cs

示例9: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag ("Enemy") || other.CompareTag("Pigeon"))
     {
         Destroy (other.gameObject);
     }
 }
开发者ID:Felina-Lain,项目名称:Russian-Dogs,代码行数:7,代码来源:Killzone.cs

示例10: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Boundary") || other.CompareTag("Enemy") || other.CompareTag("Powerup1") || other.CompareTag("Powerup2"))
        {
            return;
        }

        if (explosion != null)
        {
        //			Debug.Log ("explosion: " + explosion.gameObject.name);
            Instantiate(explosion, transform.position, transform.rotation);
        }

        //		Debug.Log ("scoreValue: " + scoreValue);
        gameController.AddScore(scoreValue);

        if (other.CompareTag("Player"))
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
        }

        if (gameObject.name.StartsWith("Enemy Ship"))
        {
            gameController.OnEnemyKilled();
        }
        else if (gameObject.name.StartsWith ("Asteroid"))
        {
            gameController.OnAsteroidDestroyed();
        }

        Destroy (other.gameObject);
        Destroy (gameObject);
    }
开发者ID:christyharagan,项目名称:ml-demojam-gamelogic,代码行数:34,代码来源:DestroyByContact.cs

示例11: OnTriggerExit

 public void OnTriggerExit(Collider other)
 {
     Destroy(other.gameObject);
     if (other.CompareTag("Bolt") || other.CompareTag("EnemyBolt")) return;
     _passCounter = _passCounter == 0 ? 0:_passCounter-1;
     UpdatePassCount();
 }
开发者ID:goost,项目名称:UnityPlayground,代码行数:7,代码来源:DestroyByBoundary.cs

示例12: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("MoveAI"))
        {
            MoveAI moveAI = other.gameObject.GetComponent<MoveAI>();

            if (moveAI != null)
            {
                moveAI.KillSelf();
            }
        }

        if (other.CompareTag("WalkPart"))
        {
            WalkAI walkAI = other.gameObject.GetComponentInParent<WalkAI>();

            if (walkAI != null)
            {
                walkAI.Failed();
            }
        }

        if (other.CompareTag("Scan"))
        {
            SpawnerScaner spawnerScaner = other.gameObject.GetComponent<SpawnerScaner>();
            if(spawnerScaner != null)
            {
                spawnerScaner.SetDir(dir);
            }
        }
    }
开发者ID:CallumCode,项目名称:GeneticAlgorithmGame,代码行数:31,代码来源:Boundary.cs

示例13: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Bullet") || other.CompareTag("Bullet2")) // hit by a bullet
        {
            TakeDamage(1); // take away 1 hit point

            // disable the bullet and put it back on its stack
            other.gameObject.SetActive(false);
            if (other.CompareTag("Bullet"))
                GameMaster.playerBulletStack.Push(other.gameObject);
            else
                GameMaster.playerBulletStack2.Push(other.gameObject);
        }
        //		if( hitPoints < nextPhase[1] && phaseCount == 1 ){
        //			++phaseCount;
        //			SetNewPath();
        //			SetEnemyPath( nodes, easeType, loopType );
        //		}
        //		else if( hitPoints < nextPhase[0] && phaseCount == 0 ){
        //			++phaseCount;
        //			SetNewPath();
        //			SetEnemyPath( nodes, easeType, loopType );
        //		}
        if( hitPoints < nextPhase[0] && phaseCount == 0 ){
            ++phaseCount;
            PhaseStart();
        }
    }
开发者ID:WorldStrongest,项目名称:ProjectCatBallZ,代码行数:28,代码来源:Boss.cs

示例14: OnTriggerEnter

    /// <summary>
    ///  Method that is called when the bomb collides with another object
    /// </summary>
    /// <param name="other">The collider object that hit the player</param>
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Bomb")) {
            return; //if we collide with a cannonball, ignore it
        }

        if (other.CompareTag("Ship") && OnBallReturning) {
            other.GetComponent<Ship>().OnShipHit(this);
            Destroy(this.gameObject); //remove cannonball
            return;
        }

        if (other.CompareTag("Player")) {
            other.GetComponent<Player>().OnPlayerHit(this);
            Destroy(this.gameObject); //remove cannonball
            return;
        }

        if (other.CompareTag("Tablet")) {
            OnBallReturning = true;

            Vector3 midPoint = (transform.position + source) / 2f;
            midPoint.y += Ship.CannonArcHeight;

            //send back to source
            iTween.MoveTo (this.gameObject, iTween.Hash ("position", source, "easeType", "spring", "speed", Ship.CannonFireSpeed, "path", new Vector3[] {
                transform.position,
                midPoint,
                source
            }, "oncomplete", "OnBombMissed", "oncompletetarget", gameObject));

        }
    }
开发者ID:vmohan7,项目名称:NaviPirateDemo,代码行数:37,代码来源:Cannonball.cs

示例15: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("ammodrop"))
        {
          GameObject.Find("Player").GetComponent<SendingPositiveVibes>().lowVibration++;
          audio.PlayOneShot(ammoPickUpSound);
          ammoFX(other.gameObject.transform.position);
          GameObject.Find("spawnPoint").GetComponent<Shoot>().ammo += 10;
          GameObject.Find("Score").GetComponent<ShowScoreValue>().score2 += 2;
          Destroy(other.gameObject);
        }

        if (other.CompareTag("dashPick"))
        {
          GameObject.Find("Player").GetComponent<SendingPositiveVibes>().lowVibration++;
          audio.PlayOneShot(dashPickUpSound);
          dashFX(other.gameObject.transform.position);
          GameObject.Find("Player").GetComponent<TP_Motor>().dashBar += 30;
          GameObject.Find("Player").GetComponent<TP_Motor>().numOfJumps += 2;
          Destroy(other.gameObject);
        }

        if (other.CompareTag("goo"))
        {
          Debug.Log("wtf");
          GameObject.Find("Player").GetComponent<TP_Motor>().playerHealth -= 1;
        }
    }
开发者ID:9,项目名称:myunityGame-1,代码行数:28,代码来源:PickupCollisions.cs


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