// ==================== END GENERIC GAME STATE FUNCTIONS APPLICABLE TO ALL CONTEXTS ==================== //



    // ==================== PLAYER-IN-TRAIN GAME STATE FUNCTIONS ==================== //

    void SetIndicatorToBlackAndIncrementCheckpointCounter()
    {
        // We turn on this flag to halt the blinking effect of the current train map indicator light
        isMovingToNextStation = true;

        // we don't bother updating train map indicators at and beyond Clementi station,
        // since the player's gonna end up taking a bus due to a train fault
        // or something that will take place at this station.
        if (m_CurrentCheckpoint < 22)
        {
            currentAccumulatedDuration = 0;
            m_Indicators [m_CurrentCheckpoint].color = Color.black;
            m_CurrentCheckpoint += 1;
        }

        // [ Message triggers ]
        // One message will already have been triggered at main menu. (Msg #1)
        // One message will also have been triggered in minigame #1 (Pasir Ris station: Msg #2)
        // One message will also have been triggered in minigame #2. (Paya Lebar station: Msg #5)
        // One message will also have been triggered before minigame #3, after boarding the bus. (Msg #9)
        // One message will also have been triggered during the bus ride. (Msg #10)
        // Two messages will also have been triggered in minigame #3. (Msg #11, #12)

        if (m_CurrentCheckpoint == 2)
        {
            // We fire another message at Simei station (Msg #3)
            m_PhoneScript.ReceiveTextFromGF();
        }
        else if (m_CurrentCheckpoint == 4)
        {
            // We fire another message at Bedok station (Msg #4)
            m_PhoneScript.ReceiveTextFromGF();
        }
        else if (m_CurrentCheckpoint == 12)
        {
            // We fire another message at City Hall station (Msg #6)
            m_PhoneScript.ReceiveTextFromGF();
        }
        else if (m_CurrentCheckpoint == 16)
        {
            // We fire another message at Outram Park station (Msg #7)
            m_PhoneScript.ReceiveTextFromGF();
        }
        else if (m_CurrentCheckpoint == 20)
        {
            // We fire another message at Buona Vista station (Msg #8)
            m_PhoneScript.ReceiveTextFromGF();
        }

        // We turn off this flag now to let the blinking effect resume on next indicator light
        isMovingToNextStation = false;
    }
    void Update()
    {
        // Update loop logic for handling minigame 1
        if (m_IsInPlay)
        {
            timeElapsedSinceMinigameStart += Time.deltaTime;

            if (timeElapsedSinceMinigameStart >= m_TimeToTriggerMessage &&
                timeElapsedSinceMinigameStart < m_TimeToTriggerMessage + Time.deltaTime)
            {
                m_PhoneScript.ReceiveTextFromGF();
            }

            if (canReceiveInput)
            {
                (m_CompetingPassengerMoving.transform as RectTransform).anchoredPosition += (competingStepDistance * Time.deltaTime);

                if (HasPassengerReachedSeatFirst())
                {
                    MovePlayerToNextCarriage();
                }
            }

            if (Input.anyKeyDown)
            {
                if (!Input.GetKeyDown(KeyCode.Mouse0))
                {
                    CheckForInputMatchWithComboString();
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (m_IsInPlay)
        {
            timeElapsedSinceMinigameStart += Time.deltaTime;

            if (timeElapsedSinceMinigameStart >= m_TimeToTriggerMessage &&
                timeElapsedSinceMinigameStart < m_TimeToTriggerMessage + Time.deltaTime)
            {
                m_PhoneScript.ReceiveTextFromGF();
            }

            // Every now and then, randomize a passenger with an item beneath their seats,
            // then animate them to lift up their foot and reveal the item below.
            // After that, check if input matches the required key
            if (isLiftingFoot)
            {
                accumulatedFootLiftDuration += Time.deltaTime;

                if (accumulatedFootLiftDuration > footLiftTimeLimit)
                {
                    if (toResumeFlow)
                    {
                        AnimatePassengerPuttingDownFoot();
                        predeterminedDelayDuration = Random.Range(m_MinimumDelayBeforePassengerLiftsFoot, m_MaximumDelayBeforePassengerLiftsFoot);

                        accumulatedFootLiftDuration = 0;
                        isLiftingFoot = false;
                    }
                }
                else
                {
                    CheckForInputMatch();
                }
            }
            else
            {
                canAcceptInput = false;

                accumulatedDelay += Time.deltaTime;

                if (accumulatedDelay > predeterminedDelayDuration)
                {
                    MakeRandomPassengerLiftFoot();

                    accumulatedDelay = 0;
                    isLiftingFoot    = true;
                }
            }

            if (HaveAllItemsBeenRetrieved())
            {
                EndGame();
            }
        }
    }
Example #4
0
    IEnumerator TransitToGameCoroutine()
    {
        m_StartButton.interactable = false;
        m_InstructionPanel.SetActive(false);
        m_HUD.SetActive(true);

        m_PhoneScript.InitializeFirstMessageCallback(HandleClearFirstMessage);

        yield return(new WaitForSeconds(1f));

        m_PhoneScript.ReceiveTextFromGF(true);
    }
    // Update is called once per frame
    void Update()
    {
        if (m_IsIdlingOnBus)
        {
            totalBusTravelTime += Time.deltaTime;

            // 2 messages will be fired on the bus ride - this is the first one.
            if (totalBusTravelTime >= m_TimeTillFirstMessageOnBusTravel &&
                totalBusTravelTime < m_TimeTillFirstMessageOnBusTravel + Time.deltaTime)
            {
                m_PhoneScript.ReceiveTextFromGF();
            }

            // 2 messages will be fired on the bus ride - this is the second one.
            if (totalBusTravelTime >= m_TimeTillLastMessageOnBusTravel &&
                totalBusTravelTime < m_TimeTillLastMessageOnBusTravel + Time.deltaTime)
            {
                m_PhoneScript.ReceiveTextFromGF();
            }

            if (totalBusTravelTime > m_BusIdleTime)
            {
                m_IsIdlingOnBus = false;
                m_MinigameUI.SetActive(true);
            }
        }

        if (m_IsInPlay)
        {
            if (toUpdateTimer)
            {
                totalBusTravelTime += Time.deltaTime;

                // 2 messages will be fired during minigame #3 - this is the first one.
                if (totalBusTravelTime >= m_BusIdleTime + m_TimeTillFirstMessageInMinigame &&
                    totalBusTravelTime < m_BusIdleTime + m_TimeTillFirstMessageInMinigame + Time.deltaTime)
                {
                    m_PhoneScript.ReceiveTextFromGF();
                }

                // 2 messages will be fired during minigame #3 - this is the second one.
                if (totalBusTravelTime >= m_BusIdleTime + m_TimeTillLastMessageInMinigame &&
                    totalBusTravelTime < m_BusIdleTime + m_TimeTillLastMessageInMinigame + Time.deltaTime)
                {
                    m_PhoneScript.ReceiveTextFromGF();
                }

                UpdateTimer();

                if (Input.GetKey(KeyCode.A))
                {
                    RotatePlankAnticlockwise();
                }
                else if (Input.GetKey(KeyCode.D))
                {
                    RotatePlankClockwise();
                }

                UpdateSliderValue();
                CheckIfSliderIsWithinBounds();

                if (timeElapsed > m_MinigameDuration)
                {
                    EndGame();
                }
            }
        }
    }