Exemplo n.º 1
0
    void Update()
    {
        if (Input.GetButtonDown("Attack") && !playerAnimator.GetCurrentAnimatorStateInfo(0).IsName("PlaceholderWeaponAttack"))
        {
            print("Attacku!");
            playerAnimator.SetTrigger("AttackTransition");
            afterImages.Show();
            afterImages.duration = normalAttackAfterImageDuration;
        }
        if ((Input.GetKeyDown(KeyCode.E) || Input.GetButtonDown("B Button")) && !playerAnimator.GetCurrentAnimatorStateInfo(0).IsName("Heavy Attack"))
        {
            if (playerMovement.currentMana >= overHeadCost)
            {
                print("ROADO ROLLA DA");
                playerAnimator.SetTrigger("AttackTransitionHeavy");
                playerMovement.UseMana(overHeadCost);
                afterImages.duration = smashAttackAfterImageDuration;
            }
        }

        if ((Input.GetKeyDown(KeyCode.Q) || Input.GetButtonDown("Y Button")) && !playerAnimator.GetCurrentAnimatorStateInfo(0).IsName("Swing Attack") && playerMovement.currentMana >= swingCost)
        {
            print("SWINGAROOO");
            playerAnimator.SetTrigger("AttackTransitionSwing");
            playerMovement.UseMana(swingCost);
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (!startDashTimer)
        {
            Vector3 movement;


            float rawAxisX, rawAxisY;
            rawAxisX = Input.GetAxisRaw("Horizontal");
            //rawAxisX = (float)System.Math.Round(rawAxisX);
            rawAxisY = Input.GetAxisRaw("Vertical");
            //rawAxisY = (float)System.Math.Round(rawAxisY);
            movement = new Vector3(rawAxisX * speed, 0, rawAxisY * speed);



            if (movement.sqrMagnitude == 0)
            {
                rb.velocity *= 0.1f;
                anim.SetFloat("Speed", 0.0f);
            }
            else
            {
                transform.rotation = Quaternion.LookRotation(movement);
                anim.SetFloat("Speed", 1.0f);
            }

            rb.AddForce(movement, ForceMode.Acceleration);

            float currentSpeed = rb.velocity.magnitude;

            if (currentSpeed > maxSpeed)
            {
                rb.velocity = (rb.velocity / currentSpeed) * maxSpeed;
            }
        }

        if (dashCooldownTimer > 0)
        {
            dashCooldownTimer       -= Time.deltaTime;
            dashCooldown.fillAmount -= 1 / dashCooldownDuration * Time.deltaTime;
            if (dashCooldownTimer < 0)
            {
                dashCooldownTimer       = 0;
                dashCooldown.fillAmount = 0;
                dashCooldown.GetComponent <Fadeplosion>().Perform();
            }
        }
        if ((Input.GetAxis("RightBumpStick") != 0 || Input.GetKeyDown(KeyCode.LeftShift)) && dashCooldownTimer == 0)
        {
            startDashTimer       = true;
            dashTimer            = dashDuration;
            afterImages.duration = dashDuration - dashDuration / afterImages.numberOfImages;
            meshRenderer.material.SetFloat("_TintAmount", afterImages.tintFactor);
            meshRenderer.material.SetColor("_TintColor", afterImages.tintColor);
            iFrames           = true;
            dashCooldownTimer = dashCooldownDuration;
            afterImages.Show();
            CameraEffects.Get.Shake(0.1f, 0.1f);
            audioSource.PlayOneShot(dashSound);
            dashCooldown.fillAmount = 1;
        }
        if (startDashTimer == true)
        {
            rb.velocity = transform.forward * dashSpeed;
            anim.SetFloat("Speed", 2.5f);
            dashTimer -= Time.deltaTime;
            if (dashTimer <= 0)
            {
                startDashTimer = false;
                dashTimer      = 0;
                rb.velocity    = new Vector3(0, 0, 0);
                iFrames        = false;
                meshRenderer.material.SetFloat("_TintAmount", 0);
            }
        }

        if (flammable.IsBurning())
        {
            currentHealth     -= (fireDamagePerSecond - armorValue) * Time.deltaTime;
            healthSlider.value = currentHealth;
            damaged            = true;
            if (currentHealth <= 0)
            {
                Die();
            }
        }

        if (damaged)
        {
            //damageImage.color = flashColour;
            float vignetteIntensity = 0.0f;
            if (currentHealth <= 50)
            {
                vignetteIntensity = Mathf.Lerp(vignetteStart, vignetteDead, 1f - currentHealth / 50f);
            }
            //print(vignetteIntensity);
            CameraEffects.Get.SetDamageVignette(vignetteIntensity);
        }
        else
        {
            //damageImage.color = Color.Lerp(damageImage.color, Color.clear, flashSpeed * Time.deltaTime);
        }
        damaged = false;


        //if (iFrames)
        //{
        //    tRail.enabled = true;
        //}
        //else if (!iFrames)
        //{
        //    tRail.enabled = false;
        //}
        //print(rb.velocity.normalized);


        //}
        //   void PlayerDirection()
        //   {
    }