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); } }
public void PushState(string state) { State toState; if (Enum.TryParse(state, out toState)) { SimulationUtil.AddState(toState); } }
public static void UpdateUI() { State state = SimulationUtil.GetCurrentState(); if (state == State.INTIALIZE) { return; } UIPanelUtil.ManagePanels(); }
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(); }
private static void GUI_DrawDebugUsers(int id) { GUILayout.Label("Username:"******"Add")) { var follower = FollowerUtil.CreateFollower(addUser_UserName, new FollowerMessageInfo()); SingletonUtil.GetMain().Client.Followers.Add(follower); SimulationUtil.GetSimulation().FollowersToAdd.Enqueue(follower); } }
public static void DebugGUI() { State state = SimulationUtil.GetCurrentState(); switch (state) { case State.IN_CHAT: if (DebugUsers) { Rect debugUsersRect = new Rect(0, 0, 300, 100); GUI.Window(Constants.GUI_DEBUG_USERS_ID, debugUsersRect, GUI_DrawDebugUsers, "Users"); } break; } }
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; } }
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); }
public static void ManagePanels() { UIHolder uiHolder = UIUtil.GetUIHolder(); Simulation simulation = SimulationUtil.GetSimulation(); State currentState = SimulationUtil.GetCurrentState(); State lastState = SimulationUtil.GetLastState(); PanelType currentPanel = GetPanelTypeByState(currentState); PanelType lastPanel = GetPanelTypeByState(lastState); if (!IsPanelOpenned(currentPanel) && uiHolder.PanelToOpen == PanelType.NONE) { uiHolder.PanelToOpen = currentPanel; } if (uiHolder.PanelToClose == PanelType.NONE) { for (int i = 0; i < uiHolder.InstantiatedPanels.Count; i++) { PanelType instantiatedPanelType = uiHolder.InstantiatedPanels[i]; UIPanel instantiatedPanel = GetUIPanel(instantiatedPanelType); State desiredState = SimulationUtil.GetStateByPanelType(instantiatedPanelType); if (instantiatedPanel.gameObject.activeSelf && !simulation.States.Contains(desiredState)) { uiHolder.PanelToClose = instantiatedPanelType; break; } } } ManageOpenningPanel(); ManageClosingPanels(); UpdateOppenedPanels(); }
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); }
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(); }
void Start() { Simulation.CurrentTick += Simulation.TickInSeconds; SimulationUtil.AddState(State.INTIALIZE); }
public void PopState() { SimulationUtil.PopState(); }