void OnTriggerStay2D(Collider2D col) { if (col.gameObject.tag == "FlyingFlame" && (CurrentState & (FLAG_STATE_SLIDE | FLAG_STATE_DIE | FLAG_STATE_FADE | FLAG_STATE_FADE_SLASH)) == 0) { AudioUtils.GetInstance().StopSound(audioSource); killedBy = KilledBy.FlyingFlame; dieCommand.execute(); InputQueue.Clear(); } if (col.gameObject.tag == "FireBall" && (CurrentState & (FLAG_STATE_DIE | FLAG_STATE_FADE | FLAG_STATE_FADE_SLASH)) == 0) { var fire = ObjectPool.Instance.GetPrefabsByName("Fire") as GameObject; fire.SetActive(true); var pos = Vector2.zero; pos.y = -0.5f; pos.x = -0.5f; fire.transform.position = pos; fire.transform.SetParent(transform, false); AudioUtils.GetInstance().StopSound(audioSource); killedBy = KilledBy.Wizard; dieCommand.execute(); InputQueue.Clear(); } }
public void Kill(KilledBy reason) { if (isAlive) { anim.SetTrigger("Kill"); GetComponent <CapsuleCollider2D>().size = new Vector2(0.1f, 0.1f); } isAlive = false; }
void OnCollisionStay2D(Collision2D col) { bool hittedEnemy = DidHitEnemy(col); int hittedWall = DidHitWall(col); int avoidState = FLAG_STATE_DIE | FLAG_STATE_FALL_DIE | FLAG_STATE_FADE | FLAG_STATE_FADE_SLASH; if ((hittedWall > 0 || hittedEnemy) && (CurrentState & (avoidState)) == 0) { if (CurrentState == FLAG_STATE_RUN && hittedWall > 0) { killedBy = KilledBy.Wall; rigidbody.AddForce(new Vector2(-125f, 25.0f)); } else if (CurrentState == FLAG_STATE_JUMP && hittedWall == 2) { killedBy = KilledBy.Slip; rigidbody.AddForce(new Vector2(125f, 250f)); rigidbody.freezeRotation = false; rigidbody.gravityScale = 2; rigidbody.angularVelocity = -360; animator.SetTrigger("shouldFallDie"); } else if (CurrentState == FLAG_STATE_JUMP && hittedWall == 1) { killedBy = KilledBy.Wall; rigidbody.AddForce(new Vector2(-125f, 0.0f)); } else { killedBy = KilledBy.Mummy; rigidbody.AddForce(new Vector2(-125f, 25.0f)); } var utils = AudioUtils.GetInstance(); utils.StopSound(audioSource); utils.PlayOnce(audioSource, "hit6"); dieCommand.execute(); InputQueue.Clear(); } }
public EnhancedScoreEntry(ScoreEntry scoreEntry) : base(scoreEntry.Score, scoreEntry.Description, scoreEntry.Details) { if ((scoreEntry == null) || (string.IsNullOrEmpty(scoreEntry.Details))) { return; } CopyFields(scoreEntry); var details = scoreEntry.Details.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); int line = 0; int posGsf = details[line].IndexOf("Game summary for"); if (posGsf > 0) { Version = "0"; } try { // Get Character Name var charLine = details[line].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); var charLine2 = charLine.Skip(1).Take(charLine.Length - 2); CharacterName = string.Join(" ", charLine2.Skip(3)); // Get Date of death line++; string date = details[line].Substring(details[line].IndexOf(",") + 2); string time = date.Substring(date.IndexOf("at") + 3, date.Length - date.IndexOf("at") - 4); date = date.Substring(0, date.IndexOf("at") - 1); DateTime deathDate; if (!DateTime.TryParseExact(date + " " + time, "dd MMMM yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out deathDate)) { if (!DateTime.TryParseExact(date + " " + time, "MMMM dd, yyyy h:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out deathDate)) { deathDate = DateTime.MinValue; } } DeathDate = deathDate; // get cause of death line++; int posKb = details[line].IndexOf(" by "); string kb = ""; if (posKb > -1) { // killed by kb = details[line].Substring(posKb + 4); if (kb.StartsWith("a ")) { kb = kb.Substring(2, kb.Length - 2); } if (kb.StartsWith("an ")) { kb = kb.Substring(3, kb.Length - 3); } } else { // from ? int posFrom = details[line].IndexOf(" from "); if (posFrom > -1) { kb = details[line].Substring(posFrom + 6); if (kb.StartsWith("a ")) { kb = kb.Substring(2, kb.Length - 2); } if (kb.StartsWith("an ")) { kb = kb.Substring(3, kb.Length - 3); } } else { if (details[line].StartsWith("You were")) { kb = details[line].Substring(9); } else { if (details[line].StartsWith("You ")) { kb = details[line].Substring(4); } } } } if (kb.EndsWith(".")) { kb = kb.Remove(kb.Length - 1); } KilledBy = ColorUtility.StripFormatting(RemoveEffect(kb)).Trim(); Abandoned = KilledBy.StartsWith("abandoned"); // get Level line++; var elts = details[line].Split(' '); Regex rgx = new Regex("[^0-9]"); string lvl = rgx.Replace(elts[3], ""); Level = int.Parse(lvl); // get Turns line++; line++; elts = details[line].Split(' '); string turns = rgx.Replace(elts[2], ""); Turns = int.Parse(turns); } catch (Exception ex) { Utilities.Logger.Log($"(Error) Unexpected issue parsing High Score entry [{ex}]"); } }
void FixedUpdate() { CurrentState = GetCurrentState(); grounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, groundLayer); isOnFire = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, fireLayer); if (isOnFire && (CurrentState & (FLAG_STATE_DIE | FLAG_STATE_FADE | FLAG_STATE_FADE_SLASH)) == 0) { AudioUtils.GetInstance().StopSound(audioSource); killedBy = KilledBy.Fire; InputQueue.Clear(); dieCommand.execute(); } if (CurrentState == FLAG_STATE_RUN) { animator.speed = bonusSpeed; } else { animator.speed = 1; } if (!grounded && (CurrentState & (FLAG_STATE_JUMP | FLAG_STATE_DIE | FLAG_STATE_FADE | FLAG_STATE_FADE_SLASH)) == 0) { animator.SetTrigger("shouldJump"); AudioUtils.GetInstance().StopSound(audioSource); } else if (grounded && CurrentState == FLAG_STATE_JUMP) { animator.SetTrigger("shouldRun"); } else if (grounded && CurrentState == FLAG_STATE_RUN) { if (!audioSource.isPlaying || audioSource.clip != AudioUtils.GetInstance().LoadClip("footstep")) { audioSource.pitch = 1.5f * bonusSpeed; audioSource.volume = 0.11f * Time.timeScale; AudioUtils.GetInstance().PlayLoop(audioSource, "footstep"); } } else if (grounded && (CurrentState & (FLAG_STATE_RUN | FLAG_STATE_DIE | FLAG_STATE_SLASH | FLAG_STATE_FADE_SLASH)) == 0) { AudioUtils.GetInstance().StopSound(audioSource); } if (CurrentState == FLAG_STATE_SLIDE && GetComponent <BoxCollider2D> ().enabled) { GetComponent <BoxCollider2D> ().enabled = false; } else if ((CurrentState & FLAG_STATE_SLIDE) == 0 && !GetComponent <BoxCollider2D> ().enabled) { GetComponent <BoxCollider2D> ().enabled = true; } HandleInput(); MovePlayer(); }
public void Kill(KilledBy reason) { _energy = 0; isAlive = false; LooseAllBabies(); }