Esempio n. 1
0
        public void Deserialize(UnitData owner, Json_Job json)
        {
            if (json == null)
            {
                throw new InvalidJSONException();
            }
            this.mJobParam = MonoSingleton <GameManager> .GetInstanceDirect().GetJobParam(json.iname);

            this.mUniqueID   = json.iid;
            this.mRank       = (OInt)json.rank;
            this.mOwner      = owner;
            this.mSelectSkin = json.cur_skin;
            for (int index = 0; index < this.mEquips.Length; ++index)
            {
                this.mEquips[index].Setup(this.mJobParam.GetRankupItemID((int)this.mRank, index));
            }
            if (json.equips != null)
            {
                for (int index = 0; index < json.equips.Length; ++index)
                {
                    this.mEquips[index].Equip(json.equips[index]);
                }
            }
            if (!string.IsNullOrEmpty(this.Param.atkskill[0]))
            {
                this.mNormalAttackSkill.Setup(this.Param.atkskill[0], 1, 1, (MasterParam)null);
            }
            else
            {
                this.mNormalAttackSkill.Setup(this.Param.atkskill[(int)owner.UnitParam.element], 1, 1, (MasterParam)null);
            }
            if (!string.IsNullOrEmpty(this.Param.master) && MonoSingleton <GameManager> .Instance.MasterParam.FixParam.IsJobMaster)
            {
                if (this.mJobMaster == null)
                {
                    this.mJobMaster = new SkillData();
                }
                this.mJobMaster.Setup(this.Param.master, 1, 1, (MasterParam)null);
            }
            if (json.abils != null)
            {
                Array.Sort <Json_Ability>(json.abils, (Comparison <Json_Ability>)((src, dsc) => (int)(src.iid - dsc.iid)));
                for (int index = 0; index < json.abils.Length; ++index)
                {
                    AbilityData abilityData = new AbilityData();
                    string      iname       = json.abils[index].iname;
                    long        iid         = json.abils[index].iid;
                    int         exp         = json.abils[index].exp;
                    abilityData.Setup(this.mOwner, iid, iname, exp, 0);
                    this.mLearnAbilitys.Add(abilityData);
                }
            }
            Array.Clear((Array)this.mAbilitySlots, 0, this.mAbilitySlots.Length);
            if (json.select != null && json.select.abils != null)
            {
                for (int index = 0; index < json.select.abils.Length && index < this.mAbilitySlots.Length; ++index)
                {
                    this.mAbilitySlots[index] = json.select.abils[index];
                }
            }
            for (int index = 0; index < this.mArtifactDatas.Length; ++index)
            {
                this.mArtifactDatas[index] = (ArtifactData)null;
            }
            Array.Clear((Array)this.mArtifacts, 0, this.mArtifacts.Length);
            if (json.select != null && json.select.artifacts != null)
            {
                for (int index = 0; index < json.select.artifacts.Length && index < this.mArtifacts.Length; ++index)
                {
                    this.mArtifacts[index] = json.select.artifacts[index];
                }
            }
            if (json.artis != null)
            {
                for (int index1 = 0; index1 < json.artis.Length; ++index1)
                {
                    if (json.artis[index1] != null)
                    {
                        int index2 = Array.IndexOf <long>(this.mArtifacts, json.artis[index1].iid);
                        if (index2 >= 0)
                        {
                            ArtifactData artifactData = new ArtifactData();
                            artifactData.Deserialize(json.artis[index1]);
                            this.mArtifactDatas[index2] = artifactData;
                        }
                    }
                }
            }
            if (string.IsNullOrEmpty(json.cur_skin))
            {
                return;
            }
            ArtifactData artifactData1 = new ArtifactData();

            artifactData1.Deserialize(new Json_Artifact()
            {
                iname = json.cur_skin
            });
            this.mSelectSkinData = artifactData1;
        }
