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


C# Transform.CompareTag方法代码示例

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


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

示例1: linkToWaterTower

    //Here is where it is invoking now.
    public void linkToWaterTower(Transform target)
    {
        Color powerLineColor = new Color (1f, 0f, 0f, 1f);

        if(Application.loadedLevelName=="Level1_1"||Application.loadedLevelName=="Level1_2")
            powerLineColor = new Color (0f, 0f, 1f, 1f);
        else
            powerLineColor = new Color (1f, 0f, 0f, 1f);

        if (target.CompareTag("waterTower")) {

            //			GameObject newGameObject = new GameObject();
            //			newGameObject.name = "line";
            //			newGameObject.transform.SetParent(gameObject.transform);
            //			newGameObject.transform.localPosition = Vector3.zero;
            //
            //			LineRenderer lineRenderer = newGameObject.AddComponent<LineRenderer>();
            //			lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
            //			lineRenderer.SetWidth(0.5f, 0.5f);
            //			lineRenderer.SetPosition(0, newGameObject.transform.position);
            //			lineRenderer.SetPosition(1, target.position);

            pumpLinks.Add(target);
            Transform newLine = (Transform) Instantiate(powerLine, gameObject.transform.position, Quaternion.identity);
            newLine.SetParent(gameObject.transform);
            newLine.localPosition = Vector3.zero;
            newLine.GetComponent<powerLineInfo>().drawLine(powerLineColor, gameObject.transform.position, target.position);

            target.GetChild(1).GetComponent<PumpAttacking>().enableWork();
        }
    }
开发者ID:RickBaksteen,项目名称:Wind-Turbine-MOOC,代码行数:32,代码来源:TransformerWorking.cs

示例2: linkToTransformer

    public void linkToTransformer(Transform target)
    {
        if (target.CompareTag ("transformer")) {

            transformers.Add(target);
            target.transform.GetComponent<TransformerWorking>().linkTurbine(gameObject.transform);

            //target.GetComponent<TransformerWorking>().linkToWaterTower();

        //			GameObject newGameObject = new GameObject();
        //			newGameObject.transform.SetParent(gameObject.transform);
        //			newGameObject.transform.localPosition = Vector3.zero;
        //
        //			LineRenderer lineRenderer = newGameObject.AddComponent<LineRenderer>();
        //			lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
        //			lineRenderer.SetWidth(0.5f, 0.5f);
        //			lineRenderer.SetPosition(0, newGameObject.transform.position);
        //			lineRenderer.SetPosition(1, target.position);

            Transform newLine = (Transform) Instantiate(powerLine, gameObject.transform.position, Quaternion.identity);
            newLine.SetParent(gameObject.transform);
            newLine.localPosition = Vector3.zero;
            newLine.GetComponent<powerLineInfo>().drawLine(new Color(1f, 0f, 0f, 1f), gameObject.transform.position, target.position);

        }
    }
开发者ID:Chillli,项目名称:Wind-Turbine-MOOC,代码行数:26,代码来源:TurbineWorking.cs

示例3: unlinkTurbine

    public void unlinkTurbine(Transform target)
    {
        if (target.CompareTag("turbine")) {

            turbineLinks.Remove(target);

        }
    }
开发者ID:RickBaksteen,项目名称:Wind-Turbine-MOOC,代码行数:8,代码来源:TransformerForTurbineWorking.cs

示例4: HandleSelected

	public void HandleSelected(Transform trans)
	{
		if (trans.CompareTag("Star")) {
			// star selected
			Debug.Log("Selected Star " + trans.name);
			SelectStar(trans.GetComponent<StarController>());
		}
	}
开发者ID:warrussell,项目名称:ggj2016,代码行数:8,代码来源:GameManager.cs

示例5: KillCount

 void KillCount(Transform other)
 {
     if (other.CompareTag(FilterTag))
     {
         _kills++;
         _textMesh.text = string.Format(TextString, _kills);
     }
 }
开发者ID:whatsthehubbub,项目名称:Nakatomi-Rider,代码行数:8,代码来源:ResultScore.cs

