本文整理汇总了C#中UnityEngine.GameObject.CompareTag方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.CompareTag方法的具体用法?C# GameObject.CompareTag怎么用?C# GameObject.CompareTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.GameObject
的用法示例。
在下文中一共展示了GameObject.CompareTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeTarget
// changes the target and sets insect color
void ChangeTarget(GameObject target)
{
// clear old target and set new one
if(targetPlant.CompareTag("plant")) {
targetPlant.GetComponent<CirclePlantPrefabScript>().IsTargeted = false;
}
if(target != targetPlant)
Comment ("New target: {0}", target);
targetPlant = target;
// then colorize insect based on target
// white=null, green=plant, yellow=tree+full, orange=tree+unfull, red=tree+empty
if(targetPlant == null) {
renderer.material.color = Color.white;
}
else if(targetPlant.CompareTag("plant")) {
renderer.material.color = Color.green;
targetPlant.GetComponent<CirclePlantPrefabScript>().IsTargeted = true;
}
else if(targetPlant.CompareTag("tree")) {
if(pollen > 0) {
renderer.material.color = pollen < pollenCapacity ? Color.Lerp(Color.red, Color.yellow, 0.5f) : Color.yellow;
}
else renderer.material.color = Color.red;
}
}
示例2: PossessPlayer
public void PossessPlayer(GameObject player)
{
if (state == CameraState.FREE_FLOW)
{
if (player.CompareTag("Salesman"))
{
character = CharacterClass.SALESMAN;
}
else if (player.CompareTag("Shopper"))
{
character = CharacterClass.SHOPPER;
}
else if (player.CompareTag("Guard"))
{
character = CharacterClass.GUARD;
}
else if (player.CompareTag("Thief"))
{
character = CharacterClass.THIEF;
}
else return;
PossessionScript ps = player.GetComponent<PossessionScript>();
ps.Possess();
possessedCharacter = player;
attachedRotation = player.transform.rotation;
attachedLocation = player.transform.position + attachedRotation * new Vector3(0, 1.85f, -2);
freeFlyLocation = transform.position;
freeFlyRotation = transform.rotation;
state = CameraState.ATTACHING;
tick = 0;
}
}
示例3: removeBuild
public void removeBuild(GameObject obj, bool bank)
{
Debug.Log("Removed" + obj.name);
if (bank)
{
banks.Remove(obj);
}
else if (obj.CompareTag("RoadBlock"))
{
targetCount.GetComponent<TargetMover>().roadBlockCounter -= 1;
//monster.GetComponent<Attack_Building>().inAction = false;
buildings.Remove(obj);
//Debug.Log("Entered");
}
else if(obj.CompareTag("PileOFish"))
{
targetCount.GetComponent<TargetMover>().PileOFishCounter -= 1;
//monster.GetComponent<Attack_Building>().inAction = false;
buildings.Remove(obj);
}
else
{
buildings.Remove(obj);
}
}
示例4: OnParticleCollision
void OnParticleCollision(GameObject other)
{
print("burn!!!!");
if (other.CompareTag("Torch"))
{
ParticleSystem fire = other.GetComponentInChildren<ParticleSystem>();
fire.Play();
}
if (other.CompareTag("Rubble"))
{
Debug.Log("boom");
Rigidbody[] pieces = other.gameObject.GetComponentsInChildren<Rigidbody>();
foreach (Rigidbody piece in pieces)
{
piece.isKinematic = false;
piece.AddExplosionForce(500, other.gameObject.transform.position, 5);
}
BoxCollider goocollider = other.GetComponent<BoxCollider>();
goocollider.enabled = false;
ParticleSystem bakahatsu = other.GetComponentInChildren<ParticleSystem>();
bakahatsu.Play();
GameObject goo = other.transform.FindChild("Goo").gameObject;
Destroy(goo);
}
}
示例5: IsBorderOrGroundHit
private bool IsBorderOrGroundHit(GameObject collidedObject)
{
if (collidedObject.CompareTag("Ground") || collidedObject.CompareTag("Border")) {
DestroyObject(gameObject);
return true;
}
return false;
}
示例6: HitBrick
public static void HitBrick(GameObject brick)
{
if (brick.CompareTag ("Breakable")) {
BrickController bc = brick.GetComponent<BrickController>();
bc.handleHits();
}
}
示例7: StartSpeech
public void StartSpeech(GameObject initiator)
{
if (showingText)
{
return;
}
if (randomizeTexts)
{
textIndex = Random.Range(0, texts.Length - 1);
}
if (initiator.CompareTag(playerTag))
{
playerControl = initiator.GetComponent<PlayerControl>();
playerControl.freezeInput = true;
speech.SetActive(true);
showingText = true;
skipUpdate = true;
textAdvancer = initiator.GetComponent<TextAdvancer>();
DrawText();
}
}
示例8: StopContactBottom
public void StopContactBottom(GameObject other)
{
if (other.CompareTag("Platform") && contactingPlatforms.Contains(other))
{
contactingPlatforms.Remove(other);
}
}
示例9: ignoreCheck
bool ignoreCheck(GameObject obj)
{
foreach (string tag in m_IgnoreTags)
if (obj.CompareTag(tag))
return true;
return false;
}
示例10: CanHitTarget
/**
* Check to see if their is los to marines target
**/
public bool CanHitTarget(GameObject marineShooter, GameObject target)
{
// exit if marine isn't shooting an alien
if(marineShooter == null || !target.CompareTag("Alien"))
return false;
// exit if the alien is already dead
if(target.GetComponent<AlienData>().unitStatus == AlienData.UnitStatus.DEAD)
return false;
RaycastHit hit;
Vector3 targetVector = target.transform.position;
targetVector.y = marineShooter.transform.position.y;
Vector3 rayDirection = targetVector - marineShooter.transform.position;
_debug_source_trans = marineShooter.transform;
_debug_target = rayDirection;
if (Physics.Raycast (marineShooter.transform.position, rayDirection, out hit)) {
if (hit.transform.gameObject.CompareTag("Alien")) {
Debug.Log("i see my target!");
return true;
} else {
// there is something obstructing the view
Debug.Log("i CANT see my target!");
GetComponentInChildren<GUIManager>().StatusMessageText = "No line of sight.";
return false;
}
}
Debug.Log("no ray collision on shot");
return false;
}
示例11: OnParticleCollision
void OnParticleCollision(GameObject obj)
{
if (obj.CompareTag("Bat"))
{
Debug.Log ("hit!");
}
}
示例12: OnParticleCollision
void OnParticleCollision(GameObject other)
{
if (other.CompareTag("Rain"))
{
isHitByRain = true;
}
}
示例13: TryDealDamage
private void TryDealDamage( GameObject victim )
{
// Check that the victim can take damage
ObjectHealthScript healthhandle = victim.GetComponent<ObjectHealthScript>();
if ( healthhandle )
{
// Isn't on the same team
if ( !victim.CompareTag( TeamTag ) )
{
// Can damage currently
if ( NextDamage <= Time.time )
{
healthhandle.TakeHealth( Damage );
// Delay before next damage to any victim
NextDamage = Time.time + BetweenDamage;
// Destroy if it was a one shot
if ( OneShot )
{
Destroy( this );
}
}
}
}
}
示例14: Spawn
private void Spawn()
{
GameObject lastPiece = this.nextPiece;
if (lastPiece == null)
{
// we didn't have the next piece ready (first run), so create one manually
int lastIndex = Random.Range (0, this.pieces.Length);
lastPiece = Instantiate<GameObject> (pieces [lastIndex]);
lastPiece.GetComponent<Tetrimino>().gameController = gameController;
}
lastPiece.transform.position = new Vector2();
lastPiece.GetComponent<Tetrimino>().enabled = true;
int index = Random.Range (0, this.pieces.Length);
// we need to generate a new piece, but not the same as the last one
nextPiece = Instantiate<GameObject>(pieces[index]);
while(nextPiece.CompareTag(lastPiece.tag)) {
DestroyImmediate(nextPiece);
nextPiece = Instantiate<GameObject>(pieces[index]);
}
Tetrimino nextTetrimino = nextPiece.GetComponent<Tetrimino>();
nextTetrimino.gameController = gameController;
nextTetrimino.enabled = false;
}
示例15: RenderLightGizmo
static void RenderLightGizmo(GameObject gameObject, GizmoType gizmoType)
{
if (gameObject.CompareTag("SpawnPoint")) {
Gizmos.color = Color.red;
Gizmos.DrawSphere(gameObject.transform.position, 0.5f);
}
}