コード例 #1
0
    void Update()
    {
        base.Update();
        if (CanLandEarthshatter() && firstPersonController.IsGrounded())
        {
            hammer.animator.Play("EarthShatterComplete");
            shatterEnabled = false;
        }
        if (ulting && firstPersonController.IsGrounded())
        {
            firstPersonController.SetCanMove(false);
        }
        else
        {
            firstPersonController.SetCanMove(true);
        }

        if (!charging)
        {
            if (firestrikeTimer < firestrikeTime)
            {
                firestrikeTimer += Time.deltaTime;
            }
            if (chargeTimer < chargeTime)
            {
                chargeTimer += Time.deltaTime;
            }
            if (ultTimer < ultTime)
            {
                ultTimer += Time.deltaTime;
            }

            if (!IsStunned() && !ulting)
            {
                if (GetInput().GetKey(KeyCode.Mouse1) && !IsStunned() && (IsHammerIdle() || shield.IsActive()))
                {
                    shield.SetActive(true);
                }
                else
                {
                    shield.SetActive(false);
                }
                if (CanFireStrike() && GetInput().GetKeyDown(KeyCode.E))
                {
                    Firestrike();
                }

                if (CanCharge() && GetInput().GetKeyDown(KeyCode.LeftShift))
                {
                    Charge();
                }

                if (CanUlt() && GetInput().GetKeyDown(KeyCode.Q))
                {
                    Ult();
                }

                if (IsSwinging())
                {
                    Swing();
                }
            }
        }
        else
        {
            chargeDurationTimer += Time.deltaTime;
            chargeStartupTimer  += Time.deltaTime;

            if (GetInput().GetKey(KeyCode.A))
            {
                transform.Rotate(0, -chargeTurnSpeed * Time.deltaTime, 0);
            }
            if (GetInput().GetKey(KeyCode.D))
            {
                transform.Rotate(0, chargeTurnSpeed * Time.deltaTime, 0);
            }

            if (chargeStartupTimer >= chargeStartupTime)
            {
                RaycastHit hit;
                bool       hitWall = Physics.Raycast(transform.position, transform.forward, out hit, stuckHero == null ? .4f : 1.4f, LayerMask.GetMask("Ground"));
                chargeHitbox.SetActive(true);

                if (chargeDurationTimer > chargeDuration + chargeStartupTime || hitWall)
                {
                    charging = false;
                    firstPersonController.SetCanTurn(true);
                    firstPersonController.allowMoveBody = false;
                    if (stuckHero != null)
                    {
                        stuckHero.SetBeingCharged(false);
                    }
                    stuckHero = null;
                }
            }
        }
        if (!charging)
        {
            chargeHitbox.SetActive(false);
        }

        if (shield.IsActive() || charging)
        {
            ToThirdPerson();
            hammerObject.SetActive(false);
            if (charging)
            {
                firstPersonController.movementSettings.JumpForce = 0;
            }
            else
            {
                firstPersonController.movementSettings.JumpForce = unmodifiedJumpForce;
            }
            firstPersonController.movementSettings.ForwardSpeed  = charging ? 0 : shieldingSpeed;
            firstPersonController.movementSettings.BackwardSpeed = charging ? 0 : shieldingSpeed;
            firstPersonController.movementSettings.StrafeSpeed   = charging ? 0 : shieldingSpeed;
            firstPersonController.moveCam = thirdPersonCam;
        }
        else
        {
            ToFirstPerson();
            hammerObject.SetActive(true);
            firstPersonController.movementSettings.JumpForce     = unmodifiedJumpForce;
            firstPersonController.movementSettings.ForwardSpeed  = regularSpeed;
            firstPersonController.movementSettings.BackwardSpeed = regularSpeed;
            firstPersonController.movementSettings.StrafeSpeed   = regularSpeed;
            firstPersonController.moveCam = firstPersonCam;
        }

        if (ai)
        {
            firstPersonCam.enabled = false;
            thirdPersonCam.enabled = false;
        }

        if (shield.IsActive())
        {
            firstPersonController.mouseLook.MaximumX = 30;
            firstPersonController.mouseLook.MinimumX = -89;

            Vector3 rot = firstPersonCam.transform.rotation.eulerAngles;
            if (rot.x > 108)
            {
                rot.x -= 360;
            }
            rot.x = Mathf.Clamp(rot.x, -89, 0);
            firstPersonCam.transform.rotation = Quaternion.Euler(rot);
        }
        else
        {
            firstPersonController.mouseLook.MaximumX = 89;
            firstPersonController.mouseLook.MinimumX = -89;
        }
    }
コード例 #2
0
 public void ChargeStick(HeroBase hero)
 {
     hero.SetBeingCharged(true);
     stuckHero = hero;
 }