private void DrawRoom(SpriteBatch spriteBatch, int scale, int blockOffset, MMRoom room) { for (int y = 0; y < 16; y++) { for (int x = 0; x < 32; x++) { var blockId = room.blocks[(y * 32) + x]; if (blockId == 4) { DrawBlock(spriteBatch, (int)(x * 8 * scale), (int)(y * 8 * scale), blockOffset, (int)scale); DrawCrumbling(spriteBatch, x, y, blockOffset, (int)scale); } else if (blockId != 7) { DrawBlock(spriteBatch, (int)(x * 8 * scale), (int)(y * 8 * scale), blockOffset + blockId, (int)scale); } } } DrawConveyor(spriteBatch, blockOffset, (int)scale); if (_roomId == 20) { Draw(spriteBatch, _background, _background.Bounds, _background.Bounds, DrawColor); Draw(spriteBatch, _sun, new Rectangle(60, 32, _sun.Width, _sun.Height), _sun.Bounds, DrawColor); } }
private void RenderExit(MMRoom room) { var exitBlocks = _sprites.GetExitFrames(21, _roomID); _exitBlock.SetSprites(exitBlocks); _exitBlock.transform.localPosition = new Vector3(room.exitPosition.x, -room.exitPosition.y); }
private void DrawKeys(SpriteBatch spriteBatch, float scale, int blockOffset, MMRoom room) { foreach (var key in room.keys) { // TODO: Figure out which ones have been collected... var keyAnimFrame = blockOffset + 11 + KeyAnimFrame; DrawBlock(spriteBatch, (int)(key.x * scale), (int)(key.y * scale), keyAnimFrame, (int)scale); } }
public override void Enter(params object[] args) { _roomId = (int)args[0]; var loadMapFile = (bool)args[1]; var lives = DEFAULT_LIVES; if (args.Length > 2) { _score = (int)args[2]; _hiScore = (int)args[3]; lives = (int)args[4]; } if (loadMapFile) { _mapFile = StateManager.Game.ContentManager.LoadJson <MMMapFile>("manicminer.json"); _font.Text = _mapFile.rooms[_roomId].name; _lives.Lives = lives; _airMeter.AirLeft = _mapFile.rooms[_roomId].airCount; _currentRoom = _mapFile.rooms[_roomId].Copy(); _roomRenderer.SetRoom(_currentRoom, _roomId); _baddieRenderer.SetRoom(_currentRoom); _willy.SetRoom(_currentRoom, _roomId, ChangeState); _exit.SetRoom(_currentRoom, _roomId); _scoreRenderer.UpdateScore(_score, _hiScore); } _livesAnimationTween = StateManager.Game.Tweens.AddClamp(0.2f, 0, 3, frame => _lives.Frame = frame); _keyAnimationTween = StateManager.Game.Tweens.AddClamp(0.2f, 0, 3, frame => _roomRenderer.KeyAnimFrame = frame); _airMeterTween = StateManager.Game.Tweens.Add(1, () => _airMeter.AirLeft--); _pauseables.Add(_livesAnimationTween); _pauseables.Add(_keyAnimationTween); _pauseables.Add(_airMeterTween); // Force all paused items to become unpaused. This is for when // the level changes _pauseables.ForEach(p => p.Paused = false); AddImage(_roomRenderer, Layer.Background); AddImage(_air, Layer.UI, 0, 16 * 8); AddImage(_airMeter, Layer.UI, 28, 10 + (16 * 8)); AddImage(_font, Layer.UI, 0, 16 * 8); AddImage(_lives, Layer.UI, 0, 168); AddImage(_scoreRenderer, Layer.UI, 0, 19 * 8); AddImage(_baddieRenderer, Layer.Sprite); AddImage(_willy, Layer.Sprite); AddImage(_exit, Layer.Sprite); AddImage(_quitGameRenderer, Layer.UI); }
private void SetupRoom() { _currentRoom = _controller.GetCurrentRoom(); _roomID = _controller._roomID; RoomChanged?.Invoke(this, EventArgs.Empty); RenderBackground(_currentRoom); AddTravelator?.Invoke(this, EventArgs.Empty); RenderExit(_currentRoom); }
public void SetRoom(MMRoom room) { _room = room; _horizonalMobs.Clear(); foreach (var horiz in room.horizEnemies) { var x = horiz.pos.x; var blockId = horiz.graphic + (x & horiz.ani) / 2; _horizonalMobs.Add(horiz, blockId); } }
public void SetRoom(MMRoom room, int roomId, Action <GameStateType> changeGameState) { _room = room; _roomId = roomId; _changeGameState = changeGameState; var start = _room.willyStart; Position = new Vector2(start.pos.x, start.pos.y); dir = start.dir; _x = start.pos.x; _y = start.pos.y; // Reset everything here! Reset(); }
private void RenderBackground(MMRoom room) { var spriteRenderer = GetComponent <SpriteRenderer>(); var texture = SpriteUtil.CreateTexture(256, 128); texture.filterMode = FilterMode.Point; var roomBlockOffsetY = (19 - _controller._roomID) * 8; for (int y = 0; y < 16; y++) { for (int x = 0; x < 32; x++) { var block = room.blocks[(y * 32) + x]; if (Array.IndexOf(IGNORE_BLOCKS, block) > -1) { // If it's a travelator or a crumble block // we don't want to show it. Those are handled separately. if (block == CRUMBLE_BLOCK) { AddCrumbleBlock?.Invoke(this, new PositionalWithSourceEventArgs(x * 8, (-y) * 8, 8 * block, roomBlockOffsetY)); } block = 0; } var roomBlockOffsetX = 8 * block; var srcRect = new Rect(roomBlockOffsetX, roomBlockOffsetY, 8, 8); var pos = new Vector2(x * 8, (15 - y) * 8); if (Array.IndexOf(KILLY_BLOCKS, block) > -1) { AddKillBlock?.Invoke(this, new PositionalEventArgs(x * 8, (-y) * 8)); } TexUtil.Blit(_blocks, texture, srcRect, pos); } } spriteRenderer.sprite = Sprite.Create(texture, new Rect(0, 0, 256, 128), new Vector2(0, 1), 1); }
public void SetRoom(MMRoom room, int roomID) { _room = room; _roomId = roomID; }
public void SetRoom(MMRoom room, int roomId) { _roomId = roomId; SetFrame(420 + roomId); Position = new Vector2(room.exitPosition.x, room.exitPosition.y); }