-
Notifications
You must be signed in to change notification settings - Fork 1
/
StoreManeger.cs
104 lines (95 loc) · 3.34 KB
/
StoreManeger.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class StoreManeger : MonoBehaviour
{
bool localisfree,HaveMoney = false;
int construido;
public controls Player;
int wood,metal,energycell,cannons,powertank;
public GameObject torre;
public TowerSelect ClickBtn { get;private set; }
public Button StoreButton;
public Button StartTowerButton;
public GameController gameController;
private AudioSource audioSource;
void Update(){
if(gameController.Status == "NOITE"){
StoreButton.interactable = true;
StartTowerButton.interactable = true;
}else {
StoreButton.interactable = false;
StartTowerButton.interactable = false;
}
}
public void MoneyBitch()
{
Recursos();
if(ClickBtn.TowerPrefab.tag == "TorreAzul")
{
if(metal>=100 && wood >= 25 && energycell>=2 && cannons>=1 )
{
HaveMoney = true;
Player.setMetal(100,true);
Player.setEnergyCells(2,true);
Player.setCannons (1,true);
Player.setWood (25,true);
}else{
print("Bitch better have my money");
}
}else if(ClickBtn.TowerPrefab.tag == "TorreRoxa"){
if(metal>=100 && wood >= 25 && powertank>=2)
{
HaveMoney = true;
Player.setMetal(100,true);
Player.setPowerTanks(2,true);
Player.setWood (25,true);
}
}else if(ClickBtn.TowerPrefab.tag == "Eletrica"){
if(metal>=100 && wood >= 25 && powertank>=2 && energycell>=2 && cannons>=1)
{
HaveMoney = true;
Player.setMetal(100,true);
Player.setPowerTanks(2,true);
Player.setWood (25,true);
Player.setEnergyCells(2,true);
Player.setCannons (1,true);
}
}
}
public void ColocaNoMundo(GameObject Maneger)
{
if(Player.vida >0 && construido >0){
localisfree = Maneger.GetComponent<BuildingPlaceController>().isFree && Maneger.GetComponent<BuildingPlaceController>().isActive;
if(localisfree){
Vector2 spawnPosition = Maneger.transform.position;
if(Input.GetButtonDown("Fire1")){
MoneyBitch();
if(HaveMoney){
print("123");
Instantiate(ClickBtn.TowerPrefab,spawnPosition,Quaternion.identity);
audioSource = GetComponent<AudioSource>();
audioSource.Play();
HaveMoney = false;
construido = 0;
}
}
}else{
}
}
}
public void Recursos()
{
wood = Player.getWood();
metal = Player.getMetal();
energycell = Player.getEnergyCells();
powertank = Player.getPowerTanks();
cannons = Player.getCannons();
}
public void PickTower(TowerSelect towerSelect)
{
this.ClickBtn = towerSelect;
construido = 1;
}
}