//§ //Omhoog duwen van blokje public static void CollisionDectectExplorerMovingBlockUp(MovingBlock block) { if (explorer.CollisionRect.Intersects(block.Rectangle) && explorer.IState.ToString() == "pp.ExplorerWalkUp" && explorer.CollisionRect.Top > block.Rectangle.Bottom - 4) //-4 anders bij het teruglopen en weer omhoog gaan loopt de explorer door het steentje { level.Blocks[(int)block.CurrentIndex.X, (int)block.CurrentIndex.Y].BlockCollision = BlockCollision.Passable; block.State = new MovingBlockUp(block); } }
//§ nieuw explorer blokkeert het pad van de teruglopende steen omhoog en omlaag public static void CollisionDectectExplorerGoBackUp(MovingBlock block) { if (explorer.CollisionRect.Intersects(block.Rectangle)) { if ( explorer.IState.ToString() == "pp.Idle" || explorer.IState.ToString() == "pp.ExplorerWalkLeft" || explorer.IState.ToString() == "pp.ExplorerWalkRight") { if (explorer.CollisionRect.Bottom - 2 < block.Rectangle.Top || //Steen blokkeren als steen naar boven gaat en explorer blokkeert pad explorer.CollisionRect.Top + 2 > block.Rectangle.Bottom) //Steen blokkeren als steen naar beneden gaat en explorer blokkeert pad { block.State = new MovingBlockIdleOffPlace(block); } //if (explorer.CollisionRect.Top > block.Rectangle.Top) heeft geen functie meer //{ // explorer.Speed = 2000.0f; //} } } }
//Constructor public MovingBlockGoBackRight(MovingBlock block) { this.block = block; }
//Constructor public MovingBlockLeft(MovingBlock block) { this.block = block; }
//§ nieuw blokkeert een movingblock als hij de muur raakt public static bool CollisionDectectionWalls(MovingBlock block) { if ( block.Location.Y > block.BorderBottom ) { explorer.Location = new Vector2(block.CurrentIndex.X * 32, (block.CurrentIndex.Y - 1) * 32); block.Location = new Vector2(block.CurrentIndex.X * 32, (block.CurrentIndex.Y) * 32); explorer.IState = new IdleExplorerMovingBlockStandStill(explorer, "Down"); return true; } if ( block.Location.Y < block.BorderTop ) { explorer.Location = new Vector2(block.CurrentIndex.X * 32, (block.CurrentIndex.Y + 2) * 32); block.Location = new Vector2(block.CurrentIndex.X * 32, (block.CurrentIndex.Y + 1) * 32); explorer.IState = new IdleExplorerMovingBlockStandStill(explorer, "Up"); return true; } return false; }
//§ nieuw zorgt ervoor dat een omlaaggaande steen weer op de startpositie terecht komt public static void SetBackOnPlaceGoingDown(MovingBlock block) { if (block.Location.Y > block.StartLocation.Y) { block.Location = block.StartLocation; level.Blocks[(int)block.CurrentIndex.X, (int)block.CurrentIndex.Y].BlockCollision = BlockCollision.NotPassable; block.State = new MovingBlockIdle(block); } }
//§ zorgt ervoor dat een omhooggaande steen weer op de startpositie terecht komt public static void SetBackOnPlaceGoingUp(MovingBlock block) { if (block.Location.Y < block.StartLocation.Y) //Zou 1 methode kunnen worden met de onderstaande SetBackOnPlaceGoingDown(MovingBlock block) { block.Location = block.StartLocation; level.Blocks[(int)block.CurrentIndex.X, (int)block.CurrentIndex.Y].BlockCollision = BlockCollision.NotPassable; block.State = new MovingBlockIdle(block); } }
//§ alles nieuw public static void DeCollisionDectectExplorerMovingBlockDown(MovingBlock block) { if ( !explorer.CollisionRect.Intersects(block.Rectangle)) { if (block.Location.Y > block.StartLocation.Y) { block.State = new MovingBlockGoBackUp(block); } else if (block.Location.Y < block.StartLocation.Y) { block.State = new MovingBlockGoBackDown(block); //§ } } }
//Constructor public MovingBlockGoBackDown(MovingBlock block) { this.block = block; }
//constructor public MovingBlockUp(MovingBlock block) { this.block = block; }
//Constructor public MovingBlockIdle(MovingBlock block) { this.block = block; }
//Constructor public MovingBlockIdleOffPlace(MovingBlock block) { this.block = block; }