-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayerScript.cs
80 lines (73 loc) · 1.85 KB
/
PlayerScript.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
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class PlayerScript : MonoBehaviour {
public List<GameObject> Players;
private List<GameObject> ownedPlanets;
private List<GameObject> systems;
public int state{get;set;}
public int numOfUnitsToDeploy{get;set;}
public bool isPlayer{get; set;}
public bool displayInfo{get; set;}
public Color color{get; set;}
//public bool hasBattled{get; set;}
void OnGUI()
{
if(displayInfo ==true)
{
GUI.BeginGroup(new Rect(Screen.width/2-475,Screen.height/2-150,500,500));
GUI.Label(new Rect(0,10,500,20), this.gameObject.name);
GUI.Label(new Rect(0,25,500,20), "Planets Owned: " + this.ownedPlanets.Count);
GUI.Label(new Rect(0,40,500,20), "Rienforcements: " + this.numOfUnitsToDeploy);
GUI.EndGroup();
}
}
void Awake()
{
DontDestroyOnLoad(this);
Players = new List<GameObject>();
}
// Use this for initialization
void Start () {
ownedPlanets = new List<GameObject>();
systems = new List<GameObject>();
}
// Update is called once per frame
void Update () {
}
public void addPlanet(GameObject planet, GameObject player)
{
ownedPlanets.Add(planet);
planet.GetComponent<Planet>().owningPlayer = player;
planet.GetComponent<Planet>().updateHalo();
}
public void removePlanet(GameObject planet)
{
ownedPlanets.Remove(planet);
}
public void addSystem(GameObject solarSystem)
{
systems.Add(solarSystem);
}
public void removeSystem(GameObject solarSystem)
{
ownedPlanets.Remove(solarSystem);
}
public int calculateUnits()
{
numOfUnitsToDeploy=0;
if(ownedPlanets.Count >9)
{
numOfUnitsToDeploy = ownedPlanets.Count/3;
}
else
{
numOfUnitsToDeploy = 3;
}
for(int i = 0; i < systems.Count;i++)
{
numOfUnitsToDeploy+= systems[i].GetComponent<SolarSystem>().numOfBonusTroops;
}
return numOfUnitsToDeploy;
}
}