Beispiel #1
0
 /// <summary>
 /// 修改关卡锁定状态
 /// </summary>
 /// <param name="levelID"></param>
 /// <param name="unlock"></param>
 /// <returns></returns>
 public static bool SetLevelsStatus(int levelID, bool unlock)
 {
     try
     {
         LevelList levels = new LevelList();
         levels.Levels = LoadLevels();
         if (unlock)
         {
             levels.Levels[levelID - 1].Unlock = 1;
         }
         else
         {
             levels.Levels[levelID - 1].Unlock = 0;
         }
         string jsonStr = JsonMapper.ToJson(levels);
         string json    = Regex.Unescape(jsonStr);
         using (StreamWriter file = new StreamWriter(Global.levelPath, false))
         {
             file.Write(json);
         }
         return(true);
     }
     catch (Exception ex)
     {
         Debug.Log(ex);
         return(false);
     }
 }
    /// <summary>
    /// Adds a level with id = levelId to list of completed levels and updates game data
    /// </summary>
    /// <param name="levelId">id of the completed level</param>
    /// <param name="xpEarned">amount of xp earned</param>
    /// <param name="goldEarned">gold earned by the player</param>
    /// <param name="gemsEarned">gems earned by the player</param>
    /// <param name="stonesCollected">stones collected during gameplay</param>
    /// <param name="time">time spent playing level</param>
    /// <param name="damageDone">damage done by player</param>
    /// <param name="damageTaken">damage taken by player from enemies</param>
    /// <param name="kills">total number of enemies killed by player</param>
    /// <param name="hits">total hits done during game session</param>
    /// <param name="playerLevel">the level the player is currently at</param>
    public bool CompleteLevel(string levelId, LevelList levelList, int xpEarned, int goldEarned, int gemsEarned,
                              int stonesCollected, float time, float damageDone, float damageTaken,
                              int kills, float hits, int playerLevel, int xpToNext, float shotAccuracy, int score)
    {
        foreach (LevelSaveData level in completedLevels)
        {
            if (level.id == levelId)
            {
                Debug.Log("[Completing level....1]");
                level.time = Mathf.Min(level.time, time);
                return(false);
            }
        }
        Debug.Log("[Completing level.....2]woaaah!!!");
        completedLevels.Add(new LevelSaveData(levelId, xpEarned, goldEarned, gemsEarned,
                                              kills, damageDone, damageTaken, time, stonesCollected, hits, shotAccuracy, score));

        LevelItem completedLevel = levelList[levelId];

        if (completedLevel != null)
        {
            int index = levelList.IndexOf(completedLevel);
            int next  = index + 1;
            if (levelList[next] != null)
            {
                // PROBLEM = the locked state of a level is not saved
                // FIGURE OUT WHY AND FIX IT
                levelList[next].Locked = false;
            }
        }

        return(true);
    }
Beispiel #3
0
 public void returntomainmenu()
 {
     currLevel = LevelList.Level1;
     maxHealth = 5;
     health    = maxHealth;
     SceneManager.LoadScene("Menu");
 }
Beispiel #4
0
    /// <summary>
    /// This function is the Constructor of the class. Reads a Loads the information
    /// of a difficulty from one folder into the levels information variables to use them.
    ///
    /// The information is retrieved differently deppending on the platform the game is playing
    /// because the folder estructure is different.
    /// </summary>
    /// <param name="diff"></param>
    public LevelReader(int diff)
    {
        // Path to find the file and data to read from the file
        string filePath = Application.streamingAssetsPath + "/Levels/Difficulties/" + diff + ".json";
        string data     = null;

#if !UNITY_EDITOR && UNITY_ANDROID
        // Get the .jar file and decompress it to load it in text value
        WWW readLevel = new WWW(filePath);
        while (!readLevel.isDone)
        {
        }

        // Read the information
        data = readLevel.text;
#else
        // Check if the file exists and notify if not
        if (File.Exists(filePath))
        {
            // Load the info
            data = File.ReadAllText(filePath);
        }
        else
        {
            Debug.LogError("Can not find data");
        }
#endif
        // Serialize that information and convert it to JSON type file to load it in the variables
        list = JsonUtility.FromJson <LevelList>(data);
    }
