Example #1
0
        // Use this for initialization
        void Start()
        {
            animateMessage     = true;
            messageOver        = false;
            isMessageToDisplay = false;
            endMessage         = false;
            inBattle           = false;
            queueHead          = new UIQueueItem();
            activeDelt         = null;
            activeItem         = null;
            secondMoveLoaded   = -1;

            currentUI = UIMode.World;

            // Set All UI except Movement as inactive
            MessageUI.gameObject.SetActive(false);
            BattleUI.gameObject.SetActive(false);
            BagMenuUI.gameObject.SetActive(false);
            ItemsUI.gameObject.SetActive(false);
            PosseUI.gameObject.SetActive(false);
            DeltDexUI.gameObject.SetActive(false);
            fade.gameObject.SetActive(false);
            SettingsUI.SetActive(false);

            StartCoroutine(messageWorker());
        }
Example #2
0
        // REFACTOR_TODO: Create an event/animation queue class outside of UIManager. No reason for it to belong here.

        // REFACTOR_TODO: Refactor this into seperate queues that still block on each other (Generic queue class?)
        // Queue display of a message, IENum, and/or function
        public void StartMessage(string message, IEnumerator ienum = null, System.Action nextFunction = null, bool startImmedately = false)
        {
            // Initialize the queue if nothing queued yet
            if (queueHead == null)
            {
                queueHead = new UIQueueItem();
            }
            UIQueueItem newMessage = new UIQueueItem();
            UIQueueItem tmp;

            newMessage.message      = message;
            newMessage.nextFunction = nextFunction;
            newMessage.ienum        = ienum;
            newMessage.next         = null;

            // Enqueue new message
            tmp = queueHead;

            // Queue immediately, or queue last
            if (startImmedately)
            {
                newMessage.next = queueHead.next;
                queueHead.next  = newMessage;
            }
            else
            {
                while (tmp.next != null)
                {
                    tmp = tmp.next;
                }
                tmp.next = newMessage;
            }
            isMessageToDisplay = true;
        }
Example #3
0
        // To execute message displays/functions in the right order
        public IEnumerator messageWorker()
        {
            UIQueueItem curItem = new UIQueueItem();

            while (true)
            {
                // Wait for another message
                if (queueHead.next == null)
                {
                    isMessageToDisplay = false;
                }

                // Wait for next message
                yield return(new WaitUntil(() => isMessageToDisplay));

                // Dequeue message
                curItem        = queueHead.next;
                queueHead.next = curItem.next;

                // Make shorter if NPC Message
                if (NPCMessage)
                {
                    MessageSize.anchorMax = new Vector2(0.67f, 0.31f);
                    MessageText.fontSize  = 25;
                }
                else
                {
                    MessageSize.anchorMax = new Vector2(1, 0.31f);
                    MessageText.fontSize  = 30;
                }

                // Display message, if one exists
                if (curItem.message != null)
                {
                    // To stall after initiating coroutine
                    messageOver    = false;
                    animateMessage = false;
                    endMessage     = false;

                    // Print message
                    StartCoroutine(displayMessage(curItem.message));
                    // Wait for message to finish
                    yield return(new WaitUntil(() => endMessage));

                    MessageUI.SetActive(false);
                }

                // Execute next function, if one exists
                if (curItem.ienum != null)
                {
                    curCoroutine = StartCoroutine(curItem.ienum);
                    yield return(curCoroutine);
                }

                // Execute next function, if one exists
                if (curItem.nextFunction != null)
                {
                    curItem.nextFunction();
                }
            }
        }