Skip to content

Instantly share code, notes, and snippets.

@walterpalladino
Created July 11, 2018 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterpalladino/9f835ae45f3d0bdbf8f1a408f5253b28 to your computer and use it in GitHub Desktop.
Save walterpalladino/9f835ae45f3d0bdbf8f1a408f5253b28 to your computer and use it in GitHub Desktop.
GameManager example
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