Esempio n. 1
0
    void FixedUpdate()
    {
        if (active)
        {
            //Current InputRaw
            cur_x = Input.GetAxisRaw("Horizontal");
            cur_y = Input.GetAxisRaw("Vertical");
            // Increase TimeElapsed
            timeElapsed += Time.deltaTime;

            TimeDataPoint prev = _currentPath.Back();

            // If we've recieved a new input:
            if ((int)Math.Round(cur_y, 0) != (int)Math.Round(prev.y_dir, 0) ||
                (int)Math.Round(cur_x, 0) != (int)Math.Round(prev.x_dir, 0))
            {
                //add new data point
                _currentPath.AddDataPoint(cur_x, cur_y, timeElapsed);
                //reset elapsed time since last call
                timeElapsed = 0f;
            }
            if (GameManager.Instance.tutorialMode == false && GameManager.Instance._currentScene == 0)
            {
                GameManager.Instance.NextLevel();
            }
        }
    }
Esempio n. 2
0
 public void LoadFromDatabaseTest()
 {
     // tests loading
     using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
     {
         var datapoints = new ObservableCollection <TimeDataPoint>();
         TimeDataPoint.LoadFromDatabase(datapoints, db.ConnectionString, false);
         db.Cleanup();
     }
 }
Esempio n. 3
0
    public void AddDataPoint(float dir_x, float dir_y, float time)
    {
        TimeDataPoint curPoint = new TimeDataPoint
        {
            x_dir = dir_x,
            y_dir = dir_y,
            time  = time
        };

        _dataPoints.Add(curPoint);
    }
Esempio n. 4
0
 public void TimeDataPointTestTimespan()
 {
     // tests init with time span and saving and loading to db
     using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
     {
         db.ClearTable(TimeDataPoint.TableName);
         var tp = new TimeDataPoint(new TimeSpan(0, 1, 0),
                                    1, null, 1, db.ConnectionString, Guid.NewGuid().ToStrGuid());
         tp.SaveToDB();
         (tp.Time.TotalMinutes).Should().Be(1);
         var datapoints = new ObservableCollection <TimeDataPoint>();
         TimeDataPoint.LoadFromDatabase(datapoints, db.ConnectionString, false);
         (1).Should().Be(datapoints.Count);
         (datapoints[0].Time.TotalMinutes).Should().Be(1);
         db.Cleanup();
     }
 }
Esempio n. 5
0
 public void TimeDataPointTest()
 {
     // tests saving and loading
     using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
     {
         db.ClearTable(TimeDataPoint.TableName);
         var tp = new TimeDataPoint(new DateTime(2010, 1, 1), 1, null, 1, db.ConnectionString,
                                    Guid.NewGuid().ToStrGuid());
         tp.SaveToDB();
         tp = new TimeDataPoint(new TimeSpan(2010, 1, 1), 1, null, 1,
                                db.ConnectionString, Guid.NewGuid().ToStrGuid());
         tp.SaveToDB();
         var datapoints = new ObservableCollection <TimeDataPoint>();
         TimeDataPoint.LoadFromDatabase(datapoints, db.ConnectionString, false);
         (2).Should().Be(datapoints.Count);
         db.Cleanup();
     }
 }
Esempio n. 6
0
    IEnumerator MoveAlongPath()
    {
        TimeDataPoint point;

        for (int i = 0; i < _path.Size() - 1; ++i)
        {
            point = _path.Get(i);
            TimeDataPoint nextPoint = _path.Get(i + 1);
            gRigid.velocity = new Vector2(walkSpeed * point.x_dir, walkSpeed * point.y_dir);

            yield return(new WaitForSeconds(nextPoint.time));
        }
        point           = _path.Get(_path.Size() - 1);
        gRigid.velocity = walkSpeed * new Vector2(point.x_dir, point.y_dir);

        /*gRigid.velocity = (gRigid.velocity.magnitude == 0)
         *  ? Vector2.zero
         *  : gRigid.velocity / gRigid.velocity.magnitude;
         * gRigid.velocity *= walkSpeed;  */
    }
 public void RemoveTimepoint([NotNull] TimeDataPoint tdp)
 {
     _tp.DeleteTimepoint(tdp);
 }