diff options
Diffstat (limited to 'Client/Assembly-CSharp/WeaponsMinigame.cs')
-rw-r--r-- | Client/Assembly-CSharp/WeaponsMinigame.cs | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/WeaponsMinigame.cs b/Client/Assembly-CSharp/WeaponsMinigame.cs new file mode 100644 index 0000000..c6dc8f6 --- /dev/null +++ b/Client/Assembly-CSharp/WeaponsMinigame.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using UnityEngine; + +public class WeaponsMinigame : Minigame +{ + public FloatRange XSpan = new FloatRange(-1.15f, 1.15f); + + public FloatRange YSpan = new FloatRange(-1.15f, 1.15f); + + public FloatRange TimeToSpawn; + + public ObjectPoolBehavior asteroidPool; + + public TextController ScoreText; + + public SpriteRenderer TargetReticle; + + public LineRenderer TargetLines; + + private Vector3 TargetCenter; + + public Collider2D BackgroundCol; + + public SpriteRenderer Background; + + public Controller myController = new Controller(); + + private float Timer; + + public AudioClip ShootSound; + + public AudioClip[] ExplodeSounds; + + public override void Begin(PlayerTask task) + { + base.Begin(task); + this.ScoreText.Text = "Destroyed: " + this.MyNormTask.taskStep; + this.TimeToSpawn.Next(); + } + + protected override IEnumerator CoAnimateOpen() + { + for (float timer = 0f; timer < 0.1f; timer += Time.deltaTime) + { + float num = timer / 0.1f; + base.transform.localScale = new Vector3(num, 0.1f, num); + yield return null; + } + for (float timer = 0.010000001f; timer < 0.1f; timer += Time.deltaTime) + { + float y = timer / 0.1f; + base.transform.localScale = new Vector3(1f, y, 1f); + yield return null; + } + base.transform.localScale = new Vector3(1f, 1f, 1f); + yield break; + } + + protected override IEnumerator CoDestroySelf() + { + for (float timer = 0.010000001f; timer < 0.1f; timer += Time.deltaTime) + { + float y = 1f - timer / 0.1f; + base.transform.localScale = new Vector3(1f, y, 1f); + yield return null; + } + for (float timer = 0f; timer < 0.1f; timer += Time.deltaTime) + { + float num = 1f - timer / 0.1f; + base.transform.localScale = new Vector3(num, 0.1f, num); + yield return null; + } + UnityEngine.Object.Destroy(base.gameObject); + yield break; + } + + public void FixedUpdate() + { + this.Background.color = Color.Lerp(Palette.ClearWhite, Color.white, Mathf.Sin(Time.time * 3f) * 0.1f + 0.79999995f); + if (this.MyNormTask && this.MyNormTask.IsComplete) + { + return; + } + this.Timer += Time.fixedDeltaTime; + if (this.Timer >= this.TimeToSpawn.Last) + { + this.Timer = 0f; + this.TimeToSpawn.Next(); + if (this.asteroidPool.InUse < this.MyNormTask.MaxStep - this.MyNormTask.TaskStep) + { + Asteroid ast = this.asteroidPool.Get<Asteroid>(); + ast.transform.localPosition = new Vector3(this.XSpan.max, this.YSpan.Next(), -1f); + ast.TargetPosition = new Vector3(this.XSpan.min, this.YSpan.Next(), -1f); + ast.GetComponent<ButtonBehavior>().OnClick.AddListener(delegate() + { + this.BreakApart(ast); + }); + } + } + this.myController.Update(); + if (this.myController.CheckDrag(this.BackgroundCol, false) == DragState.TouchStart) + { + if (Constants.ShouldPlaySfx()) + { + SoundManager.Instance.PlaySound(this.ShootSound, false, 1f); + } + Vector3 vector = this.myController.DragPosition - base.transform.position; + vector.z = -2f; + this.TargetReticle.transform.localPosition = vector; + vector.z = 0f; + this.TargetLines.SetPosition(1, vector); + if (!ShipStatus.Instance.WeaponsImage.IsPlaying(null)) + { + ShipStatus.Instance.FireWeapon(); + PlayerControl.LocalPlayer.RpcPlayAnimation(6); + } + } + } + + public void BreakApart(Asteroid ast) + { + if (Constants.ShouldPlaySfx()) + { + SoundManager.Instance.PlaySound(this.ExplodeSounds.Random<AudioClip>(), false, 1f).pitch = FloatRange.Next(0.8f, 1.2f); + } + if (!this.MyNormTask.IsComplete) + { + base.StartCoroutine(ast.CoBreakApart()); + if (this.MyNormTask) + { + this.MyNormTask.NextStep(); + this.ScoreText.Text = "Destroyed: " + this.MyNormTask.taskStep; + } + if (this.MyNormTask && this.MyNormTask.IsComplete) + { + base.StartCoroutine(base.CoStartClose(0.75f)); + foreach (PoolableBehavior poolableBehavior in this.asteroidPool.activeChildren) + { + Asteroid asteroid = (Asteroid)poolableBehavior; + if (!(asteroid == ast)) + { + base.StartCoroutine(asteroid.CoBreakApart()); + } + } + } + } + } +} |