/// <param name="direction">The direction to get a texture for.</param> /// <param name="frame">The frame of the animation to get. This will wrap around if you exceed the maximum frame count.</param> /// <returns>The texture for the selected direction.</returns> public Texture2D TextureForDirection(Engine.Game game, Direction direction, int frame = 0) { string textureTemplate = ""; switch (direction) { case Direction.Up: textureTemplate = NPC.UP_TEXTURE; break; case Direction.Down: textureTemplate = NPC.DOWN_TEXTURE; break; case Direction.Left: textureTemplate = NPC.LEFT_TEXTURE; break; case Direction.Right: textureTemplate = NPC.RIGHT_TEXTURE; break; } return(game.Assets.Get <Texture2D>(textureTemplate.Replace("{name}", ID).Replace("{i}", (frame % _frameCounts[direction]).ToString()))); }
/// <summary> /// Draws this tile. /// </summary> /// <param name="batch">The batch to draw with.</param> /// <param name="mapPos">The position this tile is on.</param> /// <param name="map">The map the tile is in.</param> /// <param name="metadata">Metadata associated with this position.</param> /// <param name="environment">The environment the map is in.</param> public virtual void Draw(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { TileAtlas.Region region = Map.Atlas[TextureName(metadata, environment)]; SpriteEffects effects = SpriteEffects.None; if (mapPos.X >= 0 && mapPos.X < map.Width && mapPos.Y >= 0 && mapPos.X < map.Height) { bool flipHorizontal = map.HasMetadata(Layer, mapPos.X, mapPos.Y) && map.GetMetadata(Layer, mapPos.X, mapPos.Y).GetOrDefault("flip-h", "false") == "True"; if (flipHorizontal) { effects |= SpriteEffects.FlipHorizontally; } bool flipVertical = map.HasMetadata(Layer, mapPos.X, mapPos.Y) && map.GetMetadata(Layer, mapPos.X, mapPos.Y).GetOrDefault("flip-v", "false") == "True"; if (flipVertical) { effects |= SpriteEffects.FlipVertically; } } game.Batch.Texture( new Vector2(mapPos.X * 16, mapPos.Y * 16), region.Texture, color.HasValue ? color.Value : Color.White, Vector2.One, region.Rectangle, 0, null, effects); }
public override void Draw(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { game.Batch.Texture( new Vector2(mapPos.X * 16, mapPos.Y * 16), Template.TextureForDirection(game, Direction.Down), color.HasValue ? color.Value : Color.White); }
public override void Draw(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { if (!_hasValues) { Random random = new Random(); for (int i = 0; i < _randomValues.Length; i++) { _randomValues[i] = random.Next(); } _hasValues = true; } int slot = _randomValues[((Math.Abs(mapPos.Y) * map.Width) + Math.Abs(mapPos.X)) % _randomValues.Length] % 4; _variation = slot == 3 ? 1 : 0; _connectedLeft = mapPos.X - 1 > 0 && map[MapLayer.Decoration, mapPos.X - 1, mapPos.Y] == this; _connectedRight = mapPos.X + 1 < map.Width && map[MapLayer.Decoration, mapPos.X + 1, mapPos.Y] == this; _connectedUp = mapPos.Y - 1 > 0 && map[MapLayer.Decoration, mapPos.X, mapPos.Y - 1] == this; _connectedDown = mapPos.Y + 1 < map.Height && map[MapLayer.Decoration, mapPos.X, mapPos.Y + 1] == this; base.Draw(game, mapPos, map, metadata, environment, color); }
public Game(int wordLenght) { MyGame = new Engine.Game(wordLenght); InitializeComponent(); lblHealth.Text = MyGame.Health.ToString(); }
public override void Draw(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { TileAtlas.Region region = Map.Atlas.MissingRegion; for (int i = 1; i <= ANIMATION_FRAMES; i++) { // preload all frames region = Map.Atlas["tiles/city/waterwheel/" + i + ".png"]; } region = Map.Atlas.MissingRegion; for (int x = 0; x < 3; x++) { for (int y = 0; y < 4; y++) { if (ScanArea(new Rectangle(mapPos.X - x, mapPos.Y - y, 3, 4), map)) { region = Map.Atlas["tiles/city/waterwheel/" + (((int)(game.Time * 10) % ANIMATION_FRAMES) + 1) + ".png"]; region.Rectangle = new Rectangle(region.Rectangle.X + x * 16, region.Rectangle.Y + y * 16, 16, 16); } } } game.Batch.Texture( new Vector2(mapPos.X * 16, mapPos.Y * 16), region.Texture, color.HasValue ? color.Value : Color.White, Vector2.One, region.Rectangle); }
public override void Draw(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { TileAtlas.Region region = Map.Atlas[TextureName(metadata, environment)]; if (mapPos.X - 1 > 0 && map[Layer, mapPos.X - 1, mapPos.Y].ID == ID) { region = Map.Atlas[TextureName(metadata, environment).Replace("tip.png", "tip_right.png")]; } if (mapPos.X + 1 <= map.Width && map[Layer, mapPos.X + 1, mapPos.Y].ID == ID) { region = Map.Atlas[TextureName(metadata, environment).Replace("tip.png", "tip_left.png")]; } if (mapPos.X - 1 > 0 && map[Layer, mapPos.X - 1, mapPos.Y].ID == ID && mapPos.X + 1 <= map.Width && map[Layer, mapPos.X + 1, mapPos.Y].ID == ID) { region = Map.Atlas[TextureName(metadata, environment).Replace("_tip.png", ".png")]; } game.Batch.Texture( new Vector2(mapPos.X * 16, mapPos.Y * 16), region.Texture, color.HasValue ? color.Value : Color.White, Vector2.One, region.Rectangle); }
public Engine.Game Create(IGameSettings gameSettings, ICurrentGameData currentGameData) { var game = new Engine.Game(); game.Initialize(gameSettings, currentGameData); return(game); }
/// <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); var textures = LoadTextures(); var heroTexture = Content.Load <Texture2D>("hero"); var screenTexture = Content.Load <Texture2D>("green-paper2"); var heroPropTextures = LoadHeroTextures(); var font = Content.Load <SpriteFont>("Font"); var menuTexture = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color); Color[] c = new Color[1]; c[0] = Color.White; menuTexture.SetData <Color>(c); _menu = new MonoMenu(font, Color.MintCream, MonoDrawer.SCREEN_WIDTH, MonoDrawer.SCREEN_HEIGHT + MonoDrawer.HEALTH_BAR_HEIGHT); _inventory = new MonoInventory(MonoDrawer.SCREEN_WIDTH, 0, MonoDrawer.INVENTORY_WIDTH, MonoDrawer.SCREEN_HEIGHT + MonoDrawer.HEALTH_BAR_HEIGHT, font, Color.Black, menuTexture); var pauseStrLength = font.MeasureString("Pause"); var switchTexture = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color); Color[] c1 = new Color[1]; c[0] = Color.WhiteSmoke; switchTexture.SetData <Color>(c); var pauseInfo = new MonoItemInfo(switchTexture, null, "Pause", () => _game.SetPaused()); _pauseSwich = new MonoSwich(pauseInfo, false, switchTexture, font, Color.Black, MonoDrawer.SCREEN_WIDTH - (int)pauseStrLength.X - 2, MonoDrawer.SCREEN_HEIGHT); var knowledgesStrLength = font.MeasureString("Knowledges"); var knowledgesInfo = new MonoItemInfo(switchTexture, null, "Knowledges", () => _game.ShowKnowledges()); _knowledgeSwich = new MonoSwich(knowledgesInfo, false, switchTexture, font, Color.Black, MonoDrawer.SCREEN_WIDTH - (int)pauseStrLength.X - (int)knowledgesStrLength.X - 10, MonoDrawer.SCREEN_HEIGHT); _monoKnowledges = new MonoKnowledges(GraphicsDevice, font); _drawer = new MonoDrawer(_spriteBatch, GraphicsDevice, textures, heroTexture, screenTexture, heroPropTextures, font, _menu, _inventory, _pauseSwich, _knowledgeSwich, _monoKnowledges); _game = new Engine.Game(_drawer, (uint)MonoDrawer.SCREEN_WIDTH, (uint)MonoDrawer.SCREEN_HEIGHT); _graphics.PreferredBackBufferWidth = MonoDrawer.SCREEN_WIDTH + MonoDrawer.INVENTORY_WIDTH; // set this value to the desired width of your window _graphics.PreferredBackBufferHeight = MonoDrawer.SCREEN_HEIGHT + MonoDrawer.HEALTH_BAR_HEIGHT; // set this value to the desired height of your window _graphics.ApplyChanges(); _monoControls.Add(_menu); _monoControls.Add(_inventory); _monoControls.Add(_pauseSwich); _monoControls.Add(_knowledgeSwich); }
public override void Draw(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { if (mapPos.Y - 1 > 0 && map[Layer, mapPos.X, mapPos.Y - 1] != this) { map[Layer, mapPos.X, mapPos.Y - 1].Draw(game, mapPos, map, map.GetMetadata(Layer, mapPos.X, mapPos.Y - 1), environment); } base.Draw(game, mapPos, map, metadata, environment, color); }
public override void Draw(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { TileAtlas.Region region = Map.Atlas["tiles/foliage/" + (Events as TallGrassEvents).CurrentTextureFor(game, map, mapPos)]; game.Batch.Texture( new Vector2(mapPos.X * 16, mapPos.Y * 16), region.Texture, color.HasValue ? color.Value : Color.White, Vector2.One, region.Rectangle); }
public void UpdateCurrentFrameWithGame(Engine.Game game, Point mapPos) { if (UseVariation) { _currentSlot = ((int)(game.Time * FPS) + ((mapPos.X + mapPos.Y) % 2)) % TextureCount; } else { _currentSlot = (int)(game.Time * FPS) % TextureCount; } }
public static void Main(string[] args) { int xRes = Console.WindowWidth - 1; int yRes = Console.WindowHeight - 1; Engine.Game g = new Engine.Game(new Vector2(xRes, yRes), ' ', 10); g.StartGame(); Console.SetCursorPosition(xRes, 0); Console.WriteLine("Good Bye!"); }
public override void DrawAfterTransition(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { TileAtlas.Region region = Map.Atlas["tiles/city/road_corner.png"]; Rectangle mapRect = new Rectangle(0, 0, map.Width, map.Height); if (mapRect.Contains(mapPos - new Point(1, 1)) && map[Layer, mapPos.X - 1, mapPos.Y - 1] != this) { game.Batch.Texture( new Vector2(mapPos.X * 16 - 16, mapPos.Y * 16 - 16), region.Texture, color.HasValue ? color.Value : Color.White, Vector2.One, region.Rectangle, 0, null, SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically); } if (mapRect.Contains(mapPos + new Point(-1, 1)) && map[Layer, mapPos.X - 1, mapPos.Y + 1] != this) { game.Batch.Texture( new Vector2(mapPos.X * 16 - 16, mapPos.Y * 16 + 16), region.Texture, color.HasValue ? color.Value : Color.White, Vector2.One, region.Rectangle, 0, null, SpriteEffects.FlipHorizontally); } if (mapRect.Contains(mapPos + new Point(1, -1)) && map[Layer, mapPos.X + 1, mapPos.Y - 1] != this) { game.Batch.Texture( new Vector2(mapPos.X * 16 + 16, mapPos.Y * 16 - 16), region.Texture, color.HasValue ? color.Value : Color.White, Vector2.One, region.Rectangle, 0, null, SpriteEffects.FlipVertically); } if (mapRect.Contains(mapPos + new Point(1, 1)) && map[Layer, mapPos.X + 1, mapPos.Y + 1] != this) { game.Batch.Texture( new Vector2(mapPos.X * 16 + 16, mapPos.Y * 16 + 16), region.Texture, color.HasValue ? color.Value : Color.White, Vector2.One, region.Rectangle); } }
public MainWindow() { InitializeComponent(); /* * CultureInfo newCulture = new CultureInfo("ru-RU"); * Thread.CurrentThread.CurrentCulture = newCulture; * Thread.CurrentThread.CurrentUICulture = newCulture; */ _drawer = new WpfDrawer(canvas1, listBox1, heroListBox, listBoxDateTime); _game = new Engine.Game(_drawer, (uint)canvas1.Width, (uint)canvas1.Height); CompositionTarget.Rendering += DrawSnapshot; }
public override void Draw(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { bool faceLeft = mapPos.X - 1 > 0 && map[Layer, mapPos.X - 1, mapPos.Y].ID.StartsWith("city/roof"); TileAtlas.Region region = Map.Atlas[TextureName(metadata, environment)]; game.Batch.Texture( new Vector2(mapPos.X * 16, mapPos.Y * 16), region.Texture, color.HasValue ? color.Value : Color.White, Vector2.One, region.Rectangle, 0, null, faceLeft ? SpriteEffects.FlipHorizontally : SpriteEffects.None); }
static void Main(string[] args) { Engine.Settings settings = new Engine.Settings(); //settings.height = 450; //settings.width = 800; //settings.titleText = "yay"; Engine.Game game = new Engine.Game(settings); //Image spriteSheet1 = Engine.Assets.ImageAsset("spritesheet.png"); game.DrawSprite("spritesheet.png", 0, 0); game.DrawSprite("spritesheet.png", 50, 50); game.Start(); }
public override void DrawAfterTransition(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { bool faceLeft = mapPos.X - 1 > 0 && map[Layer, mapPos.X - 1, mapPos.Y].ID.StartsWith("city/roof"); if (mapPos.Y + 1 < map.Height && map[Layer, mapPos.X, mapPos.Y + 1] != this) { TileAtlas.Region region = Map.Atlas["tiles/city/beam/top.png"]; game.Batch.Texture( new Vector2(mapPos.X * 16, mapPos.Y * 16 + 16), region.Texture, color.HasValue ? color.Value : Color.White, Vector2.One, region.Rectangle, 0, null, faceLeft ? SpriteEffects.FlipHorizontally : SpriteEffects.None); } }
public BattleShip() { graphics = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = 1600, PreferredBackBufferHeight = 900, //IsFullScreen = true, SupportedOrientations = DisplayOrientation.LandscapeRight }; Window.AllowUserResizing = true; Content.RootDirectory = "Content"; IsMouseVisible = true; game = new Engine.Game(); game.InitializePlayers(new SmartBehavior(), new RandomBehavior()); }
private int Run() { var levensloop = new Engine.Game(); var label = new Label(levensloop.UIContext, "Text", "Arial", 15); levensloop.Registery.Register(new WriteToConsoleSystem()); levensloop.EntityLoader.LoadLevel(File.ReadAllText("Level1.json")); //levensloop.EntityLoader.LoadJson(File.ReadAllText("camera.json")); //levensloop.EntityLoader.LoadJson(File.ReadAllText("square.json")); //levensloop.EntityLoader.LoadJson(File.ReadAllText("triangle.json")); levensloop.Run(); return(0); }
public string CurrentTextureFor(Engine.Game game, Map map, Point mapPos) { if (map == _latestMap && _walkedOn == mapPos) { long ticksSince = game.TotalFixedUpdates - _walkedOnTick; if (ticksSince > 8) { return("enemy_encounter_block_active.png"); } if (ticksSince > 4) { return("enemy_encounter_block_walkthrough2.png"); } return("enemy_encounter_block_walkthrough1.png"); } return("enemy_encounter_block.png"); }
public override void Draw(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { TileAtlas.Region region = Map.Atlas[TextureName(metadata, environment)]; for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { if (ScanArea(new Rectangle(mapPos.X - x, mapPos.Y - y, 2, 2), map)) { region = Map.Atlas["tiles/foliage/bigrock.png"]; region.Rectangle = new Rectangle(region.Rectangle.X + x * 16, region.Rectangle.Y + y * 16, 16, 16); } } } game.Batch.Texture( new Vector2(mapPos.X * 16, mapPos.Y * 16), region.Texture, color.HasValue ? color.Value : Color.White, Vector2.One, region.Rectangle); }
public override void DrawAfterTransition(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { if (!_hasValues) { Random random = new Random(); for (int i = 0; i < _randomValues.Length; i++) { _randomValues[i] = random.Next(); } _hasValues = true; } int slot = _randomValues[((Math.Abs(mapPos.Y) * map.Width) + Math.Abs(mapPos.X)) % _randomValues.Length]; _currentVariation = Variations[slot % Variations.Length]; if (_vFunc != null) { _currentVariation = _vFunc(_currentVariation, map, mapPos, slot); } base.DrawAfterTransition(game, mapPos, map, metadata, environment, color); }
/// <inheritdoc/> protected override Task <bool> Initialize(EditorServiceGame editorGame) { game = editorGame; return(Task.FromResult(true)); }
public void Setup() { AddPlayers = new ThreadSafeList<Player>(); RemovePlayers = new ThreadSafeList<Player>(); Messages = new ThreadSafeList<string>(); Game = new Engine.Game(); if (LoadedMap != null) Game.Map = LoadedMap; else { Game.Map = new Map(); Game.Map.CreateBasicMap(30, 30); } // Setup connections Server = new ServerManananger(); Server.NewUserMethod = AddNewUser; Server.RemoveUserMethod = RemoveUser; Server.UserInputMethod = ReceiveUserInputs; ThreadPool.QueueUserWorkItem(o => Server.Start(HostIP)); InGame = true; }
/// <summary> /// A second draw pass. Called after transitions have been drawn. /// </summary> /// <param name="batch">The batch to draw with.</param> /// <param name="mapPos">The position this tile is on.</param> /// <param name="map">The map the tile is in.</param> /// <param name="metadata">Metadata associated with this position.</param> /// <param name="environment">The environment the map is in.</param> public virtual void DrawAfterTransition(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { }
public override void DrawAfterTransition(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { base.DrawAfterTransition(game, mapPos + Offset, map, metadata, environment, color); }
static void Main() { // Runs the DesktopGL implementation using DirectX Dlls (Sorry!) using (var game = new Engine.Game()) game.Run(); }
public override void DrawAfterTransition(Engine.Game game, Point mapPos, Map map, TileMetadata metadata, Map.Environment environment, Color?color = null) { UpdateCurrentFrameWithGame(game, mapPos); base.DrawAfterTransition(game, mapPos, map, metadata, environment, color); }