Exemple #1
0
    public static Grammar UnitShapes()
    {
        var grammar = new Grammar();

        grammar.name = "UnitShapes";

        {
            var initRule = new Rule();
            initRule.name = "init";

            var s1 = new Replacement();
            s1.id         = "layer";
            s1.transform *= Matrix4x4.Translate(new Vector3(0f, 0, 0));

            var s2 = new Replacement();
            s2.id         = "layer";
            s2.transform *= Matrix4x4.Translate(new Vector3(0f, 1, 0));

            var s3 = new Replacement();
            s3.id         = "layer";
            s3.transform *= Matrix4x4.Translate(new Vector3(0f, 2, 0));

            initRule.replacements = new[] { s1, s2, s3 };

            grammar.startShape = "init";
            grammar.AddRule(initRule);
        }

        {
            var initRule = new Rule();
            initRule.name = "layer";

            var s1 = new Replacement();
            s1.SetSquare();
            s1.transform *= Matrix4x4.Translate(new Vector3(0f, 0, 0));
            s1.color      = new HsvColor()
            {
                h = 160, s = 1, v = 1
            };

            var s2 = new Replacement();
            s2.SetCircle();
            s2.transform *= Matrix4x4.Translate(new Vector3(0f, 0.25f, 0));
            s2.color      = new HsvColor()
            {
                h = 100, s = 1, v = 1
            };

            var s3 = new Replacement();
            s3.SetTriangle();
            s3.transform *= Matrix4x4.Translate(new Vector3(0f, 0.5f, 0));
            s3.color      = new HsvColor()
            {
                h = 60, s = 1, v = 1
            };

            initRule.replacements = new[] { s1, s2, s3 };
            grammar.AddRule(initRule);
        }

        return(grammar);
    }