Ejemplo n.º 1
0
    void CloseTutorial(TutorialEvent t)
    {
        if (t.type == TutorialEvent.TutorialTypes.popup)
        {
            switch (t.complete_trigger)
            {
            case TutorialEvent.TutorialCompletionTriggers.clickButton:
            case TutorialEvent.TutorialCompletionTriggers.clickPopup:
                tutorialOverlay.ClosePanel();
                GameManager.Instance.tracker.CreateEventExt("CloseTutorial", "clickPopup");
                break;

            case TutorialEvent.TutorialCompletionTriggers.placeSemaphore:
            case TutorialEvent.TutorialCompletionTriggers.placeSignal:
                tutorialOverlay.ClosePanel();
                GameManager.Instance.tracker.CreateEventExt("CloseTutorial", "placeDraggable");
                break;

            case TutorialEvent.TutorialCompletionTriggers.simulationInteraction:
                tutorialOverlay.ClosePanel();
                GameManager.Instance.tracker.CreateEventExt("CloseTutorial", "simulationInteraction");
                break;
            }
            t.hasCompleted = true;
        }
        else if (t.type == TutorialEvent.TutorialTypes.video)
        {
        }
        else if (t.type == TutorialEvent.TutorialTypes.simulation)
        {
            PlayerInteraction_GamePhaseBehavior playerInteractionBehavior = (PlayerInteraction_GamePhaseBehavior)GameManager.Instance.playerInteractionBehavior;
            t.hasCompleted = true;
        }
    }
Ejemplo n.º 2
0
        void OnExitConfrimed()
        {
            PlayerInteraction_GamePhaseBehavior playPhase = (PlayerInteraction_GamePhaseBehavior)GameManager.Instance.playerInteractionBehavior;

            playPhase.TriggerPlayPhaseEnd();
            pi_gpb.playerInteraction_UI.overlayBackground.SetAlpha(0f);
        }
Ejemplo n.º 3
0
    List <TutorialEvent> RetrieveTutorialEvents(int inputLevelId, TutorialEvent.TutorialInitializeTriggers inputInitPhase)
    {
        Debug.Log("Retrieving Tutorial Events... Level " + inputLevelId + " Phase " + inputInitPhase.ToString());
        List <TutorialEvent> returnEvents     = new List <TutorialEvent>();
        PlayerInteraction_GamePhaseBehavior p = (PlayerInteraction_GamePhaseBehavior)GameManager.Instance.playerInteractionBehavior;

        foreach (TutorialEvent t in tutorialEvents)
        {
            if (t.init_trigger == inputInitPhase)
            {
                if (t.levelNumber == inputLevelId && !t.hasCompleted)
                {
                    returnEvents.Add(t);
                }
            }
            else if (t.init_trigger != inputInitPhase && returnEvents.Count > 0)
            {
                break;
            }
        }
        foreach (TutorialEvent t in returnEvents)
        {
            Debug.Log("TUTORIAL QUEUED: " + t.popupDescription + "\n");
        }
        return(returnEvents);
    }
Ejemplo n.º 4
0
    public void TriggerLevelSimulation(LinkJava.SimulationFeedback feedback)
    {
        LinkJava.OnSimulationCompleted -= TriggerLevelSimulation;

        PlayerInteraction_GamePhaseBehavior castBehavior = (PlayerInteraction_GamePhaseBehavior)playerInteractionBehavior;

        //none indicates hitting the replay button
        if (feedback != LinkJava.SimulationFeedback.none)
        {
            //Debug.Log("Feedback from LinkJava to GameManager was " + feedback.ToString());
            castBehavior.StartSimulation();
        }

        if (feedback == LinkJava.SimulationFeedback.success || feedback == LinkJava.SimulationFeedback.none)
        {
            castBehavior.StartSimulation();
        }

        else if (feedback == LinkJava.SimulationFeedback.failure)
        {
            castBehavior.playerInteraction_UI.loadingOverlay.ClosePanel();
            PlayerInteraction_GamePhaseBehavior playerInteraction = playerInteractionBehavior as PlayerInteraction_GamePhaseBehavior;
            playerInteraction.EndSimulation();
            castBehavior.playerInteraction_UI.simulationErrorOverlay.OpenPanel();
        }
    }
Ejemplo n.º 5
0
    void PerformTutorial(TutorialEvent t)
    {
        //Debug.Log("Performing Tutorial Event");
        if (t.type == TutorialEvent.TutorialTypes.popup)
        {
            switch (t.complete_trigger)
            {
            case TutorialEvent.TutorialCompletionTriggers.clickButton:
            case TutorialEvent.TutorialCompletionTriggers.placeSignal:
            case TutorialEvent.TutorialCompletionTriggers.placeSemaphore:
                GameManager.Instance.tracker.CreateEventExt("PerformTutorial", t.popupDescription);
                tutorialOverlay.SetTooltip(t.popupDescription, t.targetButton, t.nextTutorial);
                tutorialOverlay.OpenPanel();
                t.ActivateTutorialEventListener();
                break;

            case TutorialEvent.TutorialCompletionTriggers.clickPopup:
                GameManager.Instance.tracker.CreateEventExt("PerformTutorial", t.popupDescription);
                if (t.targetComponentType.Length > 0)
                {
                    List <GridObjectBehavior> objectsOfType = GameManager.Instance.GetGridManager().GetGridComponentsOfType("signal");
                    if (objectsOfType.Count > 0)
                    {
                        tutorialOverlay.SetTooltip(t.popupDescription, objectsOfType[0].gameObject, t.nextTutorial);
                    }
                    else
                    {
                        tutorialOverlay.SetTooltip(t.popupDescription, t.targetButton, t.nextTutorial);
                    }
                }
                else
                {
                    tutorialOverlay.SetTooltip(t.popupDescription, t.targetButton, t.nextTutorial);
                }
                tutorialOverlay.SetTooltip(t.popupDescription, t.targetButton, t.nextTutorial);

                tutorialOverlay.OpenPanel();
                t.ActivateTutorialEventListener();
                break;

            case TutorialEvent.TutorialCompletionTriggers.simulationInteraction:
                GameManager.Instance.tracker.CreateEventExt("PerformTutorial", "simulationInteraction");
                t.ActivateTutorialEventListener();
                break;
            }
        }
        else if (t.type == TutorialEvent.TutorialTypes.video)
        {
        }
        else if (t.type == TutorialEvent.TutorialTypes.simulation)
        {
            PlayerInteraction_GamePhaseBehavior playerInteractionBehavior = (PlayerInteraction_GamePhaseBehavior)GameManager.Instance.playerInteractionBehavior;
            if (t.overrideSimulation == true)
            {
                playerInteractionBehavior.tutorialMode = true;
                GameManager.Instance.TriggerLoadTutorialLevel(t.filepath);
                t.ActivateTutorialEventListener();
            }
        }
    }
Ejemplo n.º 6
0
    void PerformTutorial(TutorialEvent t)
    {
        if (t.type == TutorialEvent.TutorialTypes.popup)
        {
            switch (t.complete_trigger)
            {
            case TutorialEvent.TutorialCompletionTriggers.clickButton:
            case TutorialEvent.TutorialCompletionTriggers.clickPopup:
            case TutorialEvent.TutorialCompletionTriggers.placeSignal:
            case TutorialEvent.TutorialCompletionTriggers.placeSemaphore:
                GameManager.Instance.tracker.CreateEventExt("PerformTutorial", t.popupDescription);
                Vector3 defaultPosition = new Vector3(Screen.width / 2, Screen.height / 2, 0);
                if (t.targetButton != null)
                {
                    defaultPosition = t.targetButton.transform.position;
                    if (defaultPosition.x > (Screen.width / 2))
                    {
                        defaultPosition.x -= t.targetButton.GetComponent <RectTransform>().rect.width / 2;
                    }
                    else
                    {
                        defaultPosition.x += t.targetButton.GetComponent <RectTransform>().rect.width / 2;
                    }
                    if (defaultPosition.y > (Screen.height / 2))
                    {
                        defaultPosition.x -= t.targetButton.GetComponent <RectTransform>().rect.height / 2;
                    }
                    else
                    {
                        defaultPosition.x += t.targetButton.GetComponent <RectTransform>().rect.height / 2;
                    }
                }
                tutorialOverlay.PrepareTutorialPopup(t.popupDescription, defaultPosition);
                tutorialOverlay.OpenPanel();
                t.ActivateTutorialEventListener();
                break;

            case TutorialEvent.TutorialCompletionTriggers.simulationInteraction:
                GameManager.Instance.tracker.CreateEventExt("PerformTutorial", "simulationInteraction");
                t.ActivateTutorialEventListener();
                break;
            }
        }
        else if (t.type == TutorialEvent.TutorialTypes.video)
        {
        }
        else if (t.type == TutorialEvent.TutorialTypes.simulation)
        {
            PlayerInteraction_GamePhaseBehavior playerInteractionBehavior = (PlayerInteraction_GamePhaseBehavior)GameManager.Instance.playerInteractionBehavior;
            if (t.overrideSimulation == true)
            {
                playerInteractionBehavior.tutorialMode = true;
                GameManager.Instance.TriggerLoadTutorialLevel(t.filepath);
                t.ActivateTutorialEventListener();
            }
        }
    }
Ejemplo n.º 7
0
    IEnumerator FinishSimulation()
    {
        Debug.Log("FinishSimulation");

        yield return new WaitForEndOfFrame();

        if (PlayerInteraction_GamePhaseBehavior.onCompletion != null) PlayerInteraction_GamePhaseBehavior.onCompletion();

        //yield return new WaitForSeconds(1f);
        //todo: switch statement of the selected goal option

        playerInteraction.ResetStartValues();

        switch (playerInteraction.playerInteraction_UI.goalOverlay.userInput)
        {
            case PlayerInteraction_UI.Goal_UIOverlay.UserInputs.exit:
            case PlayerInteraction_UI.Goal_UIOverlay.UserInputs.levels:
                playerInteraction.TriggerPlayPhaseEnd();
                //Debug.Log("User input for exit or levels hit.");
                playerInteraction.EndSimulation();
                break;
            case PlayerInteraction_UI.Goal_UIOverlay.UserInputs.stop:
                playerInteraction.TriggerPlayPhaseEnd();
                //Debug.Log("User input for exit or levels hit.");
                playerInteraction.EndSimulation();
                break;
            case PlayerInteraction_UI.Goal_UIOverlay.UserInputs.replay:

                //Debug.Log("REPLAY");
                //TODO: CHECK IF INTERACTION PHASE IS INCORRECT HERE.
                playerInteraction.interactionPhase = PlayerInteraction_GamePhaseBehavior.InteractionPhases.awaitingSimulation;
                GameManager.Instance.TriggerLevelSimulation(LinkJava.SimulationFeedback.none);

                break;
            case PlayerInteraction_UI.Goal_UIOverlay.UserInputs.retry:
                //Debug.Log("Retry");
                playerInteraction.interactionPhase = PlayerInteraction_GamePhaseBehavior.InteractionPhases.ingame_default;
                playerInteraction.EndSimulation();
                if (GameManager.Instance.GetDataManager().currentLevelData.metadata.level_type != -1)
                {
                    GameManager.Instance.TriggerLevelTutorial
                    (
                        GameManager.Instance.GetDataManager().currentLevelData.metadata.level_id,
                        playerInteraction.interactionPhase == PlayerInteraction_GamePhaseBehavior.InteractionPhases.awaitingSimulation || playerInteraction.interactionPhase == PlayerInteraction_GamePhaseBehavior.InteractionPhases.simulation ? TutorialEvent.TutorialInitializeTriggers.duringSimulation : TutorialEvent.TutorialInitializeTriggers.beforePlay
                    );
                }
                break;
            case PlayerInteraction_UI.Goal_UIOverlay.UserInputs.levelsNext:
                playerInteraction.TriggerPlayPhaseEnd(GameManager.GamePhases.LoadScreen, true);
                break;
            default:
                //Debug.Log("No case defined for " + playerInteraction.playerInteraction_UI.goalOverlay.userInput.ToString());
                playerInteraction.interactionPhase = PlayerInteraction_GamePhaseBehavior.InteractionPhases.ingame_default;
                break;
        }
    }
Ejemplo n.º 8
0
    void StepListener(StepData inputStep)
    {
        if (inputStep.componentID == targetSimulationStep.componentID)
        {
            /*
             * if (targetButton != null)
             * {
             *  targetButton.onClick.RemoveAllListeners();
             *  targetButton.enabled = true;
             *  targetButton.onClick.AddListener(() => TriggerTutorialEventListener());
             * }
             */
            if (PlayerInteraction_GamePhaseBehavior.pauseSimulation != null && pause == true)
            {
                PlayerInteraction_GamePhaseBehavior.pauseSimulation();
                //targetButton.onClick.AddListener(() => PlayerInteraction_GamePhaseBehavior.unpauseSimulation());
                if (pauseDuration != 0)
                {
                    PlayerInteraction_GamePhaseBehavior.delayedUnpause(pauseDuration, this);
                }
            }
            Vector3 targetPosition = GameManager.Instance.GetGridManager().GetGridObjectByID(inputStep.componentID).transform.position;
            targetPosition = GameManager.Instance.GetGridManager().worldCamera.WorldToScreenPoint(targetPosition);
            GameManager.Instance.CreateTutorialPopup(this, targetPosition);
            Debug.Log("Listen for step!");
            PlayerInteraction_GamePhaseBehavior.onSimulationStep -= StepListener;
        }
        //if greater or equal 9000, the component is USER created so we can't assume its id
        else if (targetSimulationStep.componentID >= 9000 && inputStep.componentID >= 9000)
        {
            if (targetSimulationStep.componentStatus.passed > 0)
            {
                if (inputStep.componentStatus != null && inputStep.componentStatus.passed != null)
                {
                    if (inputStep.componentStatus.passed > 0)
                    {
                        if (PlayerInteraction_GamePhaseBehavior.pauseSimulation != null && pause == true)
                        {
                            PlayerInteraction_GamePhaseBehavior.pauseSimulation();
                            //targetButton.onClick.AddListener(() => PlayerInteraction_GamePhaseBehavior.unpauseSimulation());
                            if (pauseDuration != 0)
                            {
                                PlayerInteraction_GamePhaseBehavior.delayedUnpause(pauseDuration, this);
                            }
                        }

                        Vector3 targetPosition = GameManager.Instance.GetGridManager().GetGridObjectByID(inputStep.componentID).transform.position;
                        targetPosition = GameManager.Instance.GetGridManager().worldCamera.WorldToScreenPoint(targetPosition);
                        GameManager.Instance.CreateTutorialPopup(this, targetPosition);
                        Debug.Log("Listen for step!");
                        PlayerInteraction_GamePhaseBehavior.onSimulationStep -= StepListener;
                    }
                }
            }
        }
    }
Ejemplo n.º 9
0
 public void ResetToLevelSelect()
 {
     AbortLinkJavaProcess();
     if (gamePhase == GamePhases.PlayerInteraction)
     {
         PlayerInteraction_GamePhaseBehavior playPhase = (PlayerInteraction_GamePhaseBehavior)playerInteractionBehavior;
         playPhase.TriggerPlayPhaseEnd();
     }
     SetGamePhase(GamePhases.LoadScreen);
 }
Ejemplo n.º 10
0
    public void AbortLinkJavaProcess()
    {
        GetLinkJava().StopExternalProcess();
        Load_GamePhaseBehavior levelSelect = loadScreenBehavior as Load_GamePhaseBehavior;

        levelSelect.loadUI.levelLoadingOverlay.ClosePanel();
        PlayerInteraction_GamePhaseBehavior playerInteraction = playerInteractionBehavior as PlayerInteraction_GamePhaseBehavior;

        playerInteraction.playerInteraction_UI.loadingOverlay.ClosePanel();
        playerInteraction.playerInteraction_UI.simulationErrorOverlay.ClosePanel();
    }
Ejemplo n.º 11
0
    void Update()
    {
        PlayerInteraction_GamePhaseBehavior p = (PlayerInteraction_GamePhaseBehavior)playerInteractionBehavior;
        string currPhase = p.interactionPhase.ToString();

        if (!currPhase.Equals(lastPhase))
        {
            lastPhase = currPhase;
        }

        UpdateGamePhaseBehavior();
    }
Ejemplo n.º 12
0
    public void PlayTutorialLevel()
    {
        string levelToString = SerializeCurrentLevel();
        //Debug.Log(levelToString);
        string filename =
            linkJava.savePath
            + Constants.FilePrefixes.inputLevelFile + "_PLAY_"
            + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";

        linkJava.simulationMode = LinkJava.SimulationTypes.Play;
        GameManager.Instance.tracker.CreateEventExt("SubmitCurrentLevel" + "PLAY", filename);

        PlayerInteraction_GamePhaseBehavior castBehavior = (PlayerInteraction_GamePhaseBehavior)playerInteractionBehavior;

        castBehavior.StartSimulation();
    }
Ejemplo n.º 13
0
    List <TutorialEvent> RetrieveTutorialEvents(int inputLevelId, TutorialEvent.TutorialInitializeTriggers inputInitPhase)
    {
        //Debug.Log("Retrieving Tutorial Events... Level " + inputLevelId + " Phase " + inputInitPhase.ToString());
        List <TutorialEvent> returnEvents     = new List <TutorialEvent>();
        PlayerInteraction_GamePhaseBehavior p = (PlayerInteraction_GamePhaseBehavior)GameManager.Instance.playerInteractionBehavior;

        bool foundSimEvents = false; //triggered once events made to play during the simulation are found, prevents queuing of beforePlay events that follow it

        int currentSequence = -1;

        foreach (TutorialEvent t in tutorialEvents)
        {
            if (t.levelNumber == inputLevelId && !t.hasCompleted)
            {
                if (t.init_trigger == TutorialEvent.TutorialInitializeTriggers.duringSimulation)
                {
                    foundSimEvents = true;
                }
                else if (t.init_trigger == TutorialEvent.TutorialInitializeTriggers.beforePlay && foundSimEvents == true)
                {
                    break;
                }
                if (currentSequence == -1)
                {
                    currentSequence = t.sequenceId;
                }
                if (currentSequence == t.sequenceId)
                {
                    returnEvents.Add(t);
                }
            }
            else if (t.levelNumber > inputLevelId)
            {
                break;
            }

            /*if (t.init_trigger == inputInitPhase)
             * {
             *  if (t.levelNumber == inputLevelId && !t.hasCompleted) returnEvents.Add(t);
             * }*/
            //else if (t.init_trigger != inputInitPhase && returnEvents.Count > 0) break;
        }
        foreach (TutorialEvent t in returnEvents)
        {
        }                                             //Debug.Log("TUTORIAL QUEUED: " + t.popupDescription + "\n");
        return(returnEvents);
    }
Ejemplo n.º 14
0
        public void EnableButtonBehaviors()
        {
            retry.onClick.RemoveAllListeners();
            replay.onClick.RemoveAllListeners();

            levels.onClick.RemoveAllListeners();
            levelsConfirm.onClick.RemoveAllListeners();
            levelsDeny.onClick.RemoveAllListeners();
            levelsNext.onClick.RemoveAllListeners();

            PlayerInteraction_GamePhaseBehavior playerInteraction = GameManager.Instance.playerInteractionBehavior as PlayerInteraction_GamePhaseBehavior;
            bool showNextLevelButton = (GameManager.Instance.GetCurrentSimulationType() == LinkJava.SimulationTypes.ME &&
                                        playerInteraction.playbackBehavior.success &&
                                        GameManager.Instance.currentLevelReferenceObject.completionRank > 0 &&
                                        !GameManager.Instance.IsInPCG());

            levelsNext.gameObject.SetActive(showNextLevelButton);

            exit.onClick.RemoveAllListeners();
            exitConfirm.onClick.RemoveAllListeners();
            exitDeny.onClick.RemoveAllListeners();

            retry.onClick.AddListener(() => { userInput = UserInputs.retry; ClosePanel(); });
            replay.onClick.AddListener(() => { userInput = UserInputs.replay; ClosePanel(); });
            levels.onClick.AddListener(() => { userInput = UserInputs.levels; OpenLevelsConfirmationScreen(); });
            levelsConfirm.onClick.AddListener(() => { ClosePanel(); });
            levelsDeny.onClick.AddListener(() => OpenRootScreen());

            levelsNext.onClick.AddListener(() => { userInput = UserInputs.levelsNext; /*GameManager.Instance.TriggerAdvanceToNextLevel();*/ ClosePanel(); });
            //levelsNext.gameObject.SetActive(!GameManager.Instance.IsInPCG());

            exit.onClick.AddListener(() => { userInput = UserInputs.exit; OpenExitConfirmationScreen(); });
            exitConfirm.onClick.AddListener(() => { GameManager.Instance.SetGamePhase(GameManager.GamePhases.CloseGame); /* /*ClosePanel();*/ });
            exitDeny.onClick.AddListener(() => OpenRootScreen());

            goalToggle.toggleButton.onClick.RemoveAllListeners();
            goalToggle.toggleButton.onClick.AddListener(() => ToggleGoalVisibility());

            saveLevel.onClick.RemoveAllListeners();
            saveLevel.onClick.AddListener(() => GameManager.Instance.TriggerPCGLevelSave());
            saveLevel.gameObject.SetActive(false);
            //saveLevel.gameObject.SetActive( GameManager.Instance.IsInPCG() );
            //just for november 2018 study
        }
    public void TriggerLevelSimulation(LinkJava.SimulationFeedback feedback)
    {
        LinkJava.OnSimulationCompleted -= TriggerLevelSimulation;

        //none indicates hitting the replay button
        if (feedback != LinkJava.SimulationFeedback.none)
        {
            Debug.Log("Feedback from LinkJava to GameManager was " + feedback.ToString());
        }

        PlayerInteraction_GamePhaseBehavior castBehavior = (PlayerInteraction_GamePhaseBehavior)playerInteractionBehavior;

        if (feedback == LinkJava.SimulationFeedback.success)
        {
            castBehavior.StartSimulation();
        }
        else
        {
            castBehavior.playerInteraction_UI.simulationErrorOverlay.OpenPanel();
        }
    }
    IEnumerator FinishSimulation(int maxStep)
    {
        Debug.Log("FinishSimulation");

        yield return(new WaitForEndOfFrame());

        if (PlayerInteraction_GamePhaseBehavior.onCompletion != null)
        {
            PlayerInteraction_GamePhaseBehavior.onCompletion();
        }

        //yield return new WaitForSeconds(1f);
        //todo: switch statement of the selected goal option

        playerInteraction.ResetStartValues();

        switch (playerInteraction.playerInteraction_UI.goalOverlay.userInput)
        {
        case PlayerInteraction_UI.Goal_UIOverlay.UserInputs.exit:
        case PlayerInteraction_UI.Goal_UIOverlay.UserInputs.levels:
            playerInteraction.TriggerPlayPhaseEnd();
            //Debug.Log("User input for exit or levels hit.");
            playerInteraction.EndSimulation();
            break;

        case PlayerInteraction_UI.Goal_UIOverlay.UserInputs.stop:
            playerInteraction.TriggerPlayPhaseEnd();
            //Debug.Log("User input for exit or levels hit.");
            playerInteraction.EndSimulation();
            break;

        case PlayerInteraction_UI.Goal_UIOverlay.UserInputs.replay:

            playerInteraction.playerInteraction_UI.goalOverlay.ClosePanel();
            StartCoroutine(PlaySimulation(maxStep));
            PauseSimulation();
            DelayedUnpause(1f);

            break;

        case PlayerInteraction_UI.Goal_UIOverlay.UserInputs.retry:
            //Debug.Log("Retry");
            playerInteraction.interactionPhase = PlayerInteraction_GamePhaseBehavior.InteractionPhases.ingame_default;
            playerInteraction.EndSimulation();
            if (GameManager.Instance.GetDataManager().currentLevelData.metadata.level_type != -1)
            {
                GameManager.Instance.TriggerLevelTutorial
                (
                    GameManager.Instance.GetDataManager().currentLevelData.metadata.level_id,
                    playerInteraction.interactionPhase == PlayerInteraction_GamePhaseBehavior.InteractionPhases.awaitingSimulation || playerInteraction.interactionPhase == PlayerInteraction_GamePhaseBehavior.InteractionPhases.simulation ? TutorialEvent.TutorialInitializeTriggers.duringSimulation : TutorialEvent.TutorialInitializeTriggers.beforePlay
                );
            }
            break;

        case PlayerInteraction_UI.Goal_UIOverlay.UserInputs.levelsNext:
            playerInteraction.TriggerPlayPhaseEnd(GameManager.GamePhases.LoadScreen, true);
            break;

        default:
            //Debug.Log("No case defined for " + playerInteraction.playerInteraction_UI.goalOverlay.userInput.ToString());
            playerInteraction.interactionPhase = PlayerInteraction_GamePhaseBehavior.InteractionPhases.ingame_default;
            break;
        }
    }
