Пример #1
0
 // Use this for initialization
 void Start()
 {
     mp     = GetComponent <Slider> ();
     skill1 = GameObject.FindGameObjectWithTag("Skill1").GetComponent <Skill1> ();
     skill2 = GameObject.FindGameObjectWithTag("Skill2").GetComponent <Skill2> ();
     level  = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerLevelData> ();
 }
    public static void Read()
    {
        bool newFile = false;

        PlayerLevelDataList newList = null;

        UnityEngine.Object oldFile = AssetDatabase.LoadAssetAtPath(outputFileName, typeof(PlayerLevelDataList));
        if (oldFile == null)
        {
            newFile = true;
            newList = ScriptableObject.CreateInstance(typeof(PlayerLevelDataList)) as PlayerLevelDataList;
        }
        else
        {
            newList = oldFile as PlayerLevelDataList;
        }

        newList._dataList.Clear();
        string jsonStr = File.ReadAllText(fileName);

        JsonHashtable ht = FCJson.jsonDecode(jsonStr) as JsonHashtable;

        foreach (System.Object obj in ht.ValueList)
        {
            Hashtable data = obj as Hashtable;

            PlayerLevelData newData = new PlayerLevelData();

            newData._level    = (int)data["level"];
            newData._exp      = (int)data["exp"];
            newData.bearPoint = (int)data["totem_Point"];
            //newData._reviveHc = (int)data["revive_hc"];

            newData._mage_attack      = (int)data["mage_Attack"];
            newData._mage_defense     = (int)data["mage_Defense"];
            newData._mage_hp          = (int)data["mage_Hp"];
            newData._mage_crit        = (float)data["mage_Crit"];
            newData._mage_crit_damage = (float)data["mage_CritDamage"];

            newData._warrior_attack      = (int)data["warrior_Attack"];
            newData._warrior_defense     = (int)data["warrior_Defense"];
            newData._warrior_hp          = (int)data["warrior_Hp"];
            newData._warrior_crit        = (float)data["warrior_Crit"];
            newData._warrior_crit_damage = (float)data["warrior_CritDamage"];

            newList._dataList.Add(newData);
        }

        newList._dataList.Sort(OnCompare);

        if (newFile)
        {
            AssetDatabase.CreateAsset(newList, outputFileName);
        }
        else
        {
            EditorUtility.SetDirty(newList);
        }
        Debug.Log(string.Format("Player level config data successfully imported. {0} records.", newList._dataList.Count));
    }
Пример #3
0
    public void AddTileCount(int level, TilePiece._TileType tileType, int value)
    {
        if (playerData.playerLevelData == null || playerData.playerLevelData.Count == 0 || playerData.playerLevelData[level] == null)
        {
            PlayerLevelData pld = new PlayerLevelData
            {
                score      = 0,
                stars      = 0,
                timestamp  = GetSecondsSinceEpoch(),
                regular    = new int[6],
                horizontal = new int[6],
                vertical   = new int[6],
                cross      = new int[6]
            };
            playerData.playerLevelData.Add(pld);
        }
        if (playerData.playerLevelData[level].regular.Length == 0)
        {
            playerData.playerLevelData[level].regular = new int[6];
        }
        if (playerData.playerLevelData[level].horizontal.Length == 0)
        {
            playerData.playerLevelData[level].horizontal = new int[6];
        }
        if (playerData.playerLevelData[level].vertical.Length == 0)
        {
            playerData.playerLevelData[level].vertical = new int[6];
        }
        if (playerData.playerLevelData[level].cross.Length == 0)
        {
            playerData.playerLevelData[level].cross = new int[6];
        }
        switch (tileType)
        {
        case TilePiece._TileType.Regular:
            playerData.playerLevelData[level].regular[value]++;
            break;

        case TilePiece._TileType.HorizontalBlast:
            playerData.playerLevelData[level].horizontal[value]++;
            break;

        case TilePiece._TileType.VerticalBlast:
            playerData.playerLevelData[level].vertical[value]++;
            break;

        case TilePiece._TileType.CrossBlast:
            playerData.playerLevelData[level].cross[value]++;
            break;

        case TilePiece._TileType.Rainbow:
            playerData.playerLevelData[level].rainbow++;
            break;

        default: break;
        }
    }
