Beispiel #1
0
        public Dijkstra()
        {
            Rand = new XSRandom();
            Path = new List <Position>();

            Goals   = new Dictionary <int, int>();
            _fresh  = new Dictionary <int, int>();
            _closed = new Dictionary <int, int>();
            _open   = new Dictionary <int, int>();
        }
Beispiel #2
0
        public Dijkstra(int[,] level)
        {
            Rand        = new XSRandom();
            CombinedMap = level.Replicate();
            PhysicalMap = level.Replicate();
            Path        = new List <Position>();

            Height  = PhysicalMap.GetLength(0);
            Width   = PhysicalMap.GetLength(1);
            Goals   = new Dictionary <int, int>();
            _fresh  = new Dictionary <int, int>();
            _closed = new Dictionary <int, int>();
            _open   = new Dictionary <int, int>();
        }
 public static void Seed(long seed)
 {
     xsr = new XSRandom(seed);
 }
Beispiel #4
0
        public Entry()
        {
            State s = new State();

            s.Entities     = new EntityDictionary();
            s.Initiative   = new Schedule();
            s.TurnsLeft    = 0;
            s.DungeonStart = new Dungeon(TilesetType.DEFAULT_DUNGEON, 40, 40); //ROUND_ROOMS_DIAGONAL_CORRIDORS
            var spawnPoint = s.DungeonStart.LogicWorld.RandomMatch(Dungeon.Floor);


            Seeker       = new Dijkstra(s.DungeonStart.LogicWorld);
            VisualRandom = new XSRandom();
            BeingDamaged = new Dictionary <string, bool>();

//            Player.Seeker.SetGoal(Player.Pos.Y, Player.Pos.X);
//            Player.Seeker.Scan();

            for (int i = 0; i < 6; i++)
            {
                do
                {
                    if (s.Entities.Contains(spawnPoint))
                    {
                        spawnPoint = s.DungeonStart.LogicWorld.RandomMatch(Dungeon.Floor);
                        continue;
                    }
                    Entity player =
                        new Entity("Hero " + ((char)(65 + i)), "@" + WeaponGlyphs[i], _playerColors[i], spawnPoint.Y,
                                   spawnPoint.X, 5, 3 + XSSR.Next(4), 0).UpdateStats(health: new Gauge(10), damage: 3);
                    // \u1202
                    player.Seeker = new Dijkstra(s.DungeonStart.LogicWorld);
                    s.Entities.Add(player);
                    spawnPoint = s.DungeonStart.LogicWorld.RandomMatch(Dungeon.Floor);
                    break;
                } while (true);
            }

            for (int i = 0; i < 25; i++)
            {
                spawnPoint = s.DungeonStart.LogicWorld.RandomMatch(Dungeon.Floor);
                if (spawnPoint.Y >= 0 && !s.Entities.Contains(spawnPoint))
                {
                    Entity baddie = new Entity("Baddie " + (char)(65 + i), "b" + IconGlyphs.RandomElement(), _bloodRed, spawnPoint.Y, spawnPoint.X, 4, XSSR.Next(1, 5), -1);
                    baddie.Seeker = new Dijkstra(s.DungeonStart.LogicWorld);
//                    baddie.Seeker.SetGoal(baddie.Pos.Y, baddie.Pos.X);
//                    baddie.Seeker.Scan();
                    s.Entities.Add(baddie);
                }
            }
            foreach (var k in s.Entities.NameToEntity.Keys)
            {
                IEnumerable <Position> foes =
                    s.Entities.NameToEntity.Where(kv => kv.Value.Faction != s.Entities[k].Faction)
                    .Select(e => e.Value.Pos);
                s.Entities[k] = s.Entities[k].AddEnemies(foes);
                IEnumerable <Position> friends =
                    s.Entities.NameToEntity.Where(kv => kv.Value.Faction == s.Entities[k].Faction)
                    .Select(e => e.Value.Pos);
                s.Entities[k] = s.Entities[k].AddAllies(friends);
            }
            s.StepsTaken = 0;
            s.XSSRState  = XSSR.GetState();
            H.S          = s;

            H.ResetInitiative();
            Entity first = H.S.Entities[H.S.Initiative.PeekTurn().Actor];

            H.S.CurrentActor = first.Name;
            H.S.Cursor       = first.Pos;
            H.S.Camera       = first.Pos;
            if (first.Faction == 0)
            {
                Seeker.SetGoal(first.Pos.Y, first.Pos.X);
                Seeker.Scan(first);

                H.S.CurrentReason = WaitReason.Receiving;
                H.Remember();
            }


            //            Player.Seeker.GetPath(Player.Y, Player.X);
        }
Beispiel #5
0
 public Entry(State state)
 {
     H.S          = state;
     Seeker       = new Dijkstra(H.S.DungeonStart.LogicWorld);
     VisualRandom = new XSRandom();
 }