예제 #1
0
    public void PlaySelectedLevel()
    {
        //SceneController.Instance.RequestSceneChange(SceneController.GameScenes.Gameplay, .333f);
        //Init();

        // build an encounters' pools list. from these pools we can randomize an order to the encounters.
        List <string> encounters = new List <string>();

        //TODO sometimes this throws a nullref ?
        foreach (var act in selectedLevel.levelData.Acts)
        {
            if (!string.IsNullOrEmpty(act.Value.CreepEncounters.EncounterPool))
            {
                int exists = encounters.IndexOf(act.Value.CreepEncounters.EncounterPool);

                if (exists == -1)
                {
                    encounters.Add(act.Value.CreepEncounters.EncounterPool);
                }
            }

            if (!string.IsNullOrEmpty(act.Value.MegaCreepEncounters.EncounterPool))
            {
                int exists = encounters.IndexOf(act.Value.MegaCreepEncounters.EncounterPool);

                if (exists == -1)
                {
                    encounters.Add(act.Value.MegaCreepEncounters.EncounterPool);
                }
            }

            if (!string.IsNullOrEmpty(act.Value.RareCreepEncounters.EncounterPool))
            {
                int exists = encounters.IndexOf(act.Value.RareCreepEncounters.EncounterPool);

                if (exists == -1)
                {
                    encounters.Add(act.Value.RareCreepEncounters.EncounterPool);
                }
            }

            if (!string.IsNullOrEmpty(act.Value.BossCreepEncounters.EncounterPool))
            {
                int exists = encounters.IndexOf(act.Value.BossCreepEncounters.EncounterPool);

                if (exists == -1)
                {
                    encounters.Add(act.Value.BossCreepEncounters.EncounterPool);
                }
            }

            if (!string.IsNullOrEmpty(act.Value.StoreEncounters.EncounterPool))
            {
                int exists = encounters.IndexOf(act.Value.StoreEncounters.EncounterPool);

                if (exists == -1)
                {
                    encounters.Add(act.Value.StoreEncounters.EncounterPool);
                }
            }

            if (!string.IsNullOrEmpty(act.Value.HeroEncounters.EncounterPool))
            {
                int exists = encounters.IndexOf(act.Value.HeroEncounters.EncounterPool);

                if (exists == -1)
                {
                    encounters.Add(act.Value.HeroEncounters.EncounterPool);
                }
            }
        }

        PF_GameData.GetEncounterLists(encounters);
        //TODO Set difficulty level on the selected level item.
    }