|
|
@@ -8,8 +8,7 @@ using UnityEngine.Tilemaps;
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
-public class GameManagerScript : MonoBehaviour
|
|
|
-{
|
|
|
+public class GameManagerScript : MonoBehaviour {
|
|
|
CinemachineBrain camBrain;
|
|
|
|
|
|
RoundManager roundManager;
|
|
|
@@ -22,87 +21,73 @@ public class GameManagerScript : MonoBehaviour
|
|
|
[SerializeField] Grid grid;
|
|
|
[SerializeField] Tilemap tileMap;
|
|
|
|
|
|
- List<Creature> combatants = new List<Creature>();
|
|
|
+ List<Creature> combatants = new();
|
|
|
|
|
|
static GameManagerScript instance;
|
|
|
- public static GameManagerScript getInstance()
|
|
|
- {
|
|
|
+ public static GameManagerScript GetInstance() {
|
|
|
return instance;
|
|
|
}
|
|
|
|
|
|
- private void Start()
|
|
|
- {
|
|
|
+ private void Start() {
|
|
|
instance = this;
|
|
|
combatants.AddRange(enemies.Select(e => e.GetComponent<Creature>()));
|
|
|
combatants.AddRange(humans.Select(h => h.GetComponent<Creature>()));
|
|
|
}
|
|
|
|
|
|
- private void Awake()
|
|
|
- {
|
|
|
- if (camBrain == null)
|
|
|
- {
|
|
|
+ private void Awake() {
|
|
|
+ if (camBrain == null) {
|
|
|
camBrain = Camera.main.GetComponent<CinemachineBrain>();
|
|
|
}
|
|
|
|
|
|
- if (roundManager == null)
|
|
|
- {
|
|
|
+ if (roundManager == null) {
|
|
|
roundManager = GameObject.Find("RoundManager").GetComponent<RoundManager>();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public CinemachineVirtualCamera getActiveCamera()
|
|
|
- {
|
|
|
+ public CinemachineVirtualCamera GetActiveCamera() {
|
|
|
CinemachineVirtualCamera cam = camBrain.ActiveVirtualCamera as CinemachineVirtualCamera;
|
|
|
|
|
|
return cam;
|
|
|
}
|
|
|
|
|
|
- internal void rollInitiative()
|
|
|
- {
|
|
|
- combatants.ForEach(creature =>
|
|
|
- {
|
|
|
- creature.rollInit();
|
|
|
+ internal void RollInitiative() {
|
|
|
+ combatants.ForEach(creature => {
|
|
|
+ creature.RollInit();
|
|
|
});
|
|
|
|
|
|
- combatants.Sort((x, y) => x.getInit().CompareTo(y.getInit()));
|
|
|
- clearInitPanel();
|
|
|
- buildInitPanel();
|
|
|
- roundManager.startFirstRound(combatants);
|
|
|
+ combatants.Sort((x, y) => x.GetInit().CompareTo(y.GetInit()));
|
|
|
+ ClearInitPanel();
|
|
|
+ BuildInitPanel();
|
|
|
+ roundManager.StartFirstRound(combatants);
|
|
|
}
|
|
|
|
|
|
- private void clearInitPanel()
|
|
|
- {
|
|
|
+ private void ClearInitPanel() {
|
|
|
int children = initPanel.transform.childCount;
|
|
|
- for (int i = children - 1; i >= 0; i--)
|
|
|
- {
|
|
|
+ for (int i = children - 1; i >= 0; i--) {
|
|
|
GameObject.Destroy(initPanel.transform.GetChild(i).gameObject);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void showInitPanel(Boolean show)
|
|
|
- {
|
|
|
+ public void ShowInitPanel(Boolean show) {
|
|
|
initPanel.SetActive(show);
|
|
|
}
|
|
|
|
|
|
- internal void buildInitPanel()
|
|
|
- {
|
|
|
+ internal void BuildInitPanel() {
|
|
|
initPanel.SetActive(true);
|
|
|
- combatants.ForEach(c =>
|
|
|
- {
|
|
|
+ combatants.ForEach(c => {
|
|
|
GameObject creturePanel = GameObject.Instantiate(initCreaturePanel, Vector3.zero, Quaternion.identity);
|
|
|
creturePanel.transform.localScale = new Vector3(1, 1, 1);
|
|
|
creturePanel.transform.SetParent(initPanel.transform);
|
|
|
- creturePanel.GetComponent<InitCreaturePanelScript>().setImage(c.GetComponent<Creature>().getSprite());
|
|
|
+ creturePanel.GetComponent<InitCreaturePanelScript>().SetImage(c.GetComponent<Creature>().GetSprite());
|
|
|
|
|
|
- Debug.Log(c.name + " init: " + c.GetComponent<Creature>().getInit() + " Dex " + c.GetComponent<Creature>().Dex + " pos: " + grid.WorldToCell(c.transform.localPosition));
|
|
|
+ Debug.Log(c.name + " init: " + c.GetComponent<Creature>().GetInit() + " Dex " + c.GetComponent<Creature>().Dex + " pos: " + grid.WorldToCell(c.transform.localPosition));
|
|
|
|
|
|
- c.setPositionInGrid(grid.WorldToCell(c.transform.localPosition));
|
|
|
+ c.SetPositionInGrid(grid.WorldToCell(c.transform.localPosition));
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
- public List<Creature> getCombatants()
|
|
|
- {
|
|
|
+ public List<Creature> GetCombatants() {
|
|
|
return combatants;
|
|
|
}
|
|
|
}
|