From bc5f57a0fb416af912c8ae9a87cba822f8950f8b Mon Sep 17 00:00:00 2001 From: "Crom (Thibaut CHARLES)" Date: Fri, 6 Mar 2015 12:20:49 +0100 Subject: [PATCH] Game singleton --- Assets/src/Game.cs | 38 ++++++++++++++++++++++++++++++++++++++ Assets/src/Game.cs.meta | 12 ++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 Assets/src/Game.cs create mode 100644 Assets/src/Game.cs.meta diff --git a/Assets/src/Game.cs b/Assets/src/Game.cs new file mode 100644 index 0000000..1a5d2f9 --- /dev/null +++ b/Assets/src/Game.cs @@ -0,0 +1,38 @@ +using UnityEngine; +using System.IO; + +public class Game { + + void SetMainPlayer(Player p){ + m_mainPlayer = p; + } + + + Player GetMainPlayer(){ + return m_mainPlayer; + } + + + + + private static Game Get() { + lock(m_singlmutex) { + if(m_inst==null) + m_inst = new Game(); + } + return m_inst; + } + private Game() { + + } + + + private static Game m_inst = null; + private static object m_singlmutex = new Object(); + + + private Player m_mainPlayer = null; + + + +} \ No newline at end of file diff --git a/Assets/src/Game.cs.meta b/Assets/src/Game.cs.meta new file mode 100644 index 0000000..61e2e3d --- /dev/null +++ b/Assets/src/Game.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fe4a245558e76304cb5e10458a6c3012 +timeCreated: 1425550993 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: