Example #1
0
 /// <summary>
 /// 增加领过的通关奖品
 /// </summary>
 public void addChapterAwardSeverSample(ChapterAwardServerSample newItem)
 {
     if (awardsList == null || awardsList.Count == 0)
     {
         awardsList = new List <ChapterAwardServerSample> ();
         awardsList.Add(newItem);
         return;
     }
     foreach (ChapterAwardServerSample item in awardsList)
     {
         if (item.chapterSid == newItem.chapterSid)
         {
             int[] sss = new int[item.awardSids.Length + 1];
             item.awardSids.CopyTo(sss, 0);
             newItem.awardSids.CopyTo(sss, item.awardSids.Length);
             item.awardSids = sss;
             return;
         }
     }
     awardsList.Add(newItem);
 }
    public override void read(ErlKVMessage message)
    {
        base.read(message);

        if (sendType == TYPE_INFO)
        {
            ErlType msg = message.getValue("msg") as ErlType;

            if (msg is ErlArray)
            {
                ErlArray array = msg as ErlArray;

                if (array == null)
                {
                    return;
                }

                List <ChapterAwardServerSample> list = new List <ChapterAwardServerSample>();
                for (int i = 0; i < array.Value.Length; i++)
                {
                    ChapterAwardServerSample info = new ChapterAwardServerSample();
                    info.chapterSid = StringKit.toInt(((array.Value [i] as ErlArray).Value[0] as ErlType).getValueString());

                    ErlArray one = (array.Value [i] as ErlArray).Value[1] as ErlArray;
                    info.awardSids = new int[one.Value.Length];
                    for (int j = 0; j < one.Value.Length; j++)
                    {
                        info.awardSids[j] = StringKit.toInt(one.Value [j].getValueString());
                    }
                    list.Add(info);
                }

                FuBenManagerment.Instance.getChapterAwardSeverSampleBySid(list);
            }
            else
            {
                MonoBase.print(GetType() + "error:" + msg);
            }
            if (callback != null)
            {
                callback();
            }
            callback = null;
        }

        else if (sendType == TYPE_GET)
        {
            string str = (message.getValue("msg") as ErlAtom).Value;

            switch (str)
            {
            case "ok":
                //UiManager.Instance.createMessageLintWindow(LanguageConfigManager.Instance.getLanguage("s0120"));
                ChapterAwardServerSample item = new ChapterAwardServerSample();
                item.chapterSid = chapterSid;
                item.awardSids  = new int[1] {
                    awardSid
                };
                FuBenManagerment.Instance.addChapterAwardSeverSample(item);
                if (callback != null)
                {
                    callback();
                }
                chapterSid = 0;
                awardSid   = 0;
                callback   = null;
                break;
            }
        }
    }