コード例 #1
0
        public void SaveLoginSettings()
        {
            Manager manager = SingletonUtil.GetMain();
            Access  access  = AccessUtil.GetAccessData();
            LoginSettingsPanelComponent loginSettingsPanelComponent = (LoginSettingsPanelComponent)UIPanelUtil.GetUIPanel(PanelType.LOGIN_SETTINGS);

#if UNITY_EDITOR
            access.DevJsonPath = loginSettingsPanelComponent.InputField_DevJsonPath.text;
#endif
            access.JsonPath = loginSettingsPanelComponent.InputField_JsonPath.text;

#if UNITY_EDITOR
            PlayerPrefs.SetString("DevJsonPath", access.DevJsonPath);
#endif
            PlayerPrefs.SetString("JsonPath", access.JsonPath);
#if UNITY_EDITOR
            if (loginSettingsPanelComponent.InputField_DevJsonPath.text != string.Empty)
            {
                ClientUtil.SetClient();
            }
#else
            if (loginSettingsPanelComponent.InputField_JsonPath.text != string.Empty)
            {
                ClientUtil.SetClient();
            }
#endif
        }
コード例 #2
0
        private static void TryEnqueueNewFollower()
        {
            Simulation simulation = SimulationUtil.GetSimulation();

            Client loadedClient = ClientUtil.GetClient();

            ClientUtil.LoadClient(out loadedClient);

            Client localClient = ClientUtil.GetClient();

            for (int i = 0; i < loadedClient.Followers.Count; i++)
            {
                Follower loadedFollower = loadedClient.Followers[i];
                Follower clientFollower = null;

                if (ExistInClient(out clientFollower, loadedFollower))
                {
                    if (loadedFollower.Messages.Count != clientFollower.Messages.Count)
                    {
                        clientFollower.Messages.Add(loadedFollower.Messages[loadedFollower.Messages.Count - 1]);
                    }

                    continue;
                }

                Follower followerToEnqueue = CreateFollower(loadedFollower.UserName, loadedFollower.Messages[loadedFollower.Messages.Count - 1]);

                localClient.Followers.Add(followerToEnqueue);
                Debug.Log("Added client to chat: " + followerToEnqueue.UserName);

                simulation.FollowersToAdd.Enqueue(followerToEnqueue);
            }
        }
コード例 #3
0
        private static void UpdateCharacters()
        {
            Client client = ClientUtil.GetClient();
            Chat   chat   = GetChat();

            for (int i = 0; i < client.Followers.Count; i++)
            {
                var       curFollower = client.Followers[i];
                Character character   = null;

                if (ExistInChat(out character, curFollower))
                {
                    //CHECK FOR ANY NEW MESSAGES HERE

                    character.PCharacter.gameObject.SetActive(GetCharacterActiveState(character));

                    UpdateCharacterMechanicsValues(character);
                    UpdateCharacterPosition(character);
                    UpdateCharacterStates(character);
                    UpdateCharacterAnimation(character);
                    continue;
                }

                chat.Characters.Add(AddCharacter(curFollower));
            }
        }
コード例 #4
0
        private static void TryDequeueNewFollowers()
        {
            Simulation simulation = SimulationUtil.GetSimulation();
            Client     client     = ClientUtil.GetClient();

            if (!string.IsNullOrEmpty(simulation.NewFollower.UserName) || simulation.FollowersToAdd.Count == 0)
            {
                return;
            }

            simulation.NewFollower = simulation.FollowersToAdd.Dequeue();
        }
コード例 #5
0
        void OnApplicationQuit()
        {
            if (Simulation.Backend == null)
            {
                return;
            }

            Client.Connected = false;
            Client.Followers.Clear();
            ClientUtil.SetClient();

            Simulation.Backend.CloseMainWindow();
        }
コード例 #6
0
        private static bool ExistInClient(out Follower follower, Follower target)
        {
            follower = null;

            Client client = ClientUtil.GetClient();

            for (int i = 0; i < client.Followers.Count; i++)
            {
                var curFollower = client.Followers[i];
                if (curFollower.UserName == target.UserName)
                {
                    follower = curFollower;
                    return(true);
                }
            }

            return(false);
        }
