public static GameObject GetUnit (this GameObject unitPart) { string tag = "Unit"; if (unitPart.CompareTag (tag)) { return unitPart; } else if (unitPart.transform.parent != null) { return unitPart.transform.parent.gameObject.GetUnit (); } return null; }
public static bool IsPlayerTag(this GameObject self) { return self.CompareTag("Player"); }
public static bool IsAlien(this Component component) { return component.CompareTag("Alien"); }
public static bool IsBunker(this Component component) { return component.CompareTag("Bunker"); }
public static bool IsCannonZone(this Component component) { return component.CompareTag("CannonZone"); }
public static bool IsProjectile(this Component component) { return component.CompareTag("Projectile"); }
public static bool IsAlienVerticalEdge(this Component component) { return component.CompareTag("AlienVerticalEdge"); }
public static bool IsHorizontalEdge(this Component component) { return component.CompareTag("HorizontalEdge"); }
/** * RemoveTag */ public static void RemoveTag(this GameObject go, string stag, bool bDestroyMultiTagComponentOnEmpty = false) { if (go == null) throw new System.ArgumentNullException("go"); //var multitag = go.GetComponent<MultiTag>(); //if (multitag != null) //{ // multitag.RemoveTag(stag); // if (bDestroyMultiTagComponentOnEmpty && multitag.Count == 0) // { // Object.Destroy(multitag); // go.tag = SPConstants.TAG_UNTAGGED; // } //} //else //{ // if (go.CompareTag(stag)) go.tag = SPConstants.TAG_UNTAGGED; //} MultiTag multitag; if (MultiTag.TryGetMultiTag(go, out multitag)) { multitag.RemoveTag(stag); if (bDestroyMultiTagComponentOnEmpty && multitag.Count == 0) { Object.Destroy(multitag); go.tag = SPConstants.TAG_UNTAGGED; } } else { if (go.CompareTag(stag)) go.tag = SPConstants.TAG_UNTAGGED; } }
public static bool HasTag(this GameObject go, params string[] stags) { if (stags == null) return false; if (go == null) return false; //foreach(var stag in stags) //{ // if (go.CompareTag(stag)) return true; //} //var multitag = go.GetComponent<MultiTag>(); //if (multitag != null && multitag.ContainsTag(stags)) return true; //return false; MultiTag c; if (MultiTag.TryGetMultiTag(go, out c)) { return c.ContainsTag(stags); } else { foreach (var stag in stags) { if (go.CompareTag(stag)) return true; } } return false; }
/** * HasTag */ public static bool HasTag(this GameObject go, string stag) { if (go == null) return false; if (go.CompareTag(stag)) return true; //var multitag = go.GetComponent<MultiTag>(); //if (multitag != null && multitag.ContainsTag(stag)) return true; //return false; MultiTag c; if (MultiTag.TryGetMultiTag(go, out c)) return c.ContainsTag(stag); else return false; }
/// <summary> /// Determines if GameObject has a tag. /// </summary> /// <param name="go"></param> /// <returns></returns> public static bool HasTag(this GameObject go) { if (go == null) return false; if (go.CompareTag(SPConstants.TAG_UNTAGGED)) return false; //if (go.CompareTag(SPConstants.TAG_MULTITAG)) //{ // var multitag = go.GetComponent<MultiTag>(); // return (multitag != null) ? multitag.Count > 0 : false; //} //else //{ // return true; //} MultiTag c; if (MultiTag.TryGetMultiTag(go, out c)) return c.Count > 0; else return true; }
public static bool IsEnemyShot(this Collider2D collider) { return collider.CompareTag ("Enemy Shot"); }
public static bool IsPowerUp(this Collider2D collider) { return collider.CompareTag ("PowerUp"); }
public static bool IsPlayerShot(this Collider2D collider) { return collider.CompareTag ("Player Shot"); }
public static bool IsObstacle(this Collider2D collider) { return collider.CompareTag ("Obstacle"); }