Пример #1
0
    private bool FallDamage()
    {
        status.TakeDamage(2);

        sound.PlayTakeDamage();

        if (status.CurrentHealth == 0)
        {
            return(true);
        }
        else
        {
            isTakingFallDamage = true;

            ScaleAnimator.GetComponent <Animation>().Play();

            status.EndInvincible();

            return(false);
        }
    }
Пример #2
0
    protected override void LateGlobalSuperUpdate()
    {
        // Trigger any objects we are directly standing on
        if (controller.IsClamping())
        {
            TriggerableObject triggerable = controller.currentGround.Transform.GetComponent <TriggerableObject>();

            if (triggerable != null)
            {
                triggerable.StandingOn(transform.position);
            }
        }

        if (goldMario)
        {
            GoldBodySlam();
        }

        // Increment our position based on our current velocity
        transform.position += moveDirection * controller.deltaTime;

        if (DebugGui)
        {
            DebugDraw.DrawVector(transform.position, lookDirection, 2.0f, 1.0f, Color.red, 0, true);
            DebugDraw.DrawVector(transform.position, input.Current.MoveInput, 1.0f, 1.0f, Color.yellow, 0, true);
            DebugDraw.DrawVector(transform.position, moveDirection, 1.0f, 1.0f, Color.blue, 0, true);
        }

        // Rotate the chest forwards or side to side
        ChestBone.Rotation = Quaternion.Euler(new Vector3(0, chestTwistAngle, chestBendAngle));

        // Angle the controller's mesh based on current art direction
        Vector3 projected = Math3d.ProjectVectorOnPlane(artUpDirection, lookDirection);

        AnimatedMesh.rotation = Quaternion.LookRotation(projected, artUpDirection);

        // End fall damage if the animation has finished playing. If not, scale the
        // animated mesh based on the animation
        if (!ScaleAnimator.GetComponent <Animation>().isPlaying)
        {
            isTakingFallDamage = false;
        }

        if (isTakingFallDamage)
        {
            AnimatedMesh.localScale = new Vector3(AnimatedMesh.localScale.x, ScaleAnimator.localScale.z, AnimatedMesh.localScale.z);
        }
        else
        {
            AnimatedMesh.localScale = new Vector3(1, 1, 1);
        }

        // Check if we have fallen through the level, and place us on the first contacted ground if we have and return Mario to idle
        if (transform.position.y < -10)
        {
            RaycastHit hit;

            Vector3 verticalPostionZeroed = transform.position;
            verticalPostionZeroed.y = 0;

            if (Physics.Raycast(verticalPostionZeroed + Vector3.up * 5000, -Vector3.up, out hit, Mathf.Infinity, controller.Walkable))
            {
                transform.position = hit.point;

                verticalMoveSpeed = 0;
                moveSpeed         = 0;
                moveDirection     = Vector3.zero;

                currentState = MarioStates.Idle;
                return;
            }
        }
    }