Ejemplo n.º 1
0
    /// <summary>
    /// Read this whole class from string.
    /// </summary>
    /// <param name="value"></param>
    public void ReadClass(string value)
    {
        string[] splitStrings = new string[] { BasicName, RaidClassName, FriendDataClassName, TotalStarDictionaryName };
        string[] outStrings = value.Split(splitStrings, StringSplitOptions.RemoveEmptyEntries);
        PersistenceFileIOHandler.CheckCount(outStrings, FieldCount - 1, FieldCount);

        string[] splitedBasic = outStrings[0].Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
        PersistenceFileIOHandler.CheckCount(splitedBasic,BasicFieldCount);
        if (BattleStageTemplate == null)BattleStageTemplate = new RaidStageTemplate();
        BattleStageTemplate.Id = int.Parse(splitedBasic[0]);
        OldExp = int.Parse(splitedBasic[1]);
        OldLevel = int.Parse(splitedBasic[2]);
        StarCount = int.Parse(splitedBasic[3]);

        Raid = new RaidInfo();
        Raid.ReadClass(outStrings[1]);

        FriendData=new FriendVO();
        FriendData.ReadClass(outStrings[2]);

        if (outStrings.Length == FieldCount)
        {
            string[] splitedTotalStarDic = outStrings[3].Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
            if (splitedTotalStarDic.Length % 2 != 0)
            {
                Logger.LogError("Not correct string num!");
                throw new Exception("ReadTotalStarDic: Not couple strings num");
            }
            TotalStarCount = PersistenceFileIOHandler.ReadDic<int, int>(splitedTotalStarDic, 0, splitedTotalStarDic.Length - 1);
        }
        else
        {
            Logger.LogWarning("A TotalStarCountDic is empty.");
        }

    }
Ejemplo n.º 2
0
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 1:
         if (field.Type == TType.Map) {
           {
             RaidTmpls = new Dictionary<int, RaidTemplate>();
             TMap _map4 = iprot.ReadMapBegin();
             for( int _i5 = 0; _i5 < _map4.Count; ++_i5)
             {
               int _key6;
               RaidTemplate _val7;
               _key6 = iprot.ReadI32();
               _val7 = new RaidTemplate();
               _val7.Read(iprot);
               RaidTmpls[_key6] = _val7;
             }
             iprot.ReadMapEnd();
           }
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 2:
         if (field.Type == TType.Map) {
           {
             RaidStageTmpls = new Dictionary<int, RaidStageTemplate>();
             TMap _map8 = iprot.ReadMapBegin();
             for( int _i9 = 0; _i9 < _map8.Count; ++_i9)
             {
               int _key10;
               RaidStageTemplate _val11;
               _key10 = iprot.ReadI32();
               _val11 = new RaidStageTemplate();
               _val11.Read(iprot);
               RaidStageTmpls[_key10] = _val11;
             }
             iprot.ReadMapEnd();
           }
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 3:
         if (field.Type == TType.Map) {
           {
             RaidMonsterGroupTmpls = new Dictionary<int, RaidMonsterGroupTemplate>();
             TMap _map12 = iprot.ReadMapBegin();
             for( int _i13 = 0; _i13 < _map12.Count; ++_i13)
             {
               int _key14;
               RaidMonsterGroupTemplate _val15;
               _key14 = iprot.ReadI32();
               _val15 = new RaidMonsterGroupTemplate();
               _val15.Read(iprot);
               RaidMonsterGroupTmpls[_key14] = _val15;
             }
             iprot.ReadMapEnd();
           }
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }
Ejemplo n.º 3
0
    public RaidStageTemplate GetNextStage()
    {
        var raids = MissionModelLocator.Instance.GetCurrentRaids();
        //int raidtemplateid = MissionModelLocator.Instance.CurrRaidType * 100 + int.Parse(themap.id);
        List<RaidStageInfo> currStages = null;
        //List<RaidStageInfo> nextStages = null;
        RaidInfo nextRaidInfo = null;
        for (int i = 0; i < raids.Count; i++)
        {
            if (raids[i].TemplateId == BattleRaidTemplate.Id)
            {
                currStages = raids[i].StateInfo;
            }
            if (raids[i].TemplateId == BattleRaidTemplate.Id + 1)
            {
                //nextStages = raids[i].StateInfo;
                nextRaidInfo = raids[i];
            }
        }

        if (currStages != null)
        {
            for (int i = 0; i < currStages.Count; i++)
            {
                if (currStages[i].TemplateId == BattleStageTemplate.Id + 1)
                {
                    NextRaidTemplate = BattleRaidTemplate;
                    NextStageTemplate = GetRaidStagrByTemplateId(currStages[i].TemplateId);
                    
                    return NextStageTemplate;
                }
            }
        }

        var k = 10000000;
        RaidStageInfo stageinfo = null;
        if (nextRaidInfo != null && nextRaidInfo.StateInfo != null)
        {
            NextRaidTemplate = GetRaidByTemplateId(nextRaidInfo.TemplateId);


            for (int i = 0; i < nextRaidInfo.StateInfo.Count; i++)
            {
                if (k > nextRaidInfo.StateInfo[i].TemplateId)
                {
                    k = nextRaidInfo.StateInfo[i].TemplateId;
                    stageinfo = nextRaidInfo.StateInfo[i];
                }
            }
        }

        if (stageinfo != null)
        {
            NextStageTemplate = GetRaidStagrByTemplateId(k);
            return NextStageTemplate;
        }
        NextStageTemplate = null;
        return null;
    }