public void BaseChangSave() { int id = -1; for (int i = 0; i < HeroData.heroData.Count; i++) { if (HeroData.heroData[i + 1].ID == heroMessage.HeroID) { HeroData.heroData[i + 1].Vitality = int.Parse(_Test_Base_Vitality.text); HeroData.heroData[i + 1].Attack = int.Parse(_Test_Base_ATK.text); HeroData.heroData[i + 1].AttackSpeed = int.Parse(_Test_Base_Speed.text); HeroData.heroData[i + 1].Skill = int.Parse(_Test_Base_Skill.text); HeroData.heroData[i + 1].HitRate = int.Parse(_Test_Base_HitRate.text); HeroData.heroData[i + 1].Dodge = int.Parse(_Test_Base_Dodge.text); HeroData.heroData[i + 1].CriticalStrike = int.Parse(_Test_Base_Crit.text); HeroData.heroData[i + 1].Tenacity = int.Parse(_Test_Base_Tenacity.text); HeroData.heroData[i + 1].Defense = int.Parse(_Test_Base_Defense.text); HeroData.heroData[i + 1].ActGrow = int.Parse(_Test_Base_AttacksGrow.text); HeroData.heroData[i + 1].VitalityGrow = int.Parse(_Test_Base_VitalityGrow.text); HeroData.heroData[i + 1].ActSpeedGrow = int.Parse(_Test_Base_SpeedGrow.text); HeroData.heroData[i + 1].TowerActFrequency = int.Parse(_Test_Base_TowerATKFrequency.text); id = i + 1; break; } } if (DataManage.HeroDataSave(HeroData.heroData, id)) { WindowControl.SetConsole("保存成功"); } else { WindowControl.SetConsole("保存失败"); } }
public void Save(int ID) { _heroID = transform.Find("Viewport/Content/obj" + ID + "/HeroID").GetComponent <Text>(); _heroQuality = transform.Find("Viewport/Content/obj" + ID + "/HeroQuality").GetComponent <Dropdown>(); _heroType = transform.Find("Viewport/Content/obj" + ID + "/HeroType").GetComponent <Dropdown>(); _ATKType = transform.Find("Viewport/Content/obj" + ID + "/ATKType").GetComponent <Dropdown>(); _heroStarID = transform.Find("Viewport/Content/obj" + ID + "/HeroStarID").GetComponent <Text>(); _heroFighting = transform.Find("Viewport/Content/obj" + ID + "/HeroFighting").GetComponent <Text>(); _heroExponentBit = transform.Find("Viewport/Content/obj" + ID + "/HeroExponentBit").GetComponent <Text>(); _heroLevel = transform.Find("Viewport/Content/obj" + ID + "/HeroLevel").GetComponent <Text>(); _heroVitality = transform.Find("Viewport/Content/obj" + ID + "/HeroVitality").GetComponent <Text>(); _heroAttack = transform.Find("Viewport/Content/obj" + ID + "/HeroAttack").GetComponent <Text>(); _heroAttackSpeed = transform.Find("Viewport/Content/obj" + ID + "/HeroAttackSpeed").GetComponent <Text>(); _heroSkill = transform.Find("Viewport/Content/obj" + ID + "/HeroSkill").GetComponent <Text>(); _heroHitRate = transform.Find("Viewport/Content/obj" + ID + "/HeroHitRate").GetComponent <Text>(); _heroDodge = transform.Find("Viewport/Content/obj" + ID + "/HeroDodge").GetComponent <Text>(); _heroCriticalStrike = transform.Find("Viewport/Content/obj" + ID + "/HeroCriticalStrike").GetComponent <Text>(); _heroTenacity = transform.Find("Viewport/Content/obj" + ID + "/HeroTenacity").GetComponent <Text>(); _heroPierce = transform.Find("Viewport/Content/obj" + ID + "/HeroPierce").GetComponent <Text>(); _heroDefense = transform.Find("Viewport/Content/obj" + ID + "/HeroDefense").GetComponent <Text>(); _heroActGrow = transform.Find("Viewport/Content/obj" + ID + "/HeroActGrow").GetComponent <Text>(); _heroVitalityGrow = transform.Find("Viewport/Content/obj" + ID + "/HeroVitalityGrow").GetComponent <Text>(); _heroActSpeedGrow = transform.Find("Viewport/Content/obj" + ID + "/HeroActSpeedGrow").GetComponent <Text>(); _heroGrowCoefficient = transform.Find("Viewport/Content/obj" + ID + "/HeroGrowCoefficient").GetComponent <Text>(); _heroActBreakLevel = transform.Find("Viewport/Content/obj" + ID + "/HeroActBreakLevel").GetComponent <Text>(); _heroVitalityBreakLevel = transform.Find("Viewport/Content/obj" + ID + "/HeroVitalityBreakLevel").GetComponent <Text>(); _heroBaseStrikeDamage = transform.Find("Viewport/Content/obj" + ID + "/HeroBaseStrikeDamage").GetComponent <Text>(); _heroTowerActFrequency = transform.Find("Viewport/Content/obj" + ID + "/HeroTowerActFrequency").GetComponent <Text>(); _heroSkillConfigID = transform.Find("Viewport/Content/obj" + ID + "/HeroSkillConfigID").GetComponent <Text>(); _heroExclusiveEquipID = transform.Find("Viewport/Content/obj" + ID + "/HeroExclusiveEquipID").GetComponent <Text>(); _heroByConfigID1 = transform.Find("Viewport/Content/obj" + ID + "/HeroByConfigID1").GetComponent <Text>(); _heroByConfigID2 = transform.Find("Viewport/Content/obj" + ID + "/HeroByConfigID2").GetComponent <Text>(); _heroByConfigID3 = transform.Find("Viewport/Content/obj" + ID + "/HeroByConfigID3").GetComponent <Text>(); _heroByConfigID4 = transform.Find("Viewport/Content/obj" + ID + "/HeroByConfigID4").GetComponent <Text>(); _heroMessageConfigID = transform.Find("Viewport/Content/obj" + ID + "/HeroMessageConfigID").GetComponent <Text>(); try { heroData[ID].ID = int.Parse(_heroID.text); switch (_heroQuality.value) { case 0: heroData[ID].Quality = "E"; break; case 1: heroData[ID].Quality = "N"; break; case 2: heroData[ID].Quality = "R"; break; case 3: heroData[ID].Quality = "SR"; break; case 4: heroData[ID].Quality = "SSR"; break; case 5: heroData[ID].Quality = "UR"; break; default: print("选择的品质" + _heroQuality.value); break; } switch (_heroType.value) { case 0: heroData[ID].Type = C_HeroData.HeroType.warrior; break; case 1: heroData[ID].Type = C_HeroData.HeroType.tank; break; case 2: heroData[ID].Type = C_HeroData.HeroType.assassin; break; case 3: heroData[ID].Type = C_HeroData.HeroType.mage; break; case 4: heroData[ID].Type = C_HeroData.HeroType.shooter; break; } heroData[ID].ATKType = _ATKType.value; heroData[ID].StarID = int.Parse(_heroStarID.text); heroData[ID].Fighting = int.Parse(_heroFighting.text); heroData[ID].ExponentBit = int.Parse(_heroExponentBit.text); heroData[ID].Level = int.Parse(_heroLevel.text); heroData[ID].Vitality = int.Parse(_heroVitality.text); heroData[ID].Attack = int.Parse(_heroAttack.text); heroData[ID].AttackSpeed = int.Parse(_heroAttackSpeed.text); heroData[ID].Skill = int.Parse(_heroSkill.text); heroData[ID].HitRate = int.Parse(_heroHitRate.text); heroData[ID].Dodge = int.Parse(_heroDodge.text); heroData[ID].CriticalStrike = int.Parse(_heroCriticalStrike.text); heroData[ID].Tenacity = int.Parse(_heroTenacity.text); heroData[ID].Pierce = int.Parse(_heroPierce.text); heroData[ID].Defense = int.Parse(_heroDefense.text); heroData[ID].ActGrow = int.Parse(_heroActGrow.text); heroData[ID].VitalityGrow = int.Parse(_heroVitalityGrow.text); heroData[ID].ActSpeedGrow = int.Parse(_heroActSpeedGrow.text); heroData[ID].GrowCoefficient = int.Parse(_heroGrowCoefficient.text); heroData[ID].ActBreakLevel = int.Parse(_heroActBreakLevel.text); heroData[ID].VitalityBreakLevel = int.Parse(_heroVitalityBreakLevel.text); heroData[ID].BaseStrikeDamage = int.Parse(_heroBaseStrikeDamage.text); heroData[ID].TowerActFrequency = int.Parse(_heroTowerActFrequency.text); heroData[ID].SkillConfigID = int.Parse(_heroSkillConfigID.text); heroData[ID].ExclusiveEquipID = int.Parse(_heroExclusiveEquipID.text); heroData[ID].ByConfigID1 = int.Parse(_heroByConfigID1.text); heroData[ID].ByConfigID2 = int.Parse(_heroByConfigID2.text); heroData[ID].ByConfigID3 = int.Parse(_heroByConfigID3.text); heroData[ID].ByConfigID4 = int.Parse(_heroByConfigID4.text); heroData[ID].MessageConfigID = int.Parse(_heroMessageConfigID.text); } catch (Exception ex) { // 错误处理代码 WindowControl.SetConsole("保存失败,你填写的数据类型不对,详细:" + ex.Message); //transform.parent.Find("Console/Text").GetComponent<Text>().text = "保存失败,你填写的数据类型不对,详细:"+ex.Message+"--------------时间:"+DateTime.Now.ToString(); return; } if (DataManage.HeroDataSave(heroData, ID)) { heroData[ID].IsJson = true; } //transform.parent.Find("Console/Text").GetComponent<Text>().text = "保存成功-----------------时间"+DateTime.Now.ToString(); }