Example #1
0
    public void PreviousPage()
    {
        InkDriverBase inkDriver = FindObjectOfType <InkDriverBase>();

        if (eventText.pageToDisplay > 1)
        {
            eventText.pageToDisplay -= 1;
            //pageSeen = true;
            inkDriver.textMask.fillAmount = 1;
            inkDriver.textMask.DOComplete();
            nextButtonText.text = defaultNextMsg;

            if (eventText.pageToDisplay == 1)
            {
                backButton.SetActive(false);
            }
            currentPage--;

            PlayCurrentPageSFX();
        }
        else
        {
            backButton.SetActive(false);
        }
    }
Example #2
0
    /// <summary>
    /// Collects and Sends data when an event is completed.
    /// </summary>
    /// <param name="gameEvent">The event that the player just completed.</param>
    public static void OnEventComplete(InkDriverBase gameEvent)
    {
        string eventType = GetEventType(ref gameEvent);

        float timeInEvent = Time.time - eventStartTime;

        Dictionary <string, object> data = new Dictionary <string, object>
        {
            { "eventName", gameEvent.EventName },                 // tracks the event name
            { "timeInEvent", timeInEvent }                        // tracks how long the player was in the event
        };

        string choiceNames = "";

        for (var i = 0; i < EventChoiceData.Count; i++)
        {
            choiceNames += EventChoiceData[i];
            data.Add("choiceName" + i, EventChoiceData[i]);     // tracks the choice name
            if (i + 1 < EventChoiceData.Count)
            {
                choiceNames += " > ";
            }
        }

        data.Add(gameEvent.EventName, choiceNames);     // tracks event name with all event choices
        EventChoiceData.Clear();

        Analytics.CustomEvent(eventType + "-completed", data);

        #if UNITY_EDITOR
        Debug.LogWarning("Analytics: On Event Complete Sent");
        #endif
    }
Example #3
0
    /// <summary>
    /// Ends the event that is currently running.
    /// If the max number of events has been reached, go to the ending
    /// </summary>
    public void ConcludeEvent()
    {
        InkDriverBase concludedEvent = eventInstance.GetComponent <InkDriverBase>();

        concludedEvent.ClearUI();

        bool isRegularEvent = !isCheatEvent;

        if (concludedEvent.isCharacterEvent)
        {
            isRegularEvent = false;
            chatting       = false;
            eventInstance.GetComponent <CharacterEvent>().EndCharacterEvent();
        }
        else if (concludedEvent.isMutinyEvent)
        {
            isRegularEvent = false;
            mutiny         = false;
        }
        else
        {
            daysSinceChat++;             //all normal events raise days since chat
        }

        AnalyticsManager.OnEventComplete(concludedEvent);
        Destroy(eventInstance);

        //Go back to travel scene
        asm.UnloadScene("Event_NoChoices");
        asm.UnloadScene("Event_General");
        asm.UnloadScene("Event_CharacterFocused");
        AudioManager.instance.PlayMusicWithTransition("General Theme");

        //reset for next event
        eventActive = false;
        tick.StartTickUpdate();
        AudioManager.instance.PlayRadio(AudioManager.instance.currentStationId, true);

        //set up for the next regular event
        if (isRegularEvent)
        {
            tick.DaysSince         = 0; // reset days since
            skippedToEvent         = false;
            nextEventLockedIn      = false;
            eventRollCounter       = 0;
            timeBeforeEventCounter = 0;
        }

        if (overallEventIndex >= maxEvents)     //Potentially end the job entirely if this is meant to be the final event
        {
            GameManager.instance.ChangeInGameState(InGameStates.JobPayment);
        }
    }
Example #4
0
    public void NextPage()
    {
        InkDriverBase inkDriver = FindObjectOfType <InkDriverBase>();

        if (inkDriver && !inkDriver.donePrinting)
        {
            inkDriver.textMask.DOComplete();
            inkDriver.donePrinting = true;
        }
        else if (eventText.pageToDisplay < eventText.textInfo.pageCount && inkDriver.donePrinting)
        {
            eventText.pageToDisplay += 1;
            if (eventText.pageToDisplay >= furthestPage)
            {
                furthestPage++;
                inkDriver.textMask.fillAmount = 0;
                inkDriver.FillBox();
            }
            else
            {
                inkDriver.textMask.fillAmount = 1;
            }
            if (!backButton.activeSelf)
            {
                backButton.SetActive(true);
            }
            currentPage++;
            PlayCurrentPageSFX();
        }
        else
        {
            if (inkDriver && !inkDriver.ShowChoices()) // normal
            {
                inkDriver.ConcludeEvent();
            }
            else if (!inkDriver && FindObjectOfType <GameIntroManager>()) // game intro
            {
                GameIntroManager intro = FindObjectOfType <GameIntroManager>();
                intro.ConcludeEvent();
            }
            else if (FindObjectOfType <MoneyEndingBehaviour>()) // endings
            {
                FindObjectOfType <MoneyEndingBehaviour>().TransitionToScene();
            }
        }

        if (madeChoice && eventText.pageToDisplay == eventText.textInfo.pageCount)
        {
            nextButtonText.text = continueNextMsg;
        }
    }
