Ejemplo n.º 1
0
    public IEnumerator PrimaryAttack()
    {
        apostleStatusVariables.isAttacking = true;
        yield return(new WaitForSeconds(0.6f));

        RaycastHit2D ray = Physics2D.Raycast(
            transform.position,
            apostleStatusVariables.facingDirection == FacingDirection.Right ? Vector2.right : Vector2.right * -1,
            range, LayerMask.GetMask("Player"));

        if (ray.collider != null &&
            !Physics.GetIgnoreLayerCollision(LayerMask.NameToLayer("Enemy"), LayerMask.NameToLayer("Player")))
        {
            var player = ray.collider.GetComponent <PlayerStatusController>();
            if (player != null)
            {
                player.TakeDamage(baseDamage);
            }
        }
        apostleController.RevokeControl(1f, true, ControlTypeToRevoke.AllMovement, this);
        apostleStatusVariables.isAttacking = false;
        CoroutineManager.DeleteCoroutine("PrimaryAttackCoroutine", this);
    }
Ejemplo n.º 2
0
    public override void StartMovement()
    {
        apostleController.CheckForVerticalInput();
        apostleStatusVariables.canJump = CheckGroundForJump();

        apostleStatusVariables.isOnAir = apostleStatusVariables.CheckIsOnAir();

        if (apostleStatusVariables.canClimbLadder && apostleController.ClimbLadderPress)
        {
            apostleStatusVariables.isClimbingLadder =
                apostleStatusVariables.canClimbLadder && apostleController.ClimbLadderPress ||
                apostleStatusVariables.isClimbingLadder;
        }

        if (apostleStatusVariables.canClimbObstacle && apostleController.ClimbObstaclePress)
        {
            apostleStatusVariables.isClimbingObstacle =
                apostleStatusVariables.canClimbObstacle && apostleController.ClimbObstaclePress ||
                apostleStatusVariables.isClimbingObstacle;
        }


        //Para velocidades ridiculamente altas, vai bugar
        if (apostleStatusVariables.isClimbingLadder && apostleStatusVariables.canJump)
        {
            var coroutine = CoroutineManager.FindCoroutine("ClimbOntoLadderCoroutine", this);
            if (coroutine != null && !coroutine.IsRunning)
            {
                PhysicsHelpers.IgnoreCollision(capsuleCollider2D,
                                               GetLadderPosition().GetComponent <LadderController>().adjacentCollider, false);
                apostleStatusVariables.isClimbingLadder = false;
                apostleController.RevokeControl(0.3f, false, ControlTypeToRevoke.AllMovement, monoBehaviour);
                PhysicsHelpers.SwitchGravity(rigidbody2D, true, currentGravityScale);
                PhysicsHelpers.ResetVelocityY(rigidbody2D);
                rigidbody2D.isKinematic = false;
                CoroutineManager.DeleteCoroutine("ClimbOntoLadderCoroutine", this);
            }
        }

        if (apostleStatusVariables.isClimbingObstacle && apostleStatusVariables.canJump)
        {
            var coroutine = CoroutineManager.FindCoroutine("ClimbOntoObstacleCoroutine", this);
            if (coroutine != null && !coroutine.IsRunning)
            {
                apostleStatusVariables.isClimbingObstacle = false;
                apostleController.RevokeControl(0.3f, false, ControlTypeToRevoke.AllMovement, monoBehaviour);
                PhysicsHelpers.SwitchGravity(rigidbody2D, true, currentGravityScale);
                rigidbody2D.isKinematic = false;

                CoroutineManager.DeleteCoroutine("ClimbOntoObstacleCoroutine", this);
            }
        }

        CheckForClimbingStairs();

        if (apostleStatusVariables.isOnAir)
        {
            VerticalMovementState = VerticalMovementState.OnAir;
        }
        else
        {
            if (apostleStatusVariables.canClimbLadder && apostleController.ClimbLadderPress)
            {
                VerticalPressMovementState = VerticalPressMovementState.ClimbLadder;
            }
            else if (apostleStatusVariables.canClimbObstacle && apostleController.ClimbObstaclePress)
            {
                VerticalPressMovementState = VerticalPressMovementState.ClimbObstacle;
            }

            if (apostleStatusVariables.isClimbingLadder &&
                !MathHelpers.Approximately(apostleController.VerticalMovement, 0, float.Epsilon))
            {
                VerticalMovementState = VerticalMovementState.ClimbingLadder;
            }
            else if (apostleStatusVariables.isClimbingObstacle)
            {
                VerticalMovementState = VerticalMovementState.ClimbingObstacle;
            }
            else
            {
                VerticalMovementState = VerticalMovementState.Grounded;
            }
        }
    }