Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
0
 public void OnIsServerFlagUpdated(GameObject player, bool isServer)
 {
     LocalPlayerDataStore.GetInstance().isServer = isServer;
 }
Ejemplo n.º 5
0
 public void OnIsReadyFlagUpdated(GameObject player, bool isReady)
 {
     LocalPlayerDataStore.GetInstance().isReady = isReady;
 }
Ejemplo n.º 6
0
 public void OnTeamUpdated(GameObject player, int newTeam)
 {
     LocalPlayerDataStore.GetInstance().team = newTeam;
 }
Ejemplo n.º 7
0
 public void OnNameUpdated(GameObject player, string newName)
 {
     LocalPlayerDataStore.GetInstance().playerName = newName;
 }
Ejemplo n.º 8
0
 public void OnPlayerColourUpdated(GameObject player, Color newColour)
 {
     LocalPlayerDataStore.GetInstance().playerColour = newColour;
 }