Exemple #1
0
    public OmothetyState Action(string action)
    {
        changed = false;
        switch (action)
        {
        case "A":
            if (state == OmothetyState.INIT)
            {
                changed = true;
                state   = OmothetyState.BIG_A;
            }

            if (state == OmothetyState.SMALL_B)
            {
                changed = true;
                state   = OmothetyState.BIG_A;
            }

            if (state == OmothetyState.BIG_C)
            {
                changed = true;
                state   = OmothetyState.SMALL_A;
            }

            break;

        case "B":
            if (state == OmothetyState.SMALL_A)
            {
                changed = true;
                state   = OmothetyState.SMALL_B;
            }

            break;

        case "C":
            if (state == OmothetyState.BIG_A)
            {
                changed = true;
                state   = OmothetyState.BIG_C;
            }

            break;
        }
        return(state);
    }
    private void ChangeCheckpointColor()
    {
        foreach (Checkpoint c in list)
        {
            c.ResetColor();
        }
        OmothetyState nextState = fsm.GetNextState();

        if (nextState == OmothetyState.SMALL_A || nextState == OmothetyState.BIG_A)
        {
            list[(int)Punto.A].ChangeColor();
        }
        if (nextState == OmothetyState.SMALL_B)
        {
            list[(int)Punto.B].ChangeColor();
        }
        if (nextState == OmothetyState.BIG_C)
        {
            list[(int)Punto.C].ChangeColor();
        }
    }
    public float Touched(Checkpoint c)
    {
        if (finished)
        {
            return(c.timeTouched);
        }
        OmothetyState actualState = fsm.Action(c.name);

        if (fsm.changed)
        {
            SaveToFile.instance.AddLog("touched " + c.name + " - correct");
            if (c.name == "A")
            {
                exited = false;
            }
            if (actualState == OmothetyState.SMALL_A)
            {
                bigTime = Time.realtimeSinceStartup - list[(int)Punto.A].timeTouched;
                bigFigureTimes.Add(bigTime);

                foreach (Checkpoint checkpoint in list)
                {
                    checkpoint.Reset();
                }

                drawingCircle = Circle.SMALL;
            }
            else if (actualState == OmothetyState.BIG_A)
            {
                if (firstTime)
                {
                    ChangeCheckpointColor();
                    firstTime = false;
                    return(Time.realtimeSinceStartup);
                }
                littleTime = Time.realtimeSinceStartup - list[(int)Punto.A].timeTouched;
                smallFigureTimes.Add(littleTime);


                foreach (Checkpoint checkpoint in list)
                {
                    checkpoint.Reset();
                }

                totalTime = littleTime + bigTime;
                totalFigureTimes.Add(totalTime);
                Counter++;
                if (counter == repetitions)
                {
                    finished = true;
                }
                drawingCircle = Circle.BIG;
            }
            ChangeCheckpointColor();

            return(Time.realtimeSinceStartup);
        }
        SaveToFile.instance.AddLog("touched " + c.name + " - wrong");
        // dove stiamo andando?
        return(c.timeTouched);
    }
Exemple #4
0
 public OmothetyFSM()
 {
     state = OmothetyState.INIT;
 }