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


C# Component.CompareTag方法代码示例

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


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

示例1: OnTriggerStay

  void OnTriggerStay(Component component) {
    if (component.CompareTag("LevelPoint")) {
      GameManager.LevelCompleted = true;

      anim.SetBool("Attacking", false);
      anim.SetBool("Walking", true);

      if (transform.position.x < component.gameObject.transform.position.x) {
        GetComponent<Rigidbody>().velocity = new Vector3(0f, 1f, 0f);
        float step = 2f * Time.deltaTime;
        transform.position = Vector3.MoveTowards(transform.position, component.gameObject.transform.position, step);
      } else {
        GetComponent<Rigidbody>().velocity = new Vector3(0f, 5f, 0f);
      }
    }
  }
开发者ID:mengtest,项目名称:ArmorBoy3D,代码行数:16,代码来源:Player.cs

示例2: OnTriggerEnter

  void OnTriggerEnter(Component component) {
    if (component.CompareTag("CheckPoint")) {
      LastCheckPoint = component.gameObject;
      component.gameObject.SetActive(false);
    }

    if (component.CompareTag("ActionPoint")) {
      component.gameObject.SetActive(false);
    }

    if (component.CompareTag("BadTouch") || (component.CompareTag("Enemy") && !Attacking)) {
      Kill();
    }

    if (component.CompareTag("Fallable")) {
      GetComponent<Collider>().isTrigger = false;
      component.GetComponent<Fallable>().Fall();
    }

    if (component.CompareTag("Breakable")) {
      component.GetComponent<Breakable>().Break();
    }
  }
开发者ID:mengtest,项目名称:ArmorBoy3D,代码行数:23,代码来源:Player.cs

示例3: AreEnemies

 public static bool AreEnemies(Component c1, Component c2)
 {
     return !c1.CompareTag(c2.tag);
 }
开发者ID:golergka,项目名称:KingOfCastles,代码行数:4,代码来源:FoFSystem.cs

示例4: OnTriggerEnter

 void OnTriggerEnter(Component component) {
   if (component.CompareTag("Player") && Player.Attacking) {
     Break();
   }
 }
开发者ID:mengtest,项目名称:ArmorBoy3D,代码行数:5,代码来源:Breakable.cs

示例5: Contains

 public bool Contains(Component component)
 {
     return (!component ? false : component.CompareTag(GameConstant.Tag.Info[this.tagNumber].tag));
 }
开发者ID:HexHash,项目名称:LegacyRust,代码行数:4,代码来源:GameConstant.cs

示例6: FindDependency

 public override object FindDependency(Component comp, FieldInfo field)
 {
     if (SearchParents) {
         comp = comp.transform.root;
     }
     if (IsContainerType(field)) {
         List<GameObject> deps = new List<GameObject>();
         if (comp.CompareTag(Tag)) {
             deps.Add(comp.gameObject);
         }
         FindDependenciesInternal(comp.gameObject, deps);
         return CreateArrayOrList(field, deps);
     }
     if (comp.CompareTag(Tag)) {
         return ExtractComponent(comp.gameObject, field.FieldType);
     }
     GameObject dep = FindDependencyInternal(comp.gameObject);
     return ExtractComponent(dep, field.FieldType);
 }
开发者ID:paulmoore,项目名称:UnJect,代码行数:19,代码来源:Attributes.cs


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