Esempio n. 1
0
 protected override void FixedUpdate()
 {
     if (IsNotRecycled)
     {
         Nowtime += Time.deltaTime;
         NowSpeed = SpeedRatio.Evaluate(Nowtime) * Speed;
         if (flyingDistance <= targetDistance)
         {
             Vector2 trans = Vector3.up * NowSpeed;
             transform.Translate(trans);
             transform.GetChild(0).transform.Rotate(NowSpeed * Vector3.forward * 30);
             flyingDistance += trans.magnitude;
         }
     }
 }
Esempio n. 2
0
    /// <summary>
    /// Updates the speed text. Automatically called when Slider is changed.
    /// </summary>
    public void UpdateSpeedText()
    {
        // Current Speed.
        float speed = (int)Sim.Settings.Speed;

        // Ratio to use based on current speed context.
        SpeedRatio useRatio = SpeedRatio.Second;

        // Find Current Ratio: Is  in hours, days, etc.
        foreach (SpeedRatio ratio in (SpeedRatio[])Enum.GetValues(typeof(SpeedRatio)))
        {
            if (speed >= (int)ratio && (int)ratio > (int)useRatio)
            {
                useRatio = ratio;
            }
        }

        // Set display speed based on ratio (e.g. Hours/sec).
        speed = speed / (float)useRatio;

        // Update display: Value, Ratio, Plural (s)
        speedText.text = string.Format(SPEED_DISPLAY_FMT, speed, useRatio.ToString(), (speed == 1.0 ? "" : "s"));
    }