예제 #1
0
    public static Level LoadLevelXML(int LevelId)
    {
        Level level;

        level = ScriptableObject.CreateInstance <Level>();
        XMLLevel xmlLevel = new XMLLevel();

        Debug.Log("Reading: " + LevelId);

        if (isLevelsFromNetwork)
        {
            xmlLevel.LoadFromWebResponse(LevelId + 1, NetPath + "/level" + LevelId.ToString() + ".xml", level);
        }
        else
        {
            xmlLevel.LoadFromResources2(LevelId + 1, "Gameplay/Levels/level" + LevelId.ToString(), level);
        }

        if (TutorialSettings.TutorialLetterInWordLevel == 0 && level.monsterInputType == MonsterInputType.LetterInWord)
        {
            TutorialSettings.TutorialLetterInWordLevel = LevelId;
        }

        if (TutorialSettings.TutorialWordLevel == 0 && level.monsterInputType == MonsterInputType.Word)
        {
            TutorialSettings.TutorialWordLevel = LevelId;
        }

        return(level);
    }
    private void SerializeLevelFromXML(int levelId, string levelPath, XmlReader reader, Level level)
    {
        var serializer = new XmlSerializer(typeof(XMLLevel));

        if (level == null)
        {
            level = new Level();
        }

        XMLLevel xmlLevel = serializer.Deserialize(reader) as XMLLevel;

        level.levelId          = levelId;
        level.lettersGroup     = xmlLevel.LettersGroup;
        level.monsterInputType = xmlLevel.monsterInputType;
        level.hideCallout      = xmlLevel.HideCallout;
        level.shuffleSegment   = xmlLevel.ShuffleSegment;
        level.SegmentTime      = (xmlLevel.SegmentTime > 0f) ? xmlLevel.SegmentTime : GameplaySettings.CountdownDefault;
        level.StoneType        = xmlLevel.StoneType;

        if (!string.IsNullOrEmpty(xmlLevel.CollectableMonster))
        {
            if (Enum.IsDefined(typeof(MonsterType), xmlLevel.CollectableMonster))
            {
                MonsterType type = (MonsterType)Enum.Parse(typeof(MonsterType), xmlLevel.CollectableMonster, true);
                level.CollectableMonster = Resources.Load("Gameplay/Monsters/" + type.ToString()) as Monster;
            }
        }
        level.Segments = xmlLevel.Segments;

        int maxPointsInLevel = 0;

        if (level.monsterInputType == MonsterInputType.Letter || level.monsterInputType == MonsterInputType.LetterInWord || level.monsterInputType == MonsterInputType.SoundLetter)
        {
            maxPointsInLevel = calcLetterMaxScore(level);
        }
        else
        {
            maxPointsInLevel = calcWordMaxScore(level);
        }

        LevelMaxScore += "Level: " + levelId + ",  FileName: " + levelPath + ",  Max Points: " + maxPointsInLevel.ToString() + "\n";

/*
 *              if ( xmlLevel.Recognitions != null) {
 *                      GameplayController.Instance.Recognitions = xmlLevel.Recognitions;
 *              }
 */
//		Level templete = Resources.Load ("Gameplay/LevelTempletes/LevelTempleteBlueSky") as Level;
//		if (templete != null) {
        level.LoadTemplete(GameplayController.Instance.DefaultLevelTempletes);
//		}
        Debug.Log("LoadLevel" + levelPath);
    }
예제 #3
0
    public static IEnumerator LoadLevelsXML()
    {
        Level[] levels = GameplayController.Instance.getLevelList();

        float t = Time.time;

        for (int i = 0; i < levels.Length; i++)
        {
            //string url = "http://storage.cet.ac.il/feedthemonster/level" + i + ".xml";
            levels [i] = ScriptableObject.CreateInstance <Level>();
            XMLLevel xmlLevel = new XMLLevel();

            if (isLevelsFromNetwork)
            {
                yield return(xmlLevel.LoadFromWebResponse(i + 1, NetPath + "/level" + i.ToString() + ".xml", levels [i]));
//				yield return xmlLevel.LoadFromWebResponse (i + 1, "http://storage.cet.ac.il/feedthemonster/level" + i.ToString () + ".xml", levels [i]);
            }
            else
            {
                yield return(xmlLevel.LoadFromResources(i + 1, "Gameplay/Levels/level" + i.ToString(), levels [i]));
            }
//			yield return xmlLevel.LoadFromResources (i + 1, path.Replace("${ID}", i.ToString()), levels [i]);
            if (TutorialSettings.TutorialLetterInWordLevel == 0 && levels [i].monsterInputType == MonsterInputType.LetterInWord)
            {
                TutorialSettings.TutorialLetterInWordLevel = i;
            }

            if (TutorialSettings.TutorialWordLevel == 0 && levels [i].monsterInputType == MonsterInputType.Word)
            {
                TutorialSettings.TutorialWordLevel = i;
            }
//			Debug.Log ("level " + i + " loaded");
        }

        Debug.Log(XMLLevel.LevelMaxScore);

        UIController.Instance.SplashScreenStartButton.gameObject.SetActive(true);

        Debug.Log("Loaded Time: " + (Time.time - t).ToString());

        yield return(true);
    }
예제 #4
0
    public static IEnumerator LoadLevelsXML()
    {
        Level[] levels = XMLController.Instance.getLevelList();

        float t = Time.time;

        for (int i = 0; i < levels.Length; i++)
        {
            //string url = "http://storage.cet.ac.il/feedthemonster/level" + i + ".xml";
            levels[i] = ScriptableObject.CreateInstance <Level>();
            XMLLevel xmlLevel = new XMLLevel();

            yield return(xmlLevel.LoadFromResources(i + 1, "Gameplay/Levels/level" + i.ToString(), levels[i]));

            //yield return xmlLevel.LoadFromResources (i + 1, path.Replace("${ID}", i.ToString()), levels [i]);
            if (TutorialSettings.TutorialLetterInWordLevel == 0 && levels[i].monsterInputType == MonsterInputType.LetterInWord)
            {
                TutorialSettings.TutorialLetterInWordLevel = i;
            }

            if (TutorialSettings.TutorialWordLevel == 0 && levels[i].monsterInputType == MonsterInputType.Word)
            {
                TutorialSettings.TutorialWordLevel = i;
            }

            yield return(new WaitForSeconds(0.01f));

            //Debug.Log ("level " + i + " loaded");
        }

        Debug.Log(XMLLevel.LevelMaxScore);

        XMLController.Instance.isLevelLoaded = true;
        //Debug.Log ("Loaded Time: " + (Time.time - t).ToString ());

        yield return(true);
    }