Пример #4
0
    public void AddExperience(int xp)
    {
        bool isLevelUp = PlayerLevelData.AddExperience(xp);

        if (isLevelUp)
        {
            // TODO do level up stuff
        }
        FetchAllLevelData();
        UpdateUI();
    }
Пример #5
0
    public PlayerLevelData GetPlayerLevelData(int levelNumber)
    {
        PlayerLevelDataScriptable playerLevelDataScriptable = GetPlayerLevelScriptable(levelNumber);
        PlayerLevelData           data = new PlayerLevelData();

        if (playerLevelDataScriptable != null)
        {
            data.levelNumber     = playerLevelDataScriptable.levelNumber;
            data.playerGunPrefab = playerLevelDataScriptable.playerGunPrefab;
            data.playerPrefab    = playerLevelDataScriptable.playerPrefab;
            return(data);
        }
        return(null);
    }
Пример #6
0
 // Use this for initialization
 void Start()
 {
     slider = GetComponent <Slider>();
     hurt   = GetComponent <AudioSource>();
     anim   = GameObject.FindGameObjectWithTag("Player").GetComponent <Animator>();
     player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();
     level  = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerLevelData> ();
     HP     = GameObject.FindGameObjectWithTag("HP").GetComponent <Slider>();
     exp    = GameObject.FindGameObjectWithTag("EXP").GetComponent <PlayerExperience> ();
     skill1 = GameObject.FindGameObjectWithTag("Skill1").GetComponent <Skill1> ();
     skill2 = GameObject.FindGameObjectWithTag("Skill2").GetComponent <Skill2> ();
     over   = GameObject.FindGameObjectWithTag("GameOver").GetComponent <GameOver> ();
     mis    = GameObject.FindGameObjectWithTag("Mission").GetComponent <MissionProgress> ();
 }
Пример #7
0
    private void UpdateUI()
    {
        // update level display
        uiLevelDisplay.text = "Level  " + playerLevel.ToString();

        int thisLevelXp = PlayerLevelData.GetLevelXpThreshold(playerLevel);
        int nextLevelXp = PlayerLevelData.GetNextLevelThreshold();

        uiXpRemainingDisplay.text = (currentXp - thisLevelXp).ToString() + "/" + (nextLevelXp - thisLevelXp).ToString();

        float   percentToNextLevel = (float)(currentXp - thisLevelXp) / (float)(nextLevelXp - thisLevelXp);
        Vector2 xpBarDimensions    = uiXpBar.GetComponent <RectTransform> ().rect.size;

        uiXpBar.transform.GetChild(0).GetComponent <RectTransform> ().sizeDelta = new Vector2(xpBarDimensions.x * percentToNextLevel, xpBarDimensions.y);
    }
    public void LoadLevelPlayerData(int levelNumber)
    {
        data = LevelDataHandler.instance.GetPlayerLevelData(levelNumber);
        if (data != null)
        {
            GameObject       playerObj        = InstantiatorHelper.instance.InstantiateObject(data.playerPrefab, this.transform.gameObject);
            PlayerController playerController = playerObj.GetComponent <PlayerController>();

            if (playerController != null)
            {
                playerController.SetPlayerLevelData(data);
                playerController.InstantiateGun(data.playerGunPrefab);
            }
        }
    }
 private static int OnCompare(PlayerLevelData data1, PlayerLevelData data2)
 {
     if (data1._level > data2._level)
     {
         return(1);
     }
     else if (data1._level == data2._level)
     {
         return(0);
     }
     else
     {
         return(-1);
     }
 }
