Example #1
0
        public static LocalPlayerDataStore GetInstance()
        {
            if (instance == null)
            {
                instance = new LocalPlayerDataStore();
            }

            return(instance);
        }
Example #2
0
        public override void OnStartLocalPlayer()
        {
            LocalPlayerDataStore store = LocalPlayerDataStore.GetInstance();

            if (store.playerColour == new Color(0, 0, 0, 0))
            {
                store.playerColour = Random.ColorHSV();
            }

            clientData.SetColour(store.playerColour);
            clientData.OnColourUpdated += OnPlayerColourUpdated;
        }
Example #3
0
        public override void OnStartLocalPlayer()
        {
            LocalPlayerDataStore store = LocalPlayerDataStore.GetInstance();

            State.GetInstance().Subscribe(
                new StateOption().GameState(State.GAME_OFFLINE),
                () => {
                if (clientData != null)
                {
                    clientData.SetName("");
                    clientData.SetTeam(0);
                    clientData.SetIsServerFlag(false);
                    clientData.SetIsReadyFlag(false);
                }
                else
                {
                    store.playerName = "";
                    store.team       = 0;
                    store.isReady    = false;
                    store.isServer   = false;
                }
            }
                );
            State.GetInstance().Subscribe(
                new StateOption().LevelState(State.LEVEL_IN_LOBBY),
                () => {
                if (clientData != null)
                {
                    clientData.SetIsReadyFlag(false);
                }
                else
                {
                    store.isReady = false;
                }
            }
                );

            CreateDefaultValues();

            clientData.SetName(store.playerName);
            clientData.SetTeam(store.team);
            clientData.SetIsReadyFlag(store.isReady);
            clientData.SetIsServerFlag(store.isServer);

            clientData.OnNameUpdated         += OnNameUpdated;
            clientData.OnTeamUpdated         += OnTeamUpdated;
            clientData.OnIsReadyFlagUpdated  += OnIsReadyFlagUpdated;
            clientData.OnIsServerFlagUpdated += OnIsServerFlagUpdated;
        }
Example #4
0
        private void CreateDefaultValues()
        {
            LocalPlayerDataStore store = LocalPlayerDataStore.GetInstance();

            if (store.playerName != "" || store.team != 0 | store.isServer != false || store.isReady != false)
            {
                return;
            }

            store.playerName = names[Random.Range(0, 8)];
            store.team       = teams[Random.Range(0, 2)];

            if (State.GetInstance().Network() == State.NETWORK_SERVER)
            {
                store.isServer = true;
            }
        }
Example #5
0
 public void OnIsServerFlagUpdated(GameObject player, bool isServer)
 {
     LocalPlayerDataStore.GetInstance().isServer = isServer;
 }
Example #6
0
 public void OnIsReadyFlagUpdated(GameObject player, bool isReady)
 {
     LocalPlayerDataStore.GetInstance().isReady = isReady;
 }
Example #7
0
 public void OnTeamUpdated(GameObject player, int newTeam)
 {
     LocalPlayerDataStore.GetInstance().team = newTeam;
 }
Example #8
0
 public void OnNameUpdated(GameObject player, string newName)
 {
     LocalPlayerDataStore.GetInstance().playerName = newName;
 }
Example #9
0
 public void OnPlayerColourUpdated(GameObject player, Color newColour)
 {
     LocalPlayerDataStore.GetInstance().playerColour = newColour;
 }