Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.32 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3.  
  4. using UnityEngine;
  5. using BigOppai;
  6.  
  7. public class InterpolatorSequence : FiringSequence
  8. {
  9.  
  10.     public int numberOfSpots = 4;
  11.     public int bulletPerSpot = 5;
  12.     public float spotOpening = 2;
  13.     public float duration = 1f;
  14.     public int layers = 3;
  15.  
  16.     [ReadOnly]
  17.     public int framesPerLayer;
  18.  
  19.     public bool redirect = false;
  20.     public bool aimPlayer = true;
  21.     public float startingAngle;
  22.  
  23.     private InterpolatorGun interpolatorGun;
  24.  
  25.     public override void SetupBoss(BossBase boss) {
  26.         base.SetupBoss(boss);
  27.         totalDurationOfSequence = duration;
  28.         numberOfSpots = DiffAdj.NSpots(numberOfSpots);
  29.         layers = DiffAdj.NSpots(layers);
  30.         interpolatorGun = (InterpolatorGun)gun;
  31.     }
  32.  
  33.     protected override void OnValidate() {
  34.         base.OnValidate();
  35.         int totalFrames = Mathf.CeilToInt(60f * duration);
  36.         if (layers > 0) {
  37.             framesPerLayer = totalFrames / layers;
  38.             duration = (float)layers * framesPerLayer / 60f;
  39.         }
  40.     }
  41.  
  42.     protected override IEnumerator Sequence() {
  43.         float secondsToWait = 0;
  44.         float baseAngle = startingAngle;
  45.         if (aimPlayer) {
  46.             baseAngle += GetAngleToPlayerRadians() - Mathf.PI + (numberOfSpots % 2) * Mathf.PI * 2 / numberOfSpots / 2f;
  47.         }
  48.  
  49.  
  50.         for (int l = 0; l < layers; l++) {
  51.             if (redirect) {
  52.                 baseAngle = GetAngleToPlayerRadians() + Mathf.Sin(l * Mathf.PI * 2f / 5f) * Mathf.PI / 4f + startingAngle;
  53.             }
  54.             float timeLastWait = Time.time;
  55.  
  56.             for (int i = 0; i < numberOfSpots; i++) {
  57.                 float angle = baseAngle + i * Mathf.PI * 2f / numberOfSpots;
  58.                 for (int j = 0; j < bulletPerSpot; j++) {
  59.                     float opening = 0 + spotOpening / (bulletPerSpot - 1) * (j - Mathf.Max(1, bulletPerSpot - 1) / 2f);
  60.                     interpolatorGun.Shoot(Mathf.Cos(angle), Mathf.Sin(angle), opening);
  61.                 }
  62.  
  63.             }
  64.             secondsToWait += duration / layers;
  65.             if (secondsToWait >= 1f / 60f) {
  66.                 yield return new WaitForSeconds(secondsToWait);
  67.                 secondsToWait -= Time.time - timeLastWait;
  68.             }
  69.         }
  70.         EndSequence();
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement