Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using BigOppai;
- public class InterpolatorSequence : FiringSequence
- {
- public int numberOfSpots = 4;
- public int bulletPerSpot = 5;
- public float spotOpening = 2;
- public float duration = 1f;
- public int layers = 3;
- [ReadOnly]
- public int framesPerLayer;
- public bool redirect = false;
- public bool aimPlayer = true;
- public float startingAngle;
- private InterpolatorGun interpolatorGun;
- public override void SetupBoss(BossBase boss) {
- base.SetupBoss(boss);
- totalDurationOfSequence = duration;
- numberOfSpots = DiffAdj.NSpots(numberOfSpots);
- layers = DiffAdj.NSpots(layers);
- interpolatorGun = (InterpolatorGun)gun;
- }
- protected override void OnValidate() {
- base.OnValidate();
- int totalFrames = Mathf.CeilToInt(60f * duration);
- if (layers > 0) {
- framesPerLayer = totalFrames / layers;
- duration = (float)layers * framesPerLayer / 60f;
- }
- }
- protected override IEnumerator Sequence() {
- float secondsToWait = 0;
- float baseAngle = startingAngle;
- if (aimPlayer) {
- baseAngle += GetAngleToPlayerRadians() - Mathf.PI + (numberOfSpots % 2) * Mathf.PI * 2 / numberOfSpots / 2f;
- }
- for (int l = 0; l < layers; l++) {
- if (redirect) {
- baseAngle = GetAngleToPlayerRadians() + Mathf.Sin(l * Mathf.PI * 2f / 5f) * Mathf.PI / 4f + startingAngle;
- }
- float timeLastWait = Time.time;
- for (int i = 0; i < numberOfSpots; i++) {
- float angle = baseAngle + i * Mathf.PI * 2f / numberOfSpots;
- for (int j = 0; j < bulletPerSpot; j++) {
- float opening = 0 + spotOpening / (bulletPerSpot - 1) * (j - Mathf.Max(1, bulletPerSpot - 1) / 2f);
- interpolatorGun.Shoot(Mathf.Cos(angle), Mathf.Sin(angle), opening);
- }
- }
- secondsToWait += duration / layers;
- if (secondsToWait >= 1f / 60f) {
- yield return new WaitForSeconds(secondsToWait);
- secondsToWait -= Time.time - timeLastWait;
- }
- }
- EndSequence();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement