Created
July 11, 2018 00:09
-
-
Save walterpalladino/9f835ae45f3d0bdbf8f1a408f5253b28 to your computer and use it in GitHub Desktop.
GameManager example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class GameManager : MonoBehaviour { | |
private static GameManager instance; | |
public static GameManager Instance { get { return instance; } } | |
[SerializeField] | |
private int startingShips = 4; | |
private int _actualShips; | |
void Awake() | |
{ | |
if (instance == null) | |
instance = this; | |
else if (instance != this) | |
Destroy(gameObject); | |
DontDestroyOnLoad(gameObject); | |
} | |
// Use this for initialization | |
void Start () { | |
ResetGameValues(); | |
} | |
// Update is called once per frame | |
void Update () { | |
} | |
private void ResetGameValues () { | |
_actualShips = startingShips; | |
} | |
public int GetShips () { | |
return _actualShips; | |
} | |
public void RemoveShip () { | |
_actualShips--; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment