Exemplo n.º 1
0
    private IEnumerator DigGrave()
    {
        isDigging = true;                  //stop us digging multiple times
        animator.SetBool("Digging", true); //set the animator bool so we start digging
        nearestGrave.AttackGrave();

        ShovelSound.gameObject.SetActive(true);

        while (!nearestGrave._destroyed) //as long as the grave we are targeting isnt destroyed, keep digging
        {
            robberRB.velocity = Vector2.zero;
            GetComponent <Collider2D>().isTrigger = true; //stop all collisions
            if (isTerrified)                              //if weve gotten terrified, break the digging loop
            {
                animator.SetBool("Digging", false);
                break;
            }
            nearestGrave.TakeDamage(0.5f);
            nearestGrave.LowerHappiness(1f);
            yield return(new WaitForSeconds(0.1f));
        }
        if (!isTerrified) //if we exited the loop and werent terrified, runaway with our loot!
        {
            animator.SetBool("Digging", false);
            hasLoot = true;
            nearestGrave.GetComponentInChildren <GraveGhost>().lootStolen = true;
            StartCoroutine(RunAwayWithLoot());
        }

        GetComponent <Collider2D>().isTrigger = false; //start collisions again
        nearestGrave.StopAttackingGrave();             //stop attacking the grave, freeing up others to potentially attack it
        isDigging         = false;
        positionToSeekOut = escapePosition;            //set our target as the escape position, and update our path
        ShovelSound.gameObject.SetActive(false);
        UpdatePath(positionToSeekOut);
    }
