상속: ImageEffectBase
예제 #1
0
    /// <summary>
    /// Returns a specific Weather class based on the value of parameter iRange
    /// </summary>
    /// <param name="iRange">Specific choice of Weather Object</param>
    /// <returns>wTempWeather</returns>
    public Weather RandomWeatherRange(int iRange)
    {
        Weather wTempWeather = new Weather();

        switch (iRange)
        {
        case 0:     //Rain
            wTempWeather = new Sunny();
            return(wTempWeather);

        case 1:     //Sunny
            wTempWeather = new Rain();
            return(wTempWeather);

        case 2:     //Cloudy
            wTempWeather = new Cloudy();
            return(wTempWeather);

        case 3:     //Snow
            wTempWeather = new Snow();
            return(wTempWeather);

        case 4:     //Windy
            wTempWeather = new Windy();
            return(wTempWeather);

        case 5:     //Thunderstorm
            wTempWeather = new Thunderstorm();
            return(wTempWeather);

        case 6:     //Hail
            wTempWeather = new Hail();
            return(wTempWeather);

        case 7:     //Fog
            wTempWeather = new Fog();
            return(wTempWeather);

        case 8:     //HeatWave
            wTempWeather = new HeatWave();
            return(wTempWeather);
        }

        return(wTempWeather);
    }
