public bool MapCollide(Game1 game) { if (CollisionDetector.CheckMapCollision((int)destRect.X, (int)destRect.Y + 1, this, game.worldMap[game.currentRoom])) { return(true); } else { return(false); } }
public void GravityUpdate(Game1 game) { if (CollisionDetector.CheckMapCollision(0, 1, this, game.worldMap[game.currentRoom]) == false) { int i = 0; do { i++; } while (CollisionDetector.CheckMapCollision(0, i, this, game.worldMap[game.currentRoom]) == false && i < 9); this.worldY += (i - 1); } }
void IMapItem.UpdateSprite(Game1 game) { CollisionState result = CollisionDetector.PerPixelSprite(this, game.player, game.graphics); if (result == CollisionState.Hurtbox || result == CollisionState.Standard) { this.timer++; if (this.timer >= 3 * this.FRAME_OFFSET) { if (this.frameNum == numFrames - 1) { if (!this.recentlyActivated) { game.OpenSaveStationMenu(); this.recentlyActivated = true; dialUp.Play("dialUp"); } } else { this.frameNum++; } this.timer = 1; } } else { this.recentlyActivated = false; this.timer--; if (this.timer <= 0) { this.timer = 3 * this.FRAME_OFFSET; if (this.frameNum <= 0) { this.frameNum = 0; } else { this.frameNum--; } } } this.UpdateSprite(game.worldMap[game.currentRoom]); if (this.onScreen) { game.AddObjectToDraw(this); } else { game.RemoveObjectToDraw(this); } }
public void UpdatePortal(Game1 game) { if (side1.active) { door1.UpdateDoor(game.worldMap[game.currentRoom]); CollisionState result = CollisionDetector.PerPixelSprite(door1, game.player, game.graphics); if (result == CollisionState.Hurtbox) { if (!side1.GetWasJustActivated()) { game.RemoveObjectToDraw(door1); game.ActivateMap(side2, door2); } } else { if (door1.onScreen) { game.AddObjectToDraw(door1); } else { game.RemoveObjectToDraw(door1); } } } else if (side2.active) { door2.UpdateDoor(game.worldMap[game.currentRoom]); CollisionState result = CollisionDetector.PerPixelSprite(door2, game.player, game.graphics); if (result == CollisionState.Hurtbox) { if (!side2.GetWasJustActivated()) { game.RemoveObjectToDraw(door2); game.ActivateMap(side1, door1); } } else { if (door2.onScreen) { game.AddObjectToDraw(door2); } else { game.RemoveObjectToDraw(door2); } } } }
public bool CheckMapCollision(Game1 game, int xOffset, int yOffset) { if (CollisionDetector.CheckMapCollision(xOffset, yOffset, this, game.worldMap[game.currentRoom])) { return(true); } if (game.worldMap[game.currentRoom].assets.Count > 0) { Spaceman offset = game.worldMap[game.currentRoom].assets[0].offsetSpaceMan(this, xOffset, yOffset); foreach (MapAsset asset in game.worldMap[game.currentRoom].assets) { if (CollisionDetector.RectCollisionDetect(asset, offset)) { return(true); } } } return(false); }