Пример #1
0
    public void PreviousRange_2_50_100_array()
    {
        var array = new double[] {
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
            10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
            20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
            30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
            40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
            50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
            60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
            70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
            80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
            90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
        };
        var stopwatch      = System.Diagnostics.Stopwatch.StartNew();
        var iterable_range = StepsCounter.GetPreviousRange(2, 50, array);

        stopwatch.Stop();
        var range = new System.Collections.Generic.List <double>(iterable_range);

        Assert.AreEqual(array[53], range[0]);
        Assert.AreEqual(array[54], range[1]);
        Assert.AreEqual(array[55], range[2]);
        Assert.AreEqual(array[98], range[45]);
        Assert.AreEqual(array[99], range[46]);
        Assert.AreEqual(array[0], range[47]);
        Assert.AreEqual(array[1], range[48]);
        Assert.AreEqual(array[2], range[49]);
    }
Пример #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            sokoban    = levelManager.GetGame(currentGame);
            counter    = new StepsCounter(sokoban);
            adapter    = new Adapter(sokoban.Map);
            currentMap = adapter.Map;

            base.Initialize();
        }
Пример #3
0
    public void PreviousRange_7_5_10()
    {
        var iterable_range = StepsCounter.GetPreviousRange(7, 5, 10);
        var range          = new System.Collections.Generic.List <int>(iterable_range);

        Assert.AreEqual(3, range[0]);
        Assert.AreEqual(4, range[1]);
        Assert.AreEqual(5, range[2]);
        Assert.AreEqual(6, range[3]);
        Assert.AreEqual(7, range[4]);
    }
Пример #4
0
    public void PreviousRange_2_5_10()
    {
        var iterable_range = StepsCounter.GetPreviousRange(2, 5, 10);
        var range          = new System.Collections.Generic.List <int>(iterable_range);

        Assert.AreEqual(8, range[0]);
        Assert.AreEqual(9, range[1]);
        Assert.AreEqual(0, range[2]);
        Assert.AreEqual(1, range[3]);
        Assert.AreEqual(2, range[4]);
    }
Пример #5
0
    void Start()
    {
        if (counter == null)
        {
            counter = new StepsCounter(MovmentThreshold, StepThreshold);
        }

        if (SystemInfo.supportsAccelerometer)
        {
            InvokeRepeating("UpdateSteps", 0.0f, Delay);
        }
    }
Пример #6
0
    public void PreviousRange_2_5_100()
    {
        var stopwatch      = System.Diagnostics.Stopwatch.StartNew();
        var iterable_range = StepsCounter.GetPreviousRange(2, 5, 100);

        stopwatch.Stop();
        var range = new System.Collections.Generic.List <int>(iterable_range);

        Assert.AreEqual(98, range[0]);
        Assert.AreEqual(99, range[1]);
        Assert.AreEqual(0, range[2]);
        Assert.AreEqual(1, range[3]);
        Assert.AreEqual(2, range[4]);
    }
Пример #7
0
    public void ReadEric92Data()
    {
        string folder = Paths.GetProjectPath("Assets", "scripts", "Editor", "test_data", "eric_main_vertical_92");
        var    data   = Paths.GetStepData(folder, 0);

        data.AddRange(Paths.GetStepData(folder, 1));
        data.AddRange(Paths.GetStepData(folder, 2));
        var counter = new StepsCounter(15.0, 0.6);

        foreach (var acceleration in data)
        {
            counter.UpdateSteps(acceleration);
        }
        Assert.AreEqual(92, counter.Steps);
    }
Пример #8
0
    public void ReadRegis75Data()
    {
        string folder = Paths.GetProjectPath("Assets", "scripts", "Editor", "test_data", "regis_main_vertical_75+1");
        var    data   = Paths.GetStepData(folder, 0);

        data.AddRange(Paths.GetStepData(folder, 1));
        data.AddRange(Paths.GetStepData(folder, 2));
        var counter = new StepsCounter();

        foreach (var acceleration in data)
        {
            counter.UpdateSteps(acceleration);
        }
        Assert.AreEqual(77, counter.Steps);
    }
