Exemple #1
0
 private void Drift()
 {
     Flip(InputUI.GetAxis("Horizontal"));
     state.SetInteger("State", (int)State.DRIFT);
     timer_on_drift += Time.deltaTime;
     if (timer_on_drift >= time_on_drift)
     {
         IsDriftAvailable = false;
         timer_on_drift   = 0;
     }
 }
Exemple #2
0
 private void Move()
 {
     if (!IsDriftAvailable && IsGround && !Shoot.IsShoot)
     {
         if (InputUI.GetAxis("Horizontal") != 0)
         {
             Flip(InputUI.GetAxis("Horizontal"));
             state.SetInteger("State", (int)State.RUN);
         }
         else
         {
             Speed = basic_speed;
             state.SetInteger("State", (int)State.IDLE);
         }
     }
     body_player.AddForce(new Vector2(InputUI.GetAxis("Horizontal") * Speed, body_player.velocity.y));
     body_player.AddForce(new Vector2(Input.GetAxis("Horizontal") * Speed, body_player.velocity.y));
 }
Exemple #3
0
 private void Update()
 {
     if (Logic.Instance.IsGameOver)         // time to restart lvl, if mario is dead
     {
         agony_timer += Time.deltaTime;
         if (agony_timer >= agony_time)
         {
             Logic.Instance.TransitToCurrentLevel();
         }
     }
     else
     {
         #region DriftCrutch
         // if direction change, then animation of drift is on
         if (IsDriftAvailable && InputUI.GetAxis("Horizontal") != last_direction && InputUI.GetAxis("Horizontal") != 0)
         {
             Drift();
         }
         else if (IsDriftAvailable && body_player.velocity.x > -0.25f && body_player.velocity.x < 0.25f)
         {
             IsDriftAvailable = false;
         }
         #endregion
         // if player in motion, then the counter is accumulated for possible the drift
         if (InputUI.GetAxis("Horizontal") != 0 && !IsDriftAvailable)
         {
             drift_timer += Time.deltaTime;
             if (drift_timer >= drift_time)
             {
                 last_direction   = InputUI.GetAxis("Horizontal");
                 IsDriftAvailable = true;
                 drift_timer      = 0;
             }
         }
     }
 }