-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.cs
375 lines (328 loc) · 9.65 KB
/
Player.cs
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
using System;
using UnityEngine;
using UnityEngine.SceneManagement;
// Token: 0x020001C6 RID: 454
public class Player : MonoBehaviour
{
// Token: 0x06000978 RID: 2424 RVA: 0x0003139C File Offset: 0x0002F59C
private void Start()
{
this._rb = base.GetComponent<Rigidbody2D>();
this._animator = base.GetComponent<Animator>();
this._gameManager = GameManager.instance;
if (this._gameManager.lastCheckpoint != Vector3.zero)
{
base.transform.position = this._gameManager.lastCheckpoint;
}
}
// Token: 0x06000979 RID: 2425 RVA: 0x000313FC File Offset: 0x0002F5FC
private void Update()
{
this.TIMEROBJ = GameObject.Find("TimerController");
this.TheTC = this.TIMEROBJ.GetComponent<TimerController>();
if (this.isDisabled)
{
return;
}
if (Input.GetKeyDown(KeyCode.R) && this._allowRestart)
{
this._gameManager.AddRestart();
this._gameManager.RemoveDeath();
this.Die();
}
this.FlipPlayer();
this.Attack();
this.ControlCoyoteTime();
this.Jump();
this._isGrounded = this.IsGrounded();
Vector3 position = this._rb.transform.position;
this.posx = position.x.ToString();
position = this._rb.transform.position;
this.posy = position.y.ToString();
this.GMObject = GameObject.Find("GameManager");
this.GMScript = this.GMObject.GetComponent<GameManager>();
if (Input.GetKeyDown(KeyCode.F1))
{
this.GMScript.ResetValues();
this.GMScript.lastCameraPosition = new Vector3(0f, 0f, -10f);
this._rb.transform.position = new Vector2(-9.5f, -3f);
this._rb.position = new Vector2(-9.5f, -3f);
this.GMScript.SetLastCheckpoint(this._rb.transform.position);
this.GMScript.checkpointNumber = 0;
if (this.TheTC.timerGoing && this.TheTC.hasWatchedCutscene && this.TheTC.elapsedTime > 0f)
{
this.TheTC.timerGoing = false;
this.TheTC.elapsedTime = 0f;
}
this.TheTC.AwakeGiven = false;
this.TheTC.BLGiven = false;
this.TheTC.PuppetGiven = false;
this.TheTC.PsychoGiven = false;
this.TheTC.ILGiven = false;
this.TheTC.EndingCount = 0;
AudioManager.instance.StopAllMusic();
SceneManager.LoadScene("MainMenu");
}
if (Input.GetKeyDown(KeyCode.F4))
{
this.GMScript.ResetValues();
this.GMScript.lastCameraPosition = new Vector3(0f, 0f, -10f);
this._rb.transform.position = new Vector2(-9.5f, -3f);
this._rb.position = new Vector2(-9.5f, -3f);
this.GMScript.SetLastCheckpoint(this._rb.transform.position);
this.GMScript.checkpointNumber = 0;
if (this.TheTC.timerGoing && this.TheTC.hasWatchedCutscene && this.TheTC.elapsedTime > 0f)
{
this.TheTC.timerGoing = false;
this.TheTC.elapsedTime = 0f;
}
this.TheTC.countingEnabled = true;
this.TheTC.AwakeGiven = false;
this.TheTC.BLGiven = false;
this.TheTC.PuppetGiven = false;
this.TheTC.PsychoGiven = false;
this.TheTC.ILGiven = false;
this.TheTC.EndingCount = 0;
AudioManager.instance.StopAllMusic();
SceneManager.LoadScene("MainMenu");
}
}
// Token: 0x0600097A RID: 2426 RVA: 0x0000F833 File Offset: 0x0000DA33
private void FixedUpdate()
{
this.Movement();
}
// Token: 0x0600097B RID: 2427 RVA: 0x0003177C File Offset: 0x0002F97C
private void Movement()
{
if (this._canMove)
{
float num = Input.GetAxisRaw("Horizontal") * this._speed * Time.deltaTime;
this._rb.velocity = new Vector2(num, this._rb.velocity.y);
this._animator.SetInteger("xSpeed", Mathf.FloorToInt(Mathf.Abs(num)));
this._animator.SetFloat("ySpeed", this._rb.velocity.y);
}
}
// Token: 0x0600097C RID: 2428 RVA: 0x00031808 File Offset: 0x0002FA08
private void FlipPlayer()
{
if (this._rb.velocity.x < 0f && !this._isFlipped)
{
this._isFlipped = true;
this._newScale.x = -1f;
}
else if (this._rb.velocity.x > 0f && this._isFlipped)
{
this._isFlipped = false;
this._newScale.x = 1f;
}
base.transform.localScale = this._newScale;
}
// Token: 0x0600097D RID: 2429 RVA: 0x00031894 File Offset: 0x0002FA94
private void ControlCoyoteTime()
{
if (this.IsGrounded())
{
if (this._groundCheckEnabled)
{
this._coyoteTime = this._maxCoyoteTime;
this._animator.SetBool("Jumping", false);
this._isFalling = false;
}
}
else
{
this._coyoteTime -= Time.deltaTime;
this._animator.SetBool("Jumping", true);
}
if (!this._groundCheckEnabled)
{
this._groundCheckTimer -= Time.deltaTime * 3f;
if (this._groundCheckTimer < 0f)
{
this._groundCheckEnabled = true;
this._groundCheckTimer = 1f;
}
}
}
// Token: 0x0600097E RID: 2430 RVA: 0x0003193C File Offset: 0x0002FB3C
private void Jump()
{
if (Input.GetButtonDown("Jump") && this._coyoteTime > 0f && this._canJump)
{
this._canJump = false;
this._groundCheckEnabled = false;
this._hasHitFloor = false;
this._rb.gravityScale = 2f;
this._coyoteTime = -10000f;
this._rb.velocity = new Vector2(this._rb.velocity.x, this._jumpForce * Time.fixedDeltaTime);
AudioManager.instance.PlaySound("PlayerJump");
}
if (Input.GetButtonUp("Jump") || this._rb.velocity.y < 0f)
{
if (this._rb.velocity.y > 0f)
{
this._rb.velocity = new Vector2(this._rb.velocity.x, this._rb.velocity.y * this._fallForce);
}
this._rb.gravityScale = 4f;
this._canJump = true;
this._isFalling = true;
}
}
// Token: 0x0600097F RID: 2431 RVA: 0x0000F83B File Offset: 0x0000DA3B
private bool IsGrounded()
{
return Physics2D.OverlapBox(this._groundCheck.position, this._groundCheckSize, 0f, LayerMask.GetMask(new string[]
{
"Ground"
}));
}
// Token: 0x06000980 RID: 2432 RVA: 0x00031A68 File Offset: 0x0002FC68
private void Attack()
{
if ((Input.GetKeyDown(KeyCode.F) || Input.GetKeyDown(KeyCode.J) || Input.GetMouseButtonDown(0)) && this._canAttack && this.IsGrounded())
{
this._canJump = false;
this._canAttack = false;
this._canMove = false;
this._animator.SetTrigger("Attack");
AudioManager.instance.PlaySound("PlayerAttack");
this._rb.velocity = new Vector2(0f, 0f);
}
}
// Token: 0x06000981 RID: 2433 RVA: 0x0000F875 File Offset: 0x0000DA75
public void FinishAttack()
{
this._canMove = true;
this._canAttack = true;
this._canJump = true;
}
// Token: 0x06000982 RID: 2434 RVA: 0x0000F88C File Offset: 0x0000DA8C
public void SetCheckpoint(Vector3 newCheckpoint)
{
this._checkpoint = newCheckpoint;
}
// Token: 0x06000983 RID: 2435 RVA: 0x00031AF0 File Offset: 0x0002FCF0
public void Die()
{
AudioManager.instance.PlaySound("PlayerHurt2");
this._gameManager.PreviousValues();
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
this._gameManager.AddDeath();
}
// Token: 0x06000984 RID: 2436 RVA: 0x0000F89A File Offset: 0x0000DA9A
public void Step()
{
this._stepParticle.Play();
AudioManager.instance.PlaySound("PlayerLand");
}
// Token: 0x06000985 RID: 2437 RVA: 0x0000F8B6 File Offset: 0x0000DAB6
public void DisablePlayer()
{
this._speed = 0f;
this._canMove = false;
this.isDisabled = true;
}
// Token: 0x06000986 RID: 2438 RVA: 0x00031B34 File Offset: 0x0002FD34
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Checkpoint"))
{
this._gameManager.SetLastCheckpoint(other.transform.position);
UnityEngine.Object.Destroy(other.gameObject);
}
if (other.CompareTag("DeathCollision"))
{
this.Die();
}
}
// Token: 0x06000987 RID: 2439 RVA: 0x0000F8D1 File Offset: 0x0000DAD1
private void OnCollisionEnter2D(Collision2D other)
{
if (this._isFalling)
{
this.Step();
}
}
// Token: 0x06000988 RID: 2440 RVA: 0x0000F8E1 File Offset: 0x0000DAE1
private void OnDrawGizmosSelected()
{
Gizmos.DrawWireCube(this._groundCheck.position, this._groundCheckSize);
}
// Token: 0x04000B8F RID: 2959
public float _speed;
// Token: 0x04000B90 RID: 2960
[SerializeField]
private float _jumpForce;
// Token: 0x04000B91 RID: 2961
[SerializeField]
[Range(0f, 1f)]
private float _fallForce;
// Token: 0x04000B92 RID: 2962
[SerializeField]
private float _coyoteTime;
// Token: 0x04000B93 RID: 2963
[SerializeField]
private float _maxCoyoteTime = 1f;
// Token: 0x04000B94 RID: 2964
[SerializeField]
private float _groundCheckTimer = 1f;
// Token: 0x04000B95 RID: 2965
[SerializeField]
private ParticleSystem _stepParticle;
// Token: 0x04000B96 RID: 2966
[SerializeField]
private Transform _groundCheck;
// Token: 0x04000B97 RID: 2967
[SerializeField]
private Vector2 _groundCheckSize;
// Token: 0x04000B98 RID: 2968
public bool _canMove = true;
// Token: 0x04000B99 RID: 2969
public bool isDisabled;
// Token: 0x04000B9A RID: 2970
public bool _allowRestart = true;
// Token: 0x04000B9B RID: 2971
[SerializeField]
private bool _isGrounded;
// Token: 0x04000B9C RID: 2972
[SerializeField]
private bool _groundCheckEnabled = true;
// Token: 0x04000B9D RID: 2973
[SerializeField]
private bool _canAttack = true;
// Token: 0x04000B9E RID: 2974
[SerializeField]
private bool _canJump = true;
// Token: 0x04000B9F RID: 2975
[SerializeField]
private bool _hasHitFloor = true;
// Token: 0x04000BA0 RID: 2976
[SerializeField]
private bool _isFlipped;
// Token: 0x04000BA1 RID: 2977
[SerializeField]
private bool _isFalling;
// Token: 0x04000BA2 RID: 2978
private Vector3 _newScale = Vector3.one;
// Token: 0x04000BA3 RID: 2979
private Vector2 _checkpoint;
// Token: 0x04000BA4 RID: 2980
private Rigidbody2D _rb;
// Token: 0x04000BA5 RID: 2981
private Animator _animator;
// Token: 0x04000BA6 RID: 2982
private GameManager _gameManager;
// Token: 0x04000BA7 RID: 2983
public GameManager GMScript;
// Token: 0x04000BA8 RID: 2984
public GameObject GMObject;
// Token: 0x04000BA9 RID: 2985
public string posx;
// Token: 0x04000BAA RID: 2986
public string posy;
// Token: 0x04000BAB RID: 2987
public TimerController TheTC;
// Token: 0x04000BAC RID: 2988
public GameObject TIMEROBJ;
}