Пример #9
0
    public void ReadStepData()
    {
        string folder = Paths.GetProjectPath("Assets", "scripts", "Editor", "test_data", "jesus_legacy_38");
        var    data   = Paths.GetStepData(folder, 4);

        Assert.AreEqual(1002, data.Count);
        // notice the precision loss : our data is 3 doubles, but Vector3 is 3 floats
        Assert.AreEqual(1.666364430f, data[0].x); Assert.AreEqual(1.688510780f, data[0].y); Assert.AreEqual(11.69507690f, data[0].z);
        Assert.AreEqual(2.324171300f, data[1].x); Assert.AreEqual(1.842936750f, data[1].y); Assert.AreEqual(12.56477070f, data[1].z);
        Assert.AreEqual(-0.265157849f, data[25].x); Assert.AreEqual(2.272696020f, data[25].y); Assert.AreEqual(6.01662874f, data[25].z);
        var counter = new StepsCounter();

        foreach (var acceleration in data)
        {
            counter.UpdateSteps(acceleration);
        }
        Assert.AreEqual(38, counter.Steps);
    }
Пример #10
0
    void Start()
    {
        List <DotData> datas = new List <DotData>();

        datas.Add(new DotData(HeroType.BLUE, DLCType.NONE, OnType.NONE, "5:5"));

        instance  = this;
        paused    = false;
        selected  = new List <Dot>();
        selecting = false;
        staying   = false;

        circle  = _circle;
        target  = _target;
        outline = _outline;

        if (rs == null)
        {
            rs = new Resources();
        }

        if (counters == null)
        {
            counters = new Dictionary <HeroType, Counter>();

            foreach (HeroType ht in Enum.GetValues(typeof(HeroType)).Cast <HeroType>())
            {
                if (ht != HeroType.NONE && ht != HeroType.CONCRETE)
                {
                    counters.Add(ht, new Counter(ht));
                }
            }
        }

        width  = _width;
        height = _height;

        if (popups == null)
        {
            popups = new Dictionary <PopupType, Popup>();

            foreach (PopupType pt in Enum.GetValues(typeof(PopupType)).Cast <PopupType>())
            {
                popups.Add(pt, new Popup(pt));
            }
        }

        if (ContentManager.level != null)
        {
            otargets = new Dictionary <OnType, Target>();
            targets  = new Dictionary <HeroType, Target>();

            foreach (TargetData t in ContentManager.level.targets)
            {
                HeroType?ht = t.getType();
                if (ht != null)
                {
                    if (targets.ContainsKey((HeroType)ht))
                    {
                        continue;
                    }
                    targets.Add((HeroType)ht, new Target((HeroType)ht, t.target));
                }
                else
                {
                    OnType?ot = t.getOType();

                    if (ot == null)
                    {
                        continue;
                    }
                    if (otargets.ContainsKey((OnType)ot))
                    {
                        continue;
                    }

                    otargets.Add((OnType)ot, new Target((OnType)ot, t.target));
                }
            }

            steps = new StepsCounter(ContentManager.level.steps);
        }
        else
        {
            steps = new StepsCounter(default_steps);
        }

        glg = GameObject.FindGameObjectWithTag("Board").GetComponent <GridLayoutGroup>() as GridLayoutGroup;

        sr        = dot.GetComponent <SpriteRenderer>() as SpriteRenderer;
        dots      = new Dot[width, height];
        positions = new Vector3[width, height + 1];
        Setup();
        StartCoroutine(checkForToilet());
    }
Пример #11
0
 private void GetNewLevel()
 {
     currentGame++;
     sokoban = levelManager.GetGame(currentGame);
     counter = new StepsCounter(sokoban);
 }