Exemplo n.º 1
0
 public For(int start, int end, Instruction body)
 {
     this.start = start;
     this.end = end;
     this.body = body;
     this.i = start;
 }
Exemplo n.º 2
0
 public override InstructionResult Execute(float deltaTime)
 {
     switch (instruction.Execute(deltaTime))
     {
         case InstructionResult.Done:
             this.instruction = this.instruction.Reset();
             break;
         case InstructionResult.RunningAndCreateAstroid:
             return InstructionResult.RunningAndCreateAstroid;
         case InstructionResult.DoneAndCreateAstroid:
             this.instruction = this.instruction.Reset();
             break;
     }
     return InstructionResult.Running;
 }
Exemplo n.º 3
0
 public override InstructionResult Execute(float deltaTime)
 {
     if (i <= end)
     {
         var execute = body.Execute(deltaTime);
         switch (execute)
         {
             case InstructionResult.Done:
                 i++;
                 body = body.Reset();
                 return InstructionResult.Running;
             case InstructionResult.DoneAndCreateAstroid:
                 i++;
                 body = body.Reset();
                 return InstructionResult.Running;
         }
         return execute;
     }
     else
     {
         return InstructionResult.Done;
     }
 }
Exemplo n.º 4
0
 public Semicolon(Instruction A, Instruction B)
 {
     this.a = A;
     this.b = B;
 }
Exemplo n.º 5
0
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            base.Initialize();
            Rectangle b = GraphicsDevice.Viewport.Bounds;
            windowWidth = b.Width;
            windowHeight = b.Height;

            // Preset players:
            Player p1 = new Player(Content.Load<Texture2D>("Fighter_small.png"), new Health(Content.Load<Texture2D>("healthBar.png")), "Player 1");
            p1.health.position = new Vector2(10.0f, (windowHeight * 95 / 100));
            p1.position = new Vector2((windowWidth/2)-80, windowHeight/2);

            Player p2 = new Player(Content.Load<Texture2D>("Fighter_small.png"), new Health(Content.Load<Texture2D>("healthBar.png")), "Player 2");
            p2.health.position = new Vector2((windowWidth * 80 / 100), (windowHeight * 95 / 100));
            p2.position = new Vector2((windowWidth / 2) - 50, windowHeight / 2);
            Player p3 = new Player(Content.Load<Texture2D>("Fighter_small.png"), new Health(Content.Load<Texture2D>("healthBar.png")), "Player 3");
            p3.health.position = new Vector2(10.0f, (windowHeight * 5 / 100));
            p3.position = new Vector2((windowWidth / 2) - 20, windowHeight / 2);

            Player p4 = new Player(Content.Load<Texture2D>("Fighter_small.png"), new Health(Content.Load<Texture2D>("healthBar.png")), "Player 4");
            p4.health.position = new Vector2((windowWidth * 80 / 100), (windowHeight * 5 / 100));
            p4.position = new Vector2((windowWidth / 2) + 10, windowHeight / 2);

            DefaultPlayerSettings.Add(p1);
            DefaultPlayerSettings.Add(p2);
            DefaultPlayerSettings.Add(p3);
            DefaultPlayerSettings.Add(p4);

            for (int i = 0; i < amountOfPlayers; i++)
            {
                Player ptoAdd = DefaultPlayerSettings[i];
                ptoAdd.controller = getController(PlayerControllerChoices[i]);
                ptoAdd.weapon = new SingleBlaster(Content, ptoAdd);
                Players.Add(ptoAdd);

            }

            astroidRain =
                new While(
                    new Semicolon(new Wait(100),
                        new Semicolon(
                            new For(0, (random.Next(50, 300)),
                                new Semicolon(
                                    new CreateAstroid(),
                                    new Wait(100)
                                )
                            ), new Wait(5000)
                        )
                    )
               );
        }
Exemplo n.º 6
0
 public While(Instruction instruction)
 {
     this.instruction = instruction;
 }