Пример #10
0
    public void OnEnable()
    {
        attribute0.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.Level, PlayerInfo.Instance.CurrentLevel);
        attribute1.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.HP, PlayerInfo.Instance.HP);
        attribute2.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.Critical, PlayerInfo.Instance.Critical);
        attribute3.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.Attack, PlayerInfo.Instance.Attack);
        attribute4.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.CritDamage, PlayerInfo.Instance.CritDamage);
        attribute5.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.Defense, PlayerInfo.Instance.Defense);
        attribute6.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.ReduceEnergy, PlayerInfo.Instance.ReduseEnergy);
        attribute7.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.ItemFind, PlayerInfo.Instance.itemFindPossibility);

        lightningDmg.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.LightningDmg, PlayerInfo.Instance.LightningDmg);
        lightningRes.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.LightningRes, PlayerInfo.Instance.LightningRes);
        fireDmg.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.FireDmg, PlayerInfo.Instance.FireDmg);
        fireRes.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.FireRes, PlayerInfo.Instance.FireRes);
        iceDmg.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.IceDmg, PlayerInfo.Instance.IceDmg);
        iceRes.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.IceRes, PlayerInfo.Instance.IceRes);
        poisonDmg.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.PosisonDmg, PlayerInfo.Instance.PosisonDmg);
        poisonRes.GetComponent <FCPlayerProperty>().RefreshKeyAndValue(PlayerPropKey.PosisonRes, PlayerInfo.Instance.PosisonRes);

        PlayerInfo playerInfo = PlayerInfo.Instance;

        attributeRoleName.text = Localization.Localize("IDS_MESSAGE_GLOBAL_CLASS") + " : "
                                 + "[BEAA82]" + Localization.Localize(FCConst.ROLE_NAME_KEYS[playerInfo.Role]) + "[-]";
        attributePlayerName.text  = playerInfo.Nickname;
        attributePlayerTitle.text = "";

        heroFSValue.FS   = playerInfo.FightScore;
        vipLogo.VipLevel = playerInfo.vipLevel;

        PlayerLevelData pld = DataManager.Instance.CurPlayerLevelDataList.GetPlayerLevelDataByLevel(playerInfo.CurrentLevel);

        if (null != pld)
        {
            EXPLabel.text = playerInfo.CurrentXp + "/" + pld._exp;
            decimal percent = (decimal)playerInfo.CurrentXp / pld._exp;
            EXPProgressBar.fillAmount = (float)percent;
        }
        else
        {
            EXPLabel.text             = "max";
            EXPProgressBar.fillAmount = 1.0f;
        }
    }
Пример #11
0
    static void MakePlayerData()
    {
        PlayerLevelData data = ScriptableObject.CreateInstance <PlayerLevelData>();

        AssetDatabase.CreateAsset((ScriptableObject)data, playerExportPath);

        //data.hideFlags = HideFlags.NotEditable;

        data.list.Clear();

        using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read))
        {
            IWorkbook book  = new XSSFWorkbook(stream);
            ISheet    sheet = book.GetSheetAt(0);

            for (int i = 2; i <= sheet.LastRowNum; i++)
            {
                IRow row = sheet.GetRow(i);

                PlayerLevelData.Attribute a = new PlayerLevelData.Attribute()
                {
                    level               = (int)row.GetCell(0).NumericCellValue,
                    maxHP               = (int)row.GetCell(1).NumericCellValue,
                    baseAttack          = (int)row.GetCell(2).NumericCellValue,
                    baseDef             = (int)row.GetCell(3).NumericCellValue,
                    requireNextLevelExp = (int)row.GetCell(4).NumericCellValue,
                    moveSpeed           = (int)row.GetCell(5).NumericCellValue,
                    turnSpeed           = (int)row.GetCell(6).NumericCellValue,
                    attackRange         = (float)row.GetCell(7).NumericCellValue
                };

                data.list.Add(a);
            }

            stream.Close();
        }

        ScriptableObject obj = AssetDatabase.LoadAssetAtPath(playerExportPath, typeof(ScriptableObject)) as ScriptableObject;

        EditorUtility.SetDirty(obj);
    }
