Exemple #1
0
        public Map(Game game)
        {
            _currentMonsterNum = 0;
            _game = game;

            MaxMonster = 10;
            TCODMap = new TCODMap(MAP_WIDTH, MAP_HEIGHT);
            _known = new bool[MAP_WIDTH, MAP_HEIGHT];
            _lights = new List<Light>();
            _monsters = new List<Monster>();
            _items = new List<Item>();
            _dead = new List<Monster>();
            _deadLights = new List<Light>();
            Dijkstra = new Dijkstra(this);

            for (int i = 0; i < MAP_WIDTH; i++)
                for (int j = 0; j < MAP_HEIGHT; j++)
                {
                    this[i, j] = true;
                }
        }
Exemple #2
0
        public Map(Game game)
        {
            _currentMonsterNum = 0;
            _game = game;

            MaxMonster  = 10;
            TCODMap     = new TCODMap(MAP_WIDTH, MAP_HEIGHT);
            _known      = new bool[MAP_WIDTH, MAP_HEIGHT];
            _lights     = new List <Light>();
            _monsters   = new List <Monster>();
            _items      = new List <Item>();
            _dead       = new List <Monster>();
            _deadLights = new List <Light>();
            Dijkstra    = new Dijkstra(this);

            for (int i = 0; i < MAP_WIDTH; i++)
            {
                for (int j = 0; j < MAP_HEIGHT; j++)
                {
                    this[i, j] = true;
                }
            }
        }
Exemple #3
0
        public void Update()
        {
            _dead.Clear();
            Dijkstra.Clear();
            foreach (Light light in _lights)
            {
                Dijkstra.AddStartPos(light.PosX, light.PosY, 40 - light.IntensityAt(light.PosX, light.PosY) * 2);
            }
            Dijkstra.AddStartPos(Player.Light.PosX, Player.Light.PosY, 20 - Player.Light.IntensityAt(Player.Light.PosX, Player.Light.PosY));

            Dijkstra.ComputeDijkstra();

            foreach (Monster mons in _monsters)
            {
                mons.Act();
                int intens = IntensityAt(mons.PosX, mons.PosY);
                if (intens > 0)
                {
                    mons.TakeDamage(intens);
                }
            }
            foreach (Light light in _lights)
            {
                light.Update();
            }
            Player.Light.Update();
            foreach (Monster mons in _dead)
            {
                _monsters.Remove(mons);
                _game.AddMonster(this);
            }
            foreach (Light light in _deadLights)
            {
                _lights.Remove(light);
            }
        }