예제 #2
0
    void Update()
    {
        healthSlider.value = health;
        if (Input.GetAxisRaw("Vertical") < -0.3)
        {
            down = true;
        }
        if (Input.GetAxisRaw("Vertical") >= 0)
        {
            down = false;
        }
        if (canMove)
        {
            dirX = Input.GetAxisRaw("Horizontal") * currentSpeed;
        }
        if (Input.GetButtonDown("Jump") || Input.GetKeyDown(KeyCode.Space) && rb.velocity.y == 0)
        {
            if (canJump)
            {
                if (canMove)
                {
                    main.PlayOneShot(Jump, hitVol / 2);
                    Physics2D.gravity = new Vector2(0, -9.8f);
                    sideStuck         = false;
                    downStuck         = false;
                    gameObject.transform.SetParent(null);
                    anim.SetBool("sidestuck", false);
                    anim.SetBool("downstuck", false);
                    anim.SetBool("dashing", false);
                    sideHitBox.SetActive(false);
                    downHitBox.SetActive(false);
                    SpinBox.SetActive(false);
                    if (isUnder == false)
                    {
                        rb.AddForce(Vector2.up * 700f);
                    }
                    else
                    {
                        rb.AddForce(Vector2.up * 400f);
                    }
                }
            }
        }
        if (Input.GetButtonDown("Fire1") || Input.GetKeyDown(KeyCode.E))
        {
            if (!dashing && !downStuck && !sideStuck)
            {
                if (electric)
                {
                    Projectile clone = (Projectile)Instantiate(projectile, barrel.transform.position, barrel.transform.rotation);
                    clone.clone = true;
                    if (facingRight)
                    {
                        clone.direction = 1;
                    }
                    else
                    {
                        clone.direction = -1;
                    }
                    main.PlayOneShot(blast, hitVol);
                    electric = false;
                }
                else if (hot && !electric)
                {
                    main.PlayOneShot(fvoosh, hitVol);
                    HeatWave clone = (HeatWave)Instantiate(heatWave, gameObject.transform.position, gameObject.transform.rotation);
                    hot = false;
                }
            }
        }


        if (Mathf.Abs(dirX) > 0 && rb.velocity.y == 0 && !sideStuck && !downStuck)
        {
            anim.SetBool("running", true);
        }
        else
        {
            anim.SetBool("running", false);
        }

        if (rb.velocity.y == 0)
        {
            anim.SetBool("jumping", false);
            anim.SetBool("falling", false);
            canJump = true;
        }

        if (rb.velocity.y > 0)
        {
            anim.SetBool("jumping", true);
            anim.SetBool("falling", false);
            canJump = false;
        }

        if (rb.velocity.y < 0)
        {
            anim.SetBool("jumping", false);
            anim.SetBool("falling", true);
            canJump = false;
        }
        if (electric)
        {
            electricity.SetActive(true);
        }
        if (electric == false)
        {
            electricity.SetActive(false);
        }
        if (hot)
        {
            heat.SetActive(true);
        }
        if (!hot)
        {
            heat.SetActive(false);
        }
        if (attacking)
        {
            time        -= Time.deltaTime;
            currentSpeed = 0;
        }
        if (time <= 0)
        {
            hitbox.SetActive(false);
            attacking = false;
            anim.SetBool("attacking", false);
            canMove = true;
            meleeeffect.SetActive(false);
        }
        if (!attacking)
        {
            time         = attackTime;
            currentSpeed = moveSpeed;
        }
        if (dirX == 0 && canJump == true && idleTime <= 0)
        {
            anim.SetBool("sleeping", true);
        }

        idleTime -= Time.deltaTime;
        Gravity   = rb.gravityScale;

        if (dirX != 0 || Input.GetButtonDown("Jump"))
        {
            idleTime = 10f;
            anim.SetBool("sleeping", false);
        }
        if (Input.GetButtonDown("Fire2"))
        {
            if (attacking == false && rb.velocity.y == 0)
            {
                Attack();
                main.PlayOneShot(melee, hitVol);
                meleeeffect.SetActive(true);
            }

            if (attacking == false && rb.velocity.y != 0 && dirX == 0 && !down && canSpin)
            {
                spinning = true;
                anim.SetBool("spinning", true);
                SpinBox.SetActive(true);
                canSpin     = false;
                rb.velocity = new Vector3(0, 10f, 0);
                main.PlayOneShot(SPin, hitVol);
            }

            if (attacking == false && rb.velocity.y != 0 && dirX != 0 && canDash && !spinning && !down)
            {
                if (firstFrameDash)
                {
                    dashSpeed      = dirX;
                    firstFrameDash = false;
                    main.PlayOneShot(DAsh, hitVol);
                }
                dashing = true;
                anim.SetBool("dashing", true);
                main.PlayOneShot(DAsh, hitVol);
                SpinBox.SetActive(true);
                sideHitBox.SetActive(true);
                if (dirX < 0)
                {
                    rb.velocity = new Vector3(dashSpeed - 5f, 0, 0);
                    Left        = true;
                }
                if (dirX > 0)
                {
                    rb.velocity = new Vector3(dashSpeed + 5f, 0, 0);
                    Left        = false;
                }

                canDash = false;
            }
            if (attacking == false && rb.velocity.y != 0 && canDash && !spinning && down)
            {
                downHitBox.SetActive(true);
                main.PlayOneShot(DAsh, hitVol);
                downDashing = true;
                anim.SetBool("downdashing", true);
                main.PlayOneShot(DAsh, hitVol);
                rb.velocity = new Vector3(0, -downDashSpeed, 0);
            }
        }
        if (dashing)
        {
            currentDashTime  -= Time.deltaTime;
            Physics2D.gravity = new Vector2(0, -0.1f);
        }
        if (currentDashTime <= 0)
        {
            dashing         = false;
            currentDashTime = dashTime;
            anim.SetBool("dashing", false);
            SpinBox.SetActive(false);
            Physics2D.gravity = new Vector2(0, -9.8f);
            sideHitBox.SetActive(false);
        }
        if (downDashing || downStuck)
        {
            rb.velocity = new Vector3(0, -downDashSpeed, 0);
        }
        if (dashing)
        {
            if (Left)
            {
                rb.velocity = new Vector3(dashSpeed - 5f, 0, 0);
            }
            if (!Left)
            {
                rb.velocity = new Vector3(dashSpeed + 5f, 0, 0);
            }
        }
        if (downStuck)
        {
            anim.SetBool("jumping", false);
        }
        if (gotHit)
        {
            invulTime -= Time.fixedDeltaTime;
            anim.SetBool("gothit", true);
        }
        if (invulTime <= 0)
        {
            gotHit    = false;
            invulTime = 2f;
            anim.SetBool("gothit", false);
        }
        if (spinning)
        {
            if (facingRight)
            {
                Swipe.SetActive(true);
                Swipe2.SetActive(false);
            }
            else
            {
                Swipe.SetActive(false);
                Swipe2.SetActive(true);
            }
        }
        if (!spinning)
        {
            Swipe.SetActive(false);
            Swipe2.SetActive(false);
        }
        if (dieing)
        {
            currentDeathTime -= Time.fixedDeltaTime;
        }
        if (currentDeathTime <= 0)
        {
            Reset();
            currentDeathTime = deathTime;
            dieing           = false;
        }
    }