void SpawnEnemies()
    {
        HashSet <Room> visited = new HashSet <Room> ();
        Queue <Room>   rooms   = new Queue <Room> ();

        visited.Add(room);
        foreach (Door d in room.doors.Values)
        {
            if (d != null)
            {
                if (d.r2 != null)
                {
                    rooms.Enqueue(d.r2);
                }
            }
        }

        while (rooms.Count > 0)
        {
            Room r = rooms.Dequeue();
            visited.Add(r);
            enemygen.GenerateEnemies(Random.Range(4, 8), r);
            foreach (Door d in r.doors.Values)
            {
                if (d != null)
                {
                    if (d.r2 != null && !visited.Contains(d.r2))
                    {
                        rooms.Enqueue(d.r2);
                    }
                }
            }
        }
    }
Exemple #2
0
    //public bool IsBlocked(Vector2 vec)
    //{
    //    if (0 < vec.x && vec.x < dungeonWidth && 0 < vec.y && vec.y < dungeonHeight)
    //    {
    //        return dungeonMatrix[(int) vec.x , (int) vec.y ].blocked;
    //    }
    //    return true;
    //}

    public void GenerateEnemies()
    {
        EnemyGenerator enemGen = GameObject.FindGameObjectWithTag("Enemies").GetComponent <EnemyGenerator>();

        enemGen.GenerateEnemies(rooms);
    }