Esempio n. 1
0
    void Awake()
    {
        m_Animator                = GetComponent <Animator>();
        GameManager.GType         = GameType.None;
        GameManager.CurrentUIRoot = GetComponent <Canvas>();
        m_Instance                = this;
        m_Blank.SetActive(false);
        m_RiseMask.gameObject.SetActive(false);
        m_LoadingFlag.SetActive(true);
        //Get chapter level prefab
        m_ChapterLevelPrefab = m_LevelRoot.transform.GetChild(0).GetComponent <ChapterLevel>();
        m_ChapterLevelPrefab.transform.SetParent(transform);
        m_ChapterLevelPrefab.gameObject.SetActive(false);
        if (PlayerPrefs.HasKey(ConstantData.MissionProgressKeyName))
        {
            m_MissionProgress = PlayerPrefs.GetString(ConstantData.MissionProgressKeyName);
        }
        else
        {
            m_MissionProgress = "1-1";
            PlayerPrefs.SetString(ConstantData.MissionProgressKeyName, m_MissionProgress);
        }

        if (string.IsNullOrEmpty(ConstantData.BattleSceneType))
        {
            m_Animator.Play("Loading");
            Invoke("LoadingDone", 1f);
        }
        else
        {
            m_Animator.SetTrigger(ConstantData.BattleSceneType);
            LoadLevelWithChapter(ConstantData.LoadedChapter);
        }
    }
	public DungeonStruct(int id , ChapterLevel level){
		this.level = level;
		this.id = id;
		baseData = new DungeonItem(id);
		this.unLocked = ToUnLockInit();							//may be not good , defalut false may be better
		this.passed = false;
		this.possessStarNum = 0;
	}
	void UpdateChapterDungeonsInfo(List<Chaptered> list , ChapterLevel level){
		ChapterManager chapterManager = MonoInstancePool.getInstance<ChapterManager>();
		foreach(var chapterd in list){
			int chapterId = chapterd.id;
			ChapterStruct chapterStruct = chapterManager.GetChapterById(chapterId);
			chapterStruct.passedDic[(int)level] = chapterd.pass;
			foreach(Dungeon dugeon in chapterd.list){
				chapterStruct.PassDungeon(level ,dugeon.id ,dugeon.star);
			}
		}
	}
Esempio n. 4
0
    public void LoadLevelResults()
    {
        mLevelResults = new Dictionary <ChapterLevel, LevelResult>();

        if (!File.Exists(Application.persistentDataPath + "//.BubbleRockLevelResult"))
        {
            return;
        }

        BinaryReader Reader = new BinaryReader(File.OpenRead(Application.persistentDataPath + "//.BubbleRockLevelResult"));

        string title = Reader.ReadString();

        if (title != "BubbleRockLevelResult")
        {
            Debug.Log("Bad title");
            return;
        }
        int version = Reader.ReadInt32();

        if (version != 2)
        {
            Debug.Log("Bad version");
            return;
        }


        while (true)
        {
            string name = Reader.ReadString();
            if (name == "End")
            {
                break;
            }
            if (name != "LR")
            {
                Debug.Log("Bad data? LevelResult");
                return;
            }
            GAMETYPE gametype = (GAMETYPE)Reader.ReadInt32();
            int      chapter  = Reader.ReadInt32();
            int      level    = Reader.ReadInt32();
            Debug.Log("GAMETYPE: " + gametype + " Chapter: " + chapter + " Level: " + level);

            ChapterLevel mChapterLevel = new ChapterLevel(gametype, chapter, level);

            BinaryFormatter bf           = new BinaryFormatter();
            LevelResult     mLevelResult = (LevelResult)bf.Deserialize(Reader.BaseStream);
            mLevelResults.Add(mChapterLevel, mLevelResult);
        }

        Reader.Close();
    }
