Esempio n. 1
0
    // Update is called once per frame
    void LateUpdate()
    {
        //Walktimer value rolloff
        if (walkTimer > 0.0f)
        {
            walkTimer -= Time.deltaTime;
        }
        if (walkTimer < 0.0f)
        {
            walkTimer = 0.0f;
        }

        //Camina y Corre
        if (moving)
        {
            if (walkTimer == 0.0f)
            {
                //CAMINA
                if (!moveState.canRun && moveState.GetComponent <Rigidbody2D>().velocity.x != 0 && moveState.isGround && moveState.isMovingByControl)
                {
                    camina = true;
                    rio    = false;
                    if (!corre)
                    {
                        corre = false;
                        //Si antes no caminaba y ahora si
                        ground.Spawn(transform.position, transform.rotation);
                        walkCooler = 0.35f;
                        walkTimer  = walkCooler;
                    }
                }
                else
                {
                    walkCooler = 0.0f;
                    camina     = false;
                }
                //CORRE
                if (moveState.canRun && moveState.GetComponent <Rigidbody2D>().velocity.x != 0 && moveState.isGround && moveState.isMovingByControl)
                {
                    camina = false;
                    if (!camina)
                    {
                        corre = true;
                        //Aqui hago sonido de correr
                        ground.Spawn(transform.position, transform.rotation);
                        walkCooler = 0.25f;
                        walkTimer  = walkCooler;
                    }
                }
                else
                {
                    walkCooler = 0.0f;
                    corre      = false;
                }
            }
        }//END MOVING

        if (moveState.isGround && !onGround)//Sonido de cayo
        {
            if (Mathf.Approximately(moveState.GetComponent <Rigidbody2D>().velocity.x, 0.0f))
            {
                if (moveState.GetComponent <Rigidbody2D>().velocity.y <= 0)//ignoro SFX en las one way platform
                {
                    if (OneWaySingleton.Instance != null)
                    {
                        ground.Spawn(transform.position, transform.rotation);

                        /*
                         * if (OneWaySingleton.Instance.isK1OneWay)
                         * {
                         *  ground.Spawn(transform.position, transform.rotation);
                         * }*/
                    }
                }
            }
            onGround = true;
        }
        if (!moveState.isGround)
        {
            onGround   = false;
            saveGround = false;
        }

        if (corre && Mathf.Approximately(moveState.GetComponent <Rigidbody2D>().velocity.y, 0.0f) && !saveGround && !rio)
        {//no ria cuando salta
            rio        = true;
            saveGround = true;
            runLaugh.Spawn(transform.position, transform.rotation);
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void LateUpdate()
    {
        if (moveState.isEnter || moveState.isEnterElevator)//intento parar la respiracion pero no lo logro :(
        {
            EndMove();
        }
        else
        {
            StartMove();
        }
        if (moveState.isInPlatform)
        {
            plat = true;
        }
        if (!moveState.isInPlatform)
        {
            plat = false;
        }
        //Walktimer value rolloff
        if (walkTimer > 0.0f)
        {
            walkTimer -= Time.deltaTime;
        }
        if (walkTimer < 0.0f)
        {
            walkTimer = 0.0f;
        }

        //Camina, Corre y esta en idle
        if (moving)
        {
            if (walkTimer == 0.0f)
            {
                //CAMINA y Corre
                if (moveState.GetComponent <Rigidbody2D>().velocity.x != 0 && moveState.isGround && moveState.isMovingByControl)
                {
                    if (!moveState.canRun)
                    {
                        camina = true;
                        corre  = false;
                        if (audioRun.volume > 0)
                        {
                            audioRun.volume -= 0.5f * Time.deltaTime;
                        }
                        if (!corre)
                        {
                            corre = false;
                            //Si antes no caminaba y ahora si
                            if (paso == 1)
                            {
                                paso = 2;

                                //resp2.Spawn(transform.position, transform.rotation);
                                if (moveState.isInPlatform)
                                {
                                    groundPlat1.Spawn(transform.position, transform.rotation);
                                }
                                if (!moveState.isInPlatform)
                                {
                                    ground1.Spawn(transform.position, transform.rotation);
                                }
                            }
                            else
                            {
                                paso = 1;

                                //resp1.Spawn(transform.position, transform.rotation);
                                if (moveState.isInPlatform)
                                {
                                    groundPlat2.Spawn(transform.position, transform.rotation);
                                }
                                if (!moveState.isInPlatform)
                                {
                                    ground2.Spawn(transform.position, transform.rotation);
                                }
                            }
                            walkCooler = 0.35f;
                            walkTimer  = walkCooler;
                        }
                    }
                    else
                    {
                        camina = false;

                        if (audioRun.volume < maxVol)
                        {//Sonido de respiracion
                            audioRun.volume += 0.5f * Time.deltaTime;
                        }
                        if (!camina)
                        {
                            corre = true;

                            /*if(moveState.isEnter || moveState.isEnterElevator)//deja de correr y caminar en las puertas, asensores
                             *                          {
                             *                                  corre = false;
                             *                                  camina = true;
                             *                                  Debug.Log ("isEnter");
                             *
                             *                          }*/
                            //Aqui hago sonido de correr
                            if (paso == 1)
                            {
                                paso = 2;
                                //ground1.Spawn(transform.position, transform.rotation);
                                //resp2.Spawn(transform.position, transform.rotation);
                                if (moveState.isInPlatform)
                                {
                                    groundPlat1.Spawn(transform.position, transform.rotation);
                                }
                                if (!moveState.isInPlatform)
                                {
                                    ground1.Spawn(transform.position, transform.rotation);
                                }
                            }
                            else
                            {
                                paso = 1;
                                //ground2.Spawn(transform.position, transform.rotation);
                                //resp2.Spawn(transform.position, transform.rotation);
                                if (moveState.isInPlatform)
                                {
                                    groundPlat2.Spawn(transform.position, transform.rotation);
                                }
                                if (!moveState.isInPlatform)
                                {
                                    ground2.Spawn(transform.position, transform.rotation);
                                }
                            }
                            walkCooler = 0.25f;
                            walkTimer  = walkCooler;
                        }
                    }
                }
                else
                {
                    walkCooler = 0.0f;
                    camina     = false;
                    corre      = false;
                    if (audioRun.volume > 0)
                    {
                        audioRun.volume -= 0.5f * Time.deltaTime;
                    }
                }
            }
        }
        else//END MOVING
        {
            if (audioRun.volume > 0)
            {
                audioRun.volume -= 0.5f * Time.deltaTime;
            }
        }

        if (moveState.isGround && !onGround)//Sonido de cayo
        {
            if (moveState.GetComponent <Rigidbody2D>().velocity.x == 0)
            {
                if (moveState.isInPlatform)
                {
                    groundPlat3.Spawn(transform.position, transform.rotation);
                }
                if (!moveState.isInPlatform)
                {
                    if (moveState.GetComponent <Rigidbody2D>().velocity.y <= 0)//ignoro SFX en las one way platform
                    {
                        if (OneWaySingleton.Instance != null)
                        {
                            ground3.Spawn(transform.position, transform.rotation);


                            /*if (!OneWaySingleton.Instance.isKlausOneWay)
                             * {
                             *  ground3.Spawn(transform.position, transform.rotation);
                             *
                             * }*/
                        }
                    }
                }
            }
            onGround = true;
        }
        if (!moveState.isGround)
        {
            onGround   = false;
            saveGround = false;
        }
    }