Пример #12
0
    public void LoadPlayerData()
    {
        string filePath = Path.Combine(Application.persistentDataPath, playerDataFile);

        if (File.Exists(filePath))
        {
            string dataAsJson = File.ReadAllText(filePath);
            playerData = JsonUtility.FromJson <PlayerData>(dataAsJson);
        }
        else
        {
            System.TimeSpan t = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1);
            int             secondsSinceEpoch = (int)t.TotalSeconds;
            playerData = new PlayerData
            {
                overallScore     = 0,
                lastLevel        = -1,
                timeStamp        = secondsSinceEpoch,
                playerLevelData  = new List <PlayerLevelData>(),
                sfxOnOff         = 1,
                musicOnOff       = 1,
                musicVolume      = 1f,
                sfxVolume        = 1f,
                rainbowHelper    = 2,
                bombHelper       = 2,
                horizontalHelper = 2,
                verticalHelper   = 2,
                hammerHelper     = 2
            };
            PlayerLevelData pld = new PlayerLevelData
            {
                score     = 0,
                timestamp = -1,
                stars     = 0
            };
            playerData.playerLevelData.Add(pld);
            string jsonString = JsonUtility.ToJson(playerData);
            Debug.Log(jsonString);
            File.WriteAllText(filePath, jsonString);
        }
    }
Пример #13
0
 public void SetLevelScore(int level, int score)
 {
     if (playerData.playerLevelData[level] != null)
     {
         playerData.playerLevelData[level].score     = score;
         playerData.playerLevelData[level].timestamp = GetSecondsSinceEpoch();
     }
     else
     {
         PlayerLevelData pld = new PlayerLevelData
         {
             score      = score,
             stars      = 0,
             timestamp  = GetSecondsSinceEpoch(),
             regular    = new int[6],
             horizontal = new int[6],
             vertical   = new int[6],
             cross      = new int[6]
         };
         playerData.playerLevelData.Add(pld);
     }
 }
Пример #14
0
    public static LevelRequiredDataModel GetLevelRequiredDataModel(int levelNumber)
    {
        LevelRequiredDataModel data            = new LevelRequiredDataModel();
        PlayerLevelData        playerLevelData = LevelDataHandler.instance.GetPlayerLevelData(levelNumber);

        if (playerLevelData == null)
        {
            return(data);
        }

        data.LevelNumber = levelNumber;

        if (playerLevelData.playerPrefab.GetComponent <PlayerController>() != null)
        {
            data.shipType = playerLevelData.playerPrefab.GetComponent <PlayerController>().GetPlayerType();
        }

        if (playerLevelData.playerGunPrefab.GetComponent <GunBase>() != null)
        {
            data.gunType = playerLevelData.playerGunPrefab.GetComponent <GunBase>().GetGun();
        }
        return(data);
    }
Пример #15
0
    public PLevelData GetCurrentClassLevelData(int level, EnumRole role)
    {
        PLevelData data = new PLevelData();

        if (level < 0 || level >= CurPlayerLevelDataList._dataList.Count)
        {
            Debug.LogError("level is out range: [" + level + "]");
            level = 1;
        }


        PlayerLevelData playerLevelData = CurPlayerLevelDataList._dataList[level];

        data._level    = playerLevelData._level;
        data._xp       = playerLevelData._exp;
        data._reviveHc = playerLevelData._reviveHc;

        if (role == EnumRole.Mage)
        {
            data._hp          = playerLevelData._mage_hp;
            data._attack      = playerLevelData._mage_attack;
            data._defense     = playerLevelData._mage_defense;
            data._crit_rate   = playerLevelData._mage_crit;
            data._crit_damage = playerLevelData._mage_crit_damage;
        }
        else if (role == EnumRole.Warrior)
        {
            data._hp          = playerLevelData._warrior_hp;
            data._attack      = playerLevelData._warrior_attack;
            data._defense     = playerLevelData._warrior_defense;
            data._crit_rate   = playerLevelData._warrior_crit;
            data._crit_damage = playerLevelData._warrior_crit_damage;
        }

        return(data);
    }
Пример #16
0
    public void StartLevel(int level)
    {
        int levelsCompleted = playerData.lastLevel;

        if (level > levelsCompleted)
        {
            for (int i = 0; i < (level - levelsCompleted); i++)
            {
                PlayerLevelData pld = new PlayerLevelData
                {
                    score      = 0,
                    stars      = 0,
                    timestamp  = GetSecondsSinceEpoch(),
                    regular    = new int[6],
                    horizontal = new int[6],
                    vertical   = new int[6],
                    cross      = new int[6]
                };
                playerData.playerLevelData.Add(pld);
            }
        }
        else if (level >= 0)
        {
            PlayerLevelData pld = new PlayerLevelData
            {
                score      = 0,
                stars      = 0,
                timestamp  = GetSecondsSinceEpoch(),
                regular    = new int[6],
                horizontal = new int[6],
                vertical   = new int[6],
                cross      = new int[6]
            };
            playerData.playerLevelData[level] = pld;
        }
    }