Esempio n. 5
0
    public void GoMisstion(ChapterLevel l)
    {
        if (ConstantData.physical < ConstantData.physicalSubstact)
        {
        }

        LevelDataIndex.CurrentLevel  = l.levelData;
        GameManager.GType            = GameType.Mission;
        ConstantData.physical       -= ConstantData.physicalSubstact;
        ConstantData.BattleSceneType = ConstantData.ToLevel;
        LoadScene(1);
    }
    public void GoMisstion(ChapterLevel l)
    {
        if (ConstantData.physical < ConstantData.physicalSubstact)
        {

        }

        LevelDataIndex.CurrentLevel = l.levelData;
        GameManager.GType = GameType.Mission;
        ConstantData.physical -= ConstantData.physicalSubstact;
        ConstantData.BattleSceneType = ConstantData.ToLevel;
        LoadScene(1);
    }
	//当一个副本通关了,检测可以开启的副本
	void UpdateUnLockedInfo (Dictionary<int ,DungeonStruct> dic, ChapterLevel level)
	{
		if (!passedDic [(int)level - 1]) {
				return;
		}
		foreach (KeyValuePair<int ,DungeonStruct> keyValue in dic){
			DungeonStruct dungeon = dic [keyValue.Key];
			//protected code
			if(dungeon.baseData.linkedId != 0 && !dic.ContainsKey(dungeon.baseData.linkedId)){
				Debug.LogError("[UpdateUnLockedInfo] the chapter or dungen table is wrong! Please fix it!");
				continue;
			}

			if (!dungeon.UnLocked) {
					if (dungeon.baseData.linkedId == 0 || dungeon.IsLinkedPassed (dic [dungeon.baseData.linkedId])) {
							dungeon.UnLocked = true;
					}
			}
		}
	}
	//通关了当前难度的为level,id为dungeonId的副本,取得的星数为starNum
	public void PassDungeon (ChapterLevel level, int dungeonId, int starNum)
	{
		possessDungeonDic [(int)level] [dungeonId].PassWithStarNum (starNum);
	}
	//获取当前章节难度为level,id为dungeonId的副本
	public DungeonStruct GetDungeonByLevelAndId (ChapterLevel level, int dungeonId)
	{
		return GetDungeonDicByLevel (level) [dungeonId];
	}
	//获取当前章节 chapterLevel难度的副本字典
	public Dictionary<int , DungeonStruct> GetDungeonDicByLevel (ChapterLevel chapterLevel)
	{
		return possessDungeonDic [(int)chapterLevel];
	}
	public ChapterStruct (int id)
	{
		this.id = id;
		this.currentLevel = ChapterLevel.Normal;
		passedDic = new Dictionary<int, bool> ();
		passedDic [(int)ChapterLevel.Normal - 1] = true;								//默认普通难度章节的上一级副本是应该通关的
		passedDic [(int)ChapterLevel.Normal] = false;
		passedDic [(int)ChapterLevel.NightMare] = false;
		baseData = new ChapterItem (id);
		possessDungeonDic = new Dictionary<int, Dictionary<int, DungeonStruct>> ();
		LoadFromLocalData ();
		award = new Award ();
		award.totalChapterStars = baseData.starCount;
	}
    void Awake()
    {
        m_Animator = GetComponent<Animator>();
        GameManager.GType = GameType.None;
        GameManager.CurrentUIRoot = GetComponent<Canvas>();
        m_Instance = this;
        m_Blank.SetActive(false);
        m_RiseMask.gameObject.SetActive(false);
        m_LoadingFlag.SetActive(true);
        //Get chapter level prefab
        m_ChapterLevelPrefab = m_LevelRoot.transform.GetChild(0).GetComponent<ChapterLevel>();
        m_ChapterLevelPrefab.transform.SetParent(transform);
        m_ChapterLevelPrefab.gameObject.SetActive(false);
        if (PlayerPrefs.HasKey(ConstantData.MissionProgressKeyName))
        {
            m_MissionProgress = PlayerPrefs.GetString(ConstantData.MissionProgressKeyName);
        }
        else
        {
            m_MissionProgress = "1-1";
            PlayerPrefs.SetString(ConstantData.MissionProgressKeyName, m_MissionProgress);
        }

        if(string.IsNullOrEmpty(ConstantData.BattleSceneType))
        {
            m_Animator.Play("Loading");
            Invoke("LoadingDone", 1f);
        }
        else
        {
            m_Animator.SetTrigger(ConstantData.BattleSceneType);
            LoadLevelWithChapter(ConstantData.LoadedChapter);
        }
    }
