public static List <UnityEngine.GameObject> FindChildWithTag(UnityEngine.GameObject Parent, string tag) { if (Parent.transform.childCount == 0) { if (!Parent.CompareTag(tag)) { return(new List <UnityEngine.GameObject>()); } else { return new List <UnityEngine.GameObject>() { Parent } }; } else { List <UnityEngine.GameObject> res = new List <UnityEngine.GameObject>(); for (int i = 0; i < Parent.transform.childCount; i++) { res.AddRange(FindChildWithTag(Parent.transform.GetChild(i).gameObject, tag)); } if (Parent.CompareTag(tag)) { res.Add(Parent); } return(res); } }
void OnParticleCollision(GameObject other) { print("burn!!!!"); if (other.CompareTag("Torch")) { ParticleSystem fire = other.GetComponentInChildren<ParticleSystem>(); fire.Play(); } if (other.CompareTag("Rubble")) { Debug.Log("boom"); Rigidbody[] pieces = other.gameObject.GetComponentsInChildren<Rigidbody>(); foreach (Rigidbody piece in pieces) { piece.isKinematic = false; piece.AddExplosionForce(500, other.gameObject.transform.position, 5); } BoxCollider goocollider = other.GetComponent<BoxCollider>(); goocollider.enabled = false; ParticleSystem bakahatsu = other.GetComponentInChildren<ParticleSystem>(); bakahatsu.Play(); GameObject goo = other.transform.FindChild("Goo").gameObject; Destroy(goo); } }
public void PossessPlayer(GameObject player) { if (state == CameraState.FREE_FLOW) { if (player.CompareTag("Salesman")) { character = CharacterClass.SALESMAN; } else if (player.CompareTag("Shopper")) { character = CharacterClass.SHOPPER; } else if (player.CompareTag("Guard")) { character = CharacterClass.GUARD; } else if (player.CompareTag("Thief")) { character = CharacterClass.THIEF; } else return; PossessionScript ps = player.GetComponent<PossessionScript>(); ps.Possess(); possessedCharacter = player; attachedRotation = player.transform.rotation; attachedLocation = player.transform.position + attachedRotation * new Vector3(0, 1.85f, -2); freeFlyLocation = transform.position; freeFlyRotation = transform.rotation; state = CameraState.ATTACHING; tick = 0; } }
public void removeBuild(GameObject obj, bool bank) { Debug.Log("Removed" + obj.name); if (bank) { banks.Remove(obj); } else if (obj.CompareTag("RoadBlock")) { targetCount.GetComponent<TargetMover>().roadBlockCounter -= 1; //monster.GetComponent<Attack_Building>().inAction = false; buildings.Remove(obj); //Debug.Log("Entered"); } else if(obj.CompareTag("PileOFish")) { targetCount.GetComponent<TargetMover>().PileOFishCounter -= 1; //monster.GetComponent<Attack_Building>().inAction = false; buildings.Remove(obj); } else { buildings.Remove(obj); } }
// changes the target and sets insect color void ChangeTarget(GameObject target) { // clear old target and set new one if(targetPlant.CompareTag("plant")) { targetPlant.GetComponent<CirclePlantPrefabScript>().IsTargeted = false; } if(target != targetPlant) Comment ("New target: {0}", target); targetPlant = target; // then colorize insect based on target // white=null, green=plant, yellow=tree+full, orange=tree+unfull, red=tree+empty if(targetPlant == null) { renderer.material.color = Color.white; } else if(targetPlant.CompareTag("plant")) { renderer.material.color = Color.green; targetPlant.GetComponent<CirclePlantPrefabScript>().IsTargeted = true; } else if(targetPlant.CompareTag("tree")) { if(pollen > 0) { renderer.material.color = pollen < pollenCapacity ? Color.Lerp(Color.red, Color.yellow, 0.5f) : Color.yellow; } else renderer.material.color = Color.red; } }
private bool IsBorderOrGroundHit(GameObject collidedObject) { if (collidedObject.CompareTag("Ground") || collidedObject.CompareTag("Border")) { DestroyObject(gameObject); return true; } return false; }
void OnParticleCollision(GameObject obj) { if (obj.CompareTag("Bat")) { Debug.Log ("hit!"); } }
private void TryDealDamage( GameObject victim ) { // Check that the victim can take damage ObjectHealthScript healthhandle = victim.GetComponent<ObjectHealthScript>(); if ( healthhandle ) { // Isn't on the same team if ( !victim.CompareTag( TeamTag ) ) { // Can damage currently if ( NextDamage <= Time.time ) { healthhandle.TakeHealth( Damage ); // Delay before next damage to any victim NextDamage = Time.time + BetweenDamage; // Destroy if it was a one shot if ( OneShot ) { Destroy( this ); } } } } }
private void Spawn() { GameObject lastPiece = this.nextPiece; if (lastPiece == null) { // we didn't have the next piece ready (first run), so create one manually int lastIndex = Random.Range (0, this.pieces.Length); lastPiece = Instantiate<GameObject> (pieces [lastIndex]); lastPiece.GetComponent<Tetrimino>().gameController = gameController; } lastPiece.transform.position = new Vector2(); lastPiece.GetComponent<Tetrimino>().enabled = true; int index = Random.Range (0, this.pieces.Length); // we need to generate a new piece, but not the same as the last one nextPiece = Instantiate<GameObject>(pieces[index]); while(nextPiece.CompareTag(lastPiece.tag)) { DestroyImmediate(nextPiece); nextPiece = Instantiate<GameObject>(pieces[index]); } Tetrimino nextTetrimino = nextPiece.GetComponent<Tetrimino>(); nextTetrimino.gameController = gameController; nextTetrimino.enabled = false; }
private void checkObjectDrag(GameObject hit) { if (hit.CompareTag("Key") && hit.name != curChar) { if (duration != 0) //don't sent first time swypeController.AddCharacter(curChar[0], duration);//send previous character curChar = hit.name; duration = 0; //swypeController.AddCharacter(curChar[0]); } if (hit.CompareTag("Key") && hit.name == curChar) duration += Time.deltaTime; if(partOfKeyBoard(hit)) painter.addPoint(fingerTipPos); }
//------------------------------------------------------------------------- public void SetTarget(GameObject newTarget) { if (newTarget.CompareTag ("Player")) { Debug.Log ("Player Detected"); target = newTarget.transform; } }
static void RenderLightGizmo(GameObject gameObject, GizmoType gizmoType) { if (gameObject.CompareTag("SpawnPoint")) { Gizmos.color = Color.red; Gizmos.DrawSphere(gameObject.transform.position, 0.5f); } }
public static void HitBrick(GameObject brick) { if (brick.CompareTag ("Breakable")) { BrickController bc = brick.GetComponent<BrickController>(); bc.handleHits(); } }
public void StartSpeech(GameObject initiator) { if (showingText) { return; } if (randomizeTexts) { textIndex = Random.Range(0, texts.Length - 1); } if (initiator.CompareTag(playerTag)) { playerControl = initiator.GetComponent<PlayerControl>(); playerControl.freezeInput = true; speech.SetActive(true); showingText = true; skipUpdate = true; textAdvancer = initiator.GetComponent<TextAdvancer>(); DrawText(); } }
static public int CompareTag(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.CompareTag(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
void OnParticleCollision(GameObject other) { if (other.CompareTag("Rain")) { isHitByRain = true; } }
public void StopContactBottom(GameObject other) { if (other.CompareTag("Platform") && contactingPlatforms.Contains(other)) { contactingPlatforms.Remove(other); } }
/** * Check to see if their is los to marines target **/ public bool CanHitTarget(GameObject marineShooter, GameObject target) { // exit if marine isn't shooting an alien if(marineShooter == null || !target.CompareTag("Alien")) return false; // exit if the alien is already dead if(target.GetComponent<AlienData>().unitStatus == AlienData.UnitStatus.DEAD) return false; RaycastHit hit; Vector3 targetVector = target.transform.position; targetVector.y = marineShooter.transform.position.y; Vector3 rayDirection = targetVector - marineShooter.transform.position; _debug_source_trans = marineShooter.transform; _debug_target = rayDirection; if (Physics.Raycast (marineShooter.transform.position, rayDirection, out hit)) { if (hit.transform.gameObject.CompareTag("Alien")) { Debug.Log("i see my target!"); return true; } else { // there is something obstructing the view Debug.Log("i CANT see my target!"); GetComponentInChildren<GUIManager>().StatusMessageText = "No line of sight."; return false; } } Debug.Log("no ray collision on shot"); return false; }
bool ignoreCheck(GameObject obj) { foreach (string tag in m_IgnoreTags) if (obj.CompareTag(tag)) return true; return false; }
// Update is called once per frame void Update () { if (UICamera.GetMouse (0).pressStarted) { currentClicked = UICamera.GetMouse (0).pressed; if(Kontext.gameObject.activeSelf){ if (currentClicked != null && (currentClicked.transform.IsChildOf (transform) || currentClicked.CompareTag ("Robot"))) NGUITools.SetActiveChildren (gameObject, true); else { Kontext.Close (); NGUITools.SetActiveChildren (gameObject, false); } } } if (UICamera.GetMouse (1).pressStarted) { currentClicked = UICamera.GetMouse (1).pressed; clicked = true; if(currentClicked != null && currentClicked.CompareTag ("Robot")){ selectedRobot = currentClicked; BehaviourTree tree = selectedRobot.GetComponent<BehaviourTree> (); if (tree != null&& tree.lastLoadedTree.Length > 0){ Kontext.value = tree.lastLoadedTree; } } if (currentClicked != null && (currentClicked.transform.IsChildOf (transform) || currentClicked.CompareTag ("Robot"))) NGUITools.SetActiveChildren (gameObject, true); else { Kontext.Close (); NGUITools.SetActiveChildren (gameObject, false); } } if (currentClicked!= null && clicked && currentClicked.CompareTag("Robot")) { transform.localPosition = NGUIMath.ScreenToPixels(UICamera.GetMouse (1).pos,UICamera.currentCamera.transform); NGUITools.SetActiveChildren(gameObject,true); clicked = false; } }
private void CheckSonarPoint_Exit(GameObject target) { if (!target.CompareTag("Sonar")) return ; // ColorFader fader = target.GetComponent<ColorFader>(); // if (fader) return fader.SonarInside(); Debug.Log("CheckSonarPoint_TriggerExit"); target.SendMessage("OnSonarOutside"); }
/// <summary> /// Determines whether this instance can pick up the specified object. /// </summary> /// <returns><c>true</c> if the ball can pick up this object; otherwise, <c>false</c>.</returns> /// <param name="other">The object to pick up.</param> bool CanStick(GameObject other) { bool stick = false; switch (stickyness) { case Stickyness.Weak: stick = other.CompareTag("Small"); break; case Stickyness.Medium: stick = other.CompareTag("Medium"); break; case Stickyness.Strong: stick = other.CompareTag("Large"); break; } return stick; }
public void triggerExit( GameObject objectInTrigger ) { if( objectInTrigger.CompareTag( "Player" ) ) { foreach( GameObject douchbag in douchbags ) douchbag.SendMessage( "DomainExited", objectInTrigger, SendMessageOptions.DontRequireReceiver ); } }
private void CheckTerrainCollision(GameObject target) { // テラインに接触したら沈んだ音を再生 if (target.CompareTag("Terrain")) { PlayAudioAtOnce(); } }
void CheckSonarCamera_Exit(GameObject target) { if (!sonarInside) return; if (!target.CompareTag("SonarCamera")) return; Debug.Log("CheckSonarCamera_Exit"); OnSonarOutside(); }
private void CheckDamageCollision(GameObject target) { // 若干スピードを落とす微調整(あまりスピードがありすぎるとexplosionがきかない) if (target.CompareTag("Torpedo")) { controller.AddSpeed( -speedDown ); } }
private void CheckSonarPoint_Enter(GameObject target) { if (!target.CompareTag("Sonar")) return; ColorFader fader = target.GetComponent<ColorFader>(); if (fader==null) return; if (fader.SonarInside()) return; Debug.Log("CheckSonarPoint"); target.BroadcastMessage("OnSonarInside"); }
static void RenderLightGizmo(GameObject gameObject, GizmoType gizmoType) { if (gameObject.CompareTag("StationSpawn") && string.IsNullOrEmpty(AssetDatabase.GetAssetPath(gameObject))) { Gizmos.color = Color.yellow; var prefab = (GameObject)GameObject.FindObjectsOfTypeIncludingAssets(typeof(GameObject)).First(g => ((GameObject)g).name == "Work Station"); var modelTransform = prefab.transform.FindChild("Cube"); Gizmos.DrawCube(gameObject.transform.position, modelTransform.localScale); } }
private void Hit(GameObject c) { if (c.CompareTag ("Player") && !destroyPlayer) { PlayerHit (); } else { Destroy(c.gameObject); GameobjectCounter.gameObjects--; } }
public void removeTarget(GameObject obj) { //Debug.Log("Hit"); if(obj.CompareTag("PileOFish")) { targetMover.GetComponent<TargetMover>().PileOFishCounter -= 1; } targets.Remove(obj); Destroy(obj); }
/// <summary> /// Coloca la imagen en la posicion indicada. /// </summary> /// <param name="pGo">Objeto que contendra la imagen.</param> /// <param name="pSprite">Sprite.</param> /// <param name="pPos">P position.</param> public static void colocarImagen(GameObject pGo, Sprite pSprite, Vector2 pPos) { SpriteRenderer imagen = pGo.GetComponent<SpriteRenderer>(); if (imagen == null){ pGo.AddComponent(typeof(SpriteRenderer)); imagen = pGo.GetComponent<SpriteRenderer>(); } imagen.sprite = pSprite; //imagen.sortingLayerName = "Background"; imagen.transform.position = Mazmorras.colocar16x16(pPos.x,pPos.y); if (pGo.CompareTag ("Wall") || pGo.CompareTag ("Rock") || pGo.CompareTag("Door")) { pGo.AddComponent (typeof(BoxCollider2D)); imagen.sortingLayerName = "Walls"; } else if (pGo.CompareTag ("Door")) { pGo.AddComponent (typeof(Door)); } pGo.AddComponent (typeof(ColorChanger)); }
bool IsExplodable(GameObject obj) { if (Exploder.DontUseTag) { return obj.GetComponent<Explodable>() != null; } else { return obj.CompareTag(ExploderObject.Tag); } }
static public int CompareTag(IntPtr l) { try { UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.CompareTag(a1); pushValue(l, ret); return(1); } catch (Exception e) { return(error(l, e)); } }
static int QPYX_CompareTag_YXQP(IntPtr L_YXQP) { try { ToLua.CheckArgsCount(L_YXQP, 2); UnityEngine.GameObject QPYX_obj_YXQP = (UnityEngine.GameObject)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.GameObject)); string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 2); bool QPYX_o_YXQP = QPYX_obj_YXQP.CompareTag(QPYX_arg0_YXQP); LuaDLL.lua_pushboolean(L_YXQP, QPYX_o_YXQP); return(1); } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
static public int CompareTag(IntPtr l) { try{ UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Boolean ret = self.CompareTag(a1); pushValue(l, ret); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static int CompareTag(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject)); string arg0 = ToLua.CheckString(L, 2); bool o = obj.CompareTag(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public static int CompareTag_wrap(long L) { try { long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L); UnityEngine.GameObject obj = get_obj(nThisPtr); string arg0 = FCLibHelper.fc_get_string_a(L, 0); bool ret = obj.CompareTag(arg0); long ret_ptr = FCLibHelper.fc_get_return_ptr(L); FCLibHelper.fc_set_value_bool(ret_ptr, ret); } catch (Exception e) { Debug.LogException(e); } return(0); }
static int CompareTag(IntPtr L) { #if UNITY_EDITOR ToluaProfiler.AddCallRecord("UnityEngine.GameObject.CompareTag"); #endif try { ToLua.CheckArgsCount(L, 2); UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject)); string arg0 = ToLua.CheckString(L, 2); bool o = obj.CompareTag(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public static bool IsFragmented(GameObject gameObject) { return(gameObject.CompareTag(Constants.FrozenFragmentStr) || gameObject.CompareTag(Constants.MovingFragmentStr)); }
/// <summary> /// Given an immovable fragment, destroy it by simulating an explosion. The explosion will be /// considered as a sphere. The fragment will be given a rigid body and will be moved accordingly. /// </summary> /// <param name="fragment">Immovable fragment to be destroyed.</param> /// <param name="hitPoint">Explosion center.</param> /// <param name="radius">Explosion radius (must be positive).</param> /// <param name="force">Explosion force (must be positive).</param> private static void DestroyFragment(GameObject fragment, Vector3 hitPoint, float radius, float force, bool immidiateHingeBreak = false) { if (fragment == null) { throw new System.ArgumentNullException("fragment"); } if (!fragment.CompareTag(Constants.FrozenFragmentStr)) { throw new System.ArgumentException("Fragment is not tagged frozen"); } if (radius <= 0.0f) { throw new System.ArgumentException("Radius is not greater than 0.0"); } if (force <= 0.0f) { throw new System.ArgumentException("Force is not greater than 0.0"); } fragment.name = Constants.MovingFragmentStr + fragment.name.Substring(Constants.FrozenFragmentStr.Length); fragment.tag = Constants.MovingFragmentStr; fragment.layer = LayerMask.NameToLayer(Constants.MovingFragmentStr); Rigidbody rb = fragment.GetComponent <Rigidbody>(); if (rb == null) { rb = fragment.AddComponent <Rigidbody>(); } rb.angularDrag = 0.0f; rb.drag = 0.0f; rb.AddExplosionForce(force, hitPoint, radius); Object.Destroy(fragment.GetComponent <JointBreakListener>()); if (immidiateHingeBreak) { HingeJoint[] hingeJoints = fragment.GetComponents <HingeJoint>(); foreach (HingeJoint hingeJoint in hingeJoints) { GameObject neighbour = hingeJoint.connectedBody.gameObject; Debug.Log($"Checking hinge {fragment.name} -> {neighbour.name}"); HingeJoint[] neighHingeJoints = neighbour.GetComponents <HingeJoint>(); foreach (HingeJoint neighHingeJoint in neighHingeJoints) { //Debug.Log($"\t Checking {neighbour.name}'s hinge with {neighHingeJoint.connectedBody.name}"); if (neighHingeJoint.connectedBody.gameObject == fragment) { Debug.Log($"\t\t Destroyed hinge {neighHingeJoint.gameObject.name} -> {fragment.name}"); Object.DestroyImmediate(neighHingeJoint); break; } } Object.DestroyImmediate(hingeJoint); } } rb.isKinematic = false; fragment.transform.parent = null; Object.Destroy(fragment, Random.Range(Constants.FragmentMinDestroyDelay, Constants.FragmentMaxDestroyDelay)); }