示例#1
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);
            }
        }
示例#2
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));
            }
        }
示例#3
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();
        }
示例#4
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);
        }
示例#5
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;
            }
        }
示例#6
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);
        }
示例#7
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);
        }