private void Chase()
    {
        attackDetector.gameObject.SetActive(true);
        // move in direction of player
        if (playerReference.transform.position.x >= transform.position.x)
        {
            entityMovement.MoveInDirection(1);
        }
        else
        {
            entityMovement.MoveInDirection(-1);
        }

        GameObject objectHit = raycastHelper.CheckForObjectHits();

        if (objectHit != null)
        {
            if (objectHit.tag == "Ground")
            {
                entityMovement.Jump();
            }
        }
        else if (groundedController.GetIsGrounded() &&
                 raycastHelper.CheckForLedges() &&
                 playerReference.transform.position.y > transform.root.position.y)
        {
            entityMovement.Jump();
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        moveDirectionX = 0f;

        // Player character actions
        if (playerHealth.GetCanAct())
        {
            moveDirectionX = Input.GetAxisRaw("Horizontal");

            if (Input.GetButtonDown("Jump"))
            {
                playerMovement.Jump();
            }
            if (Input.GetButtonUp("Jump"))
            {
                playerMovement.CutJumpHeight();
            }

            if (Input.GetButtonDown("Transform"))
            {
                //playerMovement.StopiAllMovement();
                transformationController.Transform();
            }

            if (Input.GetButtonDown("LightAttack"))
            {
                if (transformationController.GetIsInNormalForm())
                {
                    meleeAttack.Attack(ActionType.lightMelee);
                }
                else
                {
                    rangedAttack.Attack(ActionType.lightRanged);
                }
            }
            if (Input.GetButtonDown("HeavyAttack"))
            {
                if (transformationController.GetIsInNormalForm())
                {
                    meleeAttack.Attack(ActionType.heavyMelee);
                }
            }
        }

        playerMovement.MoveInDirection(moveDirectionX);

        // Interface controls
        if (Input.GetButtonDown("Cancel"))
        {
            screenManager.SetPauseMenuActive();
        }
    }