Esempio n. 2
0
        public Json_Unit GetJson_Unit()
        {
            GameManager instance = MonoSingleton <GameManager> .Instance;

            if (Object.op_Equality((Object)instance, (Object)null))
            {
                return((Json_Unit)null);
            }
            if (instance.GetUnitParam(this.mUnitIName) == null)
            {
                return((Json_Unit)null);
            }
            Json_Unit jsonUnit = new Json_Unit();

            jsonUnit.iid    = this.mDraftUnitId;
            jsonUnit.iname  = this.mUnitIName;
            jsonUnit.rare   = this.mRare;
            jsonUnit.plus   = this.mAwake;
            jsonUnit.exp    = instance.MasterParam.GetUnitLevelExp(this.mLevel);
            jsonUnit.lv     = this.mLevel;
            jsonUnit.fav    = 0;
            jsonUnit.elem   = 0;
            jsonUnit.select = new Json_UnitSelectable();
            jsonUnit.jobs   = new Json_Job[this.mVersusDraftUnitJobs.Count];
            for (int index1 = 0; index1 < this.mVersusDraftUnitJobs.Count; ++index1)
            {
                JobParam jobParam = instance.GetJobParam(this.mVersusDraftUnitJobs[index1].mIName);
                if (jobParam != null && jobParam.ranks.Length > this.mVersusDraftUnitJobs[index1].mRank)
                {
                    JobRankParam rank    = jobParam.ranks[this.mVersusDraftUnitJobs[index1].mRank];
                    Json_Job     jsonJob = new Json_Job();
                    jsonJob.iid    = this.mDummyIID * 10L + (long)index1;
                    jsonJob.iname  = this.mVersusDraftUnitJobs[index1].mIName;
                    jsonJob.rank   = this.mVersusDraftUnitJobs[index1].mRank;
                    jsonJob.equips = new Json_Equip[JobRankParam.MAX_RANKUP_EQUIPS];
                    if (this.mVersusDraftUnitJobs[index1].mEquip)
                    {
                        for (int index2 = 0; index2 < JobRankParam.MAX_RANKUP_EQUIPS; ++index2)
                        {
                            jsonJob.equips[index2] = new Json_Equip()
                            {
                                iid   = jsonJob.iid * 10L + (long)index2,
                                iname = rank.equips[index2]
                            }
                        }
                        ;
                    }
                    jsonJob.select           = new Json_JobSelectable();
                    jsonJob.select.abils     = new long[5];
                    jsonJob.select.artifacts = new long[3];
                    List <Json_Ability> jsonAbilityList = new List <Json_Ability>();
                    List <string>       stringList      = new List <string>();
                    stringList.Add(jobParam.fixed_ability);
                    for (int index2 = 1; index2 <= jsonJob.rank; ++index2)
                    {
                        if (jobParam.ranks.Length >= index2 && jobParam.ranks[index2] != null && jobParam.ranks[index2].learnings != null)
                        {
                            for (int index3 = 0; index3 < jobParam.ranks[index2].learnings.Length; ++index3)
                            {
                                stringList.Add((string)jobParam.ranks[index2].learnings[index3]);
                            }
                        }
                    }
                    for (int index2 = 0; index2 < stringList.Count; ++index2)
                    {
                        Json_Ability jsonAbility = new Json_Ability();
                        jsonAbility.iid   = jsonJob.iid * 10L + (long)index2;
                        jsonAbility.iname = stringList[index2];
                        jsonAbility.exp   = 0;
                        jsonAbilityList.Add(jsonAbility);
                        if (this.mAbilities.ContainsKey(jsonAbility.iname))
                        {
                            jsonAbility.exp = this.mAbilities[jsonAbility.iname].mLevel - 1;
                            jsonAbility.iid = this.mAbilities[jsonAbility.iname].mIID;
                        }
                    }
                    jsonJob.abils = jsonAbilityList.ToArray();
                    if (index1 == this.mSelectJobIndex)
                    {
                        jsonUnit.select.job = jsonJob.iid;
                        jsonJob.artis       = new Json_Artifact[3];
                        for (int index2 = 0; index2 < this.mVersusDraftUnitArtifacts.Count; ++index2)
                        {
                            Json_Artifact jsonArtifact = new Json_Artifact();
                            jsonArtifact.iid                 = jsonJob.iid * 100L + (long)index2;
                            jsonArtifact.iname               = this.mVersusDraftUnitArtifacts[index2].mIName;
                            jsonArtifact.rare                = this.mVersusDraftUnitArtifacts[index2].mRare;
                            jsonArtifact.exp                 = ArtifactData.StaticCalcExpFromLevel(this.mVersusDraftUnitArtifacts[index2].mLevel);
                            jsonJob.artis[index2]            = jsonArtifact;
                            jsonJob.select.artifacts[index2] = jsonArtifact.iid;
                        }
                        int index3 = 0;
                        using (Dictionary <string, VersusDraftUnitAbility> .ValueCollection.Enumerator enumerator = this.mAbilities.Values.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                VersusDraftUnitAbility current = enumerator.Current;
                                jsonJob.select.abils[index3] = current.mIID;
                                ++index3;
                            }
                        }
                        jsonJob.cur_skin = this.mSkinIName;
                    }
                    jsonUnit.jobs[index1] = jsonJob;
                }
            }
            if (!string.IsNullOrEmpty(this.mMasterAbilityIName))
            {
                jsonUnit.abil       = new Json_MasterAbility();
                jsonUnit.abil.iid   = this.mDummyIID;
                jsonUnit.abil.iname = this.mMasterAbilityIName;
                jsonUnit.abil.exp   = 0;
            }
            ConceptCardParam conceptCardParam = instance.MasterParam.GetConceptCardParam(this.mConceptCardIName);

            if (conceptCardParam != null)
            {
                RarityParam rarityParam = instance.GetRarityParam(conceptCardParam.rare);
                jsonUnit.concept_card             = new JSON_ConceptCard();
                jsonUnit.concept_card.iname       = this.mConceptCardIName;
                jsonUnit.concept_card.iid         = this.mDummyIID;
                jsonUnit.concept_card.plus        = (int)rarityParam.ConceptCardAwakeCountMax;
                jsonUnit.concept_card.exp         = instance.MasterParam.GetConceptCardLevelExp(conceptCardParam.rare, this.mConceptCardLevel);
                jsonUnit.concept_card.trust       = 0;
                jsonUnit.concept_card.trust_bonus = 0;
                jsonUnit.concept_card.fav         = 0;
            }
            jsonUnit.doors = new Json_Tobira[this.mVersusDraftUnitDoors.Count];
            List <Json_Ability> jsonAbilityList1 = new List <Json_Ability>();

            for (int index1 = 0; index1 < this.mVersusDraftUnitDoors.Count; ++index1)
            {
                Json_Tobira jsonTobira = new Json_Tobira();
                jsonTobira.category    = (int)this.mVersusDraftUnitDoors[index1].mCategory;
                jsonTobira.lv          = this.mVersusDraftUnitDoors[index1].mLevel;
                jsonUnit.doors[index1] = jsonTobira;
                TobiraParam tobiraParam = instance.MasterParam.GetTobiraParam(this.mUnitIName, this.mVersusDraftUnitDoors[index1].mCategory);
                if (tobiraParam != null)
                {
                    for (int index2 = 0; index2 < tobiraParam.LeanAbilityParam.Length; ++index2)
                    {
                        TobiraLearnAbilityParam learnAbilityParam = tobiraParam.LeanAbilityParam[index2];
                        if (learnAbilityParam.Level <= jsonTobira.lv)
                        {
                            switch (learnAbilityParam.AbilityAddType)
                            {
                            case TobiraLearnAbilityParam.AddType.JobOverwrite:
                                for (int index3 = 0; index3 < jsonUnit.jobs.Length; ++index3)
                                {
                                    for (int index4 = 0; index4 < jsonUnit.jobs[index3].abils.Length; ++index4)
                                    {
                                        if (jsonUnit.jobs[index3].abils[index4].iname == learnAbilityParam.AbilityOverwrite)
                                        {
                                            jsonUnit.jobs[index3].abils[index4].iname = learnAbilityParam.AbilityIname;
                                            if (this.mAbilities.ContainsKey(learnAbilityParam.AbilityIname))
                                            {
                                                jsonUnit.jobs[index3].abils[index4].iid = this.mAbilities[learnAbilityParam.AbilityIname].mIID;
                                                jsonUnit.jobs[index3].abils[index4].exp = this.mAbilities[learnAbilityParam.AbilityIname].mLevel - 1;
                                            }
                                        }
                                    }
                                }
                                continue;

                            case TobiraLearnAbilityParam.AddType.MasterAdd:
                                jsonAbilityList1.Add(new Json_Ability()
                                {
                                    iid   = this.mDummyIID * 100L + (long)(index1 * 10) + (long)index2,
                                    iname = learnAbilityParam.AbilityIname,
                                    exp   = 0
                                });
                                continue;

                            default:
                                continue;
                            }
                        }
                    }
                }
            }
            jsonUnit.door_abils = jsonAbilityList1.ToArray();
            return(jsonUnit);
        }
    }