コード例 #1
0
ファイル: NPCTemplate.cs プロジェクト: teamstor/aod
        /// <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())));
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
ファイル: NPCTemplate.cs プロジェクト: teamstor/aod
 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);
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        public Game(int wordLenght)
        {
            MyGame = new Engine.Game(wordLenght);
            InitializeComponent();

            lblHealth.Text = MyGame.Health.ToString();
        }
コード例 #6
0
        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);
        }
コード例 #7
0
ファイル: RoofTipTile.cs プロジェクト: teamstor/aod
        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);
        }
コード例 #8
0
        public Engine.Game Create(IGameSettings gameSettings, ICurrentGameData currentGameData)
        {
            var game = new Engine.Game();

            game.Initialize(gameSettings, currentGameData);

            return(game);
        }
コード例 #9
0
ファイル: Game1.cs プロジェクト: alex-fomin/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);
        }
コード例 #10
0
ファイル: DoormatTile.cs プロジェクト: teamstor/aod
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
 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;
     }
 }
コード例 #13
0
    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!");
    }
コード例 #14
0
ファイル: RoadTile.cs プロジェクト: teamstor/aod
        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);
            }
        }
コード例 #15
0
ファイル: MainWindow.xaml.cs プロジェクト: alex-fomin/Game
        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;
        }
コード例 #16
0
ファイル: RoofBeamTile.cs プロジェクト: teamstor/aod
        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);
        }
コード例 #17
0
    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();
    }
コード例 #18
0
ファイル: RoofBeamTile.cs プロジェクト: teamstor/aod
        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);
            }
        }
コード例 #19
0
ファイル: BattleShip.cs プロジェクト: xaviermonin/BattleShip
        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());
        }
コード例 #20
0
        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);
        }
コード例 #21
0
ファイル: TallGrassEvents.cs プロジェクト: teamstor/aod
        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");
        }
コード例 #22
0
        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);
        }
コード例 #23
0
ファイル: VariationsTile.cs プロジェクト: teamstor/aod
        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);
        }
コード例 #24
0
 /// <inheritdoc/>
 protected override Task <bool> Initialize(EditorServiceGame editorGame)
 {
     game = editorGame;
     return(Task.FromResult(true));
 }
コード例 #25
0
        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;
        }
コード例 #26
0
 /// <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)
 {
 }
コード例 #27
0
 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);
 }
コード例 #28
0
ファイル: Program.cs プロジェクト: Sussumu/Mono-chess
 static void Main()
 {
     // Runs the DesktopGL implementation using DirectX Dlls (Sorry!)
     using (var game = new Engine.Game())
         game.Run();
 }
コード例 #29
0
 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);
 }