Exemplo n.º 1
0
    /// <summary>
    /// 写入字节流(完整版)
    /// </summary>
    protected override void toWriteBytesFull(BytesWriteStream stream)
    {
        stream.startWriteObj();

        if (this.petDic != null)
        {
            stream.writeLen(this.petDic.size());
            if (!this.petDic.isEmpty())
            {
                PetUseData[] petDicVValues = this.petDic.getValues();
                for (int petDicVI = petDicVValues.Length - 1; petDicVI >= 0; --petDicVI)
                {
                    PetUseData petDicV = petDicVValues[petDicVI];
                    if (petDicV != null)
                    {
                        if (petDicV != null)
                        {
                            stream.writeDataFullNotNull(petDicV);
                        }
                        else
                        {
                            nullObjError("petDicV");
                        }
                    }
                }
            }
        }
        else
        {
            nullObjError("petDic");
        }

        stream.endWriteObj();
    }
Exemplo n.º 2
0
    /// <summary>
    /// 读取字节流(完整版)
    /// </summary>
    protected override void toReadBytesFull(BytesReadStream stream)
    {
        base.toReadBytesFull(stream);

        stream.startReadObj();

        BaseData dataT = stream.readDataFullNotNull();

        if (dataT != null)
        {
            if (dataT is PetUseData)
            {
                this.data = (PetUseData)dataT;
            }
            else
            {
                this.data = new PetUseData();
                if (!(dataT.GetType().IsAssignableFrom(typeof(PetUseData))))
                {
                    stream.throwTypeReadError(typeof(PetUseData), dataT.GetType());
                }
                this.data.shadowCopy(dataT);
            }
        }
        else
        {
            this.data = null;
        }

        stream.endReadObj();
    }
Exemplo n.º 3
0
    /// <summary>
    /// 是否数据一致
    /// </summary>
    protected override bool toDataEquals(BaseData data)
    {
        PetPartData mData = (PetPartData)data;

        if (mData.petDic != null)
        {
            if (this.petDic == null)
            {
                return(false);
            }
            if (this.petDic.size() != mData.petDic.size())
            {
                return(false);
            }
            IntObjectMap <PetUseData> petDicR = mData.petDic;
            if (!this.petDic.isEmpty())
            {
                int          petDicKFreeValue = this.petDic.getFreeValue();
                int[]        petDicKKeys      = this.petDic.getKeys();
                PetUseData[] petDicVValues    = this.petDic.getValues();
                for (int petDicKI = petDicKKeys.Length - 1; petDicKI >= 0; --petDicKI)
                {
                    int petDicK = petDicKKeys[petDicKI];
                    if (petDicK != petDicKFreeValue)
                    {
                        PetUseData petDicV = petDicVValues[petDicKI];
                        PetUseData petDicU = petDicR.get(petDicK);
                        if (petDicU != null)
                        {
                            if (petDicV == null)
                            {
                                return(false);
                            }
                            if (!petDicV.dataEquals(petDicU))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            if (petDicV != null)
                            {
                                return(false);
                            }
                        }
                    }
                }
            }
        }
        else
        {
            if (this.petDic != null)
            {
                return(false);
            }
        }

        return(true);
    }
Exemplo n.º 4
0
    /// <summary>
    /// 添加宠物
    /// </summary>
    public void addPet(PetUseData data)
    {
        _d.petDic.put(data.mIndex, data);

        PetUseLogic logic = GameC.pool.petUseLogicPool.getOne();

        initPetUseLogicByUseData(logic, data);

        me.dispatch(GameEventType.AddPet, data.mIndex);
    }
Exemplo n.º 5
0
    /// <summary>
    /// 复制(深拷贝)
    /// </summary>
    protected override void toCopy(BaseData data)
    {
        if (!(data is PetPartData))
        {
            return;
        }

        PetPartData mData = (PetPartData)data;

        if (mData.petDic != null)
        {
            if (this.petDic != null)
            {
                this.petDic.clear();
                this.petDic.ensureCapacity(mData.petDic.size());
            }
            else
            {
                this.petDic = new IntObjectMap <PetUseData>(mData.petDic.size());
            }

            IntObjectMap <PetUseData> petDicT = this.petDic;
            if (!mData.petDic.isEmpty())
            {
                PetUseData[] petDicVValues = mData.petDic.getValues();
                for (int petDicVI = petDicVValues.Length - 1; petDicVI >= 0; --petDicVI)
                {
                    PetUseData petDicV = petDicVValues[petDicVI];
                    if (petDicV != null)
                    {
                        PetUseData petDicU;
                        if (petDicV != null)
                        {
                            petDicU = (PetUseData)petDicV.clone();
                        }
                        else
                        {
                            petDicU = null;
                            nullObjError("petDicU");
                        }

                        petDicT.put(petDicU.mIndex, petDicU);
                    }
                }
            }
        }
        else
        {
            this.petDic = null;
            nullObjError("petDic");
        }
    }
