示例#1
0
        public For(int start, int end, Func<int, Instruction> getBody)
        {
            this.start = start; //0
            this.end = end; //10
            this.getBody = getBody;

            //a delegate instance points towards a method
            this.i = start; //0
            this.body = getBody(i); //getBody(0);
        }
示例#2
0
        public override InstructionResult Execute(float deltaTime)
        {
            switch (body.Execute(deltaTime))
            {
                case InstructionResult.Done:
                    body = body.Reset();
                    return InstructionResult.Running;

                case InstructionResult.DoneAndCreateEnemyObject:
                    body = body.Reset();
                    return InstructionResult.RunningAndCreateEnemyObject;

                case InstructionResult.Running:
                    return InstructionResult.Running;

                case InstructionResult.RunningAndCreateEnemyObject:
                    return InstructionResult.RunningAndCreateEnemyObject;
            }

            return InstructionResult.Running;
        }
示例#3
0
        public override InstructionResult Execute(float deltaTime)
        {
            if (i >= end)
            {
                return InstructionResult.Done;
            }

            else
            {
                switch (body.Execute(deltaTime))
                {

                    //0
                    case InstructionResult.Done:
                        i++;
                        body = getBody(i);
                        //returning back for the switch case
                        return InstructionResult.Running;

                    //1
                    case InstructionResult.DoneAndCreateEnemyObject:
                        i++;
                        body = getBody(i);
                        //returning back for the switch case
                        return InstructionResult.RunningAndCreateEnemyObject;

                    case InstructionResult.Running:
                        //returning back for the switch case
                        return InstructionResult.Running;

                    case InstructionResult.RunningAndCreateEnemyObject:
                        //returning back for the switch case
                        return InstructionResult.RunningAndCreateEnemyObject;
                }

                return InstructionResult.Done;
            }
        }
示例#4
0
 public Semicolon(Instruction A, Instruction B)
 {
     this.A = A;
     this.B = B;
 }
示例#5
0
 public Repeat(Instruction body)
 {
     this.body = body;
 }