private void Update()
    {
        // handle shooting
        SpellController basicSpell = m_SpellSlots[basicSpellIndex];

        basicSpell.HandleShootInputs(
            m_InputHandler.GetFireInputDown(),
            m_InputHandler.GetFireInputHeld(),
            m_InputHandler.GetFireInputReleased());

        SpellController altSpell = m_SpellSlots[altSpellIndex];

        altSpell.HandleShootInputs(
            m_InputHandler.GetAltInputDown(),
            m_InputHandler.GetAltInputHeld(),
            m_InputHandler.GetAltInputReleased());

        SpellController utilitySpell = m_SpellSlots[utilitySpellIndex];

        utilitySpell.HandleShootInputs(
            m_InputHandler.GetUtilityInputDown(),
            m_InputHandler.GetUtilityInputHeld(),
            m_InputHandler.GetUtilityInputReleased());

        SpellController ultimateSpell = m_SpellSlots[ultimateSpellIndex];

        ultimateSpell.HandleShootInputs(
            m_InputHandler.GetUltimateInputDown(),
            m_InputHandler.GetUltimateInputHeld(),
            m_InputHandler.GetUltimateInputReleased());

        SpellController interactSpell = interactionController;

        interactSpell.HandleShootInputs(
            m_InputHandler.GetInteractInputDown(),
            m_InputHandler.GetInteractInputHeld(),
            m_InputHandler.GetInteractInputReleased());

        // Pointing at enemy handling
        // isPointingAtEnemy = false;
        // if(Physics.Raycast(SpellCamera.transform.position, SpellCamera.transform.forward, out RaycastHit hit, 1000, -1, QueryTriggerInteraction.Ignore))
        // {
        //     if(hit.collider.GetComponentInParent<EnemyCharacterController>())
        //     {
        //         isPointingAtEnemy = true;
        //     }
        // }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;

        // Check if the player is looking at the object within a certain range
        if (m_Monolith.activeSelf && Physics.Raycast(playerCamera.transform.position, playerCamera.transform.forward, out hit))
        {
            if (hit.transform.parent && hit.transform.parent.name == "Monolith and Platform" && hit.distance <= minDistance)
            {
                lookTime += Time.deltaTime;

                if (lookTime >= destructionTimer || (m_InputHandler.GetInteractInputDown() && !GameComplete()))
                {
                    if (GameComplete())
                    {
                        playerAudio.PlayOneShot(badNoise);
                        blackOverlay.CrossFadeAlpha(1, 2f, false);

                        StartCoroutine(CloseGame());
                    }
                    else
                    {
                        Vector3 monolithPosition = m_Monolith.transform.position + new Vector3(-0.6f, 0f, -0.2f);

                        //Destroy(m_Monolith);
                        m_Monolith.SetActive(false);
                        Instantiate(brokenMonolith, monolithPosition, Quaternion.identity, gameObject.transform);

                        playerAudio.PlayOneShot(badNoise);
                        playerAudio.PlayOneShot(crumbleSFX);

                        lookTime = 0f;
                    }
                }
            }
        }
        else if (GameComplete() && !m_Monolith.activeSelf)
        {
            //m_Monolith = Instantiate(wholeMonolith, transform);
            m_Monolith.SetActive(true);
            playerAudio.PlayOneShot(badNoise);
        }
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        GroundCheck();

        // Horizontal character rotation
        transform.Rotate(new Vector3(0f, m_InputHandler.GetLookInputHorizontal() * rotationSpeed, 0f), Space.Self);

        // Vertical camera rotation
        m_VerticalCameraAngle += m_InputHandler.GetLookInputVertical() * rotationSpeed;
        m_VerticalCameraAngle  = Mathf.Clamp(m_VerticalCameraAngle, -89f, 89f);
        playerCamera.transform.localEulerAngles = new Vector3(m_VerticalCameraAngle, 0, 0);

        // Character movement
        Vector3 worldSpaceMoveInput = transform.TransformVector(m_InputHandler.GetMoveInput());

        if (isGrounded)
        {
            Vector3 targetVelocity = worldSpaceMoveInput * maxGroundSpeed;
            characterVelocity = Vector3.Lerp(characterVelocity, targetVelocity, groundMovementSharpness * Time.deltaTime);

            // Footstep SFX
            if (m_FootstepDistanceCounter >= 1f / footstepSFXFrequency)
            {
                m_FootstepDistanceCounter = 0f;
                audioSource.PlayOneShot(footstepSFX);
            }

            m_FootstepDistanceCounter += characterVelocity.magnitude * Time.deltaTime;

            // Jumping
            if (m_InputHandler.GetJumpInputDown())
            {
                // Cancel any existing vertical velocity
                characterVelocity = new Vector3(characterVelocity.x, 0f, characterVelocity.z);

                characterVelocity += Vector3.up * jumpForce;

                m_LastJumpTime = Time.time;
                isGrounded     = false;
            }
        }
        else
        {
            characterVelocity += Vector3.down * gravityDownForce * Time.deltaTime;
        }

        Vector3 capsuleBottomBeforeMove = GetBottomHemisphere();
        Vector3 capsuleTopBeforeMove    = GetTopHemisphere();

        m_CharacterController.Move(characterVelocity * Time.deltaTime);

        RaycastHit hit;

        // Detect obstructions to adjust velocity accordingly
        if (Physics.CapsuleCast(capsuleBottomBeforeMove, capsuleTopBeforeMove, m_CharacterController.radius, characterVelocity.normalized, out hit, characterVelocity.magnitude * Time.deltaTime, -1, QueryTriggerInteraction.Ignore))
        {
            characterVelocity = Vector3.ProjectOnPlane(characterVelocity, hit.normal);
        }

        // Pick up pieces on click
        if (m_InputHandler.GetInteractInputDown())
        {
            if (Physics.Raycast(playerCamera.transform.position, playerCamera.transform.forward, out hit))
            {
                if (hit.transform.gameObject.tag == "MonolithPiece" && hit.distance <= minInteractDistance)
                {
                    Destroy(hit.transform.gameObject);
                    audioSource.PlayOneShot(piecePickupSFX);
                    collectedPiecesCount++;
                }
            }
        }
    }