コード例 #1
0
    // Load Game Info
    void LoadGameData()
    {
        SaveData data = SaveSystem.LoadFull();

        heroData.heroWrapper.HeroData.HeroInfo = data.HeroInfoData;

        Dictionary <int, DungeonFloorData> dungeonData = data.DungeonFloorList;

        // if new Game
        if (dungeonData.Count == 0)
        {
            // Generate new bungeon floor
            SetBSPMapForFloor(playerStartFloor, new BSP_MapGen(DUNGEON_MAP_WIDTH, DUNGEON_MAP_HEIGHT, baseFloorDifficulty));
            BSP_MapDictionary[playerStartFloor].GenerateBSPDungeon();
            playerDungeonPosition = BSP_MapDictionary[playerStartFloor].GetMapUpStairs;
        }
        else
        {
            playerCurrentFloor      = data.HeroInfoData.CurrentDungeonFloor;
            playerDungeonPosition.x = data.HeroInfoData.CurrentXPosition;
            playerDungeonPosition.y = data.HeroInfoData.CurrentYPosition;

            foreach (var floor in dungeonData)
            {
                int newFloorDifficulty = baseFloorDifficulty + Mathf.Abs(0 - floor.Key);

                BSP_MapGen mapGen = new BSP_MapGen(DUNGEON_MAP_WIDTH, DUNGEON_MAP_HEIGHT, newFloorDifficulty);
                mapGen.LoadBSPDungeon(floor.Value.map, floor.Value.cacheList, floor.Value.upStairsPos, floor.Value.downStairsPos);
                BSP_MapDictionary.Add(floor.Key, mapGen);
            }
        }
    }
コード例 #2
0
 public void SetBSPMapForFloor(int floor, BSP_MapGen BSPmap)
 {
     if (BSP_MapDictionary.ContainsKey(floor))
     {
         // floor already exists,
         // we don't want to replace the floor already produced
         // log an error
         Debug.LogError("Attempt made to replace BSPMap for floor: " + floor + ", No Action taken.");
     }
     else
     {
         BSP_MapDictionary.Add(floor, BSPmap);
     }
 }
コード例 #3
0
    void FloorSetUp(int floorNum)
    {
        currentBSPMap = GameManager.Instance.GetBSPMapForCurrentFloor;
        dungeonWidth  = currentBSPMap.MAP_WIDTH;
        dungeonHeight = currentBSPMap.MAP_HEIGHT;
        dungeonMap    = currentBSPMap.GetMap;
        DrawMap();

        // Add Playable Character
        player      = new GameObject();
        player.name = "PlayerCharacter";
        player.transform.position = new Vector3(GameManager.Instance.GetPlayerDungeonPosition.x, GameManager.Instance.GetPlayerDungeonPosition.y, 0.0f);
        player.AddComponent <SpriteRenderer>().sprite           = PlayerCharacter;
        player.GetComponent <SpriteRenderer>().sortingLayerName = "Characters";
        player.AddComponent <Rigidbody2D>().gravityScale        = 0;
        // fix camera to player
        Camera.main.transform.position = new Vector3(player.transform.position.x, player.transform.position.y, Camera.main.transform.position.z);
    }