Beispiel #5
0
        /// <summary>
        /// Safely unsubscribes from <see cref="LevelManager" /> events.
        /// Goes to the next scene if valid
        /// </summary>
        public void GoToNextLevel()
        {
            SafelyUnsubscribe();
            if (!GameManager.instanceExists)
            {
                return;
            }
            GameManager gm         = GameManager.instance;
            LevelItem   item       = gm.GetLevelForCurrentScene();
            LevelList   list       = gm.levelList;
            int         levelCount = list.Count;
            int         index      = -1;

            for (int i = 0; i < levelCount; i++)
            {
                if (item == list[i])
                {
                    index = i + 1;
                    break;
                }
            }
            if (index < 0 || index >= levelCount)
            {
                return;
            }
            LevelItem nextLevel = gm.levelList[index];

            SceneManager.LoadScene(nextLevel.sceneName);
        }
        public void GetLevel()
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    LList = new List <LevelList>();

                    var lvl = db.EmployeeLevels.ToList();

                    foreach (var x in lvl)
                    {
                        LevelList l = new LevelList();
                        l.LevelID          = x.EmployeeLevelID;
                        l.LevelDescription = x.EmployeeLevel1;
                        LList.Add(l);
                    }
                    dgLvl.ItemsSource = LList.OrderBy(m => m.LevelDescription);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
    void LoadJsonFile()
    {
        jsonTxt = Resources.Load("Json/levelDataTest") as TextAsset;
        string _info = jsonTxt.text;

        search = JsonReader.Deserialize<LevelList>(_info);
    }
Beispiel #8
0
    public LevelReader(int diff)
    {
        string filePath = Application.streamingAssetsPath + "/Levels/Difficulties/" + diff + ".json";
        string data     = null;

#if !UNITY_EDITOR && UNITY_ANDROID
        WWW readLevel = new WWW(filePath);
        while (!readLevel.isDone)
        {
        }

        data = readLevel.text;
#else
        if (File.Exists(filePath))
        {
            data = File.ReadAllText(filePath);
        }
        else
        {
            Debug.LogError("Can not find data");
        }
#endif

        list = JsonUtility.FromJson <LevelList>(data);
    }
    private void InitCOurseMap()
    {
        bool endFlag = false;
        int  index   = 0;

        levelCfgList = Tool.Instance.getConfig();
        xOffset      = Pos2.position.x - Pos1.position.x;
        yOffset      = Pos3.position.y - Pos1.position.y;
        Vector3 currentStd = Pos1.position;

        for (int i = 0; i < row && !endFlag; i++)
        {
            currentStd = Pos1.position + new Vector3(0, i * yOffset, 0);

            for (int j = 0; j < cow; j++)
            {
                Debug.Log(index);
                if (index > levelCfgList.LevelCfgTable.Count - 1)
                {
                    endFlag = true;
                    break;
                }
                Vector3    position = currentStd + new Vector3(j * xOffset, 0, 0);
                GameObject go       = Instantiate(coursePrefab, position, new Quaternion(0, 0, 0, 0), courseParent.transform); //根据传入的预设物,生成一个新物体
                go.name = levelCfgList.LevelCfgTable[i * cow + j].Id;
                GetButton(go);
                SetCourse(go, levelCfgList.LevelCfgTable[i * cow + j].mapSprite, levelCfgList.LevelCfgTable[i * cow + j].title);
                index++;
            }
        }
    }
