private void HandleWall(Point currentPoint, Color wallColor, Color[] colorData, Level level) { Vertices vertices = new Vertices(); // Add each adjacent pixel of the same color as a vertice and then white it do { vertices.Add(PointToPosition(currentPoint)); colorData[ToArrayIndex(currentPoint.X, currentPoint.Y)] = Color.White; } while (GetAdjacent(currentPoint, wallColor, colorData, ref currentPoint)); if (vertices.Count < 3) { return; } Wall.WallType wallType = Wall.WallType.Inner; if (wallColor.R % 2 == 0) { wallType = Wall.WallType.Outer; } level.AddWall(new Wall(vertices, wallType, PlayWindow)); }
public Wall createWall(Wall.WallType mWallType, GameObject.GameObjectName gameName, int index = 0, float x = 0.0f, float y = 0.0f, float width = 0.0f, float height = 0.0f) { Wall wall = null; switch (mWallType) { case Wall.WallType.WallTop: wall = new WallTop(gameName, index, Sprite.SpriteName.NullObject, x, y, width, height, Wall.WallType.WallTop); break; case Wall.WallType.WallDown: wall = new WallDown(gameName, index, Sprite.SpriteName.NullObject, x, y, width, height, Wall.WallType.WallDown); break; case Wall.WallType.WallLeft: wall = new WallLeft(gameName, index, Sprite.SpriteName.NullObject, x, y, width, height, Wall.WallType.WallLeft); break; case Wall.WallType.WallRight: wall = new WallRight(gameName, index, Sprite.SpriteName.NullObject, x, y, width, height, Wall.WallType.WallRight); break; case Wall.WallType.WallRoot: wall = new WallRoot(gameName, index, Sprite.SpriteName.NullObject, Wall.WallType.WallRoot); GameObjectNodeManager.add(wall, cPCSTree); break; case Wall.WallType.Uninitilized: Debug.WriteLine("Wall Type is Uninitilized"); break; } this.cPCSTree.Insert(wall, this.cParent); wall.addSpriteToBatch(this.cSpriteBatch); wall.addCollisionToBatch(SpriteBatchManager.find(SpriteBatch.SpriteBatchName.Boxes)); return(wall); }
public Wall(GameObjectName mGameObjectName, int index, Sprite.SpriteName mSpriteName, Wall.WallType walltype) : base(mGameObjectName, index, mSpriteName) { type = walltype; }
public WallRoot(GameObjectName mGameObjectName, int index, Sprite.SpriteName mSpriteName, Wall.WallType walltype) : base(mGameObjectName, index, mSpriteName, walltype) { // this.cCollisionObj.cSpriteBox.setColor(Unit.spriteBoxColor); }
public WallTop(GameObjectName mGameObjectName, int index, Sprite.SpriteName mSpriteName, float x, float y, float width, float height, Wall.WallType walltype) : base(mGameObjectName, index, mSpriteName, walltype) { this.setCollisionRect(x, y, width, height); this.x = x; this.y = y; this.cCollisionObj.cSpriteBox.setColor(Unit.redColor); }