private void Awake() { if (instance != null) { Debug.LogError("Instance already assigned"); } instance = this; }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); TilesetManager.CreateTileset("tileset", Content.Load <Texture2D>("jawbreaker"), 5, 8); SceneManager.LoadScene("Level01"); //_player = new Player(Content.Load<Texture2D>("characters"), new Vector2(100, 100), new Vector2(2, 2), 9, 8, 0); }
public override void Draw(SpriteBatch spriteBatch) { base.Draw(spriteBatch); spriteBatch.Draw(GraphicAssets.itemsTileset, MathUtil.GetDrawRectangle(position, size, parentPosition), TilesetManager.GetSourceRectangle(TilesetManager.TileSetType.ITEMS, (int)TilesetManager.ItemTileSet.WOOD_SWORD), Color.White); }
public static void Create() { TilesetManager newTilesetAsset = ScriptableObject.CreateInstance <TilesetManager>(); AssetDatabase.CreateAsset(newTilesetAsset, "Assets/Maps/newTiletsetManagerSO.asset"); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = newTilesetAsset; }
public void DrawFrame(SpriteBatch p_spriteBatch, Rectangle p_pos) { if (Animation?.Frame == null) { return; } p_spriteBatch.Draw(TilesetManager.GetTileSet(Animation.Frame.frameType), p_pos, TilesetManager.GetSourceRectangle(Animation.Frame.frameType, Animation.Frame.GetFrameIndex()), Color.White); }
private Sprite CreateSprite(TilesetManager tilesetManager, int index) { string textureName; RectangleF sourceRectangle; tilesetManager.GetTile(index, out textureName, out sourceRectangle); Texture2D texture = this.LoadTexture(textureName); // !!! the SpriteMeshType.FullRect is needed !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! return(Sprite.Create(texture, sourceRectangle, Vector2.zero, tilesetManager.GetTilesetForId(index).TileSize, 0, SpriteMeshType.FullRect)); }
public Sprite GetSprite(TilesetManager tilesetManager, int index) { Sprite sprite; if (!_indexToSpriteDict.TryGetValue(index, out sprite)) { sprite = this.CreateSprite(tilesetManager, index); _indexToSpriteDict.Add(index, sprite); } return(sprite); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. SpriteBatch = new SpriteBatch(GraphicsDevice); TilesetManager = new TilesetManager(this); Graphics.PreferredBackBufferHeight = 720; Graphics.PreferredBackBufferWidth = 1280; Graphics.ApplyChanges(); ViewportMain = GraphicsDevice.Viewport; GameFont = Content.Load <SpriteFont>("GameFont"); LoadLevel("level1"); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load <SpriteFont>("Menu"); var eventService = new EventService(); var graphics = new Graphics(Content, spriteBatch, font); var tilesetManager = new TilesetManager(Content, spriteBatch); var dialogManager = new DialogManager(Content, spriteBatch); var songManager = new SongManager(Content); var soundManager = new SoundManager(Content); var actorManager = new ActorManager(Content, spriteBatch); var enemyManager = new EnemyManager(Content, spriteBatch); var iconManager = new IconManager(Content, spriteBatch); var battleManager = new BattleManager(Content, spriteBatch); _dataStore = new BinaryDataStore(); _gameState = new GameState(actorManager, battleManager, _dataStore, dialogManager, enemyManager, eventService, graphics, iconManager, inputManager, songManager, tilesetManager); _gameState.OnLoad(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. SpriteBatch = new SpriteBatch(GraphicsDevice); TilesetManager = new TilesetManager(this); Graphics.PreferredBackBufferHeight = 720; Graphics.PreferredBackBufferWidth = 1280; Graphics.ApplyChanges(); ViewportMain = GraphicsDevice.Viewport; GameFont = Content.Load <SpriteFont>("GameFont"); LoadLevelSelectionDesktop(); if (InitialLevelName != null) { LoadLevel(InitialLevelName); State = "playing"; } }
public override void Draw(SpriteBatch p_spriteBatch) { base.Draw(p_spriteBatch); //Draw Background p_spriteBatch.Draw(GraphicAssets.guiItemsBackground, new Rectangle(88 * Main.s_scale, ((int)parentPosition.Y + 188) * Main.s_scale, 144 * Main.s_scale, 32 * Main.s_scale), Color.White); //Draw -LIFE- p_spriteBatch.DrawString(GraphicAssets.zeldaFont12, "-LIFE-", new Vector2(185f * Main.s_scale, ((int)parentPosition.Y + 188.0f) * Main.s_scale), GraphicAssets.guiRedColor, 0.0f, Vector2.Zero, Main.s_scale / 2.0f, SpriteEffects.None, 0.0f); //Draw Rupees p_spriteBatch.DrawString(GraphicAssets.zeldaFont12, "X" + Inventory.Instance.rupeeCount, new Vector2((parentPosition.X + 97.0f) * Main.s_scale, (parentPosition.Y + 188.0f) * Main.s_scale), Color.White, 0.0f, Vector2.Zero, Main.s_scale / 2.0f, SpriteEffects.None, 0.0f); //Draw Keys p_spriteBatch.DrawString(GraphicAssets.zeldaFont12, "X" + Inventory.Instance.keyCount, new Vector2((parentPosition.X + 97.0f) * Main.s_scale, (parentPosition.Y + 204.0f) * Main.s_scale), Color.White, 0.0f, Vector2.Zero, Main.s_scale / 2.0f, SpriteEffects.None, 0.0f); //Draw Bombs p_spriteBatch.DrawString(GraphicAssets.zeldaFont12, "X" + Inventory.Instance.bombCount, new Vector2((parentPosition.X + 97.0f) * Main.s_scale, (parentPosition.Y + 212.0f) * Main.s_scale), Color.White, 0.0f, Vector2.Zero, Main.s_scale / 2.0f, SpriteEffects.None, 0.0f); //Draw Second Item HotKey p_spriteBatch.DrawString(GraphicAssets.zeldaFont12, "B", new Vector2((parentPosition.X + 129.0f) * Main.s_scale, (parentPosition.Y + 188.0f) * Main.s_scale), Color.White, 0f, Vector2.Zero, Main.s_scale / 2.0f, SpriteEffects.None, 0.0f); p_spriteBatch.Draw(GraphicAssets.inventoryTileset, new Rectangle((124 + (int)parentPosition.X) * Main.s_scale, (196 + (int)parentPosition.Y) * Main.s_scale, 16 * Main.s_scale, 16 * Main.s_scale), TilesetManager.GetSourceRectangle(TilesetManager.TileSetType.INVENTORY, 7), Color.White); //Draw Sword HotKey p_spriteBatch.DrawString(GraphicAssets.zeldaFont12, "A", new Vector2((parentPosition.X + 153.0f) * Main.s_scale, (parentPosition.Y + 188.0f) * Main.s_scale), Color.White, 0.0f, Vector2.Zero, Main.s_scale / 2.0f, SpriteEffects.None, 0.0f); p_spriteBatch.Draw(GraphicAssets.inventoryTileset, new Rectangle((148 + (int)parentPosition.X) * Main.s_scale, (196 + (int)parentPosition.Y) * Main.s_scale, 16 * Main.s_scale, 16 * Main.s_scale), TilesetManager.GetSourceRectangle(TilesetManager.TileSetType.INVENTORY, 9), Color.White); //Draw Hearts var __x = 0; for (var __i = 0; __i < _player.maximumLife; __i += 2) { var __type = 0; if (_player.life - __i > 1) { __type = 0; } else if (_player.life - __i == 1) { __type = 1; } else { __type = 2; } p_spriteBatch.Draw(GraphicAssets.inventoryTileset, new Rectangle((176 + (int)parentPosition.X + __x * 8) * Main.s_scale, (208 + (int)parentPosition.Y) * Main.s_scale, 16 * Main.s_scale, 16 * Main.s_scale), TilesetManager.GetSourceRectangle(TilesetManager.TileSetType.INVENTORY, __type), Color.White); __x++; } }
public override void Draw(SpriteBatch p_spriteBatch) { base.Draw(p_spriteBatch); //Draw Small Item Frame p_spriteBatch.Draw(GraphicAssets.guiInventorySmallItemFrame, new Rectangle(56 * Main.s_scale, ((int)parentPosition.Y + 39) * Main.s_scale, 32 * Main.s_scale, 32 * Main.s_scale), Color.White); //Draw Big Item Frame p_spriteBatch.Draw(GraphicAssets.guiInventoryBigItemFrame, new Rectangle(116 * Main.s_scale, ((int)parentPosition.Y + 39) * Main.s_scale, 112 * Main.s_scale, 48 * Main.s_scale), Color.White); //Draw INVENTORY p_spriteBatch.DrawString(GraphicAssets.zeldaFont12, "INVENTORY", new Vector2(34.0f * Main.s_scale, (parentPosition.Y + 23.0f) * Main.s_scale), GraphicAssets.guiRedColor, 0.0f, Vector2.Zero, Main.s_scale / 2.0f, SpriteEffects.None, 0.0f); //Draw Use B Button p_spriteBatch.DrawString(GraphicAssets.zeldaFont12, "USE B BUTTON\n FOR THIS", new Vector2(16.0f * Main.s_scale, (parentPosition.Y + 71.0f) * Main.s_scale), Color.White, 0.0f, Vector2.Zero, Main.s_scale / 2.0f, SpriteEffects.None, 0.0f); p_spriteBatch.Draw(GraphicAssets.inventoryTileset, new Rectangle((63 + (int)parentPosition.X) * Main.s_scale, (47 + (int)parentPosition.Y) * Main.s_scale, 16 * Main.s_scale, 16 * Main.s_scale), TilesetManager.GetSourceRectangle(TilesetManager.TileSetType.INVENTORY, 6), Color.White); //Draw Map if (Inventory.Instance.hasMap) { p_spriteBatch.DrawString(GraphicAssets.zeldaFont12, "MAP", new Vector2(40.0f * Main.s_scale, (parentPosition.Y + 95.0f) * Main.s_scale), GraphicAssets.guiRedColor, 0.0f, Vector2.Zero, Main.s_scale / 2.0f, SpriteEffects.None, 0.0f); p_spriteBatch.Draw(GraphicAssets.inventoryTileset, new Rectangle((44 + (int)parentPosition.X) * Main.s_scale, (111 + (int)parentPosition.Y) * Main.s_scale, 16 * Main.s_scale, 16 * Main.s_scale), TilesetManager.GetSourceRectangle(TilesetManager.TileSetType.INVENTORY, 3), Color.White); //Draw Compass if (Inventory.Instance.hasCompass) { p_spriteBatch.DrawString(GraphicAssets.zeldaFont12, "COMPASS", new Vector2(24.0f * Main.s_scale, (parentPosition.Y + 135.0f) * Main.s_scale), GraphicAssets.guiRedColor, 0.0f, Vector2.Zero, Main.s_scale / 2.0f, SpriteEffects.None, 0.0f); p_spriteBatch.Draw(GraphicAssets.inventoryTileset, new Rectangle((44 + (int)parentPosition.X) * Main.s_scale, (151 + (int)parentPosition.Y) * Main.s_scale, 16 * Main.s_scale, 16 * Main.s_scale), TilesetManager.GetSourceRectangle(TilesetManager.TileSetType.INVENTORY, 4), Color.White); } } //Draw Big Triforce else { p_spriteBatch.Draw(GraphicAssets.guiInventoryBigTriforce, new Rectangle(80 * Main.s_scale, ((int)parentPosition.Y + 103) * Main.s_scale, 96 * Main.s_scale, 48 * Main.s_scale), Color.White); p_spriteBatch.DrawString(GraphicAssets.zeldaFont12, "TRIFORCE", new Vector2(97.0f * Main.s_scale, (parentPosition.Y + 159.0f) * Main.s_scale), GraphicAssets.guiRedColor, 0.0f, Vector2.Zero, Main.s_scale / 2.0f, SpriteEffects.None, 0.0f); } //Draw Items p_spriteBatch.Draw(GraphicAssets.inventoryTileset, new Rectangle((63 + (int)parentPosition.X) * Main.s_scale, (47 + (int)parentPosition.Y) * Main.s_scale, 16 * Main.s_scale, 16 * Main.s_scale), TilesetManager.GetSourceRectangle(TilesetManager.TileSetType.INVENTORY, 6), Color.White); }
public void CreateFrom(TilemapData tilemapData, TilesetManager tilesetManager) { this.TilemapData = tilemapData; this.TilesetManager = tilesetManager; this.Create(); }
private void CreateTile(List <Vector3> vertices, List <int> triangles, List <Vector2> uvs, int x, int y, int tile, TilesetManager tilesetManager) { // coordinates start from top-left, remember vertices.Add(new Vector2f(x, y)); // TL vertices.Add(new Vector2f(x + 1, y)); // TR vertices.Add(new Vector2f(x, y + 1)); // BL vertices.Add(new Vector2f(x, y + 1)); // BL vertices.Add(new Vector2f(x + 1, y)); // TR vertices.Add(new Vector2f(x + 1, y + 1)); // BR for (int i = 0; i < 6; i++) { triangles.Add(triangles.Count); } Sprite sprite = TilemapSpriteManager.Instance.GetSprite(tilesetManager, tile); if (sprite == null) { FlaiDebug.LogErrorWithTypeTag <Tilemap>("Error - No Sprite found in TilemapSpriteManager"); return; } RectangleF uv = sprite.textureRect.ToRectangleF() * sprite.texture.texelSize; uvs.Add(uv.TopLeft); uvs.Add(uv.TopRight); uvs.Add(uv.BottomLeft); uvs.Add(uv.BottomLeft); uvs.Add(uv.TopRight); uvs.Add(uv.BottomRight); }
public override void LoadContent(ContentManager contentManager) { _cursorTile = new TiledSprite(TilesetManager.GetTileset(_tilesetName), Vector2.Zero, _spriteScale, _tilesetIndex); _tilesetTile = new TiledSprite(TilesetManager.GetTileset(_tilesetName), Vector2.Zero, _spriteScale, _tilesetIndex); }
private static void InitializeTilemapData(TmxAsset data, TmxData tmxData) { TilesetManager tilesetManager = TilemapLoader.CreateTilesetManager(tmxData); data.Initialize(tmxData.TmxTileLayers.Select(tl => new TilemapData(tl.TileData, tmxData.MapSize, tl.Properties, tl.Name)), tilesetManager); }