Beispiel #10
0
    static void BuildList()
    {
        /*if (LoggingManager.instance.GetABStoredValue () == 0) {
         *              TextAsset json = Resources.Load ("LevelProgressions/ProgA") as TextAsset;
         *              levelList = LevelList.CreateFromJson (json.text).levelList;
         *      } else if (LoggingManager.instance.GetABStoredValue () == 1) {
         *              TextAsset json = Resources.Load ("LevelProgressions/ProgB") as TextAsset;
         *              levelList = LevelList.CreateFromJson (json.text).levelList;
         *      } else if (!LoggingManager.instance.isDebugging) {
         *              throw new Exception ("PlayerPref for AB testing was not initialized correctly.");
         *      } else { // Logging manager is debugging, just default to ProgA
         *              TextAsset json = Resources.Load ("LevelProgressions/ProgA") as TextAsset;
         *              levelList = LevelList.CreateFromJson (json.text).levelList;
         *      }*/
        TextAsset json = Resources.Load("LevelProgressions/ProgFinal") as TextAsset;

        levelList = LevelList.CreateFromJson(json.text).levelList;

        challengeUnlocks = new Dictionary <int, int>();
        challengeUnlocks.Add(11, 25);
        challengeUnlocks.Add(15, 26);
        challengeUnlocks.Add(19, 27);
        challengeUnlocks.Add(22, 28);
        challengeUnlocks.Add(24, 29);
    }
Beispiel #11
0
 public void onEnter()
 {
     if (currentLevel != null)
     {
         currentLevel.Highlight(false);
         currentLevel = null;
     }
 }
Beispiel #12
0
 /// <summary>
 /// Ensure the button is not null
 /// </summary>
 protected void LazyLoad()
 {
     if (m_Button == null)
     {
         m_Button = GetComponent <Button>();
     }
     levelList = GameManager.instance.LevelList;
 }
Beispiel #13
0
 //获取LevelList
 public LevelList GetLevelDataList()
 {
     if (levelDataList == null)
     {
         levelDataList = Resources.Load <LevelList>("LevelData/LevelAsset");
     }
     return(levelDataList);
 }
Beispiel #14
0
    // Use this for initialization
    void Start()
    {
        TextAsset t = Resources.Load("Level") as TextAsset;

        levelList = JsonUtility.FromJson <LevelList>(t.text);
        GameObject.Find("Communicator").GetComponent <Communicator>().levelList = levelList;
        InstantiateButtons();
    }
Beispiel #15
0
    void RandomReset()
    {
        int maxReset = /*(gameMode == GAME_MODE_CLASSIC) ? ((difficultyLevel == DIFFICULTY_LEVEL_HARD) ? Random.Range(-maxPipeReset, maxPipeReset) : Random.Range(0, maxPipeReset)) :*/ Random.Range(1, maxPipeReset + 1);

        int[] usedIndexes = new int[maxReset];

        for (int cntr = 0; cntr < usedIndexes.Length; cntr++)
        {
            usedIndexes[cntr] = -1;
        }

        // Add AI to random reset functionality.
        if (maxReset > 0)
        {
            for (int cntr = 1; cntr <= maxReset; cntr++)
            {
                repeat_iteration :;
                int curIndex = 0;

                while (true)
                {
                    bool isSuccess = true;

                    curIndex = Random.Range(0, TotalPipes);

                    foreach (int index in usedIndexes)
                    {
                        if (index == curIndex)
                        {
                            isSuccess = false; break;
                        }
                    }

                    if (isSuccess)
                    {
                        break;
                    }
                }

                GameObject selectedObject = findGameObjectWithId(curIndex);

                if (selectedObject != null && selectedObject.GetComponent <PipeController>() != null && selectedObject.GetComponent <PipeController>().isInFieldOfView)
                {
                    //selectedObject.GetComponent<PipeController>().isMatched = false;
                    selectedObject.SendMessage("RandomReset");
                    selectedObject.SendMessage("EmphasizePipe");
                    usedIndexes[cntr - 1] = curIndex;
                }
                else /*if (difficultyLevel == DIFFICULTY_LEVEL_HARD || gameMode == GAME_MODE_SURPRISE)*/ goto {
                    repeat_iteration;
                }
            }
        }

        /*if (gameMode == GAME_MODE_SURPRISE)*/ max_pipes = maxReset;
        timeCounter = (max_pipes * LevelList.FindLevelWithId(gameMode, levelNumber).levelTime / ((TypeDefinations.LevelSurpriseModeData)LevelList.FindLevelWithId(gameMode, levelNumber)).maxPipesOnEntry) + ((difficultyLevel == DIFFICULTY_LEVEL_NORMAL) ? ((max_pipes * 6 / ((TypeDefinations.LevelSurpriseModeData)LevelList.FindLevelWithId(gameMode, levelNumber)).maxPipesOnEntry) + 1) : 0); // Relative time calculation.
    }
