本文整理汇总了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;
}
}
示例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);
}
示例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);
}
}
示例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;
}
}
}
示例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;
}
}
}
示例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();
}
示例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());
}
}
示例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;
}
示例9: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.CompareTag ("Enemy") || other.CompareTag("Pigeon"))
{
Destroy (other.gameObject);
}
}
示例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);
}
示例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();
}
示例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);
}
}
}
示例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();
}
}
示例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));
}
}
示例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;
}
}