public override void Initialize() { playerInput = new PlayerInput(PlayerIndex.One); this.Game.Components.Add(playerInput); playerInput.BindAction("Quit", Keys.Escape); playerInput.BindAction("Up", Keys.Up); playerInput.BindAction("Down", Keys.Down); playerInput.BindAction("Left", Keys.Left); playerInput.BindAction("Right", Keys.Right); playerInput.BindAction("Swap", Keys.Space); playerInput.BindAction("Explode", Keys.Z); playerInput.BindAction("ExplodeAll", Keys.X); playerInput.BindAction("Reset", Keys.Enter); playerInput.BindAction("Up", Buttons.DPadUp); playerInput.BindAction("Down", Buttons.DPadDown); playerInput.BindAction("Left", Buttons.DPadLeft); playerInput.BindAction("Right", Buttons.DPadRight); blockGrid = new BlockGrid(48, 48, 12, 10); blockGrid.X = 48; blockGrid.Y = 64; BlockGroup bg = new BlockGroup(3, 3, blockGrid); bg.Add(new Block(BlockType.White), 0, 1); bg.Add(new Block(BlockType.White), 1, 1); bg.Add(new Block(BlockType.White), 2, 1); bg.Add(new Block(BlockType.White), 2, 2); //blockGrid.Drop(bg, 2); blockGrid.Drop(bg, 4); InputLimiter = new Limiter[2] { new Limiter(InputLimiterInterval), new Limiter(InputLimiterInterval) }; dropLimiter = new Limiter(0.15); burstEffect = new ParticleEffect_B(); this.Game.Components.Add(burstEffect); explodeEffect = new ParticleEffect_C(); this.Game.Components.Add(explodeEffect); blockGrid.BurstEffect = burstEffect; blockGrid.ExplodeEffect = explodeEffect; this.Game.Components.Add(blockGrid); base.Initialize(); this.Enabled = true; }
public override void Initialize() { playerInput = new PlayerInput(PlayerIndex.One); this.Game.Components.Add(playerInput); playerInput.BindAction("Quit", Keys.Escape); playerInput.BindAction("Up", Keys.Up); playerInput.BindAction("Down", Keys.Down); playerInput.BindAction("Left", Keys.Left); playerInput.BindAction("Right", Keys.Right); playerInput.BindAction("Swap", Keys.Space); playerInput.BindAction("Explode", Keys.Z); playerInput.BindAction("ExplodeAll", Keys.X); playerInput.BindAction("Reset", Keys.Enter); playerInput.BindAction("Up", Buttons.DPadUp); playerInput.BindAction("Down", Buttons.DPadDown); playerInput.BindAction("Left", Buttons.DPadLeft); playerInput.BindAction("Right", Buttons.DPadRight); blockGrid = new BlockGrid(48, 48, 12, 10); blockGrid.X = 48; blockGrid.Y = 64; BlockGroup bg = new BlockGroup(3, 3, blockGrid); bg.Add(new Block(BlockType.White), 0, 1); bg.Add(new Block(BlockType.White), 1, 1); bg.Add(new Block(BlockType.White), 2, 1); bg.Add(new Block(BlockType.White), 2, 2); //blockGrid.Drop(bg, 2); blockGrid.Drop(bg, 4); InputLimiter = new Limiter[2]{new Limiter(InputLimiterInterval),new Limiter(InputLimiterInterval)}; dropLimiter = new Limiter(0.15); burstEffect = new ParticleEffect_B(); this.Game.Components.Add(burstEffect); explodeEffect = new ParticleEffect_C(); this.Game.Components.Add(explodeEffect); blockGrid.BurstEffect = burstEffect; blockGrid.ExplodeEffect = explodeEffect; this.Game.Components.Add(blockGrid); base.Initialize(); this.Enabled = true; }
public void ExplodeBlock(int row, int col) { if (_Blocks[row, col] != null && _Blocks[row, col].State == BlockState.Normal) { BlockGroup bg = new BlockGroup(NumRows, NumCols, this); bg.Add(_Blocks[row, col], row, col); bg.Blocks[row, col].State = BlockState.Exploding; _ExplodeBlocks.Add(bg); } }
private bool TryChainExplode(Block b, int r, int c, BlockGroup chainGroup) { if (InBounds(r, c, this) && !BlockIsEmpty(r, c)) { Block target = _Blocks[r, c]; if (target.State == BlockState.Normal && target.Type == b.Type && !target.IsEmpty) { target.State = BlockState.Exploding; chainGroup.Add(target, r, c); return(true); } } return(false); }
public override void Update(GameTime gameTime) { base.Update(gameTime); InputLimiter[HORIZONTAL].Update(gameTime); InputLimiter[VERTICAL].Update(gameTime); HandleInput(gameTime); //dropLimiter.Reset(); //dropLimiter.Enabled = false; dropLimiter.Update(gameTime); if (dropLimiter.Ready) { BlockGroup bg = new BlockGroup(1, 1, blockGrid); BlockType bt = (BlockType)RNG.Next(4); bg.Add(new Block(bt), 0, 0); blockGrid.Drop(bg, RNG.Next(blockGrid.NumCols)); } }
private bool TryChainExplode(Block b, int r, int c, BlockGroup chainGroup) { if (InBounds(r, c, this) && !BlockIsEmpty(r, c)) { Block target = _Blocks[r, c]; if (target.State == BlockState.Normal && target.Type == b.Type && !target.IsEmpty) { target.State = BlockState.Exploding; chainGroup.Add(target, r, c); return true; } } return false; }