예제 #1
0
    //enters astral form when in prisoner
    public IEnumerator enterAstral()
    {
        canSwap = false;
        //Prisoner to Julia
        Vector3         juliaNewPosition = currentlyPossessing.transform.position;
        CapsuleCollider prisonerCapsule = currentlyPossessing.GetComponent <CapsuleCollider>();
        Vector3         capsuleStart = currentlyPossessing.transform.position, capsuleEnd = Vector3.zero;

        capsuleStart.y += prisonerCapsule.height;
        capsuleEnd      = capsuleStart;
        capsuleEnd.y   -= prisonerCapsule.height;

        //make sure to spawn julia in a place where there is no collisions
        if (!Physics.CapsuleCast(capsuleStart, capsuleEnd, prisonerCapsule.radius / 1.5f, currentlyPossessing.transform.forward, 1))
        {
            juliaNewPosition += currentlyPossessing.transform.forward;
            Debug.Log("forward");
        }
        else if (!Physics.CapsuleCast(capsuleStart, capsuleEnd, prisonerCapsule.radius / 1.5f, currentlyPossessing.transform.forward * -1, 1))
        {
            juliaNewPosition += (currentlyPossessing.transform.forward * -1);
            Debug.Log("back");
        }
        else if (!Physics.CapsuleCast(capsuleStart, capsuleEnd, prisonerCapsule.radius / 1.5f, currentlyPossessing.transform.right, 1))
        {
            juliaNewPosition += currentlyPossessing.transform.right;
            Debug.Log("right");
        }
        else if (!Physics.CapsuleCast(capsuleStart, capsuleEnd, prisonerCapsule.radius / 1.5f, currentlyPossessing.transform.right * -1, 1))
        {
            juliaNewPosition += (currentlyPossessing.transform.right * -1);
            Debug.Log("left");
        }
        //make him her a little higher so she doesnt fall through the floor
        juliaNewPosition.y += 1;
        yield return(new WaitForSeconds(transitionP(currentlyPossessing, false)));

        prisonerCamera.gameObject.SetActive(false);
        Julia.gameObject.SetActive(true);
        Julia.transform.position = juliaNewPosition;
        yield return(new WaitForSeconds(transitionJ(true)));

        Julia.startControlling();
        canSwap = true;
    }
예제 #2
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));
            }
        }
    }