public Placeable(Game game, Vector2 position, Rectangle areaBorders, PlaceableData data, char symbol) : base(game, position) { this.Enabled = false; List <Texture2D> textureList = new List <Texture2D>(); foreach (string texture in data.sprites) { textureList.Add(game.Content.Load <Texture2D>(texture)); } this.animation = new Animation(textureList, data.animSpeed); this.animation.LayerDepth = data.layerDepth; this.symbol = symbol; this.moveable = data.moveable; this.gravity = data.gravity; this.drillable = data.drillable; this.incollidable = data.incollidable; this.areaBorders = areaBorders; this.destroyable = data.destroyable; this.endCondition = data.endCondition; this.damage = data.damage; this.health = data.health; // this.placeableData = data; this.velocity = Vector2.Zero; // data.dialog is a string so test against string "null" instead of null. if (data.dialog != "null") { this.dialog = new Dialog(game, XMLHandler.LoadXML <DialogData>(data.dialog)); } // Load destroyed sound if (data.destroyedSound != "null") { this.soundEffectDestroyed = game.Content.Load <SoundEffect>(@data.destroyedSound); } else { this.soundEffectDestroyed = null; } game.Components.Add(this); }
public Player(Game game, Vector2 position, Rectangle areaBorders, PlaceableData data, char symbol) : base(game, position, areaBorders, data, symbol) { this.acceleration = data.acceleration; this.direction = Direction.Left; this.drilling = false; this.drillingDirection = Direction.Center; this.jumping = false; this.jumpTimer = 0.0f; this.alive = true; this.atEndCondition = false; this.currentDrillRotatingSpeed = 0.0f; this.minDrillRotatingSpeedToDrill = 0.25f; this.LoadAndSetupAnimations(); this.LoadDrillData(); }
public Map(Game game, MapData mapData) { this.game = game; this.completed = false; this.isGamePaused = false; this.endConditionReached = false; camera = new Camera(((PORAGame)game).Graphics); int offset = mapData.backgroundOffset; int width = 0; int height = 0; this.completionTime = 0.0f; placeables = new List <Placeable>(); background = game.Content.Load <Texture2D>(mapData.background); for (int y = mapData.Tiles.Length - 1; y >= 0; y--) { if (y + 1 > height) { height = y + 1; } for (int x = 0; x < mapData.Tiles[y].Length; x++) { if (x + 1 > width) { width = x + 1; } Vector2 position = new Vector2(x * 64 + 32, y * 64 + 32 + offset); foreach (tileProperty item in mapData.tileInfo) { if (mapData.Tiles[y][x] == item.symbol) { PlaceableData placeableData = XMLHandler.LoadXML <PlaceableData>(item.name); if (placeableData.player == true) { player = new Player(game, position, areaBorders, placeableData, item.symbol); } else { placeables.Add( new Placeable( game, position, areaBorders, placeableData, item.symbol ) ); } } } } } // Apply area borders to all items and enable game components areaBorders = new Rectangle(0, 0, width * 64, height * 64 + offset); foreach (Placeable item in placeables) { item.SetBordersRectangle(areaBorders); item.Enabled = true; } player.SetBordersRectangle(areaBorders); player.Enabled = true; // Create the ending delay timer endingTimer = new Timer(mapData.endDelay, false); // Create timer for death's after effects deadTimer = new Timer(1.0f, false); // Create dialog and add it to the DialogEngine DialogEngine.GetInstance().AddDialog(new Dialog(game, XMLHandler.LoadXML <DialogData>(mapData.dialog))); // Load Game Over dialog textureGameOver = game.Content.Load <Texture2D>("gameover"); //Load background music if (mapData.music != "null") { this.soundEffectMusic = game.Content.Load <SoundEffect>(@mapData.music); this.soundEffectInstanceMusic = this.soundEffectMusic.CreateInstance(); } else { this.soundEffectInstanceMusic = null; this.soundEffectMusic = null; } }