public FrozenBlock GenerateFrozenBlockAtPosition(Point aPosition) { FrozenBlock block = new FrozenBlock(myGridBundle, GetRandomizedColor()); block.LoadContent(); myGridBundle.Container.SetBlock(aPosition, block); return(block); }
public void ConvertFrozenBlockToFallingOrColorBlock(FrozenBlock aBlock) { AbstractBlock blockBeneath = myGridBundle.Container.GetBlockAtPosition(aBlock.GetPosition() + new Point(0, -1)); AbstractBlock newBlock; if (blockBeneath.AllowsFalling()) { newBlock = new FallingBlock(myGridBundle, aBlock.GetColor()); ((FallingBlock)newBlock).CanChain = true; } else { newBlock = new ColorBlock(myGridBundle, aBlock.GetColor(), true); } myGridBundle.Container.SetBlock(aBlock.GetPosition(), newBlock); newBlock.LoadContent(); }
public void GenerateGrid() { if (myGridBundle.Behavior != null) { myGridBundle.Behavior.OnGridReset(); } myGridBundle.Container.RemoveAll(); myGridBundle.Container.GenerateTiles(); myGridBundle.Container.myBlocks = new List <AbstractBlock>(); for (int columns = 0; columns < myGridBundle.Container.GetInitialWidth(); ++columns) { FrozenBlock block = new FrozenBlock(myGridBundle); block.SetPosition(columns, 0); myGridBundle.Container.myBlocks.Add(block); Tile tiley = myGridBundle.Container.myGrid[0][columns]; tiley.SetBlock(block); } for (int rows = 1; rows < myGridBundle.Container.GetInitialHeight(); ++rows) { for (int columns = 0; columns < myGridBundle.Container.GetInitialWidth(); ++columns) { EmptyBlock block = new EmptyBlock(myGridBundle); //ColorBlock block = new ColorBlock(myGridBundle); block.SetPosition(columns, rows); myGridBundle.Container.myBlocks.Add(block); Tile tiley = myGridBundle.Container.myGrid[rows][columns]; tiley.SetBlock(block); } } foreach (AbstractBlock block in myGridBundle.Container.myBlocks) { block.LoadContent(); } myGridBundle.Container.PrintGrid(); myGridBundle.Container.EnsureUnique(); }
public int CheckWeaponDestructible(ref Hitbox hitbox, WeaponType weapon, int strength) { int x1 = Math.Max(0, (int)hitbox.Left >> 5); int x2 = Math.Min((int)hitbox.Right >> 5, levelWidth - 1); int y1 = Math.Max(0, (int)hitbox.Top >> 5); int y2 = Math.Min((int)hitbox.Bottom >> 5, levelHeight - 1); int hit = 0; for (int tx = x1; tx <= x2; tx++) { for (int ty = y1; ty <= y2; ty++) { ref LayerTile tile = ref layers[sprLayerIndex].Layout[tx + ty * levelWidth]; if (tile.DestructType == TileDestructType.Weapon) { if (weapon == WeaponType.Freezer && (animatedTiles[tile.DestructAnimation].Length - 2) > tile.DestructFrameIndex) { FrozenBlock frozen = new FrozenBlock(); frozen.OnAttach(new ActorInstantiationDetails { Api = levelHandler.Api, Pos = new Vector3(32 * tx + 16 - 1, 32 * ty + 16 - 1, LevelHandler.MainPlaneZ) }); levelHandler.AddActor(frozen); hit++; } else if (tile.ExtraData == 0 || tile.ExtraData == (uint)(weapon + 1)) { if (AdvanceDestructibleTileAnimation(ref tile, tx, ty, ref strength, "SceneryDestruct")) { hit++; } if (strength <= 0) { goto Done; } } } } }