private void UpdateRearParticles(float withSpeed, float withoutSpeed, float slowingDown, float startSpeed)
    {
        rearParticle1.startSpeed = startSpeed;
        rearParticle2.startSpeed = startSpeed;

        if (Input.GetKey("z") || (Input.GetAxis("PS4_R2") > 0.0f))
        {
            ParticleSystemExtension.SetEmissionRate(rearParticle1, withSpeed);
            ParticleSystemExtension.SetEmissionRate(rearParticle2, withSpeed);

            rearParticle1.startColor = gameManagerScript.interfaceColor;
            rearParticle2.startColor = gameManagerScript.interfaceColor;
        }
        else if (Input.GetKey("x") || (Input.GetAxis("PS4_L2") > 0.0f))
        {
            ParticleSystemExtension.SetEmissionRate(rearParticle1, slowingDown);
            ParticleSystemExtension.SetEmissionRate(rearParticle2, slowingDown);
            rearParticle1.startColor = Color.white;
            rearParticle2.startColor = Color.white;
        }
        else
        {
            ParticleSystemExtension.SetEmissionRate(rearParticle1, withoutSpeed);
            ParticleSystemExtension.SetEmissionRate(rearParticle2, withoutSpeed);

            rearParticle1.startColor = Color.white;
            rearParticle2.startColor = Color.white;
        }
    }
    private void UpdateWindParticle(float withSpeed, float withoutSpeed, float slowingDown)
    {
        travelerParticle.startColor = gameManagerScript.interfaceColor;

        if (Input.GetKey("z") || (Input.GetAxis("PS4_R2") > 0.0f))
        {
            ParticleSystemExtension.SetEmissionRate(travelerParticle, withSpeed);
        }
        else if (Input.GetKey("x") || (Input.GetAxis("PS4_L2") > 0.0f))
        {
            ParticleSystemExtension.SetEmissionRate(travelerParticle, slowingDown);
        }
        else
        {
            ParticleSystemExtension.SetEmissionRate(travelerParticle, withoutSpeed);
        }
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (!dnf && fin.HasBegun())
        {
            this.GetComponent <Animator> ().SetBool("grounded", grounded);
            this.GetComponent <Animator> ().SetBool("crashed", crashed);
            this.GetComponent <Animator> ().SetBool("inBush", inBush);
            this.GetComponent <Animator> ().SetBool("inWater", inWater);

            Vector3 viewPos = Camera.main.WorldToViewportPoint(this.transform.position);

            if (viewPos.x <= 0.1f)
            {
                speedMod = Mathf.Lerp(speedMod, pc.GetLeader().GetComponent <HorseController> ().GetSpeedMod(), Time.deltaTime * 0.5f);
            }
            if (viewPos.x <= -0.1f && callOnce)
            {
                OutOfBounds();
            }
            //this.transform.position = new Vector3 (Camera.main.transform.position.x, this.transform.position.y, this.transform.position.z);
            if (viewPos.x >= 0)
            {
                callOnce = true;
            }

            if (!crashed)
            {
                //StopCoroutine (waitFor (2));

                if (grounded)
                {
                    ParticleSystemExtension.SetEmissionRate(ps, speed * 50);
                    if (speed > 0.25)
                    {
                        GetComponent <AudioSource> ().mute = false;
                    }
                    else
                    {
                        GetComponent <AudioSource> ().mute = true;
                    }
                }
                else
                {
                    ParticleSystemExtension.SetEmissionRate(ps, 0);
                    GetComponent <AudioSource> ().mute = true;
                }

                if (Input.GetButton(this.name))
                {
                    speedInp -= Time.deltaTime;
                }
                if (Input.GetButtonUp(this.name))
                {
                    if (speedInp <= 0.9f)
                    {
                        speedMod += (speedInp * 1.25f);
                    }
                    speedInp = 1;
                }
                if (Input.GetAxis(this.name) < 0)
                {
                    jumpInp += Time.deltaTime;
                }
                else
                {
                    jumpInp = 0;
                }

                speedMod -= 1.5f * Time.deltaTime;
                //stamina += 10 * Time.deltaTime * (1 + pc.GetLead (this.transform) / 10);

                speed = (speedMod / 5) * slowValue * baseMoveMod * Time.deltaTime * (pc.GetLead(this.transform) / 10 + 1);
                this.GetComponent <Animator> ().SetFloat("speed", speed);

                this.transform.position += new Vector3(speed / 10, 0, 0);
                if (!Input.GetButton(this.name + " Jump") && grounded && !jumpOnce)
                {
                    this.GetComponent <Rigidbody2D> ().AddForce(jumpForce);
                    jumpOnce = true;
                    //stamina -= 10;
                    //grounded = false;
                }
                if (Input.GetButtonDown(this.name + " Jump"))
                {
                    jumpOnce = false;
                }

                //if (stamina <= 10)
                //crashed = true;
            }
            else if (crashed)
            {
                speedMod -= Time.deltaTime * 50;
                //stamina -= 10 * Time.deltaTime;
                //StartCoroutine (waitFor (3));
                //if (!callOnce) {
                //	speedMod = speedMod / 4;
                //	callOnce = true;
                //}
            }

            speedInp = Mathf.Clamp(speedInp, 0, 1);
            speedMod = Mathf.Clamp(speedMod, 0.025f, 100);
            speed    = Mathf.Clamp(speed, 0.025f, 100);

            this.GetComponent <Animator> ().SetBool("grounded", grounded);
            this.GetComponent <Animator> ().SetBool("crashed", crashed);
            this.GetComponent <Animator> ().SetBool("inBush", inBush);
            this.GetComponent <Animator> ().SetBool("inWater", inWater);
            //stamina = Mathf.Clamp (stamina, 0, 100);

            //staminaBar.value = stamina;
            //staminaBar.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y + 1, 0);
        }
    }