Exemplo n.º 6
0
    /// <summary>
    /// 转文本输出
    /// </summary>
    protected override void toWriteDataString(DataWriter writer)
    {
        writer.writeTabs();
        writer.sb.Append("petDic");
        writer.sb.Append(':');
        writer.sb.Append("Map<int,PetUseData>");
        if (this.petDic != null)
        {
            writer.sb.Append('(');
            writer.sb.Append(this.petDic.size());
            writer.sb.Append(')');
            writer.writeEnter();
            writer.writeLeftBrace();
            if (!this.petDic.isEmpty())
            {
                int          petDicKFreeValue = this.petDic.getFreeValue();
                int[]        petDicKKeys      = this.petDic.getKeys();
                PetUseData[] petDicVValues    = this.petDic.getValues();
                for (int petDicKI = petDicKKeys.Length - 1; petDicKI >= 0; --petDicKI)
                {
                    int petDicK = petDicKKeys[petDicKI];
                    if (petDicK != petDicKFreeValue)
                    {
                        PetUseData petDicV = petDicVValues[petDicKI];
                        writer.writeTabs();
                        writer.sb.Append(petDicK);

                        writer.sb.Append(':');
                        if (petDicV != null)
                        {
                            petDicV.writeDataString(writer);
                        }
                        else
                        {
                            writer.sb.Append("PetUseData=null");
                        }

                        writer.writeEnter();
                    }
                }
            }
            writer.writeRightBrace();
        }
        else
        {
            writer.sb.Append("=null");
        }

        writer.writeEnter();
    }
Exemplo n.º 7
0
    /// <summary>
    /// 读取字节流(完整版)
    /// </summary>
    protected override void toReadBytesFull(BytesReadStream stream)
    {
        stream.startReadObj();

        int petDicLen = stream.readLen();

        if (this.petDic != null)
        {
            this.petDic.clear();
            this.petDic.ensureCapacity(petDicLen);
        }
        else
        {
            this.petDic = new IntObjectMap <PetUseData>(petDicLen);
        }

        IntObjectMap <PetUseData> petDicT = this.petDic;

        for (int petDicI = petDicLen - 1; petDicI >= 0; --petDicI)
        {
            PetUseData petDicV;
            BaseData   petDicVT = stream.readDataFullNotNull();
            if (petDicVT != null)
            {
                if (petDicVT is PetUseData)
                {
                    petDicV = (PetUseData)petDicVT;
                }
                else
                {
                    petDicV = new PetUseData();
                    if (!(petDicVT.GetType().IsAssignableFrom(typeof(PetUseData))))
                    {
                        stream.throwTypeReadError(typeof(PetUseData), petDicVT.GetType());
                    }
                    petDicV.shadowCopy(petDicVT);
                }
            }
            else
            {
                petDicV = null;
            }

            petDicT.put(petDicV.mIndex, petDicV);
        }

        stream.endReadObj();
    }
Exemplo n.º 8
0
    public void initPetUseLogicByUseData(PetUseLogic logic, PetUseData useData)
    {
        me.character.initUseLogicByUseData(logic, useData, Global.isPetNeedEquip, true, false);

        _petDic.put(logic.index, logic);

        if (Global.isPetUnique)
        {
            if (_petDicByID.contains(useData.id))
            {
                me.errorLog("已存在的宠物数据");
            }

            _petDicByID.put(useData.id, logic);
        }
    }
Exemplo n.º 9
0
    /// <summary>
    /// 读取字节流(简版)
    /// </summary>
    protected override void toReadBytesSimple(BytesReadStream stream)
    {
        base.toReadBytesSimple(stream);

        this.data = (PetUseData)stream.readDataSimpleNotNull();
    }
Exemplo n.º 10
0
    /// <summary>
    /// 回池
    /// </summary>
    protected override void toRelease(DataPool pool)
    {
        base.toRelease(pool);

        this.data = null;
    }