Пример #17
0
    private void Awake()
    {
        //instance = GetComponent<DataManager>();
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }


        playerLevelData = Resources.Load("Data/PlayerLevelData") as PlayerLevelData;
        enemyData       = Resources.Load("Data/EnemyData") as EnemyData;


        GameObject go = GameObject.FindWithTag("Player");

        player = go.GetComponent <Player>();


        playerData = GetComponent <PlayerData>();
    }
Пример #18
0
 // Use this for initialization
 void Start()
 {
     currentExp = GetComponent <Text> ();
     level      = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerLevelData>();
 }
Пример #19
0
    public void UnlockNextLevel(PlayerLevelData level)
    {
        if(PlayerLevels.Count <= level.LevelNumber + 1)
        {
            Debug.Log("Finished last level");
            return;
        }

        //Get the next level and flip the switch
        PlayerLevels[level.LevelNumber + 1].IsLevelUnlocked = true;
        //Save our progress
        SaveAllLevelData();
    }
Пример #20
0
 public void SetPlayerLevelData(PlayerLevelData data)
 {
     this._playerLevelData = data;
 }
Пример #21
0
    void Awake()
    {
        DontDestroyOnLoad(this.gameObject);

        //Singleton
        if (uniqueInstance == null)
            uniqueInstance = this;
        else
            Destroy(this.gameObject);

        //Datas.
        Status = new StatusStruct[32];
        Status[0] = new StatusStruct(0, 10000.0f, 10000.0f, 1, 2);
        Status[1] = new StatusStruct(1, 100.0f, 10.0f, 0, 0);
        Status[2] = new StatusStruct(2, 120.0f, 10.0f, 20, 20);
        for (int i = 3; i < 31; i++)
        {
            float tmaxHP, tdamage;
            int tneedEXP, tneedEXPSum;
            //tmaxHP
            if (i <= 10)
            {
                tmaxHP = Status[i - 1].maxHP + 20;
            }
            else if (i <= 20)
            {
                tmaxHP =  Status[i - 1].maxHP + 20;
            }
            else
            {
                tmaxHP =  Status[i - 1].maxHP + 20;
            }
            //tdamage
            if (i <= 9)
            {
                tdamage = Status[i - 1].damage;
            }
            else if (i <= 19)
            {
                tdamage = Status[i - 1].damage;
            }
            else
            {
                tdamage = 2 * Status[i - 1].damage - Status[i - 2].damage ;
            }
            //tneedEXP
            if (i <= 10)
            {
                tneedEXP = 2 * Status[i - 1].needEXP - Status[i - 2].needEXP + 20;
            }
            else if (i <= 19)
            {
                tneedEXP = 2 * Status[i - 1].needEXP - Status[i - 2].needEXP + 40;
            }
            else
            {
                tneedEXP = 2 * Status[i - 1].needEXP - Status[i - 2].needEXP + 60;
            }
            //tneedEXPSum
            tneedEXPSum = 0;
            for (int j = 1; j < i; j++)
                tneedEXPSum += Status[j].needEXP;
            tneedEXPSum += tneedEXP;
            Status[i] = new StatusStruct(i, tmaxHP, tdamage, tneedEXP, tneedEXPSum);

            Status[31] = new StatusStruct(31, 5000, 2000, 15000, 130000);
        }
        //Datas End.
    }
Пример #22
0
 public void SaveSpecificLevel(PlayerLevelData level)
 {
     //Loop thought for our level
     for (int i = 0; i < PlayerLevels.Count; i++)
     {
         //When we find it replace the data
         if(i == level.LevelNumber)
         {
             PlayerLevels[i].LevelNumber = level.LevelNumber;
             PlayerLevels[i].LevelTime = level.LevelTime;
             PlayerLevels[i].IsLevelUnlocked = level.IsLevelUnlocked;
             PlayerLevels[i].LevelScore = level.LevelScore;
             break;
         }
     }
     SaveAllLevelData();
 }
