/// <summary> /// 初始化初值 /// </summary> public override void initDefault() { this.avatar = new UnitAvatarData(); this.avatar.initDefault(); this.fight = new UnitFightData(); this.fight.initDefault(); this.equips = new EquipContainerData(); this.equips.initDefault(); }
/// <summary> /// 回池 /// </summary> protected override void toRelease(DataPool pool) { this.id = 0; this.level = 0; this.avatar = null; this.fight = null; this.equips = null; this.mIndex = 0; this.isWorking = false; }
/// <summary> /// 回池 /// </summary> protected override void toRelease(DataPool pool) { this.instanceID = 0; this.identity = null; this.normal = null; this.pos = null; this.avatar = null; this.move = null; this.fight = null; this.fightEx = null; this.ai = null; this.func = null; }
/// <summary> /// 复制(潜拷贝) /// </summary> protected override void toShadowCopy(BaseData data) { if (!(data is UnitFightData)) { return; } UnitFightData mData = (UnitFightData)data; this.status = mData.status; this.attributes = mData.attributes; this.skills = mData.skills; this.buffs = mData.buffs; this.cds = mData.cds; }
/// <summary> /// 读取字节流(简版) /// </summary> protected override void toReadBytesSimple(BytesReadStream stream) { this.id = stream.readInt(); this.level = stream.readInt(); this.avatar = (UnitAvatarData)stream.readDataSimpleNotNull(); this.fight = (UnitFightData)stream.readDataSimpleNotNull(); this.equips = (EquipContainerData)stream.readDataSimpleNotNull(); this.mIndex = stream.readInt(); this.isWorking = stream.readBoolean(); }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is MUnitUseData)) { return; } MUnitUseData mData = (MUnitUseData)data; this.id = mData.id; this.level = mData.level; if (mData.avatar != null) { this.avatar = (UnitAvatarData)mData.avatar.clone(); } else { this.avatar = null; nullObjError("avatar"); } if (mData.fight != null) { this.fight = (UnitFightData)mData.fight.clone(); } else { this.fight = null; nullObjError("fight"); } if (mData.equips != null) { this.equips = (EquipContainerData)mData.equips.clone(); } else { this.equips = null; nullObjError("equips"); } this.mIndex = mData.mIndex; this.isWorking = mData.isWorking; }
/// <summary> /// 复制(潜拷贝) /// </summary> protected override void toShadowCopy(BaseData data) { if (!(data is MUnitUseData)) { return; } MUnitUseData mData = (MUnitUseData)data; this.id = mData.id; this.level = mData.level; this.avatar = mData.avatar; this.fight = mData.fight; this.equips = mData.equips; this.mIndex = mData.mIndex; this.isWorking = mData.isWorking; }
/** 设置数据 */ public void setData(UnitFightData fightData, UnitAvatarData facadeData) { if ((_data = fightData) != null) { status.setData(fightData.status); attribute.setData(fightData.attributes); cd.setData(fightData.cds); buff.setData(fightData.buffs); avatar.setData(facadeData); } else { status.setData(null); attribute.setData(null); cd.setData(null); buff.setData(null); avatar.setData(null); } }
/// <summary> /// 复制(潜拷贝) /// </summary> protected override void toShadowCopy(BaseData data) { if (!(data is UnitData)) { return; } UnitData mData = (UnitData)data; this.instanceID = mData.instanceID; this.identity = mData.identity; this.normal = mData.normal; this.pos = mData.pos; this.avatar = mData.avatar; this.move = mData.move; this.fight = mData.fight; this.fightEx = mData.fightEx; this.ai = mData.ai; this.func = mData.func; }
/// <summary> /// 是否数据一致 /// </summary> protected override bool toDataEquals(BaseData data) { UnitFightData mData = (UnitFightData)data; if (mData.status != null) { if (this.status == null) { return(false); } if (this.status.size() != mData.status.size()) { return(false); } IntBooleanMap statusR = mData.status; if (!this.status.isEmpty()) { int statusKFreeValue = this.status.getFreeValue(); int[] statusKKeys = this.status.getKeys(); bool[] statusVValues = this.status.getValues(); for (int statusKI = statusKKeys.Length - 1; statusKI >= 0; --statusKI) { int statusK = statusKKeys[statusKI]; if (statusK != statusKFreeValue) { bool statusV = statusVValues[statusKI]; bool statusU = statusR.get(statusK); if (statusV != statusU) { return(false); } } } } } else { if (this.status != null) { return(false); } } if (mData.attributes != null) { if (this.attributes == null) { return(false); } if (this.attributes.size() != mData.attributes.size()) { return(false); } IntIntMap attributesR = mData.attributes; if (!this.attributes.isEmpty()) { int attributesKFreeValue = this.attributes.getFreeValue(); int[] attributesKKeys = this.attributes.getKeys(); int[] attributesVValues = this.attributes.getValues(); for (int attributesKI = attributesKKeys.Length - 1; attributesKI >= 0; --attributesKI) { int attributesK = attributesKKeys[attributesKI]; if (attributesK != attributesKFreeValue) { int attributesV = attributesVValues[attributesKI]; int attributesU = attributesR.get(attributesK); if (attributesV != attributesU) { return(false); } } } } } else { if (this.attributes != null) { return(false); } } if (mData.skills != null) { if (this.skills == null) { return(false); } if (this.skills.size() != mData.skills.size()) { return(false); } IntObjectMap <SkillData> skillsR = mData.skills; if (!this.skills.isEmpty()) { int skillsKFreeValue = this.skills.getFreeValue(); int[] skillsKKeys = this.skills.getKeys(); SkillData[] skillsVValues = this.skills.getValues(); for (int skillsKI = skillsKKeys.Length - 1; skillsKI >= 0; --skillsKI) { int skillsK = skillsKKeys[skillsKI]; if (skillsK != skillsKFreeValue) { SkillData skillsV = skillsVValues[skillsKI]; SkillData skillsU = skillsR.get(skillsK); if (skillsU != null) { if (skillsV == null) { return(false); } if (!skillsV.dataEquals(skillsU)) { return(false); } } else { if (skillsV != null) { return(false); } } } } } } else { if (this.skills != null) { return(false); } } if (mData.buffs != null) { if (this.buffs == null) { return(false); } if (this.buffs.size() != mData.buffs.size()) { return(false); } IntObjectMap <BuffData> buffsR = mData.buffs; if (!this.buffs.isEmpty()) { int buffsKFreeValue = this.buffs.getFreeValue(); int[] buffsKKeys = this.buffs.getKeys(); BuffData[] buffsVValues = this.buffs.getValues(); for (int buffsKI = buffsKKeys.Length - 1; buffsKI >= 0; --buffsKI) { int buffsK = buffsKKeys[buffsKI]; if (buffsK != buffsKFreeValue) { BuffData buffsV = buffsVValues[buffsKI]; BuffData buffsU = buffsR.get(buffsK); if (buffsU != null) { if (buffsV == null) { return(false); } if (!buffsV.dataEquals(buffsU)) { return(false); } } else { if (buffsV != null) { return(false); } } } } } } else { if (this.buffs != null) { return(false); } } if (mData.cds != null) { if (this.cds == null) { return(false); } if (this.cds.size() != mData.cds.size()) { return(false); } IntObjectMap <CDData> cdsR = mData.cds; if (!this.cds.isEmpty()) { int cdsKFreeValue = this.cds.getFreeValue(); int[] cdsKKeys = this.cds.getKeys(); CDData[] cdsVValues = this.cds.getValues(); for (int cdsKI = cdsKKeys.Length - 1; cdsKI >= 0; --cdsKI) { int cdsK = cdsKKeys[cdsKI]; if (cdsK != cdsKFreeValue) { CDData cdsV = cdsVValues[cdsKI]; CDData cdsU = cdsR.get(cdsK); if (cdsU != null) { if (cdsV == null) { return(false); } if (!cdsV.dataEquals(cdsU)) { return(false); } } else { if (cdsV != null) { return(false); } } } } } } else { if (this.cds != null) { return(false); } } return(true); }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is UnitFightData)) { return; } UnitFightData mData = (UnitFightData)data; if (mData.status != null) { if (this.status != null) { this.status.clear(); this.status.ensureCapacity(mData.status.size()); } else { this.status = new IntBooleanMap(mData.status.size()); } IntBooleanMap statusT = this.status; if (!mData.status.isEmpty()) { int statusKFreeValue = mData.status.getFreeValue(); int[] statusKKeys = mData.status.getKeys(); bool[] statusVValues = mData.status.getValues(); for (int statusKI = statusKKeys.Length - 1; statusKI >= 0; --statusKI) { int statusK = statusKKeys[statusKI]; if (statusK != statusKFreeValue) { bool statusV = statusVValues[statusKI]; int statusW; bool statusU; statusW = statusK; statusU = statusV; statusT.put(statusW, statusU); } } } } else { this.status = null; nullObjError("status"); } if (mData.attributes != null) { if (this.attributes != null) { this.attributes.clear(); this.attributes.ensureCapacity(mData.attributes.size()); } else { this.attributes = new IntIntMap(mData.attributes.size()); } IntIntMap attributesT = this.attributes; if (!mData.attributes.isEmpty()) { int attributesKFreeValue = mData.attributes.getFreeValue(); int[] attributesKKeys = mData.attributes.getKeys(); int[] attributesVValues = mData.attributes.getValues(); for (int attributesKI = attributesKKeys.Length - 1; attributesKI >= 0; --attributesKI) { int attributesK = attributesKKeys[attributesKI]; if (attributesK != attributesKFreeValue) { int attributesV = attributesVValues[attributesKI]; int attributesW; int attributesU; attributesW = attributesK; attributesU = attributesV; attributesT.put(attributesW, attributesU); } } } } else { this.attributes = null; nullObjError("attributes"); } if (mData.skills != null) { if (this.skills != null) { this.skills.clear(); this.skills.ensureCapacity(mData.skills.size()); } else { this.skills = new IntObjectMap <SkillData>(mData.skills.size()); } IntObjectMap <SkillData> skillsT = this.skills; if (!mData.skills.isEmpty()) { SkillData[] skillsVValues = mData.skills.getValues(); for (int skillsVI = skillsVValues.Length - 1; skillsVI >= 0; --skillsVI) { SkillData skillsV = skillsVValues[skillsVI]; if (skillsV != null) { SkillData skillsU; if (skillsV != null) { skillsU = (SkillData)skillsV.clone(); } else { skillsU = null; nullObjError("skillsU"); } skillsT.put(skillsU.id, skillsU); } } } } else { this.skills = null; nullObjError("skills"); } if (mData.buffs != null) { if (this.buffs != null) { this.buffs.clear(); this.buffs.ensureCapacity(mData.buffs.size()); } else { this.buffs = new IntObjectMap <BuffData>(mData.buffs.size()); } IntObjectMap <BuffData> buffsT = this.buffs; if (!mData.buffs.isEmpty()) { BuffData[] buffsVValues = mData.buffs.getValues(); for (int buffsVI = buffsVValues.Length - 1; buffsVI >= 0; --buffsVI) { BuffData buffsV = buffsVValues[buffsVI]; if (buffsV != null) { BuffData buffsU; if (buffsV != null) { buffsU = (BuffData)buffsV.clone(); } else { buffsU = null; nullObjError("buffsU"); } buffsT.put(buffsU.instanceID, buffsU); } } } } else { this.buffs = null; nullObjError("buffs"); } if (mData.cds != null) { if (this.cds != null) { this.cds.clear(); this.cds.ensureCapacity(mData.cds.size()); } else { this.cds = new IntObjectMap <CDData>(mData.cds.size()); } IntObjectMap <CDData> cdsT = this.cds; if (!mData.cds.isEmpty()) { CDData[] cdsVValues = mData.cds.getValues(); for (int cdsVI = cdsVValues.Length - 1; cdsVI >= 0; --cdsVI) { CDData cdsV = cdsVValues[cdsVI]; if (cdsV != null) { CDData cdsU; if (cdsV != null) { cdsU = (CDData)BytesControl.createData(CDData.dataID); cdsU.copy(cdsV); } else { cdsU = null; nullObjError("cdsU"); } cdsT.put(cdsU.id, cdsU); } } } } else { this.cds = null; nullObjError("cds"); } }
/// <summary> /// 读取字节流(完整版) /// </summary> protected override void toReadBytesFull(BytesReadStream stream) { stream.startReadObj(); this.id = stream.readInt(); this.level = stream.readInt(); BaseData avatarT = stream.readDataFullNotNull(); if (avatarT != null) { if (avatarT is UnitAvatarData) { this.avatar = (UnitAvatarData)avatarT; } else { this.avatar = new UnitAvatarData(); if (!(avatarT.GetType().IsAssignableFrom(typeof(UnitAvatarData)))) { stream.throwTypeReadError(typeof(UnitAvatarData), avatarT.GetType()); } this.avatar.shadowCopy(avatarT); } } else { this.avatar = null; } BaseData fightT = stream.readDataFullNotNull(); if (fightT != null) { if (fightT is UnitFightData) { this.fight = (UnitFightData)fightT; } else { this.fight = new UnitFightData(); if (!(fightT.GetType().IsAssignableFrom(typeof(UnitFightData)))) { stream.throwTypeReadError(typeof(UnitFightData), fightT.GetType()); } this.fight.shadowCopy(fightT); } } else { this.fight = null; } BaseData equipsT = stream.readDataFullNotNull(); if (equipsT != null) { if (equipsT is EquipContainerData) { this.equips = (EquipContainerData)equipsT; } else { this.equips = new EquipContainerData(); if (!(equipsT.GetType().IsAssignableFrom(typeof(EquipContainerData)))) { stream.throwTypeReadError(typeof(EquipContainerData), equipsT.GetType()); } this.equips.shadowCopy(equipsT); } } else { this.equips = null; } this.mIndex = stream.readInt(); this.isWorking = stream.readBoolean(); stream.endReadObj(); }
/// <summary> /// 读取字节流(简版) /// </summary> protected override void toReadBytesSimple(BytesReadStream stream) { this.instanceID = stream.readInt(); this.identity = (UnitIdentityData)stream.readDataSimpleNotNull(); this.normal = (UnitNormalData)stream.readDataSimpleNotNull(); if (stream.readBoolean()) { this.pos = (UnitPosData)stream.readDataSimpleNotNull(); } else { this.pos = null; } if (stream.readBoolean()) { this.avatar = (UnitAvatarData)stream.readDataSimpleNotNull(); } else { this.avatar = null; } if (stream.readBoolean()) { this.move = (UnitMoveData)stream.readDataSimpleNotNull(); } else { this.move = null; } if (stream.readBoolean()) { this.fight = (UnitFightData)stream.readDataSimpleNotNull(); } else { this.fight = null; } if (stream.readBoolean()) { this.fightEx = (UnitFightExData)stream.readDataSimpleNotNull(); } else { this.fightEx = null; } if (stream.readBoolean()) { this.ai = (UnitAIData)stream.readDataSimpleNotNull(); } else { this.ai = null; } if (stream.readBoolean()) { this.func = (UnitFuncData)stream.readDataSimpleNotNull(); } else { this.func = null; } }
/// <summary> /// 读取字节流(完整版) /// </summary> protected override void toReadBytesFull(BytesReadStream stream) { stream.startReadObj(); this.instanceID = stream.readInt(); BaseData identityT = stream.readDataFullNotNull(); if (identityT != null) { if (identityT is UnitIdentityData) { this.identity = (UnitIdentityData)identityT; } else { this.identity = new UnitIdentityData(); if (!(identityT.GetType().IsAssignableFrom(typeof(UnitIdentityData)))) { stream.throwTypeReadError(typeof(UnitIdentityData), identityT.GetType()); } this.identity.shadowCopy(identityT); } } else { this.identity = null; } BaseData normalT = stream.readDataFullNotNull(); if (normalT != null) { if (normalT is UnitNormalData) { this.normal = (UnitNormalData)normalT; } else { this.normal = new UnitNormalData(); if (!(normalT.GetType().IsAssignableFrom(typeof(UnitNormalData)))) { stream.throwTypeReadError(typeof(UnitNormalData), normalT.GetType()); } this.normal.shadowCopy(normalT); } } else { this.normal = null; } if (stream.readBoolean()) { BaseData posT = stream.readDataFullNotNull(); if (posT != null) { if (posT is UnitPosData) { this.pos = (UnitPosData)posT; } else { this.pos = new UnitPosData(); if (!(posT.GetType().IsAssignableFrom(typeof(UnitPosData)))) { stream.throwTypeReadError(typeof(UnitPosData), posT.GetType()); } this.pos.shadowCopy(posT); } } else { this.pos = null; } } else { this.pos = null; } if (stream.readBoolean()) { BaseData avatarT = stream.readDataFullNotNull(); if (avatarT != null) { if (avatarT is UnitAvatarData) { this.avatar = (UnitAvatarData)avatarT; } else { this.avatar = new UnitAvatarData(); if (!(avatarT.GetType().IsAssignableFrom(typeof(UnitAvatarData)))) { stream.throwTypeReadError(typeof(UnitAvatarData), avatarT.GetType()); } this.avatar.shadowCopy(avatarT); } } else { this.avatar = null; } } else { this.avatar = null; } if (stream.readBoolean()) { BaseData moveT = stream.readDataFullNotNull(); if (moveT != null) { if (moveT is UnitMoveData) { this.move = (UnitMoveData)moveT; } else { this.move = new UnitMoveData(); if (!(moveT.GetType().IsAssignableFrom(typeof(UnitMoveData)))) { stream.throwTypeReadError(typeof(UnitMoveData), moveT.GetType()); } this.move.shadowCopy(moveT); } } else { this.move = null; } } else { this.move = null; } if (stream.readBoolean()) { BaseData fightT = stream.readDataFullNotNull(); if (fightT != null) { if (fightT is UnitFightData) { this.fight = (UnitFightData)fightT; } else { this.fight = new UnitFightData(); if (!(fightT.GetType().IsAssignableFrom(typeof(UnitFightData)))) { stream.throwTypeReadError(typeof(UnitFightData), fightT.GetType()); } this.fight.shadowCopy(fightT); } } else { this.fight = null; } } else { this.fight = null; } if (stream.readBoolean()) { BaseData fightExT = stream.readDataFullNotNull(); if (fightExT != null) { if (fightExT is UnitFightExData) { this.fightEx = (UnitFightExData)fightExT; } else { this.fightEx = new UnitFightExData(); if (!(fightExT.GetType().IsAssignableFrom(typeof(UnitFightExData)))) { stream.throwTypeReadError(typeof(UnitFightExData), fightExT.GetType()); } this.fightEx.shadowCopy(fightExT); } } else { this.fightEx = null; } } else { this.fightEx = null; } if (stream.readBoolean()) { BaseData aiT = stream.readDataFullNotNull(); if (aiT != null) { if (aiT is UnitAIData) { this.ai = (UnitAIData)aiT; } else { this.ai = new UnitAIData(); if (!(aiT.GetType().IsAssignableFrom(typeof(UnitAIData)))) { stream.throwTypeReadError(typeof(UnitAIData), aiT.GetType()); } this.ai.shadowCopy(aiT); } } else { this.ai = null; } } else { this.ai = null; } if (stream.readBoolean()) { BaseData funcT = stream.readDataFullNotNull(); if (funcT != null) { if (funcT is UnitFuncData) { this.func = (UnitFuncData)funcT; } else { this.func = new UnitFuncData(); if (!(funcT.GetType().IsAssignableFrom(typeof(UnitFuncData)))) { stream.throwTypeReadError(typeof(UnitFuncData), funcT.GetType()); } this.func.shadowCopy(funcT); } } else { this.func = null; } } else { this.func = null; } stream.endReadObj(); }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is UnitData)) { return; } UnitData mData = (UnitData)data; this.instanceID = mData.instanceID; if (mData.identity != null) { this.identity = (UnitIdentityData)mData.identity.clone(); } else { this.identity = null; nullObjError("identity"); } if (mData.normal != null) { this.normal = (UnitNormalData)mData.normal.clone(); } else { this.normal = null; nullObjError("normal"); } if (mData.pos != null) { this.pos = (UnitPosData)mData.pos.clone(); } else { this.pos = null; } if (mData.avatar != null) { this.avatar = (UnitAvatarData)mData.avatar.clone(); } else { this.avatar = null; } if (mData.move != null) { this.move = (UnitMoveData)mData.move.clone(); } else { this.move = null; } if (mData.fight != null) { this.fight = (UnitFightData)mData.fight.clone(); } else { this.fight = null; } if (mData.fightEx != null) { this.fightEx = (UnitFightExData)mData.fightEx.clone(); } else { this.fightEx = null; } if (mData.ai != null) { this.ai = (UnitAIData)mData.ai.clone(); } else { this.ai = null; } if (mData.func != null) { this.func = (UnitFuncData)mData.func.clone(); } else { this.func = null; } }