示例#1
0
    public LevelUPReward GetLevelUpReward(int level)
    {
        LevelUPReward lr = null;

        dicLevelUpReward.TryGetValue(level, out lr);
        return(lr);
    }
示例#2
0
    /// <summary>
    /// 加载升级奖励数据
    /// </summary>
    IEnumerator InitLevelup()
    {
//		TextAsset s = Resources.Load( WGConfig.Path_levelup)as TextAsset;
        ResourceRequest rr = Resources.LoadAsync(WGConfig.Path_levelup);

        yield return(rr);

        TextAsset s = rr.asset as TextAsset;

        using (StreamReader sr = new StreamReader(new MemoryStream(s.bytes)))
        {
            string line;
            while ((line = sr.ReadLine()) != null)
            {
                try{
                    LevelUPReward lr = SDK.Deserialize <LevelUPReward>(line);
                    lr.refreshWeight();
                    dicLevelUpReward.Add(lr.level, lr);
                }
                catch (IOException e) {
                    Debug.Log(e.ToString());
                }
            }
        }
        Resources.UnloadAsset(s);
    }
示例#3
0
    /// <summary>
    /// 当前等级
    /// </summary>
    /// <returns>数组0:奖励物品的ID,1:物品奖励数量</returns>
    /// <param name="level">Level.</param>
    public int[] GetLevelUPRewardID(int level)
    {
        int[] reward = new int[2];

        int           type = 1;
        LevelUPReward lr   = dicLevelUpReward[level];

        type = lr.randomRewardType();


        if (type != -1 && lr.reward.Length >= type)
        {
            reward[1] = lr.reward[type - 1];
        }
        else
        {
            Debug.LogWarning("SONG==>get level(" + level + ") reward type is -1");
            return(null);
        }

        if (type == 1)
        {
            reward[0] = WGDefine.CommonCoin;
        }
        else
        {
            List <BCObj> sztype = dicTypeGameObj[type];
            if (sztype != null && sztype.Count > 0)
            {
                int idx = Random.Range(1, sztype.Count);
                reward[0] = sztype[idx].ID;
            }
            else
            {
                Debug.LogWarning("SONG==>get level=(" + level + ") reward with type=(" + type + ")is null");
                return(null);
            }
        }

        return(reward);
    }