Esempio n. 1
0
        private static void DisplayCharactersUsername()
        {
            Chat    chat    = ChatUtil.GetChat();
            Prefabs prefabs = SingletonUtil.GetMain().Prefabs;
            InChatPanelComponent inChatPanelComponent = (InChatPanelComponent)UIPanelUtil.GetUIPanel(PanelType.IN_CHAT);

            if (inChatPanelComponent.CharactersUsername.Length != chat.Characters.Count)
            {
                if (inChatPanelComponent.CharactersUsername.Length > chat.Characters.Count)
                {
                    int diff = inChatPanelComponent.CharactersUsername.Length - chat.Characters.Count;
                    for (int i = diff + 1; i < inChatPanelComponent.CharactersUsername.Length; i++)
                    {
                        inChatPanelComponent.CharactersUsername[i].gameObject.SetActive(false);
                    }
                }
                else
                {
                    int diff = chat.Characters.Count - inChatPanelComponent.CharactersUsername.Length;
                    for (int i = 0; i < diff; i++)
                    {
                        Pool.TryGetMonoBehaviourFromPool <UIText>(ref inChatPanelComponent.CharactersUsername, prefabs.UiText);
                    }
                }
            }
        }
Esempio n. 2
0
        public static void InitializeState()
        {
            State state = GetCurrentState();

            switch (state)
            {
            case State.IN_CHAT:
                ChatUtil.InitializeChat();
                break;
            }
        }
Esempio n. 3
0
        private static void UpdateUsernamesAppearance()
        {
            Chat chat = ChatUtil.GetChat();
            MainCameraComponent  cameraComponent      = CameraUtil.GetMainCameraComponent();
            InChatPanelComponent inChatPanelComponent = (InChatPanelComponent)UIPanelUtil.GetUIPanel(PanelType.IN_CHAT);

            for (int i = 0; i < inChatPanelComponent.CharactersUsername.Length; i++)
            {
                UIText    uiText             = inChatPanelComponent.CharactersUsername[i];
                Character referenceCharacter = chat.Characters[i];

                uiText.text = chat.CharacterConfiguration.BaseName;
                UIUtil.FormatUIText(uiText, referenceCharacter);

                uiText.fontSize = chat.CharacterConfiguration.UsernameSize;
                uiText.color    = chat.CharacterConfiguration.UsernameColor;
            }
        }
Esempio n. 4
0
        private static void UpdateUsernamesPosition()
        {
            Chat chat = ChatUtil.GetChat();
            MainCameraComponent  cameraComponent      = CameraUtil.GetMainCameraComponent();
            InChatPanelComponent inChatPanelComponent = (InChatPanelComponent)UIPanelUtil.GetUIPanel(PanelType.IN_CHAT);

            for (int i = 0; i < inChatPanelComponent.CharactersUsername.Length; i++)
            {
                UIText    uiText             = inChatPanelComponent.CharactersUsername[i];
                Character referenceCharacter = chat.Characters[i];

                uiText.transform.SetParent(inChatPanelComponent.CharacterUsernamesHolder);

                Vector2 worldPosition = chat.Characters[i].Position + Vector2.up * referenceCharacter.PCharacter.Render.sprite.bounds.size;
                Vector2 offset        = chat.CharacterConfiguration.UsernameOffset;

                uiText.transform.position = cameraComponent.Camera.WorldToScreenPoint(worldPosition + offset);
            }
        }
Esempio n. 5
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();
        }