Exemple #1
0
    /// <summary>
    /// 复制(深拷贝)
    /// </summary>
    protected override void toCopy(BaseData data)
    {
        if (!(data is SceneEnterData))
        {
            return;
        }

        SceneEnterData mData = (SceneEnterData)data;

        if (mData.hero != null)
        {
            this.hero = (UnitData)mData.hero.clone();
        }
        else
        {
            this.hero = null;
        }

        if (mData.units != null)
        {
            if (this.units != null)
            {
                this.units.clear();
                this.units.ensureCapacity(mData.units.size());
            }
            else
            {
                this.units = new SList <UnitData>();
            }

            SList <UnitData> unitsT = this.units;
            if (!mData.units.isEmpty())
            {
                UnitData[] unitsVValues = mData.units.getValues();
                for (int unitsVI = 0, unitsVLen = mData.units.length(); unitsVI < unitsVLen; ++unitsVI)
                {
                    UnitData unitsV = unitsVValues[unitsVI];
                    UnitData unitsU;
                    if (unitsV != null)
                    {
                        unitsU = (UnitData)unitsV.clone();
                    }
                    else
                    {
                        unitsU = null;
                        nullObjError("unitsU");
                    }

                    unitsT.add(unitsU);
                }
            }
        }
        else
        {
            this.units = null;
            nullObjError("units");
        }

        if (mData.roles != null)
        {
            if (this.roles != null)
            {
                this.roles.clear();
                this.roles.ensureCapacity(mData.roles.size());
            }
            else
            {
                this.roles = new LongObjectMap <SceneRoleData>(mData.roles.size());
            }

            LongObjectMap <SceneRoleData> rolesT = this.roles;
            if (!mData.roles.isEmpty())
            {
                SceneRoleData[] rolesVValues = mData.roles.getValues();
                for (int rolesVI = rolesVValues.Length - 1; rolesVI >= 0; --rolesVI)
                {
                    SceneRoleData rolesV = rolesVValues[rolesVI];
                    if (rolesV != null)
                    {
                        SceneRoleData rolesU;
                        if (rolesV != null)
                        {
                            rolesU = (SceneRoleData)rolesV.clone();
                        }
                        else
                        {
                            rolesU = null;
                            nullObjError("rolesU");
                        }

                        rolesT.put(rolesU.playerID, rolesU);
                    }
                }
            }
        }
        else
        {
            this.roles = null;
            nullObjError("roles");
        }

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

            IntObjectMap <FieldItemBagBindData> selfBindFieldItemBagsT = this.selfBindFieldItemBags;
            if (!mData.selfBindFieldItemBags.isEmpty())
            {
                FieldItemBagBindData[] selfBindFieldItemBagsVValues = mData.selfBindFieldItemBags.getValues();
                for (int selfBindFieldItemBagsVI = selfBindFieldItemBagsVValues.Length - 1; selfBindFieldItemBagsVI >= 0; --selfBindFieldItemBagsVI)
                {
                    FieldItemBagBindData selfBindFieldItemBagsV = selfBindFieldItemBagsVValues[selfBindFieldItemBagsVI];
                    if (selfBindFieldItemBagsV != null)
                    {
                        FieldItemBagBindData selfBindFieldItemBagsU;
                        if (selfBindFieldItemBagsV != null)
                        {
                            selfBindFieldItemBagsU = (FieldItemBagBindData)selfBindFieldItemBagsV.clone();
                        }
                        else
                        {
                            selfBindFieldItemBagsU = null;
                        }

                        selfBindFieldItemBagsT.put(selfBindFieldItemBagsU.instanceID, selfBindFieldItemBagsU);
                    }
                }
            }
        }
        else
        {
            this.selfBindFieldItemBags = null;
        }

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

            IntObjectMap <UnitSimpleData> bindVisionUnitsT = this.bindVisionUnits;
            if (!mData.bindVisionUnits.isEmpty())
            {
                int              bindVisionUnitsKFreeValue = mData.bindVisionUnits.getFreeValue();
                int[]            bindVisionUnitsKKeys      = mData.bindVisionUnits.getKeys();
                UnitSimpleData[] bindVisionUnitsVValues    = mData.bindVisionUnits.getValues();
                for (int bindVisionUnitsKI = bindVisionUnitsKKeys.Length - 1; bindVisionUnitsKI >= 0; --bindVisionUnitsKI)
                {
                    int bindVisionUnitsK = bindVisionUnitsKKeys[bindVisionUnitsKI];
                    if (bindVisionUnitsK != bindVisionUnitsKFreeValue)
                    {
                        UnitSimpleData bindVisionUnitsV = bindVisionUnitsVValues[bindVisionUnitsKI];
                        int            bindVisionUnitsW;
                        UnitSimpleData bindVisionUnitsU;
                        bindVisionUnitsW = bindVisionUnitsK;

                        if (bindVisionUnitsV != null)
                        {
                            bindVisionUnitsU = (UnitSimpleData)bindVisionUnitsV.clone();
                        }
                        else
                        {
                            bindVisionUnitsU = null;
                        }

                        bindVisionUnitsT.put(bindVisionUnitsW, bindVisionUnitsU);
                    }
                }
            }
        }
        else
        {
            this.bindVisionUnits = null;
        }

        if (mData.battleData != null)
        {
            this.battleData = (BattleSceneData)mData.battleData.clone();
        }
        else
        {
            this.battleData = null;
        }
    }