Game singleton

This commit is contained in:
Crom (Thibaut CHARLES) 2015-03-06 12:20:49 +01:00
parent be171484c4
commit bc5f57a0fb
2 changed files with 50 additions and 0 deletions

38
Assets/src/Game.cs Normal file
View File

@ -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;
}

12
Assets/src/Game.cs.meta Normal file
View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fe4a245558e76304cb5e10458a6c3012
timeCreated: 1425550993
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: