public override void LoadContent(ContentManager contentManager) { _sprite = contentManager.Load <SpriteSheet>("Environment/GreenTent")["14"]; Width = _sprite.Width; Height = _sprite.Height; VisualBounds = new Rectangle((int)Position.X, (int)Position.Y, Width, Height); var height = VisualBounds.Height / 2; CollisionBounds = new Rectangle(VisualBounds.X + 14, VisualBounds.Y + height - 8, VisualBounds.Width - 30, height - 8); _hull = new Hull( new Vector2(10, 59), new Vector2(48, 21), new Vector2(85, 58), new Vector2(85, 115), new Vector2(10, 115) ); _hull.Position = Position; _penumbra.Hulls.Add(_hull); var device = Services.GetService <GraphicsDevice>(); _rectangle1 = new PrimitiveRectangle(device, Color.Yellow, false); _rectangle2 = new PrimitiveRectangle(device, Color.DarkGreen, false); }
public override void LoadContent(ContentManager contentManager) { var sheet = contentManager.Load <SpriteSheet>("Environment/Plants/FoliagePlants"); string[] potentialShrubs = Tile.TileType switch { TileType.LightGrass => new [] { "359", "361", "363" }, TileType.Grass => new[] { "391", "393", "395", "413" }, TileType.DeadGrass => new [] { "365", "327" }, TileType.Sand => new [] { "365", "327" }, TileType.Gravel => new[] { "365", "327" }, _ => null }; var rand = new Random(Guid.NewGuid().GetHashCode()); _sprite = sheet[potentialShrubs[rand.Next(0, potentialShrubs.Length)]]; Width = _sprite.Width; Height = _sprite.Height; VisualBounds = new Rectangle((int)Tile.X * 32, (int)Tile.Y * 32, Width, Height); Origin = new Vector2(_sprite.Width / 2f - 16, _sprite.Height - 32); _rectangle = new PrimitiveRectangle(Services.GetService <GraphicsDevice>(), Color.DarkGreen, false); }
public override void LoadContent(ContentManager contentManager) { base.LoadContent(contentManager); // Move to content json _walkingAnimationSet = new AnimationSetBuilder(contentManager) .WithName("Walk") .WithAsset("Character/Female/BodyFemaleLight") .WithAsset("Character/Hair/HairLongPink") .WithAsset("Character/Torso/FemaleBlackCorset") .WithAsset("Character/Legs/FemaleRedPants") .WithFrameCount(8) .WithIndex(Orientation.Left, 118) .WithIndex(Orientation.Top, 105) .WithIndex(Orientation.Bottom, 131) .WithIndex(Orientation.Right, 144) .Build(); _rectangle = new PrimitiveRectangle(Services.GetService <GraphicsDevice>(), Color.Blue, false); _rectangle2 = new PrimitiveRectangle(Services.GetService <GraphicsDevice>(), Color.Green, false); Origin = new Vector2(32, 64); Width = 32; Height = 64; }
public override void LoadContent(ContentManager contentManager) { _sheet = contentManager.Load <AnimatedSpriteSheet>("Environment/CampFire"); _light = new PointLight() { CastsShadows = true, Scale = new Vector2(800f), ShadowType = ShadowType.Illuminated }; _penumbra.Lights.Add(_light); Height = _sheet.Sprites.FirstOrDefault().Value.Height; Width = _sheet.Sprites.FirstOrDefault().Value.Width; _rectangle = new PrimitiveRectangle(Services.GetService <GraphicsDevice>(), Color.Red, false); }
public override void LoadContent(ContentManager contentManager) { _sheet = contentManager.Load <T>(_assetName); if (_spriteName != null) { _sprite = _sheet[_spriteName]; } _rectangle = new PrimitiveRectangle(Services.GetService <GraphicsDevice>(), Color.Yellow, false); if (_sprite != null) { Width = _sprite.Width; Height = _sprite.Height; } else { Width = _sheet.Width; Height = _sheet.Height; } }
protected override void LoadContent() { _camera2D = new Camera2D(GraphicsDevice.Viewport); Services.AddService(_camera2D); Services.AddService(_penumbra); Services.AddService(_timeService = new TimeService(Services)); Services.AddService(GraphicsDevice); Services.AddService(_aiService = new AIService(Services, Content)); var mapService = new MapService(); Services.AddService(mapService); _gameObjectManager = new GameObjectManager(); Services.AddService(_gameObjectManager); _pathFindingService = new PathFindingService(mapService, _gameObjectManager); _character = new PlayerCharacter(Services); _character.LoadContent(Content); Services.AddService(_character); _spriteBatch = new SpriteBatch(GraphicsDevice); Services.AddService(_uiManager = new UIManager(Services, Content)); //var mapGenerator = new MapGenerator(Services, GraphicsDevice, Guid.NewGuid().GetHashCode(), Content); var mapGenerator = new MapGenerator(Services, GraphicsDevice, -425262119, Content); _map = mapGenerator.Generate(400, 400); //_map = mapGenerator.Generate(100, 100); mapService.Map = _map; _character.Position = _map.StartPosition; _gameObjectManager.LoadAll(Content); _pathFindingService = new PathFindingService(mapService, _gameObjectManager); _pathFindingService.Initialize(); Services.AddService(_pathFindingService); _mapRenderer = new MapRenderer(Services, _map); _mapRenderer.LoadContent(Content); _uiManager.Initialize(); _uiManager.AddVisual(new HotbarPanel()); _uiManager.AddVisual(new TimePanel(Services) { Position = new UVector2(UDim.Relative(0.01f), UDim.Relative(0.5f)) }); _chicken = new Chicken(Services); _chicken.LoadContent(Content); _chicken.Position = _character.Position + new Vector2(4f * 32f, 4f * 32f); _gameObjectManager.AddGameObject(_chicken); _gameObjectManager.AddGameObject(_character); _temp = new PrimitiveRectangle(GraphicsDevice, Color.Black, false); }
public override void LoadContent(ContentManager contentManager) { string name = Tile.TileType switch { TileType.Sand => "Dead", TileType.LightGrass => "Green", TileType.Grass => "Pale", TileType.DeadGrass => "Brown", TileType.Gravel => "Dead", TileType.Mountain => "Dead", _ => null }; var treesSheet = contentManager.Load <SpriteSheet>("Environment/Trees/Trees" + name); var rand = new Random(Guid.NewGuid().GetHashCode()); var exclude = new string[] { "713", "722", "730", "897", "730", "544", "456", "117", "251", "24", "68", "69", "70", "71", "72", "73", "74", "65", "66", "67", "1", "3", "5", "7", "9" }; var potentialTrees = treesSheet.Sprites.Where(x => !exclude.Contains(x.Key)).ToList(); _sprite = potentialTrees[rand.Next(0, potentialTrees.Count)].Value; // Precalculate position and origin _destinationRectangle = new Rectangle((int)Position.X, (int)Position.Y, (int)_sprite.Width, (int)_sprite.Height); Origin = new Vector2(_sprite.Width / 2f - 16, _sprite.Height - 32); _rectangle = new PrimitiveRectangle(Services.GetService <GraphicsDevice>(), Color.Red, false); _rectangle2 = new PrimitiveRectangle(Services.GetService <GraphicsDevice>(), Color.Yellow, false); _rectangle3 = new PrimitiveRectangle(Services.GetService <GraphicsDevice>(), Color.Green, false); _rectangle4 = new PrimitiveRectangle(Services.GetService <GraphicsDevice>(), Color.SkyBlue, false); Width = _sprite.Width; Height = _sprite.Height; VisualBounds = new Rectangle((int)(Position.X - Origin.X), (int)(Position.Y - Origin.Y), Width, Height); var width = (int)(_sprite.Width / 2f); CollisionBounds = new Rectangle(VisualBounds.X + VisualBounds.Width / 2 - width / 2, (int)Position.Y - 4, width, 36); //32 }