public LSystemAction(Vector3 direction, float angle, bool spawn, LSystemState state)
        {
            this.direction = direction;
            this.angle     = angle;
            this.spawn     = spawn;

            this.state = state;
        }
Example #2
0
        public LSystemAction[] Interpret(string input, LSystemState state, bool isTree)
        {
            string inputTransformed = TransformInput(input);

            List <LSystemAction> r = new List <LSystemAction>();

            foreach (char c in inputTransformed)
            {
                switch (c)
                {
                case 'F':     // spawn in forward direction
                    r.Add(CreateLSystemAction(isTree, Vector3.zero, 0f, true, state));
                    break;

                case 'f':     // move in forward direction
                    r.Add(CreateLSystemAction(isTree, Vector3.forward, 0f, false, state));
                    break;

                case 'R':
                    r.Add(CreateLSystemAction(isTree, Vector3.zero, 90f, true, state));
                    break;

                case 'r':
                    r.Add(CreateLSystemAction(isTree, Vector3.right, 90f, false, state));
                    break;

                case 'L':
                    r.Add(CreateLSystemAction(isTree, Vector3.zero, -90f, true, state));
                    break;

                case 'l':
                    r.Add(CreateLSystemAction(isTree, Vector3.left, -90f, false, state));
                    break;

                case 'd':
                    r.Add(CreateLSystemAction(isTree, Vector3.back, 0f, false, state));
                    break;
                }
            }

            return(r.ToArray());
        }
Example #3
0
 LSystemAction CreateLSystemAction(bool isTree, Vector3 dir, float angle, bool spawn, LSystemState state)
 {
     if (isTree)
     {
         return(new LSystemActionTree(dir, angle, spawn, state));
     }
     else
     {
         return(new LSystemActionStreet(dir, angle, spawn, state));
     }
 }
 public LSystemActionStreet(Vector3 direction, float angle, bool spawn, LSystemState state) :
     base(direction, angle, spawn, state)
 {
 }
Example #5
0
 public LSystemActor(LSystemState state, LSystemInterpreter interpreter, GameObject toClone)
 {
     this.state       = state;
     this.interpreter = interpreter;
     this.toClone     = toClone;
 }
Example #6
0
        public void Init()
        {
            state = new LSystemState();

            actor = new LSystemActor(state, interpreter, toClone);
        }