Beispiel #16
0
    private void OnEnable()
    {
        levelNumber = 0;
        TextAsset levelData       = (TextAsset)Resources.Load("Levels");
        string    jsonLevelString = levelData.text;

        levelList = JsonUtility.FromJson <LevelList>(jsonLevelString);
        Debug.Log(levelList.levels[levelNumber + 1].ToString());
    }
Beispiel #17
0
    private void Awake()
    {
        LevelList list = new LevelList();

        levelList = list.GetLevelList();

        levelNumber = 1;

        BuildLevel();
    }
 public void SaveLevels(LevelList list)
 {
     if (list != null)
     {
         loader.SaveLevels(list, delegate
         {
             FindObjectOfType <ButtonIconChanger>().TemporaryChange();
         });
     }
 }
Beispiel #19
0
 public void StartTwo(string newKey)
 {
     if (!string.IsNullOrEmpty(newKey))
     {
         key        = newKey;
         playerType = PlayerType.Player2;
         currLevel  = LevelList.Level1;
         SceneManager.LoadScene("Player2Level1");
     }
 }
Beispiel #20
0
        // GET: Class/Create
        public ActionResult Create()
        {
            BatchList    Batchlist = new BatchList();     //Khởi tạo biếm có giá trị là class được khai báo trong models/batch
            LevelList    Levellist = new LevelList();
            List <batch> obj       = Batchlist.ListAll(); //Gọi hàm listall khai báo trong class trong models lấy ra danh sách batch
            List <level> obj1      = Levellist.ListAll();

            ViewBag.batchCode = new SelectList(obj, "code", "name"); //Đưa viewBag vào view
            ViewBag.levelCode = new SelectList(obj1, "code", "name");
            return(View());
        }
Beispiel #21
0
        public void LoadLevelDictionary(ContentManager content)
        {
            this.content = content;
            levels       = new List <string>();
            LevelList levelList = content.Load <XMLData.LevelList>("Levels");

            foreach (string levelName in levelList.Levels)
            {
                levels.Add(levelName);
            }
        }
Beispiel #22
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
Beispiel #23
0
    public void SaveLevels(LevelList list, Action callback)
    {
        if (list != null)
        {
            string dataAsJson = JsonUtility.ToJson(list);

            File.WriteAllText(GetSaveFileForSlot(currentSlot), dataAsJson);

            callback();
        }
    }
Beispiel #24
0
 public static void SetLevelList(LevelList list)
 {
     if (currentList != list)
     {
         if (LevelListChanged != null)
         {
             LevelListChanged(list);
         }
         currentList = list;
     }
 }
Beispiel #25
0
 public void LoadNewLevel(int i)
 {
     currLevel = (LevelList)(i - 1);
     if ((int)currLevel < levelLength)
     {
         if (health < maxHealth)
         {
             UpdateHealth(maxHealth - health);
         }
         SceneManager.LoadScene(playerType.ToString() + currLevel.ToString());
     }
 }
Beispiel #26
0
 public void init()
 {
     if (levelList.Count != PlayerPrefsLevel.maxLevel)
     {
         Debug.LogWarning("levelList.Count != MAX_LEVEL");
     }
     for (int i = 0; i < levelList.Count; i++)
     {
         levelList[i].SetInfo(PlayerPrefsLevel.levelData.GetLevelInfo(i));
     }
     currentLevel = null;
 }
Beispiel #27
0
    void OpenNextLevel()
    {
        Communicator communicator = GameObject.Find("Communicator").GetComponent <Communicator>();
        LevelList    levelList    = communicator.levelList;
        Level        currentLevel = communicator.GetLevel();
        int          currentIndex = levelList.Level.IndexOf(currentLevel);

        if (levelList.Level[currentIndex + 1] != null)
        {
            communicator.SetLevel(levelList.Level[currentIndex + 1]);
            SceneManager.LoadScene("GameScene", LoadSceneMode.Single);
        }
    }
