예제 #1
0
    public void DoneLoadingMap()
    {
        LevelFinishedLoadingEventArgs args = new LevelFinishedLoadingEventArgs();
        args.startPos = playerSpawnPosition;
        args.region = this;

        GameEventSystem.PublishEvent(typeof(LevelLoadedSubscriber), args);
    }
예제 #2
0
    IEnumerator CreateBoxLevel(LevelGenInfo info)
    {
        //LoadBossArena(info);

        LevelFinishedLoadingEventArgs args = new LevelFinishedLoadingEventArgs();
        args.startPos = Tile.MapToWorldPosition(startPoint);
        args.endPos = Tile.MapToWorldPosition(endPoint);
        //createBorder(info);
        GameEventSystem.PublishEvent(typeof(LevelLoadedSubscriber), args);

        yield return new WaitForSeconds(0);
    }
예제 #3
0
    public IEnumerator GenerateRandomLevel(LevelGenInfo info)
    {
        //Tile.NewLevel(new Int2(width, height), 0, 4, 0, LayerLock.None);

        Debug.Log("Genarating a random Room");
        int rooms = 0;
        int fails = 0;
        while(fails < info.numFails && rooms < info.maxRooms)
        {

            float failPercent =  1 - ((float) fails / (float) info.numFails );
           // Debug.Log(failPercent);
            float maxW = info.minRoomWidth + info.maxRoomWidth * failPercent;
            float maxH = info.minRoomHeight+ info.maxRoomHeight * failPercent;

            int maxWidthInt = Mathf.CeilToInt(maxW);
            int maxHeightInt = Mathf.CeilToInt(maxH);

            if (CreateRoom(Random.Range(info.minRoomWidth, maxWidthInt), Random.Range(info.minRoomHeight, maxHeightInt),info))
            {
                rooms++;

                yield return new WaitForSeconds(.0f);
            }
            else
            {
                fails++;
                yield return new WaitForSeconds(.0f) ;
            }
        }
        Debug.Log("rooms Created" + rooms);
        Debug.Log("times Failed" + fails);

        yield return new WaitForSeconds(.1f);
        createBorder(info);
        yield return new WaitForSeconds(.01f);
        //fillEmpty();

        LevelFinishedLoadingEventArgs args = new LevelFinishedLoadingEventArgs();
        args.startPos = Tile.MapToWorldPosition(startPoint);
        args.endPos = Tile.MapToWorldPosition(endPoint);
        Debug.Log("startpos"+args.startPos);
        Debug.Log("end pos"+args.endPos);

        GameEventSystem.PublishEvent(typeof(LevelLoadedSubscriber), args);
    }
예제 #4
0
    IEnumerator CreateBossArena(LevelGenInfo info)
    {
        MapData mapBlock = Tile.LoadMapBlock(bossArena.bytes);
        Tile.SetMapBlock(new Int2(info.startX, 0), mapBlock);
        startPoint = new Int2(mapBlock.mapSize.x / 2 + info.startX,  info.startY + 5);
        //endPoint= new Int2(info.levelWidth + info.startX -5 , info.levelHeight  + info.startY -5);
        SpawnBoss(info ,mapBlock);

        LevelFinishedLoadingEventArgs args = new LevelFinishedLoadingEventArgs();
        args.startPos = Tile.MapToWorldPosition(startPoint);
        //args.endPos = Tile.MapToWorldPosition(endPoint);
        //createBorder(info);
        GameEventSystem.PublishEvent(typeof(LevelLoadedSubscriber), args);

        yield return new WaitForSeconds(0);
    }