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


C# GameObject.CompareTag方法代码示例

本文整理汇总了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;
        }
    }
开发者ID:edwonia,项目名称:Ponder,代码行数:27,代码来源:InsectPrefabScript.cs

示例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;
        }
    }
开发者ID:CG-F15-20-Rutgers,项目名称:UnityProjects,代码行数:35,代码来源:CameraP3Controller.cs

示例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);
     }
 }
开发者ID:PileOfFish,项目名称:PileOfFishProductions,代码行数:25,代码来源:BuildingCollector.cs

示例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);

		}
    }
开发者ID:Darylcxz,项目名称:ANIMA-FYP,代码行数:26,代码来源:HitbyExplosion.cs

示例5: IsBorderOrGroundHit

    private bool IsBorderOrGroundHit(GameObject collidedObject)
    {
        if (collidedObject.CompareTag("Ground") || collidedObject.CompareTag("Border")) {
            DestroyObject(gameObject);
            return true;
        }

        return false;
    }
开发者ID:DJCrossman,项目名称:capstoneproject-public,代码行数:9,代码来源:Bullet.cs

示例6: HitBrick

 public static void HitBrick(GameObject brick)
 {
     if (brick.CompareTag ("Breakable")) {
         BrickController bc = brick.GetComponent<BrickController>();
         bc.handleHits();
     }
 }
开发者ID:jd4rider,项目名称:bunnybreakout,代码行数:7,代码来源:BrickController.cs

示例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();
        }
    }
开发者ID:BlazingMammothGames,项目名称:LD29,代码行数:25,代码来源:SpeechController.cs

示例8: StopContactBottom

 public void StopContactBottom(GameObject other)
 {
     if (other.CompareTag("Platform") && contactingPlatforms.Contains(other))
     {
         contactingPlatforms.Remove(other);
     }
 }
开发者ID:Mouserr,项目名称:ScaryDream,代码行数:7,代码来源:MovementController.cs

示例9: ignoreCheck

 bool ignoreCheck(GameObject obj)
 {
     foreach (string tag in m_IgnoreTags)
         if (obj.CompareTag(tag))
             return true;
     return false;
 }
开发者ID:williamd4112,项目名称:DugeonSurvivor,代码行数:7,代码来源:TouchDamageEmitter.cs

示例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;
    }
开发者ID:mdeegler,项目名称:xeno,代码行数:38,代码来源:MarineManager.cs

示例11: OnParticleCollision

 void OnParticleCollision(GameObject obj)
 {
     if (obj.CompareTag("Bat"))
     {
         Debug.Log ("hit!");
     }
 }
开发者ID:kannolab-waseda,项目名称:BBB,代码行数:7,代码来源:BallScript.cs

示例12: OnParticleCollision

 void OnParticleCollision(GameObject other)
 {
     if (other.CompareTag("Rain"))
     {
         isHitByRain = true;
     }
 }
开发者ID:Sushiy,项目名称:ShamanDance,代码行数:7,代码来源:Seed.cs

示例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 );
                    }
				}
			}
		}
	}
开发者ID:johnjoemcbob,项目名称:Honours_Game,代码行数:26,代码来源:ObjectDoesDamageScript.cs

示例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;
    }
开发者ID:antonvlad,项目名称:clonetris,代码行数:26,代码来源:Spawner.cs

示例15: RenderLightGizmo

 static void RenderLightGizmo(GameObject gameObject, GizmoType gizmoType)
 {
     if (gameObject.CompareTag("SpawnPoint")) {
         Gizmos.color = Color.red;
         Gizmos.DrawSphere(gameObject.transform.position, 0.5f);
     }
 }
开发者ID:LoganBarnett,项目名称:Droids,代码行数:7,代码来源:DroidSpawnGizmo.cs


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