コード例 #7
0
        public static void SetupPanel()
        {
            LoginPanelComponent loginPanelComponent = (LoginPanelComponent)UIPanelUtil.GetUIPanel(PanelType.LOGIN);

            string credentialsPath = string.Empty;

#if UNITY_EDITOR
            credentialsPath = AccessUtil.GetCredentialsJsonPath() + "/DevClient.json";
#else
            credentialsPath = AccessUtil.GetCredentialsJsonPath() + "/client.json";
#endif
            if (System.IO.File.Exists(credentialsPath))
            {
                Manager manager = SingletonUtil.GetMain();
                manager.Client = ClientUtil.LoadClient();

                loginPanelComponent.InputField_Username.text = manager.Client.UserName;
                loginPanelComponent.InputField_Token.text    = manager.Client.AccessToken;
            }
        }
コード例 #8
0
        private static void UpdateNewFollower()
        {
            Simulation simulation = SimulationUtil.GetSimulation();
            Client     client     = ClientUtil.GetClient();

            if (string.IsNullOrEmpty(simulation.NewFollower.UserName))
            {
                return;
            }

            simulation.CurrentTimeDisplayFollower += Time.deltaTime / simulation.TimeDisplayFollower;

            if (simulation.CurrentTimeDisplayFollower >= 1)
            {
                simulation.NewFollower          = new Follower();
                simulation.NewFollower.Messages = new List <FollowerMessageInfo>();

                simulation.CurrentTimeDisplayFollower = 0;
            }
        }
コード例 #9
0
        public void Login()
        {
            LoginPanelComponent loginPanelComponent = (LoginPanelComponent)UIPanelUtil.GetUIPanel(PanelType.LOGIN);

            Client client = ClientUtil.GetClient();

            client.UserName     = loginPanelComponent.InputField_Username.text;
            client.AccessToken  = loginPanelComponent.InputField_Token.text;
            client.ReadMessages = false;
            client.Followers    = new List <Follower>();

            ClientUtil.SetClient();

            Simulation       simulation = SimulationUtil.GetSimulation();
            ProcessStartInfo backEnd    = new ProcessStartInfo();

            backEnd.FileName         = "TwitchChat_bckEnd.exe";
            backEnd.WorkingDirectory = AccessUtil.GetBackEndProcessPath();
            simulation.Backend       = Process.Start(backEnd);
        }
コード例 #10
0
        private static bool GetCharacterActiveState(Character character)
        {
            //CHARACTER WILL ONLY SHOW UP IF HE IS NOT IN FOLLOWERS TO ADD QUEUE AND IF HE IS NOT BEN SHWING AT
            //THE NEW FOLLOWER OBEJCT

            Client     client     = ClientUtil.GetClient();
            Simulation simulation = SimulationUtil.GetSimulation();
            Chat       chat       = GetChat();

            if (character.FollowerReference.UserName == simulation.NewFollower.UserName)
            {
                return(false);
            }

            foreach (Follower follower in simulation.FollowersToAdd)
            {
                if (follower.UserName == character.FollowerReference.UserName)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #11
0
        void Update()
        {
            SimulationUtil.ManageStateChanging();

            State currentState = SimulationUtil.GetCurrentState();

            SimulationUtil.UpdateTick();

            switch (currentState)
            {
            case State.INTIALIZE:
                AccessUtil.LoadAccess();
                SimulationUtil.InitializeSimulation();
                CameraUtil.InitializeMainCameraComponent();
                UIUtil.InitializeUI();
                SimulationUtil.SetState(State.LOGIN);
                break;

            case State.LOGIN:
            {
                if (Simulation.Backend != null)
                {
                    SimulationUtil.SetState(State.CONNECTING);
                }
            }
            break;

            case State.IN_CHAT:
            {
                if (!ClientUtil.IsConnected())
                {
                    UnityEngine.Debug.Log("Disconnected");

                    if (Simulation.Backend != null && Simulation.Backend.HasExited)
                    {
                        Simulation.Backend = null;
                    }

                    SimulationUtil.SetState(State.LOGIN);
                    break;
                }

                if (SimulationUtil.Tick())
                {
                    FollowerUtil.UpdateFollowers();
                }

                ChatUtil.UpdateChat();
            }
            break;

            case State.LOGIN_SETTINGS:
                break;

            case State.CONNECTING:
            {
                if (!SimulationUtil.Tick())
                {
                    break;
                }

                UnityEngine.Debug.Log("Connecting");

                if (ClientUtil.IsConnected())
                {
                    SimulationUtil.SetState(State.HUB);
                    UnityEngine.Debug.Log("Connection complete !");
                }
            }
            break;

            case State.HUB:
            {
                Client.ReadMessages = true;

                if (SimulationUtil.Tick())
                {
                    FollowerUtil.UpdateFollowers();
                }
            }
            break;
            }

            UIUtil.UpdateUI();
        }