本文整理汇总了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();
}
}
示例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);
}
}
示例3: unlinkTurbine
public void unlinkTurbine(Transform target)
{
if (target.CompareTag("turbine")) {
turbineLinks.Remove(target);
}
}
示例4: HandleSelected
public void HandleSelected(Transform trans)
{
if (trans.CompareTag("Star")) {
// star selected
Debug.Log("Selected Star " + trans.name);
SelectStar(trans.GetComponent<StarController>());
}
}
示例5: KillCount
void KillCount(Transform other)
{
if (other.CompareTag(FilterTag))
{
_kills++;
_textMesh.text = string.Format(TextString, _kills);
}
}
示例6: linkTurbine
public void linkTurbine(Transform target)
{
if (target.CompareTag("turbine")) {
enabled = true;
turbineLinks.Add(target);
}
}
示例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]);
}
}
示例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));
}
}
示例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;
}
}
}
}
}
示例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);
}
}
示例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;
}
}
示例12: AgentLibre
protected bool AgentLibre(Transform t)
{
return t.CompareTag ("Personnage") && t.gameObject.name.StartsWith("Bucheron") && !dialogue.personneAborde.Contains (t);
}
示例13: TransformInSight
public void TransformInSight(Transform t)
{
if (t.CompareTag("Player") && chasePlayerBehaviour!=null)
{
chasePlayerBehaviour.ApplyBehaviour();
}
}
示例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);
}
}
示例15: CheckBodyPartHit
void CheckBodyPartHit(Transform objectT)
{
if(objectT.CompareTag("Shootable"))
{
//Debug.Log(objectT);
}
}