public void Tick() { dashTimer += Time.deltaTime; if (dashTimer <= _sheep.DashChargeTime) { _rb.velocity = new Vector2(0f, 0f); } else if ((dashTimer > _sheep.DashChargeTime) && (dashTimer <= _sheep.DashChargeTime + _sheep.DashTime)) { CinemachineImpulseManager.Play("Weak Impulse"); if (!hasDashed) { AudioManager.Instance.Play("Stampede"); _sheep.StartCoroutine(_sheep.SpawnDashTrail()); attackDirection = (GameManager.GetMainPlayerRb().position - _rb.position).normalized; hasDashed = true; _sheep.dashHitboxActive = true; _rb.velocity = _sheep.DashSpeed * attackDirection; } } else if (dashTimer > _sheep.DashChargeTime + _sheep.DashTime) // If done charging and dashing { AudioManager.Instance.Stop("Stampede"); _sheep.isDashing = false; _sheep.dashHitboxActive = false; if (_sheep.curPhase == 1) { _sheep.nextState = SheepBossStatesEnum.SheepProjectiling; // Transition into projectile after dashing } } }
void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
public void OnEnter() { _sheep.curPhase = 2; // Transition to phase 2 _sheep.angryVeinParticle.SetActive(true); AudioManager.Instance.Play("SheepAngry"); CinemachineImpulseManager.Play("Extra Strong Impulse"); _sheep.ChangeColorToRed(); _sheep.nextState = SheepBossStatesEnum.SheepLaunchingExplodingSheep; }
// Checks if player is invulnerable. If not, reduces health by damageAmount. public void TakeDamage(int damageAmount) { if (Time.time - prevDamageTime > DamageInvulnDuration) // checking if invulnerability time is up { AudioManager.Instance.PlayPitch("Hurt", UnityEngine.Random.Range(1.5f, 2f)); CinemachineImpulseManager.Play("Strong Impulse"); WhiteFlashManager.FlashWhite(gameObject); prevDamageTime = Time.time; health -= damageAmount; } if (health < 0) { health = 0; } }
protected override void Die() { isDead = true; ChangeColorToWhite(); StartCoroutine(SpawnDashTrail()); AudioManager.Instance.Play("SheepAngry"); AudioManager.Instance.Stop("Stampede"); CinemachineImpulseManager.Play("Extra Strong Impulse"); _animator.SetTrigger("die"); _rb.velocity = new Vector2(0f, 0f); GetComponent <Collider2D>().enabled = false; // disable collisions woolBallParticle.SetActive(true); angryVeinParticle.SetActive(false); Destroy(transform.GetChild(0).gameObject); // Destroy healthbar GameManager.GetMainPlayer().GetComponent <Collider2D>().enabled = false; // Disable player hitbox UIManager.Instance.Invoke("ActivateVictoryScreen", 5f); }
void DrawSpreadGraph(Rect rect, float spread) { // Resample if necessary if (m_SpreadGraphSize != rect.size) { m_SpreadGraphSize = rect.size; for (int i = 0; i <= kNumSamples >> 1; ++i) { var x = (float)i / kNumSamples; var y = CinemachineImpulseManager.EvaluateDissipationScale(spread, Mathf.Abs(1 - x * 2)); m_SpreadGraphSnapshot[i] = new Vector2(x * rect.width, rect.height * (1 - y)); m_SpreadGraphSnapshot[kNumSamples - i] = new Vector2((1 - x) * rect.width, rect.height * (1 - y)); } } EditorGUI.DrawRect(rect, new Color(0.2f, 0.2f, 0.2f, 1)); var oldMatrix = Handles.matrix; Handles.matrix = Handles.matrix * Matrix4x4.Translate(rect.position); Handles.color = new Color(0, 0, 0, 1); Handles.DrawLine(new Vector3(rect.width * 0.5f, 0, 0), new Vector3(rect.width * 0.5f, rect.height, 0)); Handles.color = new Color(0, 0.6f, 1, 1); Handles.DrawPolyLine(m_SpreadGraphSnapshot); Handles.matrix = oldMatrix; }
public void Tick() { attackTimer += Time.deltaTime; if (attackTimer <= _sheep.ScatterProjectileChargeTime) { _rb.velocity = new Vector2(0f, 0f); } else if (attackTimer > _sheep.ScatterProjectileChargeTime && attackTimer <= _sheep.ScatterProjectileAnimationTime) { if (!hasFired) { CinemachineImpulseManager.Play("Strong Impulse"); AudioManager.Instance.PlayPitch("Sheep1", 1f); hasFired = true; _sheep.LaunchProjectilesScatter(); } } else if (attackTimer > _sheep.ScatterProjectileAnimationTime) // Once animation has ended, exit this state { _sheep.isProjectiling = false; } }
private void Awake() { CinemachineImpulseManager.Play("Weak Impulse"); AudioManager.Instance.PlayOneShot("Explosion"); ps = GetComponent <ParticleSystem>(); }