Beispiel #1
0
        /// <summary>
        /// 从JSON源数据转换为数据项
        /// </summary>
        /// <param name="item"></param>
        /// <param name="data"></param>
        public static void FillFromJSON(ref JsonData item, out HeroItem data)
        {
            data = new HeroItem
            {
                id        = int.Parse(item["id"].ToString()),
                name      = item["name"].ToString(),
                level     = int.Parse(item["level"].ToString()),
                hp        = double.Parse(item["hp"].ToString()),
                atk       = double.Parse(item["atk"].ToString()),
                def       = double.Parse(item["def"].ToString()),
                intellect = double.Parse(item["intellect"].ToString()),
                aow       = double.Parse(item["aow"].ToString()),
                troops    = int.Parse(item["troops"].ToString()),

                skillCIC        = int.Parse(item["skillCIC"].ToString()),
                skillCounsellor = int.Parse(item["skillCounsellor"].ToString()),
            };

            JsonData list = item["skillGeneral"];

            int n = list.Count;

            data.skillGeneral = new int[n];
            for (int j = 0; j < n; j++)
            {
                data.skillGeneral[j] = int.Parse(list[j].ToString());
            }
        }
Beispiel #2
0
        /// <summary>
        /// 从数据项(配置、本地缓存等)转换为字段数据
        /// </summary>
        /// <param name="heroItem"></param>
        public void InitFormItem(ref HeroItem heroItem)
        {
            "error".Log(heroItem == default, "Hero item is null");

            mHeroItem = heroItem;

            mStringFieldSource = new List <string> {
                heroItem.name,
            };

            mIntFieldSource = new List <int> {
                heroItem.id,
                Consts.CAMP_PLAYER,
                heroItem.level,
                heroItem.troops,
            };

            mFloatFieldSource = new List <float> {
                (float)heroItem.hp,
                (float)heroItem.atk,
                (float)heroItem.def,
                (float)heroItem.intellect,
                (float)heroItem.aow,
            };

            FillValues();
            LogFields();

            SkillCIC        = heroItem.skillCIC;
            SkillCounsellor = heroItem.skillCounsellor;
            SkillGeneral    = heroItem.skillGeneral;

            mSkillCIC = new SkillFields();
        }
        public void AddHero(int sid, ref HeroItem item)
        {
            HeroFields heroFields = new HeroFields();

            heroFields.InitFormItem(ref item);
            mHeros[sid] = heroFields;

            //先直接放入队伍
            mTeamHeros.Add(heroFields);
        }
Beispiel #4
0
 /// <summary>
 /// 从数据字段转换为数据项(本地缓存)
 /// </summary>
 /// <param name="heroItem"></param>
 public void ParseToHeroItem(ref HeroItem heroItem)
 {
     heroItem.name      = GetStringData(Consts.FN_NAME);
     heroItem.id        = GetIntData(Consts.FN_ID);
     heroItem.level     = GetIntData(Consts.FN_LEVEL);
     heroItem.hp        = GetFloatData(Consts.FN_HP);
     heroItem.atk       = GetFloatData(Consts.FN_ATK);
     heroItem.def       = GetFloatData(Consts.FN_DEF);
     heroItem.intellect = GetFloatData(Consts.FN_INTELLECT);
     heroItem.aow       = GetFloatData(Consts.FN_AOW);
     heroItem.troops    = GetIntData(Consts.FN_TROOPS);
 }
        public void SyncHerosToClient(ref IsKingClientInfo clientInfo)
        {
            int        max = mHeros.Size;
            HeroItem   item;
            HeroFields fields;

            clientInfo.heros = new HeroItem[max];
            for (int i = 0; i < max; i++)
            {
                item   = new HeroItem();
                fields = mHeros.GetValueByIndex(i);
                fields.ParseToHeroItem(ref item);
                clientInfo.heros[i] = item;
            }
        }