Ejemplo n.º 17
0
        void OnExitConfrimed()
        {
            PlayerInteraction_GamePhaseBehavior playPhase = (PlayerInteraction_GamePhaseBehavior)GameManager.Instance.playerInteractionBehavior;

            playPhase.TriggerPlayPhaseEnd();
        }
Ejemplo n.º 18
0
    IEnumerator PlaySimulation(int maxStep)
    {
        int maxGoalsCompleted = 0;
        currentStep = 0;
        paused = false;
        playerInteraction.playerInteraction_UI.playbackSlider.value = 0;
        bool nextLevelButtonVisibility = false;
        while (currentStep <= maxStep)
        {
            if (paused != true)
            {
                if (stepDictionary.ContainsKey(currentStep))
                {
                    float waitTime = 0f;
                    int count = 0;
                    foreach (StepData step in stepDictionary[currentStep])
                    {
                        count++;
                        if (step.componentID == 0)
                        {
                            yield return new WaitForSeconds(0.5f);
                            if (step.componentStatus == null) continue;
                            if (step.componentStatus.goals_completed != null && step.componentStatus.final_condition != -1)
                            {
                                if (maxGoalsCompleted < step.componentStatus.goals_completed) { maxGoalsCompleted = step.componentStatus.goals_completed; }
                            }
                            if (step.componentStatus.final_condition != null && step.componentStatus.final_condition != -1)
                            {
                                playerInteraction.score.stepCount = maxStep;
                                string titleFormatString = "<size=18><b>{0}</b></size>\n";
                                string titleString = "";
                                string goalString = "";
                                string levelFileName = "";
                                if (GameManager.Instance.currentLevelReferenceObject != null) levelFileName = GameManager.Instance.currentLevelReferenceObject.file;

                                switch (step.componentStatus.final_condition)
                                {
                                    case 2:
                                    case 8:
                                    case 10:
                                        success = true;
                                        //if "test" versus "submit" change this text
                                        if (GameManager.Instance.GetCurrentSimulationType() == LinkJava.SimulationTypes.ME)
                                        {
                                            titleString = "SUCCESSFUL SOLUTION";
                                            goalString += "\n• Congratulations! This solution will always work. Please proceed to the next level.";
                                            playerInteraction.score.completed = true;

                                            //get current score
                                            int currentScore = GameManager.Instance.GetScoreManager().GetCalculatedScore(playerInteraction.score);
                                            //update saved score
                                            GameManager.Instance.GetScoreManager().ScoreLevel(playerInteraction.score);
                                            int lvlScore = GameManager.Instance.GetScoreManager().GetCalculatedScore(playerInteraction.score.index);

                                            GameManager.Instance.currentLevelReferenceObject.completionRank = lvlScore;
                                            GameManager.Instance.GetDataManager().UpdateLevelRank(levelFileName, lvlScore);

                                            //use 'current' not 'best' score for the feedback
                                            playerInteraction.playerInteraction_UI.goalOverlay.SetFeedbackScore(currentScore);

                                            nextLevelButtonVisibility = true;
                                        }
                                        else if (GameManager.Instance.GetCurrentSimulationType() == LinkJava.SimulationTypes.Play)
                                        {
                                            titleString = "TEST COMPLETE";
                                            goalString += "\n• This solution was successful this time. Submit to check if it's always successful.";
                                            playerInteraction.playerInteraction_UI.goalOverlay.SetFeedbackScore(-1);
                                        }
                                        break;
                                    default:
                                        success = false;
                                        //if "test" versus "submit" change this text
                                        if (GameManager.Instance.GetCurrentSimulationType() == LinkJava.SimulationTypes.ME)
                                        {
                                            titleString = "UNSUCCESSFUL SOLUTION";
                                        }
                                        else if (GameManager.Instance.GetCurrentSimulationType() == LinkJava.SimulationTypes.Play)
                                        {
                                            titleString = "TEST COMPLETE";
                                            playerInteraction.playerInteraction_UI.goalOverlay.SetFeedbackScore(-1);
                                        }

                                        goalString = "";
                                        if ((step.componentStatus.final_condition & 1) != 0)
                                        {
                                            goalString += "\n• Make sure arrows aren't blocked.";
                                        }
                                        if ((step.componentStatus.final_condition & 4) != 0)
                                        {
                                            goalString += "\n• This solution was unsuccessful.";
                                        }
                                        if ((step.componentStatus.final_condition & 16) != 0)
                                        {
                                            goalString += "\n• Make sure arrows can't deliver at the same time.";
                                        }
                                        if ((step.componentStatus.final_condition & 32) != 0)
                                        {
                                            goalString += "\n• Make sure all arrows can move.";
                                        }
                                        if ((step.componentStatus.final_condition & 64) != 0)
                                        {
                                            goalString += "\n• Make sure arrows don't get caught in an infinite loop.";
                                        }
                                        if ((step.componentStatus.final_condition & 512) != 0)
                                        {
                                            goalString += "\n• Wrong turn! Check the Flow Arrows on the right of the screen.";
                                        }
                                        List<string> errorFeedback = new List<string>();
                                        foreach (string errorKey in step.componentStatus.goal_descriptions)
                                        {
                                            string key = errorKey.Substring(0, 3);
                                            if (Constants.GoalFeedbackValues.GoalErrorFeedback.ContainsKey(key))
                                            {
                                                if (!errorFeedback.Contains(Constants.GoalFeedbackValues.GoalErrorFeedback[key]))
                                                    errorFeedback.Add(Constants.GoalFeedbackValues.GoalErrorFeedback[key]);
                                            }
                                        }
                                        foreach (string s in errorFeedback) goalString += ("• " + s + "\n");

                                        break;
                                }

                                if (GameManager.Instance.GetCurrentSimulationType() == LinkJava.SimulationTypes.ME)
                                {
                                    playerInteraction.playerInteraction_UI.goalOverlay.levels.gameObject.SetActive(true);
                                }
                                else if (GameManager.Instance.GetCurrentSimulationType() == LinkJava.SimulationTypes.Play)
                                {
                                    playerInteraction.playerInteraction_UI.goalOverlay.levels.gameObject.SetActive(false);
                                }

                                yield return StartCoroutine(playerInteraction.playerInteraction_UI.TriggerGoalPopUp(titleString, goalString));
                            }
                        }
                        else
                        {
                            GridObjectBehavior g = GameManager.Instance.GetGridManager().GetGridObjectByID(step.componentID);
                            if (g != null)
                            {
                                if (g.timeStep == null)
                                    g.SetTimestep(timeSteps[currentStep]);
                                float time = g.DoStep(step, stepDictionary);
                                if (time > waitTime)
                                    waitTime = time;
                            }
                            else { Debug.Log("Could not find " + step.componentID); }
                        }

                        if (PlayerInteraction_GamePhaseBehavior.onSimulationStep != null)
                        {
                            PlayerInteraction_GamePhaseBehavior.onSimulationStep(step);
                            //PauseSimulation();
                            //UnpauseAfterDelay(5);
                        }
                    }
                    while (paused) yield return new WaitForSeconds(0.1f);
                    yield return new WaitForSeconds(waitTime);
                }
                currentStep++;
                playerInteraction.playerInteraction_UI.playbackSlider.value = currentStep;
                //Debug.Log(currentStep);
            }
            else
            {
                yield return new WaitForEndOfFrame();
            }
        }

        yield return StartCoroutine(FinishSimulation());
    }