// Use this for initialization void Awake() { ResetHp(); deathTrigger = GetComponent<DeathTrigger>(); deathTrigger.Initialize += ResetHp; }
private void Awake() { initialPos = transform.position; newPosition = transform.position; animPlatform = GetComponent <Animator>(); deathTrigger = GameObject.Find("DeathTrigger").GetComponent <DeathTrigger>(); }
/// <summary> /// Load all components required to run this script. /// </summary> protected void Awake() { deathTrigger = GetComponent<DeathTrigger>(); audioSource = GetComponent<AudioSource>(); movement = GetComponent<Movement>(); animator = GetComponent<Animator>(); deathTrigger.Death += OnDeath; }
public void death() { Destroy(gameObject); if (GetComponent <DeathTrigger>() != null) { DeathTrigger dt = GetComponent <DeathTrigger>(); dt.deathTrigger(); } }
/// <summary> /// Load all components required for this script and validate the parameters. /// </summary> protected void Awake() { if (gameManager == null) { Debug.LogError("Cannot end game without a game manager linked to all planets."); } deathTrigger = GetComponent<DeathTrigger>(); deathTrigger.Death += OnDeath; ai = playerInput.GetComponent<PlayerAi>(); }
void Start() { deathTrigger = new DeathTrigger(); animator = GetComponent <Animator>(); health = maxHealth; if (game == null) { Debug.LogError("!!! No Reference to GameController !!!"); } }
// Use this for initialization void Awake() { goalController = GameObject.FindWithTag("GoalController"); GameObject deathTrigger = GameObject.FindWithTag("DeathTrigger"); //create reference for Player gameobject, and assign the variable via FindWithTag at start if (deathTrigger != null) // if the playerObject gameObject-reference is not null - assigning the reference via FindWithTag at first frame - { deathTriggerScript = deathTrigger.GetComponent<DeathTrigger>();// - set the PlayerController-reference (called playerControllerScript) to the <script component> of the Player gameobject (via the gameObject-reference) to have access the instance of the PlayerController script } if (deathTrigger == null) //for exception handling - to have the console debug the absense of a player controller script in order for this entire code, the code in the GameController to work { Debug.Log("Cannot find DeathTrigger script for final score referencing to GameOver - finalScore Label"); } }
/// <summary> /// Load all components required to run this script. Validate all parameters. /// </summary> protected void Awake() { deathTrigger = GetComponent<DeathTrigger>(); movement = GetComponent<Movement>(); if (dropChances.Count != spawnablePowerUps.Count) { Debug.LogError("There must be a drop chance for every spawnable powerup."); } added = false; deathTrigger.Initialize += Enable; }
private void specialRevertLogic(GameObject g, GameObject sg = null) { if (sg != null) { } PathFollowing p = g.GetComponent <PathFollowing>(); if (p != null) { p.setStateToIdle(); } CollideTrigger ct = g.GetComponent <CollideTrigger>(); if (ct != null) { ct.reset(); } TimeTrigger tt = g.GetComponent <TimeTrigger>(); if (tt != null) { tt.reset(); } DeathTrigger dt = g.GetComponent <DeathTrigger>(); if (dt != null) { dt.reset(); } Health h = g.GetComponent <Health>(); if (h != null) { h.hp = h.startHP; } StarPower sp = g.GetComponent <StarPower>(); if (sp != null) { sp.reset(); } }
// Update is called once per frame void Update() { if (hp <= 0) { switch (da) { case DeathActions.Despawn: { // De-activate this object, it will re-activate when the Reset button is pressed. Despawn d = gameObject.GetComponent <Despawn>(); if (d == null) { d = gameObject.AddComponent <Despawn>(); } d.deathAnimID = d.defaultDeathAnimID; d.run(); } break; case DeathActions.Respawn: LevelManager.instance.revertObject(gameObject); break; default: break; } DeathTrigger dt = GetComponent <DeathTrigger>(); if (dt != null) { dt.run(); } } if (damageCooldownTimer > 0) { damageCooldownTimer -= Time.deltaTime; } }
/// <summary> /// Load all components required to run this script. /// </summary> protected void Awake() { myTransform = transform; movement = GetComponent<Movement>(); deathTrigger = GetComponent<DeathTrigger>(); }
public void Start() { dt = GameObject.Find("DeathTrigger").GetComponent <DeathTrigger>(); }
//Float void Start() { deathTrigger = GameObject.Find("DeathTrigger"); deathScript = deathTrigger.GetComponent<DeathTrigger>(); }
internal void OnDeathTrigger(IEntity sender) { DeathTrigger?.Invoke(sender); }
public void Start () { dt = GameObject.Find("DeathTrigger").GetComponent<DeathTrigger>(); }
private IEnumerator addComponentByName(GameObject go, GameObject staticGO, string name, string data1, string data2, string data3, string data4, string data5) { go.layer = LayerMask.NameToLayer("BlockingLayer"); staticGO.layer = LayerMask.NameToLayer("BlockingLayer"); switch (name) { case "PathFollowing": go.AddComponent <PathFollowing>().initDrawing(0, true).setStateToIdle(); staticGO.AddComponent <PathFollowing>().initDrawing(0, false).setStateToIdle(); break; case "SpriteRenderer": { SpriteRenderer r = go.AddComponent <SpriteRenderer>(); SpriteRenderer sr = staticGO.AddComponent <SpriteRenderer>(); if (data1.Length > 0) { int index = data1.LastIndexOf('_'); if (index > 0) { int spriteIndex; if (Int32.TryParse(data1.Substring(index + 1), out spriteIndex)) { string path = data1.Substring(0, index); Sprite[] sprites = Resources.LoadAll <Sprite>(path); if (spriteIndex < sprites.Length) { r.sprite = sprites[spriteIndex]; sr.sprite = sprites[spriteIndex]; } } } else { r.sprite = Resources.Load <Sprite>(data1); sr.sprite = Resources.Load <Sprite>(data1); } } if (data2.Length > 0) { r.sortingLayerName = data2; sr.sortingLayerName = data2; } } break; case "Animator": go.AddComponent <Animator>().runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>(data1); staticGO.AddComponent <Animator>().runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>(data1); break; case "BoxCollider2D": { BoxCollider2D bc = go.AddComponent <BoxCollider2D>(); BoxCollider2D sbc = staticGO.AddComponent <BoxCollider2D>(); bool trigger; if (Boolean.TryParse(data1, out trigger)) { bc.isTrigger = trigger; sbc.isTrigger = trigger; } } break; case "RigidBody2D": { Rigidbody2D rb = go.AddComponent <Rigidbody2D>(); bool kinematic, fixedAngle; if (Boolean.TryParse(data1, out kinematic)) { rb.isKinematic = kinematic; } if (Boolean.TryParse(data2, out fixedAngle)) { rb.fixedAngle = fixedAngle; } } break; case "Tag": go.tag = data1; if (data1 == "PaintableBackground") { staticGO.tag = data1; } break; case "CustomScript": go.AddComponent(Type.GetType(data1)); break; case "Move": { Move mc = go.AddComponent <Move>(); mc.maxSpeed[0] = float.Parse(data1); mc.maxSpeed[1] = float.Parse(data2); mc.maxSpeed[2] = float.Parse(data3); mc.maxSpeed[3] = float.Parse(data4); } break; case "Jump": { go.AddComponent <Jump>(); Rigidbody2D rb = null; rb = go.GetComponent <Rigidbody2D>(); if (rb == null) { rb = go.AddComponent <Rigidbody2D>(); } rb.isKinematic = false; rb.fixedAngle = true; } break; case "Health": { BoxCollider2D c = null; c = go.GetComponent <BoxCollider2D>(); if (c == null) { c = go.AddComponent <BoxCollider2D>(); } Health h = go.AddComponent <Health>(); Int32.TryParse(data1, out h.maxHP); Int32.TryParse(data2, out h.startHP); Int32.TryParse(data3, out h.directions); int deathAction; if (Int32.TryParse(data4, out deathAction)) { h.setDeathAction(deathAction); } float.TryParse(data5, out h.damageCooldown); } break; case "Resize": { Resize r = staticGO.AddComponent <Resize>(); r.arrowPrefab = pentaArrow; r.nonStatic = go; } break; case "CollideTrigger": { CollideTrigger ct = go.GetComponent <CollideTrigger>(); if (ct == null) { ct = go.AddComponent <CollideTrigger>(); } CustomAction.ActionTypes a = (CustomAction.ActionTypes)Enum.Parse(typeof(CustomAction.ActionTypes), data1); int directions; Int32.TryParse(data2, out directions); string[] delimiters = { "|" }; string[] tags = data3.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); List <String> includedTags = new List <String>(), excludedTags = new List <String>(); for (int i = 0; i < tags.Length; i++) { if (tags[i].StartsWith("!")) { string tag = tags[i].Substring(1); excludedTags.Add(tag); } else { includedTags.Add(tags[i]); } } switch (a) { case CustomAction.ActionTypes.Spawn: { Spawn s = go.AddComponent <Spawn>(); string rfidKey = data4; if (database.ContainsKey(rfidKey)) { s.toSpawn = database[rfidKey].first; } else { string url = "http://" + databaseAddress + "/playtime/getComponents.php"; yield return(StartCoroutine(pollDatabase(url, rfidKey, false))); if (database.ContainsKey(rfidKey)) { s.toSpawn = database[rfidKey].first; } } int spawnCount = 0; Int32.TryParse(data5, out spawnCount); s.setMaxSpawnCount(spawnCount); s.includedTags = includedTags; s.excludedTags = excludedTags; ct.actions.Add(s); ct.directions.Add(directions); } break; case CustomAction.ActionTypes.Despawn: { Despawn d = go.AddComponent <Despawn>(); int deathAnimID; int.TryParse(data4, out deathAnimID); d.deathAnimID = deathAnimID; d.defaultDeathAnimID = deathAnimID; d.includedTags = includedTags; d.excludedTags = excludedTags; ct.actions.Add(d); ct.directions.Add(directions); } break; case CustomAction.ActionTypes.Transfigure: { Transfigure t = go.GetComponent <Transfigure>(); if (t == null) { t = go.AddComponent <Transfigure>(); } bool repeatable; Boolean.TryParse(data5, out repeatable); t.addTargetAnimControllerAndTags(data4, includedTags, excludedTags, repeatable, ct.actions.Count); ct.actions.Add(t); ct.directions.Add(directions); } break; case CustomAction.ActionTypes.DespawnOther: { DespawnOther dOther = go.AddComponent <DespawnOther>(); dOther.includedTags = includedTags; dOther.excludedTags = excludedTags; ct.actions.Add(dOther); ct.directions.Add(directions); } break; case CustomAction.ActionTypes.RespawnOther: { RespawnOther rOther = go.AddComponent <RespawnOther>(); rOther.includedTags = includedTags; rOther.excludedTags = excludedTags; ct.actions.Add(rOther); ct.directions.Add(directions); } break; case CustomAction.ActionTypes.Damage: { Damage d = go.AddComponent <Damage>(); d.includedTags = includedTags; d.excludedTags = excludedTags; Int32.TryParse(data4, out d.dmg); ct.actions.Add(d); ct.directions.Add(directions); } break; case CustomAction.ActionTypes.MoveHoriz: { MoveHorizontalUntilCollision m = go.AddComponent <MoveHorizontalUntilCollision>(); m.includedTags = includedTags; m.excludedTags = excludedTags; float.TryParse(data4, out m.speed); m.tagsToIgnore = new List <string>(data5.Split(delimiters, StringSplitOptions.RemoveEmptyEntries)); ct.actions.Add(m); ct.directions.Add(directions); } break; case CustomAction.ActionTypes.CustomScript: { Type t = Type.GetType(data4); Component comp = go.AddComponent(t); CustomAction c = (CustomAction)comp; c.includedTags = includedTags; c.excludedTags = excludedTags; ct.actions.Add(c); ct.directions.Add(directions); } break; case CustomAction.ActionTypes.Bounce: { Bounce b = go.AddComponent <Bounce>(); b.includedTags = includedTags; b.excludedTags = excludedTags; float bounceHeight; float.TryParse(data4, out bounceHeight); b.bounceHeight = bounceHeight; ct.actions.Add(b); ct.directions.Add(directions); } break; default: break; } } break; case "TimeTrigger": { TimeTrigger tt = go.GetComponent <TimeTrigger>(); if (tt == null) { tt = go.AddComponent <TimeTrigger>(); } CustomAction.ActionTypes a = (CustomAction.ActionTypes)Enum.Parse(typeof(CustomAction.ActionTypes), data1); float time; float.TryParse(data2, out time); bool repeats = false; bool.TryParse(data3, out repeats); switch (a) { case CustomAction.ActionTypes.Spawn: { Spawn s = go.AddComponent <Spawn>(); string rfidKey = data4; if (database.ContainsKey(rfidKey)) { s.toSpawn = database[rfidKey].first; } else { string url = "http://" + databaseAddress + "/playtime/getComponents.php"; yield return(StartCoroutine(pollDatabase(url, rfidKey, false))); if (database.ContainsKey(rfidKey)) { s.toSpawn = database[rfidKey].first; } } int spawnCount = 0; Int32.TryParse(data5, out spawnCount); s.setMaxSpawnCount(spawnCount); tt.actions.Add(s); tt.originalTimes.Add(time); tt.repeats.Add(repeats); } break; case CustomAction.ActionTypes.Despawn: { Despawn d = go.AddComponent <Despawn>(); tt.actions.Add(d); tt.originalTimes.Add(time); tt.repeats.Add(repeats); } break; case CustomAction.ActionTypes.Transfigure: { Transfigure t = go.GetComponent <Transfigure>(); if (t == null) { t = go.AddComponent <Transfigure>(); } bool repeatable; Boolean.TryParse(data5, out repeatable); List <string> tags = new List <string>(); t.addTargetAnimControllerAndTags(data4, tags, tags, repeatable, tt.actions.Count); tt.actions.Add(t); tt.originalTimes.Add(time); tt.repeats.Add(repeats); } break; case CustomAction.ActionTypes.DespawnOther: { DespawnOther dOther = go.AddComponent <DespawnOther>(); tt.actions.Add(dOther); tt.originalTimes.Add(time); tt.repeats.Add(repeats); } break; case CustomAction.ActionTypes.RespawnOther: { RespawnOther rOther = go.AddComponent <RespawnOther>(); tt.actions.Add(rOther); tt.originalTimes.Add(time); tt.repeats.Add(repeats); } break; case CustomAction.ActionTypes.Damage: { Damage d = go.AddComponent <Damage>(); Int32.TryParse(data4, out d.dmg); tt.actions.Add(d); tt.originalTimes.Add(time); tt.repeats.Add(repeats); } break; } } break; case "DeathTrigger": { DeathTrigger dt = go.GetComponent <DeathTrigger>(); if (dt == null) { dt = go.AddComponent <DeathTrigger>(); } CustomAction.ActionTypes a = (CustomAction.ActionTypes)Enum.Parse(typeof(CustomAction.ActionTypes), data1); switch (a) { case CustomAction.ActionTypes.Spawn: { Spawn s = go.AddComponent <Spawn>(); string rfidKey = data2; if (database.ContainsKey(rfidKey)) { s.toSpawn = database[rfidKey].first; } else { string url = "http://" + databaseAddress + "/playtime/getComponents.php"; yield return(StartCoroutine(pollDatabase(url, rfidKey, false))); if (database.ContainsKey(rfidKey)) { s.toSpawn = database[rfidKey].first; } } int spawnCount = 0; Int32.TryParse(data3, out spawnCount); s.setMaxSpawnCount(spawnCount); s.spawnUnderParent = true; dt.actions.Add(s); } break; default: break; } } break; case "Invisible": { Invisible i = go.AddComponent <Invisible>(); i.reset(); } break; case "MoveHorizontalUntilCollision": { MoveHorizontalUntilCollision m = go.AddComponent <MoveHorizontalUntilCollision>(); List <String> ignoredTags; string[] delimiters = { "|" }; string[] tags = data1.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); ignoredTags = new List <string>(tags); m.tagsToIgnore = ignoredTags; } break; case "Spawn": { Spawn s = go.AddComponent <Spawn>(); string rfidKey = data1; if (database.ContainsKey(rfidKey)) { s.toSpawn = database[rfidKey].first; } else { string url = "http://" + databaseAddress + "/playtime/getComponents.php"; yield return(StartCoroutine(pollDatabase(url, rfidKey, false))); if (database.ContainsKey(rfidKey)) { s.toSpawn = database[rfidKey].first; } } int spawnCount = 0; int.TryParse(data2, out spawnCount); s.setMaxSpawnCount(spawnCount); } break; case "Despawn": { Despawn d = go.AddComponent <Despawn>(); int deathAnimID; int.TryParse(data1, out deathAnimID); d.deathAnimID = deathAnimID; d.defaultDeathAnimID = deathAnimID; } break; case "ChildObject": { string rfidKey = data1; GameObject child, staticChild; if (database.ContainsKey(rfidKey)) { child = database[rfidKey].first; staticChild = database[rfidKey].second; } else { string url = "http://" + databaseAddress + "/playtime/getComponents.php"; yield return(StartCoroutine(pollDatabase(url, rfidKey, false))); if (database.ContainsKey(rfidKey)) { child = database[rfidKey].first; staticChild = database[rfidKey].second; Vector2 offset = new Vector2(); float.TryParse(data2, out offset.x); float.TryParse(data3, out offset.y); child.transform.parent = go.transform; child.transform.localPosition = offset; child.SetActive(true); staticChild.transform.parent = staticGO.transform; staticChild.transform.localPosition = offset; staticChild.SetActive(true); } } } break; case "JumpAI": { go.AddComponent <JumpAI>(); } break; case "Chase": { go.AddComponent <Chase>(); } break; case "Shoot": { Shoot s = go.AddComponent <Shoot>(); string rfidKey = data1; if (database.ContainsKey(rfidKey)) { s.projectile = database[rfidKey].first; } else { string url = "http://" + databaseAddress + "/playtime/getComponents.php"; yield return(StartCoroutine(pollDatabase(url, rfidKey, false))); if (database.ContainsKey(rfidKey)) { s.projectile = database[rfidKey].first; } } float.TryParse(data2, out s.projectileSpeed); } break; case "Color": { ColorComponent c = go.AddComponent <ColorComponent>(); float.TryParse(data1, out c.r); float.TryParse(data2, out c.g); float.TryParse(data3, out c.b); float.TryParse(data4, out c.a); } break; default: print("Component " + name + " is undefined."); break; } }
/// <summary> /// Load the components required for this script. /// </summary> protected void Awake() { deathTrigger = GetComponent<DeathTrigger>(); }
/// <summary> /// Load all components required to run the time out logic. /// </summary> protected void Awake() { deathTrigger = GetComponent<DeathTrigger>(); deathTrigger.Initialize += Initialize; }
/// <summary> /// Load objects required components. /// </summary> protected void Awake() { animator = GetComponent<Animator>(); deathTrigger = GetComponent<DeathTrigger>(); movement = GetComponent<Movement>(); }
/// <summary> /// Load all components required for this script. /// </summary> protected void Awake() { deathTrigger = GetComponent<DeathTrigger>(); movement = GetComponent<Movement>(); }