Пример #23
0
    private List<PlayerLevelData> MergeLevelData(List<PlayerLevelData> defaultData, List<PlayerLevelData> prefs, List<PlayerLevelData> cloud)
    {
        //First check if we are new/have no saved data
        if(prefs.Count == 0 && cloud.Count == 0)
        {
            //Could find any data in our cloud or locally
            Debug.Log("Loading Default Data!");
            return defaultData;
        }
        //We just have local data
        else if(cloud.Count == 0 && prefs.Count > 0)
        {
            Debug.Log("Loading prefs Data!");
            HandleNewLevels(ref defaultData, ref prefs);
            return prefs;
        }
        //We just have cloud data
        else if (cloud.Count > 0 && prefs.Count == 0)
        {
            Debug.Log("Loading cloud Data!");
            HandleNewLevels(ref defaultData, ref prefs);
            return cloud;
        }
        //We have both, merge them!
        else if (cloud.Count > 0 && prefs.Count > 0)
        {
            Debug.Log("Both cloud and prefs, starting merge");
            List<PlayerLevelData> MergedResults = new List<PlayerLevelData>();

            //Determine how many times we have to iterate over these lists
            int looper;
            if (cloud.Count > prefs.Count)
            {
                looper = cloud.Count;
                //Added the difference to each the opposing list (to make merging easier)
                for (int i = prefs.Count; i < cloud.Count; i++)
                {
                    prefs.Add(null);
                }
            }
            else
            {
                looper = prefs.Count;
                //Added the difference to each the opposing list (to make merging easier)
                for (int i = cloud.Count; i < prefs.Count; i++)
                {
                    cloud.Add(null);
                }
            }

            //Start merging each object in the list
            for (int i = 0; i < looper; i++)
            {
                //Get the data out of each
                PlayerLevelData prefsLevel, cloudLevel, mergedLevel;
                prefsLevel = prefs[i];
                cloudLevel = cloud[i];

                //Check for null, if so, we want to take the non-null (This is for if one list has more than anther)
                if (prefsLevel == null)
                {
                    mergedLevel = cloudLevel;
                }
                else if(cloudLevel == null)
                {
                    mergedLevel = prefsLevel;
                }
                else
                {
                    //Two valid objects? Gotta merge!

                    //Make sure we are working with the same level
                    if(prefsLevel.LevelNumber == cloudLevel.LevelNumber)
                    {
                        float levelTime;
                        bool IsLevelUnlocked = false;
                        float levelScore;

                        //Compare time
                        if(prefsLevel.LevelTime > cloudLevel.LevelTime)
                        {
                            //Smaller time is better
                            levelTime = cloudLevel.LevelTime;
                        }
                        else
                        {
                            levelTime = prefsLevel.LevelTime;
                        }

                        //Compare unlocks
                        if(prefsLevel.IsLevelUnlocked || cloudLevel.IsLevelUnlocked)
                        {
                            //if any one of them has the level unlocked, give it to the user
                            IsLevelUnlocked = true;
                        }

                        //Compare Score
                        if(prefsLevel.LevelScore > cloudLevel.LevelScore)
                        {
                            levelScore = cloudLevel.LevelScore;
                        }
                        else
                        {
                            levelScore = prefsLevel.LevelScore;
                        }

                        //Finally, create our merged object
                        mergedLevel = new PlayerLevelData(
                            prefsLevel.LevelNumber,
                            levelTime,
                            IsLevelUnlocked,
                            levelScore
                            );
                    }
                    else
                    {
                        Debug.LogError("Trying to merge different levels, this is bad and we f****d up, forcing local to be safe");
                        //TODO: Tell users
                        return prefs;
                    }
                }

                //Now that we have a merged level add it to the list!
                MergedResults.Add(mergedLevel);
            }

            //Finished looping
            HandleNewLevels(ref defaultData, ref MergedResults);
            return MergedResults;
        }
        else
        {
            Debug.LogError("Error Merging List<PlayerLevelData> results!");
            return null;
        }
    }
Пример #24
0
 private void FetchAllLevelData()
 {
     playerLevel = PlayerLevelData.GetPlayerLevel();
     currentXp   = PlayerLevelData.GetTotalExperience();
 }