Beispiel #28
0
    /// <summary>
    /// 得到配置文件
    /// </summary>
    /// <returns></returns>
    public LevelList getConfig()
    {
        TextAsset jsonText     = Resources.Load <TextAsset>("LevelConfigTable");
        LevelList levelCfgList = JsonUtility.FromJson <LevelList>(jsonText.text);

        if (levelCfgList == null)
        {
            Debug.Log("没有配置存储不存在");
            return(null);
        }

        return(levelCfgList);
    }
Beispiel #29
0
    public LevelReader(string filePath, string diff)
    {
        if (File.Exists(filePath))
        {
            string data = File.ReadAllText(filePath);

            list       = JsonUtility.FromJson <LevelList>(data);
            difficulty = diff;
        }
        else
        {
            Debug.LogError("Cannot find data");
        }
    }
Beispiel #30
0
    // Use this for initialization
    //   void Start () {
    //	//动态生成level按钮


    //}

    //// Update is called once per frame
    //void Update () {

    //}

    //根据数据 生成关卡的按钮
    public void GenerateLevelButton()
    {
        //读取保存的玩家数据
        PlayerData playerData = ResManager.instance.GetPlayerData();

        //读取关卡数据
        LevelList levelData = ResManager.instance.GetLevelDataList();

        //根据数据生成LevelButton
        list_levelButton.Clear();
        for (int i = 0; i < levelData.levelList.Count; i++)
        {
            LevelButton button = GameObject.Instantiate <GameObject>(levelButtonPrefab).GetComponent <LevelButton>();
            list_levelButton.Add(button);

            //为LevelData中的levelButtonParent赋值
            levelData.levelList[i].levelButtonParent = levelPosRoot.Find("LevelPos (" + (i + 1) + ")");
            //设置位置
            button.transform.SetParent(levelData.levelList[i].levelButtonParent);
            button.parentPos = levelData.levelList[i].levelButtonParent;
            button.transform.localPosition = Vector3.zero;
            button.transform.localScale    = Vector3.one;

            //设置关卡数和关卡文字
            button.SetLevelNum(levelData.levelList[i].levelNum);

            //设置target图标
            button.SetTargetImage(levelData.levelList[i]);

            //是否打开
            if (i < playerData.reachedLevel)
            {
                //已经开启
                //显示获得的星星
                button.SetActiveStar(playerData.list_levelScore[i].starCount);
                //变为可交互
                button.SetButtonState(true);
            }
            else
            {
                //未开启
                //隐藏所有的星星
                button.SetActiveStar(0);
                //变为不可交互
                button.SetButtonState(false);
            }
        }
    }
Beispiel #31
0
 public bool IsZombieMap(string name)
 {
     if (!Running)
     {
         return(false);
     }
     if (IgnorePersonalWorlds && name.IndexOf('+') >= 0)
     {
         return(false);
     }
     if (IgnoredLevelList.CaselessContains(name))
     {
         return(false);
     }
     return(LevelList.Count == 0 ? true : LevelList.CaselessContains(name));
 }
Beispiel #32
0
	void Awake()
	{
		Instance = this;
		LevelList = new LevelList();
		InitLevel();

		board.Initialize(8, 8);
		if (CurrentLevel != null && Debug.isDebugBuild)
		{
			m_style = new GUIStyle();

			m_style.fontSize = 16;
		}

		GameManager.Pause = false;
	}
Beispiel #33
0
    void OnGUI()
    {
        if(menuNumber == 1){
            LevelList ll = new LevelList();
            ll.tempFill();
            ll.listToButtons();
        } else {
            // Make a background box
            GUI.Box(new Rect(10,10,120,90), "Continue Menu");

            // Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
            if(GUI.Button(new Rect(20,40,100,20), "Continue"))
            {
                //leveltag will be set equal to that actual level tag as a string
                Application.LoadLevel(Application.loadedLevel);
            }

            // Make the second button.
            if(GUI.Button(new Rect(20,70,100,20), "Level Select"))
            {
                menuNumber = 1;
            }
        }
    }