Example #1
0
    void Update()
    {
        if (fireTimer > 0)
        {
            if (!infinite)
            {
                fireTimer -= Time.deltaTime;
            }

            if (fireTimer <= 0)
            {
                StopBurning();
            }

            fireSpreadTimer += Time.deltaTime;
            if (fireSpreadTimer > spreadInterval)
            {
                print("Spread fire!");
                fireSpreadTimer = 0f;
                Collider[] nearbyColliders = Physics.OverlapSphere(transform.position, fireSpreadRadius);
                foreach (Collider colliderToMakeBurn in nearbyColliders)
                {
                    Flammable flammable = colliderToMakeBurn.GetComponent <Flammable>();
                    if (flammable != null && flammable.gameObject != gameObject && !flammable.IsBurning())
                    {
                        flammable.StartBurning();
                    }
                }
            }
        }
    }
Example #2
0
    virtual protected void Update()
    {
        speed = GetComponent <TestEnemy>().maxSpeed = 6;
        if (flammable && flammable.IsBurning())
        {
            SetHealth(health - fireDamagePerSecond * Time.deltaTime);
        }

        if (freezable && freezable.IsFreezing())
        {
            SetHealth(health - iceDamagePerSecond * Time.deltaTime);
            slowSpeed = GetComponent <TestEnemy>().maxSpeed = 1.5f;
        }

        if (poisonStatus > 0)
        {
            SetHealth(health - poisonDamagePerSecond * Time.deltaTime);
            poisonStatus -= Time.deltaTime;

            if (poisonStatus <= 0)
            {
                poisonStatus = -1;
                ParticleEffectsManager.GetEffect("Poison").Stop(poisonEffectIndex);
            }
        }

        if (electracuted && electracuted.IsElc())
        {
            //healthSlider.value = health;
            //healthSlider.gameObject.SetActive(true);
            stun = GetComponent <TestEnemy>().maxSpeed = 0f;

            print("STUNNED");
        }

        if (iFramesTimer > 0)
        {
            iFramesTimer -= Time.deltaTime;
            if (iFramesTimer <= 0)
            {
                iFramesTimer = -1;
                GetComponent <Renderer>().material.SetFloat("_TintAmount", 0);
            }
        }
        slowSpeed = speed;
        stun      = speed;
    }
Example #3
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()
        //   {
    }