Esempio n. 13
0
    void Awake()
    {
        // First we check if there are any other instances conflicting
        if (Instance != null && Instance != this)
        {
            // If that is the case, we destroy other instances
            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(this);

        // Here we save our singleton instance
        Instance = this;


        PlayerName = PlayerPrefs.GetString("PlayerName");
        LoadLevelResults();

        mCurrentLevelResult  = new LevelResult();
        mCurrentChapterLevel = new ChapterLevel();

        mCurrentChapterLevel.iChapter = PlayerPrefs.GetInt("LastChapter");
        mCurrentChapterLevel.iLevel   = PlayerPrefs.GetInt("LastLevel");

        bToolTipOff = PlayerPrefs.GetInt("bToolTipOff") > 0;

        //mLevelResults.Add (mCurrentChapterLevel, mCurrentLevelResult);

                #if !UNITY_EDITOR
        AndroidJavaClass  up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = up.GetStatic <AndroidJavaObject> ("currentActivity");
        AndroidJavaObject contentResolver = currentActivity.Call <AndroidJavaObject> ("getContentResolver");
        AndroidJavaClass  secure          = new AndroidJavaClass("android.provider.Settings$Secure");
        android_id = secure.CallStatic <string> ("getString", contentResolver, "android_id");
                #endif

        int iCounterApplicationLaunch;         //Счетчик запуска приложения
        iCounterApplicationLaunch = PlayerPrefs.GetInt("iCounterApplicationLaunch");
        Debug.Log("iCounterApplicationLaunch = " + iCounterApplicationLaunch);
        if (iCounterApplicationLaunch == 0)
        {
            switch (Application.systemLanguage.ToString())
            {
            case "Russian":
                Localization.language = "Русский";
                break;

            case "Ukrainian":
                Localization.language = "Українська";
                break;

            default:
                Localization.language = "English";
                break;
            }
        }
        iCounterApplicationLaunch++;
        GameSetting.Instance.googleAnalytics.LogEvent("Statistics", "StartApplication", "iCounterApplicationLaunch", iCounterApplicationLaunch);
        PlayerPrefs.SetInt("iCounterApplicationLaunch", iCounterApplicationLaunch);

        quitGame = false;
    }
Esempio n. 14
0
    public void ShowLevelSelector()
    {
        gameObject.SetActive(true);

        ChapterButtonDictionary = new Dictionary <GameObject, int> ();
        ChapterList             = new List <ChapterData>();
        ChapterDataDictionary   = new Dictionary <int, ChapterData> ();

        foreach (GameObject ChapterButton in ChapterButtonList)
        {
            ChapterButton.transform.parent = UIGridChapter.transform;
        }

        Object[] bindata = Resources.LoadAll("Levels");
        Debug.Log("Loading map all");
        foreach (TextAsset thisone in bindata)
        {
            Debug.Log("Loading map name" + thisone.name);
            Debug.Log("Loading map text" + thisone.text);
            Stream s = new MemoryStream(thisone.bytes);
            //ChapterData cd = GameSetting.Instance.LoadChapter(s);
            ChapterData cd = new ChapterData();
            cd.LoadDataFromMemory(s);
//			if(cd.GameType == GameSetting.Instance.mCurrentChapterLevel.mGameType){
            ChapterList.Add(cd);
            ChapterDataDictionary.Add(cd.ID, cd);
//			}
        }

        ChapterList = ChapterList.OrderBy(Chapter => Chapter.ID).ToList();

        while (ChapterList.Count > ChapterButtonList.Count)
        {
            GameObject newButton = NGUITools.AddChild(UIGridChapter, ObjectChapter);
            ChapterButtonList.Add(newButton);
            newButton.name = "Chapter" + ChapterButtonList.Count.ToString();

            ChapterCache chaptercache = new ChapterCache();
            chaptercache.Setup(newButton);
            ChapterCacheDictionaty.Add(newButton, chaptercache);

            UIGridChapter.GetComponent <UIGrid>().Reposition();
        }

        int i = 0;

        foreach (ChapterData mChapterData in ChapterList)
        {
            ChapterButtonList[i].SetActive(true);
            ChapterCache chaptercache;
            if (!ChapterCacheDictionaty.TryGetValue(ChapterButtonList[i], out chaptercache))
            {
                Debug.Log("ChapterCacheDictionaty.TryGetValue die");
            }
            chaptercache.NAME.text = mChapterData.Name;

            ChapterLevel mChapterLevel = new ChapterLevel(mChapterData.GameType, mChapterData.ID, 1);
            if (GameSetting.Instance.mLevelResults.ContainsKey(mChapterLevel))
            {
                chaptercache.NEW.SetActive(false);
            }
            else
            {
                chaptercache.NEW.SetActive(true);
            }

            if (mChapterLevel.iChapter == GameSetting.Instance.mCurrentChapterLevel.iChapter)
            {
                Debug.Log("CenterOn please");
                UICenterOnChapter.CenterOn(ChapterButtonList[i].transform);
            }

            ChapterButtonDictionary.Add(ChapterButtonList[i], mChapterData.ID);
            i++;
        }

        while (i < ChapterButtonList.Count)
        {
            ChapterButtonList[i].SetActive(false);
            ChapterButtonList[i].transform.parent = this.transform;
            i++;
        }

        //UIGridChapter.GetComponent<UIGrid>().Reposition();
        //UICenterOnChapter.Recenter ();

        UpdateChapterInCenter();
    }