public Dijkstra(Map source) { _source = source; _pathMap = new float[Map.MAP_WIDTH,Map.MAP_HEIGHT]; _startPos = new List<DijkstraStart>(); Clear(); }
public Monster(char c, TCODColor color, Map map, int health) : base(c, color) { Health = health; map.AddCreature(this); _ai = new MonsterAI(this); _ai.SetMap(map); }
public void FindOpenSpot(out int x, out int y, Map map) { do { x = _rand.getInt(1, Map.MAP_WIDTH - 2); y = _rand.getInt(1, Map.MAP_HEIGHT - 2); } while (map[x, y]); }
public void AddMonster(Map map) { int x, y; do Gen.FindOpenSpot(out x, out y, map); while (Math.Distance_King(x, y, _player.PosX, _player.PosY) < 30); Monster m = new Monster('X', TCODColor.red, map, 50); m.PlaceAt(x, y, map); }
public void PlaceRandomItem(Map map) { int x, y; int n = _rand.getInt(0, ItemsData.TotalWeight); FindOpenSpot(out x, out y, map); Item item = ItemsData.PickWeightedItem(n); n = _rand.getInt(0, 10); item.SwitchLight(n == 0); item.Drop(x, y, map); }
public override bool PlaceAt(int x, int y, Map map) { if (map != CurrentMap) { CurrentMap.Player = null; map.Player = this; } bool ret = base.PlaceAt(x, y, map); if (ret) Light.PlaceAt(PosX, PosY, CurrentMap); return ret; }
public override bool PlaceAt(int x, int y, Map map) { if (CurrentMap != map) { if (CurrentMap != null) CurrentMap.RemoveCreature(this); map.AddCreature(this); _ai.SetMap(map); } bool ret = base.PlaceAt(x, y, map); return ret; }
private void GenRoom(TCODBsp bsp, ref Map map) { if (bsp.isLeaf()) { float propX1 = _rand.getInt(0, 33); float propX2 = _rand.getInt(0, 33); float propY1 = _rand.getInt(0, 33); float propY2 = _rand.getInt(0, 33); int x = bsp.x + (int)(propX1 / 100f * bsp.w); int w = bsp.w - (x - bsp.x) - (int)(propX2 / 100f * bsp.w); int y = bsp.y + (int)(propY1 / 100f * bsp.h); int h = bsp.h - (y - bsp.y) - (int)(propY2 / 100f * bsp.h); for (int i = x; i < x + w; i++) for (int j = y; j < y + h; j++) { map[i, j] = false; } } else { TCODBsp left = bsp.getLeft(); TCODBsp right = bsp.getRight(); GenRoom(left, ref map); GenRoom(right, ref map); if (bsp.horizontal) { int midx = (left.x + left.x + left.w) / 2; int midL = (left.y + left.y + left.h) / 2; int midR = (right.y + right.y + right.h) / 2; for (int y = midL; y < midR; y++) { map[midx, y] = false; } } else { int midy = (left.y + left.y + left.h) / 2; int midL = (left.x + left.x + left.w) / 2; int midR = (right.x + right.x + right.w) / 2; for (int x = midL; x < midR; x++) { map[x, midy] = false; } } } }
public Player(Map map) : base('@', TCODColor.green) { CurrentMap = map; Light = new Light(0, 0, 0); _inventory = new Inventory(this); _inventory.Add(new ItemsData.TorchLight()); Equip(Inventory.GetAtLetter('a')); for (int i = 0; i < 5; i++) { _inventory.Add(new ItemsData.WeakTorch()); } _inventory.Add(new ItemsData.FlashScroll()); _inventory.Add(new ItemsData.FlashScroll()); _inventory.Add(new ItemsData.FlashScroll()); }
public void Generate(int level, out Map map, Game game) { map = new Map(game); TCODBsp root = new TCODBsp(1, 1, Map.MAP_WIDTH - 2, Map.MAP_HEIGHT - 2); root.splitRecursive(_rand, level, 3, 3, 1.5f, 1.5f); //map = new Map(80, 50, new TCODConsole(5, 5)); GenRoom(root, ref map); int x; int y; FindOpenSpot(out x, out y, map); map.SetStartPos(x, y); FindOpenSpot(out x, out y, map); map.Stair = new Stairs(x, y); for (int i = 0; i < 20; i++) { PlaceRandomItem(map); } }
public bool PlaceAt(int x, int y, Map map) { if (x >= 0 && x < Map.MAP_WIDTH && y >= 0 && y < Map.MAP_HEIGHT) { if (!_isOnMap || map != _currentMap) { if (_currentMap != null) _currentMap.RemoveLight(this); _currentMap = map; map.AddLight(this); _tcodmap = new TCODMap(Map.MAP_WIDTH, Map.MAP_HEIGHT); _tcodmap.copy(map.TCODMap); } PosX = x; PosY = y; _tcodmap.computeFov(PosX, PosY, _radius, true); _isOnMap = true; return true; } return false; }
public void SetMap(Map map) { Map = map; }
public virtual bool Drop(int x, int y, Map map) { if (x >= 0 && x < Map.MAP_WIDTH && y >= 0 && y < Map.MAP_HEIGHT) { PosX = x; PosY = y; Map = map; State = ItemState.Dropped; map.AddItem(this); if (IsLight && LightOn) Light.PlaceAt(x, y, map); return true; } return false; }
public override bool Drop(int x, int y, Map map) { IsLight = true; SwitchLight(true); return base.Drop(x, y, map); }