示例6: linkTurbine

    public void linkTurbine(Transform target)
    {
        if (target.CompareTag("turbine")) {

            enabled = true;
            turbineLinks.Add(target);

        }
    }
开发者ID:RickBaksteen,项目名称:Wind-Turbine-MOOC,代码行数:9,代码来源:TransformerWorking.cs

示例7: linkTurbine

    public void linkTurbine(Transform target)
    {
        if (target.CompareTag("turbine")) {

            enabled = true;
            turbineLinks.Add(target);
            //target.GetComponent<TurbineInfo>().calculatePowerLoss();
            transform.GetComponent<TransformerForTurbineInfo> ().showNewPower (turbineLinks[turbineLinks.Count-1]);
        }
    }
开发者ID:RickBaksteen,项目名称:Wind-Turbine-MOOC,代码行数:10,代码来源:TransformerForTurbineWorking.cs

示例8: unLinkToWaterTower

    public void unLinkToWaterTower(Transform target)
    {
        int index = pumpLinks.IndexOf(target);

        if (target.CompareTag("waterTower")) {

            enabled = true;
            pumpLinks.Remove(target);
            Destroy(gameObject.transform.GetChild(index+1));

        }
    }
开发者ID:Chillli,项目名称:Wind-Turbine-MOOC,代码行数:12,代码来源:TransformerWorking.cs

示例9: LateUpdate

    void LateUpdate()
    {
        cameraPosition = gameObject.transform.position;
        cameraPosition.z = 0f;
        //cameraPosition.x = 0f;
        if (cameraPosition.magnitude > threshold)
        {
            objects = FindObjectsOfType(typeof(Transform));
            for(int i=0;i<objects.Length;i++)
            {
                t = objects[i] as Transform;
                if(t.CompareTag("Stationary"))
                {
                    continue;
                }
                if(t.parent == null || t.parent.name=="Pooler")
                {
                    t.position -= cameraPosition;
                }
            }

            objects = FindObjectsOfType(typeof(ParticleEmitter));
            for (int i = 0; i < objects.Length; i++)
            {
                pe = objects[i] as ParticleEmitter;
                emitterParticles = pe.particles;
                for (int j = 0; j < emitterParticles.Length; j++)
                {
                    emitterParticles[j].position -= cameraPosition;
                }
                pe.particles = emitterParticles;
            }

            if (physicsThreshold >= 0f)
            {
                objects = FindObjectsOfType(typeof(Rigidbody));
                for (int i = 0; i < objects.Length; i++)
                {
                    r = objects[i] as Rigidbody;
                    if (r.gameObject.transform.position.magnitude > physicsThreshold)
                    {
                        r.sleepAngularVelocity = float.MaxValue;
                        r.sleepVelocity = float.MaxValue;
                    }
                    else
                    {
                        r.sleepAngularVelocity = defaultSleepVelocity;
                        r.sleepVelocity = defaultAngularVelocity;
                    }
                }
            }
        }
    }
开发者ID:Skytou,项目名称:Project-P,代码行数:53,代码来源:FloatingOrigin.cs

示例10: unlinkToTransformer

    public void unlinkToTransformer(Transform target)
    {
        if (target.CompareTag ("transformerForTurbine")) {

            int index = transformers.IndexOf(target);

            Transform newGameObject = gameObject.transform.GetChild(index+1);
            Destroy(newGameObject.gameObject);
            transformers.Remove(target);

            LineRenderer lineRenderer = gameObject.GetComponent<LineRenderer>();
            Destroy(lineRenderer.gameObject); //I don't know whether this would work or not.
            target.transform.GetComponent<TransformerForTurbineWorking>().unlinkTurbine(gameObject.transform);
        }
    }
开发者ID:RickBaksteen,项目名称:Wind-Turbine-MOOC,代码行数:15,代码来源:TurbineWorking.cs