Exemplo n.º 2
0
    //EVENT STUFF

    private IEnumerator StartTutorial()
    {
        print("starting tutorial");

        _isPlayingTutorial = true;


        //  Setup of Scene for the tutorial

        //  UI

        _UIScript.StartTutorial();

        Unpause();
        SpawnPlayer();
        SetPlayerReferencesInScene();
        References.playerScript.HidePlayer();
        References.playerScript.LockMovement();
        References.playerScript.playerAnimator.SetBool("HatOn", false);
        //lock all our abilities
        References.playerScript._screamLocked = References.playerScript._dashLocked = References.playerScript._possessionLocked
                                                                                          = References.playerScript._depossessionLocked = References.playerScript._interactionLocked = true;
        DayNightLighting.freezeDayNight = true;
        SetupDayAndNight();


        DisableGraveghostFadein();

        //  First Scene; Zooms In and caretaker talks to you

        StartCoroutine(_UIScript.FadeFromBlack());
        yield return(new WaitForSeconds(2f));

        _cameraScript.Zoom(30, 0.75f);
        yield return(new WaitForSeconds(1f));

        StartCoroutine(_tutorialGhost.FadeIn());
        yield return(new WaitForSeconds(1f));

        //Scene #1: The Wakeup

        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        _UIScript.HidePlayerUI();

        References.playerScript.ShowPlayer();

        //  Scene #2; Player looks around and then talks to the ghost

        yield return(new WaitForSeconds(1.5f));

        //player looks around...
        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(-1, -1);
        yield return(new WaitForSeconds(0.5f));

        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(0, -1);
        yield return(new WaitForSeconds(0.5f));

        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(1, -1);
        yield return(new WaitForSeconds(1f));

        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(0, -1);
        yield return(new WaitForSeconds(0.1f));

        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(-1, 0);
        yield return(new WaitForSeconds(0.1f));

        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(-1, 1);
        yield return(new WaitForSeconds(0.5f));

        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        //Scene #3: Move our ghosts to the new location, then give the backstory of our ghost

        _tutorialGhost.MoveToNextPos();
        yield return(new WaitForSeconds(1.5f));

        References.playerScript.MoveToNextPos();
        yield return(new WaitWhile(() => !References.playerScript.reachedEndOfPath));

        yield return(new WaitWhile(() => !_tutorialGhost.reachedEndOfPath));

        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(-1, 0); //player looks at tutorial ghost
        yield return(new WaitForSeconds(0.5f));

        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        yield return(new WaitForSeconds(1f));

        // Scene #4: Tutorial ghost moves to our right to investigate, asks us to follow after

        _tutorialGhost.MoveToNextPos();
        while (!_tutorialGhost.reachedEndOfPath)
        {
            References.playerScript.lastMovementDir = References.playerScript.movement = (_tutorialGhost.transform.position - References.playerScript.transform.position);
            yield return(new WaitForFixedUpdate());
        }
        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        _tutorialGhost.MoveToNextPos();
        yield return(new WaitForSeconds(1f));

        References.playerScript.MoveToNextPos();
        yield return(new WaitWhile(() => !References.playerScript.reachedEndOfPath));

        yield return(new WaitWhile(() => !_tutorialGhost.reachedEndOfPath));

        //player look at ghost
        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(1, 1);
        yield return(new WaitForSeconds(0.2f));

        //  Scene #5: Talk with Grandma and Grandpa about Incense, and the graverobbers
        _grandma.DistanceFromPlayerToActivate = 100;
        _grandpa.DistanceFromPlayerToActivate = 100;
        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        _grandma.DistanceFromPlayerToActivate = 0;
        _grandpa.DistanceFromPlayerToActivate = 0;

        //  Scene #6: Move Player and tutorial to the kitty, and fight the robber!

        _kitty.DistanceFromPlayerToActivate = 100;
        _kittyGrave.InitMaxHealth(100000); //make kitty grave unkillable for tutorial purposes
        _kittyGrave.TakeDamage(40000);     //set at half health

        GraveRobber Robber = SpawnTutorialRobber(tutorialRobberPositions[0]);

        Robber.InitRobber(allGraves, _graveRobberEscapePos);
        _tutorialGhost.MoveToNextPos();
        yield return(new WaitForSeconds(1f));

        References.playerScript.MoveToNextPos();
        yield return(new WaitWhile(() => !References.playerScript.reachedEndOfPath));

        yield return(new WaitWhile(() => !_tutorialGhost.reachedEndOfPath));

        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        StartCoroutine(_UIScript.FadeInPrompts());
        _UIScript.PromptScream();
        Robber.fearLevel.InitMaxFear(40);
        References.playerScript._screamLocked = false;
        _UIScript.ScreamMeterHidden           = false;
        _UIScript.portraitHidden = false;
        _UIScript.ShowPlayerUI();

        yield return(new WaitWhile(() => !Robber.isTerrified));

        StartCoroutine(_UIScript.FadeOutPrompts());

        float timer = 0f;

        while (timer < 1.5f)
        {
            timer += Time.deltaTime;
            References.playerScript.lastMovementDir = References.playerScript.movement = (Robber.transform.position - References.playerScript.transform.position);
            yield return(new WaitForFixedUpdate());
        }
        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(0, 1);
        yield return(new WaitForSeconds(0.5f));


        //  Scene #7: Player defeated Robber, unlock possession, fix Cats Grave


        Destroy(Robber.gameObject);

        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        References.playerScript.MoveToNextPos();
        yield return(new WaitWhile(() => !References.playerScript.reachedEndOfPath));

        _UIScript.PromptPossess();
        StartCoroutine(_UIScript.FadeInPrompts());
        References.playerScript._possessionLocked = false;
        _UIScript.ShowPlayerUI();
        yield return(new WaitWhile(() => !References.playerScript.IsPossessing));

        StartCoroutine(_UIScript.FadeOutPrompts());
        yield return(new WaitForSeconds(2.5f));

        _kittyGrave.InitMaxHealth(100f);
        _kittyGrave.RestoreGrave(1f); //plays the healing sound
        yield return(new WaitForSeconds(0.5f));


        //  Scene #8: Player is prompted to leave grave


        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        StartCoroutine(_UIScript.FadeInPrompts());
        _UIScript.PromptDepossess();
        References.playerScript._depossessionLocked = false;
        yield return(new WaitWhile(() => References.playerScript.IsPossessing));

        StartCoroutine(_UIScript.FadeOutPrompts());
        References.playerScript.LockMovement();
        References.playerScript._depossessionLocked = true;
        References.playerScript._possessionLocked   = true;
        yield return(new WaitForSeconds(1f));

        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(-1, 0);
        print("left");

        //Scene #9: Player has depossessed, but theres a new robber on our left


        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));


        // Scene #10: Robber is stealing loot, cool ghost talks

        _coolGhost.DistanceFromPlayerToActivate = 100f;
        _coolGrave.InitMaxHealth(100000);
        _coolGrave.TakeDamage(50000); //get to last stage of damage

        GameObject coolGhostGraveItem = _coolGhost._graveItem;

        _coolGhost._graveItem = _coolGhost._questItemPrefab;

        Robber = SpawnTutorialRobber(tutorialRobberPositions[1]);
        Robber.InitRobber(allGraves, _graveRobberEscapePos);

        _tutorialGhost.MoveToNextPos();
        yield return(new WaitForSeconds(1f));

        References.playerScript.MoveToNextPos();
        yield return(new WaitWhile(() => !References.playerScript.reachedEndOfPath));

        yield return(new WaitWhile(() => !_tutorialGhost.reachedEndOfPath));

        yield return(new WaitForSeconds(0.25f));

        _kitty.DistanceFromPlayerToActivate = 0f;
        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        yield return(new WaitForSeconds(1f));

        _coolGrave.TakeDamage(100000);
        yield return(new WaitForSeconds(0.85f));

        Robber.lockMovement = true;

        //Scene #11: Ghost tells you to dash

        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        Robber.fearLevel.InitMaxFear(20);
        StartCoroutine(_UIScript.FadeInPrompts());
        _UIScript.PromptDash();
        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(-1, 0);
        References.playerScript._dashLocked     = false;
        _UIScript.DashMeterHidden = false;
        _UIScript.ShowPlayerUI();

        yield return(new WaitWhile(() => !Robber.isTerrified));

        StartCoroutine(_UIScript.FadeOutPrompts());
        Robber.lockMovement = false;
        References.playerScript._dashLocked     = true;
        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(1, 1);

        //Scene #12: Move to cool ghost, Cool Ghost compliments you asks you to pick up his shades

        yield return(new WaitWhile(() => References.playerScript.TimeSinceLastDash < 1f));

        _tutorialGhost.MoveToNextPos();
        yield return(new WaitForSeconds(0.1f));

        References.playerScript.MoveToNextPos();
        yield return(new WaitWhile(() => !References.playerScript.reachedEndOfPath));

        yield return(new WaitWhile(() => !_tutorialGhost.reachedEndOfPath));

        yield return(new WaitForSeconds(0.25f));

        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        yield return(new WaitForSeconds(0.25f));


        //Scene #13: Move to bag, press interact and carry shades over

        _tutorialGhost.MoveToNextPos();
        yield return(new WaitForSeconds(0.1f));

        References.playerScript.MoveToNextPos();
        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(0, 1);
        yield return(new WaitWhile(() => !References.playerScript.reachedEndOfPath));

        yield return(new WaitWhile(() => !_tutorialGhost.reachedEndOfPath));

        yield return(new WaitForSeconds(0.25f));

        StartCoroutine(_UIScript.FadeInPrompts());
        _UIScript.PromptPossessShades();
        References.playerScript._possessionLocked = false;
        yield return(new WaitWhile(() => !References.playerScript.IsPossessing));

        StartCoroutine(_UIScript.FadeOutPrompts());

        References.playerScript.possessedObject.lockMovement = true;

        GameObject sunglasses = References.playerScript.possessedObject.gameObject;

        print(sunglasses);

        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        References.playerScript.possessedObject.lockMovement = false;

        //Scene #14: Move and place down Sunglasses

        StartCoroutine(_UIScript.FadeInPrompts());
        _UIScript.PromptMoveWithArrowKeys();
        yield return(new WaitWhile(() => Vector2.Distance(References.playerScript.possessedObject.transform.position, _coolGrave.transform.position) > 0.5f));

        StartCoroutine(_UIScript.FadeOutPrompts());
        References.playerScript.possessedObject.lockMovement = true;
        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        yield return(new WaitForSeconds(0.2f));

        StartCoroutine(_UIScript.FadeInPrompts());
        _UIScript.PromptDepossessShades();
        References.playerScript._depossessionLocked = false;
        yield return(new WaitWhile(() => References.playerScript.IsPossessing));

        StartCoroutine(_UIScript.FadeOutPrompts());
        References.playerScript.LockMovement();

        yield return(new WaitForSeconds(0.2f));

        References.playerScript._depossessionLocked = true;
        References.playerScript._possessionLocked   = true;

        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(0, 1);

        //Scene #15: Cool ghost thanks you, move to the next location to talk more about possession

        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));


        _coolGhost.TryCompleteQuest(sunglasses);
        _UIScript.QuestChecklist.GetComponent <UIQuestManager>().CheckOffQuest(_coolGhost);
        _UIScript.QuestChecklist.SetActive(true);
        _UIScript.QuestsHidden = true;
        _coolGhost.lootStolen  = false;

        Instantiate(_allOfferingTypes[3], tutorialOffering.position, tutorialOffering.rotation);
        _tutorialGhost.MoveToNextPos();
        yield return(new WaitForSeconds(0.1f));

        References.playerScript.MoveToNextPos();
        yield return(new WaitWhile(() => !References.playerScript.reachedEndOfPath));

        yield return(new WaitWhile(() => !_tutorialGhost.reachedEndOfPath));

        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(1, 0);
        yield return(new WaitForSeconds(0.25f));

        //Scene #16: Talk about possession and offerings, pick up offering

        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        References.playerScript.MoveToNextPos();
        yield return(new WaitWhile(() => !References.playerScript.reachedEndOfPath));

        References.playerScript.lastMovementDir    = References.playerScript.movement = new Vector2(0, 1);
        References.playerScript._interactionLocked = false;
        StartCoroutine(_UIScript.FadeInPrompts());
        _UIScript.PromptPickUp();

        yield return(new WaitWhile(() => References.playerScript.collectedOfferings.Count == 0));

        StartCoroutine(_UIScript.FadeOutPrompts());
        _UIScript.InventoryHidden = false;
        _UIScript.ShowPlayerUI();

        _coolGrave.InitHappiness(250f);
        _coolGrave.RaiseHappiness(35f);
        _coolGhost.happiness.gameObject.SetActive(true);

        //Scene #17: Bring offering to cool ghost

        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        _tutorialGhost.MoveToNextPos();
        yield return(new WaitForSeconds(0.1f));

        References.playerScript.MoveToNextPos();
        yield return(new WaitWhile(() => !References.playerScript.reachedEndOfPath));

        yield return(new WaitWhile(() => !_tutorialGhost.reachedEndOfPath));

        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(1, 0);

        yield return(new WaitForSeconds(0.25f));

        StartCoroutine(_UIScript.FadeInPrompts());
        _UIScript.PromptPlaceDown();

        //Scene #18: Cool ghost thanks you for the meal

        yield return(new WaitWhile(() => References.playerScript.collectedOfferings.Count != 0));

        StartCoroutine(_UIScript.FadeOutPrompts());
        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        yield return(new WaitForSeconds(0.25f));

        //Scene #19: Move to Final Location, tutorial is effectively done, tutorial ghost moves up a bit to get emotional

        _tutorialGhost.MoveToNextPos();
        yield return(new WaitForSeconds(0.1f));

        References.playerScript.MoveToNextPos();
        yield return(new WaitWhile(() => !References.playerScript.reachedEndOfPath));

        yield return(new WaitWhile(() => !_tutorialGhost.reachedEndOfPath));

        yield return(new WaitForSeconds(0.25f));

        _coolGhost.DistanceFromPlayerToActivate = 0f;

        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        yield return(new WaitForSeconds(0.25f));

        _tutorialGhost.MoveToNextPos();
        yield return(new WaitWhile(() => !_tutorialGhost.reachedEndOfPath));

        References.playerScript.lastMovementDir = References.playerScript.movement = new Vector2(1, 1);

        //  FINAL SCENE! Play final dialogue, relinquish the lock on the player and then finally start the game!

        TriggerDialogue(TutorialConversations[tutorialIndex]);
        tutorialIndex++;
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        _tutorialGhost.animator.SetBool("HatOn", false);
        References.playerScript.playerAnimator.SetBool("HatOn", true);

        StartCoroutine(_tutorialGhost.FadeOut());
        yield return(new WaitForSeconds(1f));

        _isPlayingTutorial = false;

        _cameraScript.Zoom(15, 0.2f);
        References.playerScript.UnlockMovement();

        //unlock all our abilities
        References.playerScript._screamLocked = References.playerScript._dashLocked = References.playerScript._possessionLocked
                                                                                          = References.playerScript._depossessionLocked = References.playerScript._interactionLocked = false;
        DayNightLighting.freezeDayNight = false;

        //  Reset UI
        _UIScript.proximityButtonsEnabled = true;
        _UIScript.portraitHidden          = false;
        _UIScript.DashMeterHidden         = false;
        _UIScript.ScreamMeterHidden       = false;
        _UIScript.SundialHidden           = false;
        _UIScript.TimeDisplayHidden       = false;
        _UIScript.InventoryHidden         = false;
        _UIScript.ShowPlayerUI();

        //  Reset graves to default values again
        EnableGraveghostFadein();

        _kittyGrave.InitMaxHealth(100f);
        _coolGrave.InitMaxHealth(100f);
        _kittyGrave.InitHappiness(250f);
        _kittyGrave.GetComponent <PossessableObject>().isRestoring = false;
        _coolGrave.GetComponent <PossessableObject>().isRestoring  = false;
        _coolGhost.timesGraveWasDestroyed = 0;
        _kitty.timesGraveWasDestroyed     = 0;

        _UIScript.TutorialPromptsBackground.color = _UIScript.PromptText.color = new Color(1, 1, 1, 0);
        _coolGhost._graveItem = null;
        SpawnQuestItems();
        SpawnOfferings();
        HasTalkedToGhost = false;

        GameStart.Play();
    }