-
Notifications
You must be signed in to change notification settings - Fork 0
/
CurrencyManager.cs
114 lines (94 loc) · 4.09 KB
/
CurrencyManager.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class CurrencyManager : MonoBehaviour
{
public TMP_Text laughsText;
public int laughsCurrency;
public GameObject upgradePanel;
public TMP_Text micUpgradeText;
public TMP_Text chairUpgradeText;
public TMP_Text shoesUpgradeText;
private int micUpgradeCost;
private int chairUpgradeCost;
private int shoesUpgradeCost;
private Vector3[] chairGrid = new Vector3[6];
public GameObject chair;
public bool isUpgradePhase;
private int micUpgraded;
private int chairUpgraded;
private int shoesUpgraded;
DayManager dayScript;
Player playerScript;
MicrophoneMinigame microphoneScript;
void Start() {
laughsCurrency = 0;
micUpgradeCost = 3;
chairUpgradeCost = 4;
shoesUpgradeCost = 7;
isUpgradePhase = false;
micUpgraded = 0;
chairUpgraded = 0;
shoesUpgraded = 0;
dayScript = GameObject.FindGameObjectWithTag("GameManager").GetComponent<DayManager>();
playerScript = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
microphoneScript = GameObject.FindGameObjectWithTag("Microphone").GetComponent<MicrophoneMinigame>();
createChairArray();
}
private void Update() {
laughsText.text = "Laughs: " + laughsCurrency;
if (Input.GetKeyUp("z") && laughsCurrency >= micUpgradeCost && isUpgradePhase && micUpgraded < 3) { // upgrade mic
micUpgraded++;
laughsCurrency = laughsCurrency - micUpgradeCost;
micUpgradeCost = micUpgradeCost + 3;
if (micUpgraded < 3) {
micUpgradeText.text = "press 'Z' to upgrade laughs per joke | " + micUpgradeCost + " Laughs";
} else {
micUpgradeText.text = "MAX UPGRADE";
}
microphoneScript.happinessIncreaser++;
} else if (Input.GetKeyUp("c") && laughsCurrency >= chairUpgradeCost && isUpgradePhase && chairUpgraded < 5) { // upgrade chairs
chairUpgraded++;
laughsCurrency = laughsCurrency - chairUpgradeCost;
chairUpgradeCost = chairUpgradeCost + 2;
if (chairUpgraded < 5) {
chairUpgradeText.text = "press 'C' to add another chair | "+chairUpgradeCost+" Laughs";
} else {
chairUpgradeText.text = "MAX UPGRADE";
}
Instantiate(chair, chairGrid[chairUpgraded], Quaternion.identity);
} else if (Input.GetKeyUp("v") && laughsCurrency >= shoesUpgradeCost && isUpgradePhase && shoesUpgraded < 5) { // upgrade shoes
shoesUpgraded++;
laughsCurrency = laughsCurrency - shoesUpgradeCost;
shoesUpgradeCost = shoesUpgradeCost + 4;
if (shoesUpgraded < 5) {
shoesUpgradeText.text = "press 'V' to increase player movement speed | "+shoesUpgradeCost+" Laughs";
} else {
shoesUpgradeText.text = "MAX UPGRADE";
}
playerScript.speed = playerScript.speed + 0.15f;
} else if (Input.GetKeyUp("q") && isUpgradePhase) { // next day
upgradePanel.SetActive(false);
isUpgradePhase = false;
dayScript.startNewDay();
}
}
public void startUpgradePhase() {
if (dayScript.dayNumber == 5) {
dayScript.gameWin();
} else {
dayScript.isDay = false;
upgradePanel.SetActive(true);
isUpgradePhase = true;
}
}
private void createChairArray(){
chairGrid[0] = new Vector3(-0.514f, -0.504f, 0.14f);
chairGrid[1] = new Vector3(-0.514f, -0.504f, 0.14f);
chairGrid[2] = new Vector3(-0.514f, 0.387f, 0.14f);
chairGrid[3] = new Vector3(-0.189f, -0.504f, 0.14f);
chairGrid[4] = new Vector3(-0.189f, -0.064f, 0.14f);
chairGrid[5] = new Vector3(-0.189f, 0.387f, 0.14f);
}
}