Пример #1
0
    private IEnumerator TriggerQuestComplete()
    {
        print("completing quest");

        QuestComplete = true;
        yield return(new WaitWhile(() => References.playerScript.IsPossessing));

        References.playerScript.LockMovement();
        References.playerScript.lastMovementDir = transform.position - References.playerScript.transform.position;
        PossessableObject questPossessable = questItem.GetComponent <PossessableObject>();

        LevelSceneManager.instance.TriggerDialogue(_questItemReturnedConvo);
        LevelSceneManager.instance._UIScript.QuestChecklist.GetComponent <UIQuestManager>().CheckOffQuest(this);
        yield return(new WaitWhile(() => DialogueManager.playingConversation));

        References.playerScript.UnlockMovement();
        questPossessable.ReturnPossessableToGhost();
        grave.RaiseHappiness(100);

        Instantiate(QuestCompleteSFX);

        if (_questItemPrefab.tag == "FishermanGhostQuestItem")
        {
            LevelSceneManager.catGhostQuestItem.SetActive(true);
            print("spawning fish");
        }
    }
Пример #2
0
    public IEnumerator DepossessObject()
    {
        _DepossessSound.loop = true;
        _DepossessSound.Play();
        startingPossession = true;
        transform.position = possessedObject.transform.position; //move our player to the possessed object so we can reemerge

        playerAnimator.SetBool("Disappear", false);              //play disappear animation
        possessedObject.Depossess();                             //leave the possessed object so we may inhabit it again later
        Events.current.PossessObject(gameObject);                //send out a possession event, to say we are back in our own body (important for grave robbers and Cameras)
        yield return(new WaitForSeconds(0.1f));

        _DepossessSound.loop = false;
        yield return(new WaitForSeconds(0.65f)); //unlock movement around 3/4 through the animation


        _ghostGlow.SetActive(true); //turn back on our glow and shadow
        _shadow.SetActive(true);
        IsPossessing    = false;    //and the ability to possess again
        possessedObject = null;     //remove the ref to any possessed object
        if (!LevelSceneManager._isPlayingTutorial)
        {
            lockMovement = false; //unlock movement
        }
        startingPossession = false;
        yield return(new WaitForSeconds(0.1f));
    }
Пример #3
0
    private void OnTriggerEnter2D(Collider2D hitCollider)
    {
        if (hitCollider.tag != "Ground" && hitCollider.tag != "Player" && hitCollider.gameObject.activeInHierarchy)
        {
            GameObject hitObject = hitCollider.gameObject;

            PossessableObject possessScript = hitObject.GetComponent <PossessableObject>();

            if (possessScript != null)
            {
                if (possessScript.isPossessable)
                {
                    //Player.GetComponent<Byte>().PPossess(hitObject);

                    possessScript.currentlyPossessed = true;
                    possessScript.Player             = Player;
                }
            }
            else
            {
                Debug.Log("Didn't Respond");
            }

            DestroySelf();
        }
    }
Пример #4
0
    public virtual void Init()
    {
        animator = GetComponent <Animator>();
        pos      = GetComponent <PossessableObject>();

        pos.AddListenerPossess(OnPosses);
        pos.AddListenerPower(OnPower);
    }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        if (fading)
        {
            if (fade.Step(transform))
            {
                fading = false;
            }
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            if (!possessing)
            {
                string[]     names = { "PossesableObject", "kitchen" };
                RaycastHit2D hit   = Physics2D.Raycast(transform.position, Vector2.zero, Mathf.Infinity, LayerMask.GetMask(names));
                if (hit.transform != null)
                {
                    PossessableObject obj = hit.transform.GetComponentInChildren <PossessableObject>();
                    if (obj != null && obj.CanPosses)
                    {
                        possessedObj = obj;
                        possessedObj.Posses();
                        ghostMove  = false;
                        possessing = true;
                        StartFadeOut();
                        PositionDifference = obj.transform.position - transform.position;
                    }
                }
            }
            else
            {
                possessedObj.Unposses();
                possessing = false;
                ghostMove  = true;
                StartFadeIn();
            }
        }
        if (!possessing)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                Debug.Log("DOOR TRY");
                if (inDoor &&)
                {
                    LevelManager.Manager.NextLevel();
                }
            }
        }
        if (possessing && Input.GetKeyDown(KeyCode.Space))
        {
            possessedObj.UsePower();
        }
        if (possessing)
        {
            transform.position = possessedObj.transform.position - PositionDifference;
        }
    }
Пример #6
0
    private IEnumerator PossessObject()
    {
        if (_possessableCollider.PossessablesInCollider.Count > 0)
        {
            _PossessSound.Play();
            startingPossession = true;
            List <PossessableObject> possessables = _possessableCollider.PossessablesInCollider;

            float             Distance           = Vector2.Distance(playerRB.position, possessables[0].transform.position);
            PossessableObject closestPossessable = possessables[0];
            foreach (PossessableObject possessable in possessables)
            {
                if (possessable.tag == "Broom" || possessable.tag == "WateringCan")
                {
                    closestPossessable = possessable;
                    break;
                }
                if (Vector2.Distance(playerRB.position, possessable.transform.position) < Distance)
                {
                    Distance           = Vector2.Distance(playerRB.position, possessable.transform.position);
                    closestPossessable = possessable;
                }
            }
            lockMovement = true;                       //stops the player from being able to move
            movement     = Vector2.zero;               //make sure we dont move anymore
            closestPossessable.Possess();              //possess the highlighted object
            possessedObject = closestPossessable;      //set our local ref to the object were possessing
            playerAnimator.SetBool("Disappear", true); //play the dissappear animation

            //TODO: track object when its a moveable one!
            _ghostGlow.SetActive(false);                              //disable the glowy effect and our shadow
            _shadow.SetActive(false);
            Events.current.PossessObject(possessedObject.gameObject); //send out an event that we are possessing something
            yield return(new WaitForSeconds(0.538f));                 //lock us from depossessing for the duration of the animation

            IsPossessing       = true;                                //finally set the bool so we can depossess again
            startingPossession = false;
        }
    }