1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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());
}
}
}
}
}
}
|