Example #1
0
    private void OnReq_PassCopy(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        ReqPassCopy            req = Serializer.Deserialize <ReqPassCopy>(ms);

        AckPassCopy ack = new AckPassCopy();

        ack.CopyType = req.CopyType;
        ack.CopyID   = req.CopyID;
        ack.Chapter  = req.Chapter;
        ack.StarNum  = req.StarNum;
        NetworkManager.Instance.Send(MessageID.MSG_ACK_PASSCOPY, ack, 0, 0);
    }
Example #2
0
    private void OnAck_PassCopy(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AckPassCopy            ack = Serializer.Deserialize <AckPassCopy>(ms);
        int chapter  = ack.Chapter;
        int copyID   = ack.CopyID;
        int copyType = ack.CopyType;
        int starNum  = ack.StarNum;

        XCopy copy;

        if (!DataDBSCopy.ContainsKey(copyID))
        {
            copy         = new XCopy();
            copy.Id      = copyID;
            copy.StarNum = starNum;
        }
        else
        {
            copy = DataDBSCopy.GetDataById(copyID);
            if (copy.StarNum < starNum)
            {
                copy.StarNum = starNum;
            }
        }
        DataDBSCopy.Update(copyID, copy);
        DCopy copyDB = ReadCfgCopy.GetDataById(copyID);

        GTDataManager.Instance.UseAction(copyDB.CostActionId, copyDB.CostActionNum);
        int   key = (int)copyType;
        XRaid raid;

        if (!DataDBSRaid.ContainsKey(key))
        {
            raid = new XRaid();
        }
        else
        {
            raid = DataDBSRaid.GetDataById(key);
        }

        raid.MaxChapter = chapter;
        raid.MaxCopyId  = copyID;
        raid.Id         = key;
        DataDBSRaid.Update(key, raid);

        if (starNum > 0)
        {
            XCharacter role = RoleModule.Instance.GetCurPlayer();
            RoleService.Instance.TryAddRoleExp(copyDB.GetExpRatio * role.Level);

            GTDataManager.Instance.AddMoney(copyDB.GetMoneyId, copyDB.GetMoneyRatio * role.Level);
            GTDataManager.Instance.UseAction(copyDB.CostActionId, copyDB.CostActionNum);
            List <KStruct> list = AwardModule.Instance.GetAwardDataByID(copyDB.AwardId);
            if (list != null)
            {
                GTDataManager.Instance.AddNewItemList(list, false);
            }
        }

        GTEventCenter.FireEvent(GTEventID.TYPE_PASS_COPY);
    }