コード例 #1
0
    public void TestRecordEvent()
    {
        PositionMetric pm1 = new PositionMetric(new List <string> {
            "1", "2"
        });

        pm1.startRecording();
        Assert.IsEmpty(pm1.eventList);
        Assert.IsTrue(pm1.isRecording);

        pm1.recordEvent(null);
        Assert.IsEmpty(pm1.eventList);

        // Test adding events to a PositionMetric which has not started recording
        PositionMetric pm2 = new PositionMetric(new List <string> {
            "1", "2"
        });

        Assert.IsFalse(pm2.isRecording);
        Assert.IsEmpty(pm2.eventList);

        List <Vector2> v1 = new List <Vector2>();

        v1.Add(new Vector2(10, 10));
        v1.Add(new Vector2(0, 0));
        pm2.recordEvent(new PositionEvent(new System.DateTime(2021, 2, 1), v1));
        Assert.IsEmpty(pm2.eventList);
    }
コード例 #2
0
    public void TestConstructor()
    {
        PositionMetric pm = new PositionMetric(new List <string> {
            "1", "2"
        });

        Assert.IsFalse(pm.isRecording);
        Assert.IsNotNull(pm.eventList);
        Assert.IsEmpty(pm.eventList);
    }
コード例 #3
0
    public void TestStartFinishRecording()
    {
        PositionMetric pm = new PositionMetric(new List <string> {
            "1", "2"
        });

        Assert.IsFalse(pm.isRecording);

        pm.startRecording();
        Assert.IsTrue(pm.isRecording);

        pm.finishRecording();
        Assert.IsFalse(pm.isRecording);
    }
コード例 #4
0
    float currRockstarVel;          // used to detect change in rockstar velocity for pMetric

    // Start is called before the first frame update
    void Start()
    {
        Setup();            // run initial setup, inherited from parent class

        InitConfigurable(); // initialize configurable values

        randomSeed = new System.Random(seed.GetHashCode());

        // set the leftKey for the intro instructions
        int tempIdx = lrkeyText.text.IndexOf("LKEY");

        lrkeyText.text = lrkeyText.text.Substring(0, tempIdx) + KeyCodeDict.toString[leftKey] + lrkeyText.text.Substring(tempIdx + 4);

        // set the rightKey for the intro instructions
        tempIdx        = lrkeyText.text.IndexOf("RKEY");
        lrkeyText.text = lrkeyText.text.Substring(0, tempIdx) + KeyCodeDict.toString[rightKey] + lrkeyText.text.Substring(tempIdx + 4);

        // set the upKey for the intro instructions
        tempIdx       = ukeyText.text.IndexOf("UKEY");
        ukeyText.text = ukeyText.text.Substring(0, tempIdx) + KeyCodeDict.toString[upKey] + ukeyText.text.Substring(tempIdx + 4);

        countDoneText = "Rock!";

        pMetric = new PositionMetric(new List <string> {
            "rockstar", "spotlight"
        });                                                                      // initialize position metric recorder
        lvMetric = new LinearVariableMetric(0f, 100f, 75f, new List <string> {
            "gameDrop", "playerRaise"
        });                                                                  // initialize linear variable metric recorder
        metricWriter = new MetricJSONWriter("Rockstar", DateTime.Now, seed); // initialize metric data writer

        rockstar.Init(seed, rockstarChangeFreq, rockstarVelocity);
        spotlight.Init(spotlightVelocity);
        meter.Init(seed, meterChangeFreq, meterMinVel, meterMaxVel, meterUpVel, 0f, 100f, meterGoodRange, 50f);
        rockstar.enabled  = false;
        spotlight.enabled = false;
        meter.enabled     = false;

        currMeterVel    = 0f;
        lastMeterLvl    = 50f;
        currRockstarVel = 0f;
    }
コード例 #5
0
    public void TestGetJSON()
    {
        // Test getJSON() when metric has no records
        PositionMetric pm1 = new PositionMetric(new List <string> {
            "1", "2"
        });

        Assert.IsEmpty(pm1.eventList);

        JObject json1 = pm1.getJSON();

        Assert.IsNotNull(json1);

        // Test getJSON() with one record
        PositionMetric pm2 = new PositionMetric(new List <string> {
            "1", "2"
        });

        pm2.startRecording();
        Assert.IsTrue(pm2.isRecording);
        Assert.IsEmpty(pm2.eventList);

        List <Vector2> v1 = new List <Vector2>();

        v1.Add(new Vector2(20, 20));
        v1.Add(new Vector2(20, 30));
        pm2.recordEvent(new PositionEvent(new System.DateTime(2021, 2, 1), v1));
        pm2.finishRecording();

        JObject json2 = pm2.getJSON();

        Assert.AreEqual(1, pm2.eventList.Count);
        Assert.IsNotNull(json2);

        JArray json2p = (JArray)json2["eventList"];

        Assert.AreEqual(1, json2p.Count);
        Assert.AreEqual("2021-02-01 12:00:00 AM", json2p[0]["eventTime"].ToString());
    }