private void SetUpMonsterUIAndInfo(int index) { MonsterDataWithUIDipslay monsterDataWithUIDipslay = monstersWithUI[index]; monsterDataWithUIDipslay.monsterUI.gameObject.SetActive(true); MonsterData monsterData = monsterDataWithUIDipslay.monsterData; monsterNameText.text = monsterData.monsterName; monsterMaxHealthText.text = monsterData.originalMaxHealth.ToString(); monsterAttackText.text = monsterData.originalAttack.ToString(); monsterMagicAttackText.text = monsterData.originalMagicAttack.ToString(); monsterArmorText.text = monsterData.originalArmor.ToString(); monsterMagicResistText.text = monsterData.originalMagicResist.ToString(); int attackTransformTo = TransformToBarFillAmout(monsterData.originalAttack, 1000); int magicAttackTramsformTo = TransformToBarFillAmout(monsterData.originalMagicAttack, 1000); int armorTransformto = TransformToBarFillAmout(monsterData.originalArmor, 1000); int magicResistTransformTo = TransformToBarFillAmout(monsterData.originalMagicResist, 1000); monsterAttackBar.InitHLHFillBar(1000, attackTransformTo); monsterMagicAttackBar.InitHLHFillBar(1000, magicAttackTramsformTo); monsterArmorBar.InitHLHFillBar(1000, armorTransformto); monsterMagicResistBar.InitHLHFillBar(1000, magicResistTransformTo); monsterGoldText.text = monsterData.rewardGold.ToString(); monsterExperienceText.text = monsterData.rewardExperience.ToString(); monsterCritText.text = string.Format("{0}%", (int)(monsterData.originalCrit * 100)); monsterDodgeText.text = string.Format("{0}%", (int)(monsterData.originalDodge * 100)); switch (monsterData.attackSpeedLevel) { case 0: monsterAttackSpeedText.text = "极快"; break; case 1: monsterAttackSpeedText.text = "快速"; break; case 2: monsterAttackSpeedText.text = "中速"; break; case 3: monsterAttackSpeedText.text = "慢速"; break; case 4: monsterAttackSpeedText.text = "极慢"; break; } switch (monsterData.mosnterEvaluate) { case 0: monsterEvaluateText.text = "普通"; break; case 1: monsterEvaluateText.text = "精英"; break; case 2: monsterEvaluateText.text = "Boss"; break; } monsterArmorDecreaseText.text = monsterData.originalArmorDecrease.ToString(); monsterMaigcResistDecreaseText.text = monsterData.originalMagicResistDecrease.ToString(); monsterStoryText.text = monsterData.monsterStory; }
public static void SaveMonstersData() { List <MonsterData> monsterDatas = new List <MonsterData>(); string monsterDataPath = "/Users/houlianghong/Desktop/MyGameData/monsters.csv"; MonsterModel[] monsterModels = LoadMonsterModels(monsterDataPath); for (int i = 0; i < monsterModels.Length; i++) { MonsterModel monsterModel = monsterModels[i]; MonsterData monsterData = new MonsterData(); monsterData.agentLevel = 1; monsterData.monsterId = monsterModel.monsterId; monsterData.monsterName = monsterModel.monsterName; monsterData.originalMaxHealth = monsterModel.maxHealth; //基础最大生命值 monsterData.originalAttack = monsterModel.attack; //基础物理伤害 monsterData.originalMagicAttack = monsterModel.magicAttack; //基础魔法伤害 monsterData.originalArmor = monsterModel.armor; //基础护甲 monsterData.originalMagicResist = monsterModel.magicResist; //基础抗性 monsterData.originalArmorDecrease = monsterModel.armorDecrease; //基础护甲穿刺 monsterData.originalMagicResistDecrease = monsterModel.magicResistDecrease; //基础抗性穿刺 monsterData.originalCrit = monsterModel.crit; //基础暴击率 monsterData.originalDodge = monsterModel.dodge; //基础闪避率 monsterData.originalCritHurtScaler = monsterModel.critHurtScaler; //基础暴击系数 monsterData.attackInterval = monsterModel.attackInterval; //攻击间隔 monsterData.rewardExperience = monsterModel.experience; //奖励的经验值 monsterData.rewardGold = monsterModel.gold; //奖励的金钱 monsterData.attackSpeedLevel = monsterModel.attackSpeedLevel; monsterData.mosnterEvaluate = monsterModel.evaluate; monsterData.monsterStory = monsterModel.story.Replace('+', ','); monsterDatas.Add(monsterData); } monsterDataPath = "/Users/houlianghong/Desktop/MyGameData/boss.csv"; monsterModels = LoadMonsterModels(monsterDataPath); for (int i = 0; i < monsterModels.Length; i++) { MonsterModel monsterModel = monsterModels[i]; MonsterData monsterData = new MonsterData(); monsterData.agentLevel = 1; monsterData.monsterId = monsterModel.monsterId; monsterData.monsterName = monsterModel.monsterName; monsterData.originalMaxHealth = monsterModel.maxHealth; //基础最大生命值 monsterData.originalAttack = monsterModel.attack; //基础物理伤害 monsterData.originalMagicAttack = monsterModel.magicAttack; //基础魔法伤害 monsterData.originalArmor = monsterModel.armor; //基础护甲 monsterData.originalMagicResist = monsterModel.magicResist; //基础抗性 monsterData.originalArmorDecrease = monsterModel.armorDecrease; //基础护甲穿刺 monsterData.originalMagicResistDecrease = monsterModel.magicResistDecrease; //基础抗性穿刺 monsterData.originalCrit = monsterModel.crit; //基础暴击率 monsterData.originalDodge = monsterModel.dodge; //基础闪避率 monsterData.originalCritHurtScaler = monsterModel.critHurtScaler; //基础暴击系数 monsterData.attackInterval = monsterModel.attackInterval; //攻击间隔 monsterData.rewardExperience = monsterModel.experience; //奖励的经验值 monsterData.rewardGold = monsterModel.gold; //奖励的金钱 monsterData.attackSpeedLevel = monsterModel.attackSpeedLevel; monsterData.mosnterEvaluate = monsterModel.evaluate; monsterData.monsterStory = monsterModel.story.Replace('+', ','); monsterDatas.Add(monsterData); } string targetPath = CommonData.originDataPath + "/MonstersData.json"; DataHandler.SaveInstanceListToFile <MonsterData>(monsterDatas, targetPath); Debug.Log("怪物数据存储完毕!"); }