public Player(IInputSet input, Map map) { this.input = input; this.map = map; Position = new Vector2(0, 0); Velocity = new Vector2(0, 0); Radius = .1f; InventoryItems = new List <InventoryItem>(); InventoryItems.Add(new InventoryItem() { Name = "Apfel" }); }
public World(IInputSet input) { Map = Map.Load(@"Assets\test10.map"); Chunk = new Chunk(); Player = new Player(input, Map); cellTypes = new Dictionary <CellType, CellTypeDefinition>(); cellTypes.Add(CellType.Grass, new CellTypeDefinition() { CanGoto = true, VelocityFactor = .8f }); cellTypes.Add(CellType.Sand, new CellTypeDefinition() { CanGoto = true, VelocityFactor = 1f }); cellTypes.Add(CellType.Water, new CellTypeDefinition() { CanGoto = false, VelocityFactor = 0f }); // Map cache generieren Map.CellCache = new CellCache[Map.Columns, Map.Rows]; for (int x = 0; x < Map.Columns; x++) { for (int y = 0; y < Map.Rows; y++) { CellType celltype = Map.GetCell(x, y); bool haveItems = Map.Items.Any(i => (int)i.Position.X == x && (int)i.Position.Y == y); Map.CellCache[x, y] = new CellCache() { CellType = celltype, CanGoto = cellTypes[celltype].CanGoto && !haveItems, VelocityFactor = cellTypes[celltype].VelocityFactor }; } } Map.Items.Add(Player); }