Exemplo n.º 1
0
    // private const int _ROW_ = 15;
    // private const int _COLUMN_ = 15;

    private void Awake()
    {
        state = State.Idle;

        dungeonManager = GameObject.Find("DungeonManager");

        DungeonMapRandomBuilder mapBuilder =
            dungeonManager.GetComponent <DungeonMapRandomBuilder>();

        levelInformation = mapBuilder.LevelInformation;

        enemyTypes = levelInformation.listEnemies.ToArray();
        enemies    =
            new GameObject[Random.Range(_MIN_ENEMY_NUMBER_, _MAX_ENEMY_NUMBER_ + 1)];
        enemyEvents = new Enemy[enemies.Length];

        for (int i = 0, size = enemies.Length; i < size; i++)
        {
            enemies[i] = enemyTypes[Random.Range(0, enemyTypes.Length)];
        }

        boss = levelInformation.boss;

        roomBuilder = room.GetComponent <DungeonRoomBuilder>();
    }
    private const int _ROOM_MINIMAP_WIDTH_ = 1; // == _ROOM_MINIMAP_HEIGHT_
    // private const int _ROOM_MINIMAP_HEIGHT_ = 1;

    // Start is called before the first frame update
    void Start()
    {
        mapBuilder = dungeonManager.GetComponent <DungeonMapRandomBuilder>();

        mapMatrix    = mapBuilder.RandomMap;
        rootPosition = mapBuilder.RootPosition;
        bossPosition = mapBuilder.BossPosition;

        minimapCamera = GameObject.Find("Minimap Camera");

        minimapRealization =
            new GameObject[mapMatrix.GetLength(0), mapMatrix.GetLength(1)];

        instantiateMinimapWithBFS();

        for (int i = 0; i < minimapRealization.GetLength(0); i++)
        {
            for (int j = 0; j < minimapRealization.GetLength(1); j++)
            {
                if (minimapRealization[i, j] == null)
                {
                    continue;
                }

                DungeonMinimapRoomBuilder minimapRoomBuilder =
                    minimapRealization[i, j].GetComponent <DungeonMinimapRoomBuilder>();
                minimapRoomBuilder.UpdateNeighbours();
            }
        }

        for (int i = 0; i < minimapRealization.GetLength(0); i++)
        {
            for (int j = 0; j < minimapRealization.GetLength(1); j++)
            {
                if (minimapRealization[i, j] == null)
                {
                    continue;
                }

                DungeonMinimapRoomBuilder minimapRoomBuilder =
                    minimapRealization[i, j].GetComponent <DungeonMinimapRoomBuilder>();
                minimapRoomBuilder.UpdateMinimapRoomAppearance();
            }
        }
    }