// Use this for initialization
 void Start()
 {
     //charger = GetComponent<ChargerServer>();
     variables       = GetComponent <VariableScheduler>();
     height          = new Vector3(0.0f, transform.position.y, 0.0f);
     currentPosition = transform.position - height;
     vectors.Add(currentPosition);
     rb        = GetComponent <Rigidbody>();
     speed     = variables.getMinSpeed();
     maxSpeed  = variables.getMaxSpeed();
     hour      = 0.0f;
     min       = 0.0f;
     sec       = 0.0f;
     esc       = 0.0f;
     isMoving  = false;
     escPar    = variables.getESC();
     moment    = variables.getMinSpeed();
     diffTime  = 0.0f;
     otherTime = System.DateTime.Now;
     wholeTime.Add(System.DateTime.Now);
     wholeTime.Add(System.DateTime.Now);
     Power();
     PowerInput();
     curPowerPercent = (curPower / (power * (60 * 60))) * 100;
 }
 void SpeedRise()
 {
     if (curPowerPercent >= 0.0f)
     {
         List <float> avg = new List <float>();
         speedTime.Add(System.DateTime.Now);
         bool chg = false;
         if (wayFIFO.Count >= 2)
         {
             if (wayFIFO[wayFIFO.Count - 1] != wayFIFO[wayFIFO.Count - 2])
             {
                 chg = true;
             }
             else
             {
                 chg = false;
             }
             float transition = wayFIFO[wayFIFO.Count - 1];
             wayFIFO.Clear();
             wayFIFO.Add(transition);
         }
         if (speedTime.Count >= 2)
         {
             avg.Add(speedTime[speedTime.Count - 1].Hour * 60 * 60 * 1000 + speedTime[speedTime.Count - 1].Minute * 60 * 1000 + speedTime[speedTime.Count - 1].Second * 1000 + speedTime[speedTime.Count - 1].Millisecond);
             avg.Add(speedTime[0].Hour * 60 * 60 * 1000 + speedTime[0].Minute * 60 * 1000 + speedTime[0].Second * 1000 + speedTime[0].Millisecond);
             if ((((avg[0] - avg[1]) / 1000) >= 0) && chg)
             {
                 moment  += (1.0f * ((avg[0] - avg[1]) / 10));
                 isMoving = true;
             }
             else
             {
                 moment   = variables.getMinSpeed();
                 isMoving = false;
             }
             if ((avg[0] - avg[1] < 1))
             {
                 System.DateTime time = speedTime[0];
                 speedTime.Clear();
                 speedTime.Add(time);
             }
             else
             {
                 System.DateTime time = speedTime[speedTime.Count - 1];
                 speedTime.Clear();
                 speedTime.Add(time);
             }
             avg.Clear();
         }
         SpeedCalc();
         UpdateText();
     }
 }
Esempio n. 3
0
 // Use this for initialization
 void Start()
 {
     //charger = GetComponent<ChargerServer>();
     variables = GetComponent<VariableScheduler>();
     height = new Vector3(0.0f, transform.position.y, 0.0f);
     currentPosition = transform.position - height;
     vectors.Add(currentPosition);
     rb = GetComponent<Rigidbody>();
     speed = variables.getMinSpeed();
     maxSpeed = variables.getMaxSpeed();
     hour = 0.0f;
     min = 0.0f;
     sec = 0.0f;
     esc = 0.0f;
     isMoving = false;
     escPar = variables.getESC();
     moment = variables.getMinSpeed();
     diffTime = 0.0f;
     otherTime = System.DateTime.Now;
     wholeTime.Add(System.DateTime.Now);
     wholeTime.Add(System.DateTime.Now);
     Power();
     PowerInput();
     curPowerPercent = (curPower / (power * (60 * 60))) * 100;
 }