Пример #1
0
        /// <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);

            GameModel = new GameModel(Content, _graphics, _spriteBatch);

            var testTexture = Content.Load <Texture2D>("Enemy");

            _units = new List <Unit>();

            var ar = new AbilityRepository();

            ar.Load();

            var ur = new UnitRepository();

            ur.Load(ar);

            var sr = new SquadRepository();

            sr.Load();

            var startPositions = new List <Point>()
            {
                new Point(1, 2),
                new Point(4, 2),
                new Point(0, 5),
                new Point(2, 3),
                new Point(3, 1),
            };

            var squad = sr.Squads.First();

            foreach (var unitId in squad.UnitIds)
            {
                var index = Random.Next(0, startPositions.Count);

                var startPoint = startPositions[index];
                startPositions.RemoveAt(index);

                var unitModel = ur.GetById(unitId);

                _units.Add(new Unit(testTexture)
                {
                    TilePosition = Map.PointToVector2(startPoint.X, startPoint.Y),
                    UnitModel    = unitModel,
                    Layer        = 0.6f,
                });
            }

            //_state = new BattleState(GameModel, _units);
            _state = new HomeState(GameModel);
            _state.LoadContent();
        }