Exemple #1
0
    private void Phy(int HorizontalDir)
    {
        if (HorizontalDir == 1)
        {
            Rotator.turnright();
        }
        else if (HorizontalDir == -1)
        {
            Rotator.turnleft();
        }


        Vector3 mov = Vector3.zero;

        if (!CC.isGrounded)
        {
            VerticalForce += Gravity * Time.deltaTime;
        }
        else
        {
            direction     = Player.PlayerSingleton.LeftOrRightFrom(transform.position.z);
            VerticalForce = JumpPower;
            anim.Play("Salto");
        }

        mov += Vector3.down * -VerticalForce;
        mov += Front * HorizontalDir * HorizontalSpeed;
        CC.Move(mov * Time.deltaTime);
    }
Exemple #2
0
 private void Update()
 {
     if (Input.anyKey)
     {
         if (Input.GetKeyDown(SaveB))
         {
             PowerUpController.instance.Save();
         }
         for (int K = 0; K < Weapons.Count; K++)
         {
             if (Input.GetKeyDown(Weapons[K]))
             {
                 // Debug.Log("entroCambioDeArma");
                 P.TakeAnyInput(K);
             }
         }
         if (Input.GetKeyDown(Left) || LeftDown)
         {
             Rotator.turnleft();
         }
         if (Input.GetKeyDown(Right) || RightDown)
         {
             Rotator.turnright();
         }
     }
 }
Exemple #3
0
    protected void Phy(int HorizontalDir)
    {
        if (HorizontalDir == 1)
        {
            Rotator.turnright();
        }
        else if (HorizontalDir == -1)
        {
            Rotator.turnleft();
        }
        Vector3 mov = Vector3.zero;

        mov += Vector3.down * -VerticalForce;
        mov += Front * HorizontalDir * HorizontalSpeed;
        //gravedad
        if (!CC.isGrounded)
        {
            mov += new Vector3(0, Gravity, 0);
        }
        CC.Move(mov * Time.deltaTime);
    }
Exemple #4
0
    private void Update()
    {
        if (!DroppedWeaponAlready)
        {
            if (CC.isGrounded)
            {
                anim.Play("Salto");
                if (P.LeftOrRightFrom(transform.position.z) == -1)
                {
                    Rotator.turnleft();
                }
                else
                {
                    Rotator.turnright();
                }
                float D;
                if (Jumps > 0)
                {
                    D = transform.position.z - Target.position.z;
                    Jumps--;
                }
                else
                {
                    Jumps = MaxJumps;
                    if (P.LeftOrRightFrom(transform.position.z) == -1)
                    {
                        D = transform.position.z - RightC.position.z;
                    }
                    else
                    {
                        D = transform.position.z - LeftC.position.z;
                    }
                }

                vx        = VX(D);
                VForce    = JumpPower;
                Direction = P.LeftOrRightFrom(transform.position.z);
            }
            else
            {
                VForce -= Gravity * Time.deltaTime;
            }
            Vector3 mov = new Vector3(0, VForce, vx * -1);
            CC.Move(mov * Time.deltaTime);
        }
        else
        {
            //ultimo salto
            if (CC.isGrounded && !LastJump)
            {
                gameObject.layer = AcrossPlatformsLayer;
                anim.Play("Salto");
                if (P.LeftOrRightFrom(transform.position.z) == -1)
                {
                    Rotator.turnleft();
                }
                else
                {
                    Rotator.turnright();
                }
                float D;


                Jumps = MaxJumps;

                D = transform.position.z - LeftC.position.z;



                vx        = LVX(D);
                VForce    = LastJumpPower;
                Direction = P.LeftOrRightFrom(transform.position.z);
                LastJump  = true;
            }
            else
            {
                VForce -= Gravity * Time.deltaTime;
            }

            if (transform.position.z - LeftC.position.z <= LastJumpError ||
                -transform.position.z + LeftC.position.z >= -LastJumpError) //para no seguir muy de largo
            {
                vx = 0;
            }
            if (transform.position.y >= (LastJumpPower / 2) * lastairtime)//receta casera para calcular altura maxima
            {
                gameObject.layer = DefaultLayer;
            }
            Vector3 mov = new Vector3(0, VForce, vx * -1);

            CC.Move(mov * Time.deltaTime);
        }
    }