示例11: GuidePointerAt

    public void GuidePointerAt(Vector3 hitPoint, Transform hitTrans, Vector3 hitNormal, Vector3 fireDir)
    {
        //gameObject.SetActive(true);

        Vector3 shp = MathTools.World2UI(hitPoint),//hit point
            shtp = MathTools.World2UI(hitTrans.position),//hitball position
            shwp = MathTools.World2UI(hitPoint + hitNormal.normalized * Pools.CueBall.GetRadius()),//whiteball position when hit
            swp = MathTools.World2UI(Pools.CueBall.GetPosition());//whiteball current position
        ////pivot
        m_Pivot = swp;
        //ball
        m_CueBall.position = shwp;
        m_Forbidden.position = shwp;
        //line
        m_Aim.position = shwp + fireDir * m_GuidelineOffset;
        Vector2 v1 = m_CueBall.parent.worldToLocalMatrix.MultiplyPoint(shwp);
        Vector2 v2 = m_CueBall.parent.worldToLocalMatrix.MultiplyPoint(swp);
        //m_AimLine.sizeDelta = new Vector2(Mathf.Max(Vector2.Distance(v1, v2) - Pools.CueBall.GetRadius(),1), m_AimLine.rect.height);
        m_Aim.size = new Vector2(Vector2.Distance(v1, v2), m_Aim.size.y);
        m_Aim.direction = (swp - shwp).normalized;
        //cue
        m_Cue.position = m_Pivot - m_Cue.right * m_CueOffset * m_CuePullStrength;
        m_Cue.right = -m_Aim.direction;
        if(hitTrans.CompareTag("Ball"))
        {
            m_TargetBallDir.active = !m_bForbidden;
            m_CueBallDir.active = !m_bForbidden;
            //hitballdir
            m_TargetBallDir.position = shtp;
            Vector3 v3 = (shtp - shp).normalized;
            float d = Mathf.Max(Vector2.Dot(-m_Aim.direction, v3), 0);
            float d40 = d * ConstantData.GuidelineLength;
            v3 = v3 * d;
            m_TargetBallDir.direction = v3;
            m_TargetBallDir.size = new Vector2(d40, m_TargetBallDir.size.y);
            //whiteballdir
            m_CueBallDir.position = shwp;
            m_CueBallDir.direction = -m_Aim.direction - v3;
            m_CueBallDir.size = new Vector2(ConstantData.GuidelineLength - d40, m_CueBallDir.size.y);
        }
        else
        {
            m_TargetBallDir.active = false;
            m_CueBallDir.active = false;
        }
    }
开发者ID:y378076136,项目名称:PoolGame-template,代码行数:46,代码来源:CueAndGuidelines.cs

示例12: AgentLibre

 protected bool AgentLibre(Transform t)
 {
     return t.CompareTag ("Personnage") && t.gameObject.name.StartsWith("Bucheron") && !dialogue.personneAborde.Contains (t);
 }
开发者ID:robinDesBits,项目名称:socialMobilityUnity,代码行数:4,代码来源:Marchand.cs

示例13: TransformInSight

 public void TransformInSight(Transform t)
 {
     if (t.CompareTag("Player") && chasePlayerBehaviour!=null)
     {
         chasePlayerBehaviour.ApplyBehaviour();
     }
 }
开发者ID:tansir23,项目名称:LD32,代码行数:7,代码来源:Agent.cs

示例14: OnTargetSeen

 void OnTargetSeen(Transform target)
 {
     if (target.CompareTag(Constants.TAG_BLOCK)) // Turn around because blocked
     {
         //Debug.Log(getFullName() + " is blocked by " + target.name);
         WalkToNext();
         vision.gameObject.SetActive(false);
         vision.gameObject.SetActive(true);
     }
     else if (target.CompareTag(Constants.TAG_OBSTACLE)) // Go around obstacle
     {
         goAround(target);
     }
 }
开发者ID:pkurowsk,项目名称:stratventure,代码行数:14,代码来源:NPCWalk.cs

示例15: CheckBodyPartHit

 void CheckBodyPartHit(Transform objectT)
 {
     if(objectT.CompareTag("Shootable"))
     {
         //Debug.Log(objectT);
     }
 }
开发者ID:Meny22,项目名称:SmartClothingProject,代码行数:7,代码来源:Character.cs


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