-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBossKillerPlayerScript.cs
More file actions
110 lines (90 loc) · 3.05 KB
/
BossKillerPlayerScript.cs
File metadata and controls
110 lines (90 loc) · 3.05 KB
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
using UnityEngine;
using System.Collections;
using System;
using UnityEngine.Events;
public class BossKillerPlayerScript : MonoBehaviour
{
[SerializeField] private float speed = 5f;
private float moveDirection = 0f; // -1 for left, 1 for right
private Rigidbody2D rb;
private Animator anim;
[SerializeField] private float movementTime = 1f;
private PolygonCollider2D batCollider;
public float hitForce = 1f;
public bool isDead = false;
private BossLevelManager bossLevelManager;
[SerializeField] private float hitForceMultiplier = 1.8f;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
batCollider = GetComponentInChildren<PolygonCollider2D>();
batCollider.enabled = false;
bossLevelManager = FindObjectOfType<BossLevelManager>();
EnableTotems();
}
private void Update()
{
rb.velocity = new Vector2(moveDirection * speed, rb.velocity.y);
}
public void SetDirection(float direction)
{
moveDirection = direction;
}
private void StopPlayer()
{
moveDirection = 0f;
}
public void MovePlayerMethod(float direction)
{
StartCoroutine(MovePlayer(direction));
}
private IEnumerator MovePlayer(float direction)
{
SetDirection(direction);
yield return new WaitForSeconds(movementTime);
StopPlayer();
}
public void HitTheProjectile()
{
batCollider.enabled = true;
anim.SetTrigger("BossHit");
}
public void DisableCollider()
{
batCollider.enabled = false;
}
private void EnableTotems()
{
int totemAmount = Enum.GetValues(typeof(TotemScript.TotemType)).Length;
for (int i = 0; i < totemAmount; i++)
{
if(PlayerPrefs.GetInt($"isPurchased{((TotemScript.TotemType)i).ToString()}", 0) == 1)
{
switch ((TotemScript.TotemType)i)
{
case TotemScript.TotemType.Power:
hitForce *= hitForceMultiplier;
Debug.Log("Power totem enabled");
break;
case TotemScript.TotemType.Accuracy:
//Projectile.targetPosAfterReverse = blm.currentBoss.transform.position;
Debug.Log("Accuracy totem enabled");
break;
case TotemScript.TotemType.Money:
GameManager.Instance.extraRewardAmount = GameManager.Instance.currentBossLevelData.rewardAmount/2;
Debug.Log("Money totem enabled");
break;
default:
GameManager.Instance.extraRewardAmount = 0f;
hitForce = 1f;
break;
}
}
}
}
private void OnDestroy()
{
isDead = true;
}
}