當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。