示例#1
0
    public void PlayOrderly(List <string> orderedTags)
    {
        if (m_isProcessing ||
            m_effects.Count == 0)
        {
            return;
        }

        foreach (var tag in orderedTags)
        {
            if (!m_effects.ContainsKey(tag))
            {
                return;
            }
        }

        m_isProcessing = true;

        var process = new SerialProcess();

        foreach (var tag in orderedTags)
        {
            process.Add(m_effects[tag]);
        }

        process.Add((System.Action finish) =>
        {
            m_isProcessing = false;
            Clear();
        });

        process.Flush();
    }
示例#2
0
    public void Test()
    {
        var testCases = new List <TestCase>
        {
            new TestCase
            {
                title = "ordered test 1",
                raw   = new List <int>
                {
                    1, 2, 3, 4
                },
                expected = new List <int>
                {
                    1, 2, 3, 4
                }
            },
            new TestCase
            {
                title = "reverse ordered test 1",
                raw   = new List <int>
                {
                    5, 4, 3, 2, 1
                },
                expected = new List <int>
                {
                    5, 4, 3, 2, 1
                }
            }
        };

        foreach (var testCase in testCases)
        {
            int size     = testCase.raw.Count;
            var procaess = new SerialProcess();

            var result = new List <int>();

            for (int i = 0; i < size; i++)
            {
                int index = i;
                procaess.Add((System.Action finish) =>
                {
                    result.Add(testCase.raw[index]);
                    finish();
                });
            }

            procaess.Add((System.Action finish) =>
            {
                if (!IsSameList(result, testCase.expected))
                {
                    Assert.Fail("Test : " + testCase.title + " failed.");
                }

                finish();
            });

            procaess.Flush();
        }

        Assert.Pass();
    }