private void RandomWanderTarget() { if (m_triggerableAI.GetTriggerArea() != null) { Collider2D triggerArea = m_triggerableAI.GetTriggerArea().GetComponent <Collider2D>(); m_wanderTarget = triggerArea.bounds.center; m_wanderTarget += MathsHelper.RandomWithNegativeVector2() * triggerArea.bounds.extents; } }
private void SpinAttackState() { if (m_timeInState == 0.0f) { m_audio.TriggerSpin(); } Vector2 targetPosition = m_triggerableAI.GetTriggerArea().transform.position; Vector2 myPosition = transform.position; if ((myPosition - targetPosition).magnitude > 1.0f) { m_movement.SetSpeed(m_spinAttackMovementSpeed); m_movement.MoveToTarget(targetPosition); } bool readyToEnd = false; transform.Rotate(new Vector3(0, 0, 1) * m_spinAttackRotationSpeed * m_spinAttackStageRotationSpeedMod * m_stage * Time.deltaTime); if (m_timeInState > m_spinAttackDuration * (m_spinAttackStageDurationMod * m_stage)) { if (Mathf.Abs(transform.eulerAngles.z) < 5.0f) { transform.eulerAngles = new Vector3(0, 0, 0); readyToEnd = true; } } m_timeSinceLastShot += Time.deltaTime; if (m_timeInState > m_spinAttackWindup) { float attackRate = 1 / (m_spinAttackSpeed * m_stage * m_spinAttackStageSpeedMod); if (m_timeSinceLastShot > attackRate) { m_shooting.Shoot(transform.up * m_spinAttackBulletSpeed, 1); m_shooting.Shoot(-transform.up * m_spinAttackBulletSpeed, 1); m_shooting.Shoot(transform.right * m_spinAttackBulletSpeed, 1); m_shooting.Shoot(-transform.right * m_spinAttackBulletSpeed, 1); m_timeSinceLastShot = 0.0f; } } if (readyToEnd) { ChooseNextState(); } }