Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //we make sure that we are not jumping
        bool prisonerGrounded = (PossessionMaster.CurrentlyPossesing == null) ? false : PossessionMaster.CurrentlyPossesing.PrisonerAnimator.GetBool("OnGround");

        //Entering into astral
        if (Input.GetKeyUp(KeyCode.E) && !PossessionMaster.AstralForm && possMaster.CanSwap && prisonerGrounded)
        {
            StartCoroutine(possMaster.enterAstral());
        }

        //Swapping
        if (Input.GetKeyUp(KeyCode.Q) && possMaster.CanSwap)
        {
            if (PossessionMaster.AstralForm && (possMaster.getInventory().Count >= 1))
            {
                StartCoroutine(possMaster.swap(possMaster.getInventory()[0]));
            }
            else if ((possMaster.getInventory().Count > 1) && prisonerGrounded)
            {
                ++curPosIndex;
                if (curPosIndex >= possMaster.getInventory().Count)
                {
                    curPosIndex = 0;
                    StartCoroutine(possMaster.swap(possMaster.getInventory()[curPosIndex]));
                }
                else
                {
                    StartCoroutine(possMaster.swap(possMaster.getInventory()[curPosIndex]));
                }
            }
        }

        if (Input.GetKeyUp(KeyCode.R) && julia.CurrentlyViewing != null && !possMaster.getInventory().Contains(julia.CurrentlyViewing) && !julia.CurrentlyViewing.IsDead)
        {
            julia.addPrisoner();
        }

        if (Input.GetKeyUp(KeyCode.T))
        {
            if (selectionMode)
            {
                julia.gameObject.rigidbody.useGravity = true;
                selectionMode = false;
                HOTween.To(julia.gameObject.transform.GetChild(0).GetChild(0).gameObject.GetComponent <Camera>(), 0.5f, "fieldOfView", 60);
                julia.startControlling();
            }
            else
            {
                julia.gameObject.rigidbody.useGravity = false;
                selectionMode = true;
                StartCoroutine(astralUp());
                //Vector3 up = julia.gameObject.transform.position;
                //up.y += 1.5f;
                // HOTween.To(julia.gameObject.transform, 0.5f, new TweenParms().Prop("position", up).Ease(EaseType.EaseOutQuad));
                // curPosIndex = 0;
                //julia.stopControlling();
                // selectPris2Poss(possMaster.getInventory()[0]);
            }
        }
        if (selectionMode)
        {
            if (Input.GetKeyUp(KeyCode.LeftArrow))
            {
                StartCoroutine(deselectPris2Pos(true));
            }
            if (Input.GetKeyUp(KeyCode.RightArrow))
            {
                StartCoroutine(deselectPris2Pos(false));
            }
        }
    }