Example #5
0
 private void PlayCurrentPageSFX()
 {
     if (currentPage != 1) //doesn't need to play on the first page of the event
     {
         InkDriverBase inkDriver = FindObjectOfType <InkDriverBase>();
         //uses currentPage to figure out which SFX to play
         if (inkDriver && inkDriver.pageClips.Count >= currentPage)
         {
             if (inkDriver.pageClips[currentPage - 1] != null) //make sure there is something in that slot
             {
                 AudioManager.instance.PlaySFX(inkDriver.pageClips[currentPage - 1]);
             }
         }
     }
 }
Example #6
0
 /// <summary>
 /// Returns the type of game event as a string.
 /// </summary>
 /// <param name="gameEvent">The game event that is being checked.</param>
 /// <returns>A string for the event type.</returns>
 private static string GetEventType(ref InkDriverBase gameEvent)
 {
     if (gameEvent.isMutinyEvent)
     {
         return("mutinyEvent");
     }
     if (gameEvent.isCharacterEvent)
     {
         return("characterEvent");
     }
     if (gameEvent.isStoryEvent)
     {
         return("storyEvent");
     }
     return(gameEvent.nextChoices.Count != 0 ? "randomEvent" : "introEvent");
 }
Example #7
0
    /// <summary>
    /// Collects and Sends data when an event is started.
    /// </summary>
    /// <param name="gameEvent">The event that has started.</param>
    /// <param name="eventLockedIn">If </param>
    public static void OnEventStarted(InkDriverBase gameEvent, bool eventLockedIn)
    {
        EventChoiceData.Clear();
        string eventType = GetEventType(ref gameEvent);
        Dictionary <string, object> data = new Dictionary <string, object>
        {
            { "eventName", gameEvent.EventName }          // tracks the event name
        };

        if (!gameEvent.isCharacterEvent && !gameEvent.isMutinyEvent)
        {
            data.Add("eventWasLockedIn", eventLockedIn); // tracks if story/random event was skipped to or not
        }

        Analytics.CustomEvent(eventType + "-started", data);

        #if UNITY_EDITOR
        Debug.LogWarning("Analytics: On Event Started Sent");
        #endif

        eventStartTime = Time.time; // store time for determining how long the player was in an event
    }
Example #8
0
    /// <summary>
    /// Extra code to determine if a choice is actually available
    /// </summary>
    /// <param name="ship"></param>
    /// <param name="myButton"></param>
    public void CreateChoice(ShipStats ship, Button myButton, Story thisStory, InkDriverBase thisDriver, OutcomeTooltipUI tooltip)
    {
        bool requirementMatch = true;

        driver = thisDriver;

        //as long as it's not a story event, it's scalable
        isScalableEvent = driver.isScalableEvent;
        if (hasRandomEnding)
        {
            RandomizeEnding(thisStory);
        }

        foreach (ChoiceOutcomes outcome in this.outcomes)
        {
            outcome.isScaledOutcome = isScalableEvent;
        }

        if (driver.isCharacterEvent)
        {
            foreach (ChoiceOutcomes outcome in this.outcomes)
            {
                outcome.AssignCharacterDriver((CharacterEvent)driver);
            }
        }

        if (hasRequirements)
        {
            //if anything in choiceRequirements does not match, this bool is automatically false
            for (int i = 0; i < choiceRequirements.Count; i++)
            {
                choiceRequirements[i].isScalableEvent = isScalableEvent;

                if (!choiceRequirements[i].MatchesRequirements(ship, driver.campMan))
                {
                    requirementMatch = false;
                }
            }
        }

        if (hasPercentChange)
        {
            for (int i = 0; i < percentIncrease.Count; i++)
            {
                if (percentIncrease[i].MatchesSuccessChance(ship))
                {
                    percantageIncreased = percentIncrease[i].GetTotalPercentIncrease();
                    increasedPercent    = true;
                }
            }
        }

        if (requirementMatch)
        {
            myButton.interactable = true;
            story = thisStory;
        }
        else
        {
            myButton.interactable = false;
        }
        // Tooltip stuff
        if (hasRandomEnding)
        {
            tooltip.SetOutcomeData(description, secretOutComeText, randomEndingOutcomes);
        }
        else
        {
            if (!hasSecretOutcomes)
            {
                tooltip.SetOutcomeData(description, outcomes);
            }
            else
            {
                tooltip.SetOutcomeData(description, secretOutComeText, outcomes);
            }
        }
    }