internal override void ReadItem(XmlElement item) { LevelItem levelItem = new LevelItem(); levelItem.level = int.Parse(item.GetAttribute("level")); levelItem.exp = int.Parse(item.GetAttribute("exp")); levelItem.heart = int.Parse(item.GetAttribute("heart")); levelItem.star = int.Parse(item.GetAttribute("star")); levelItem.coin = int.Parse(item.GetAttribute("coin")); levelItem.props = ReadProps(item.GetAttribute("props")); dic.Add(levelItem.level, levelItem); }
public PlayerModelErr QuestComplate(out string storyID, string selectedID = "") { Messenger.Broadcast <CallMethodInfo>(ELocalMsgID.CallPlayerModel, new CallMethodInfo() { name = "QuestComplate", parameters = new object[] { "", selectedID }, }); storyID = ""; //检测完成任务条件 config.QuestItem questItem = playerData.GetQuest(); if (questItem.type == QuestItem.QuestType.Ending) { return(PlayerModelErr.NULL); } //完成过的任务无消耗 无经验 if (!playerData.complatedQuests.ContainsKey(questItem.id)) { if (playerData.starNum < questItem.requireStar) { return(PlayerModelErr.NOT_ENOUGH_STAR); } List <PropItem> needProps = questItem.requireItem; foreach (PropItem item in needProps) { PropItem haveItem = playerData.GetPropItem(item.id); int haveCount = haveItem == null ? 0 : haveItem.count; if (haveCount < item.count) { return(PlayerModelErr.NOT_ENOUGH_PROP); } } //扣除完成任务物品 playerData.starNum -= questItem.requireStar; foreach (PropItem item in needProps) { playerData.RemovePropItem(item.id, item.count); } playerData.complatedQuests.Add(questItem.id, 0); //获得奖励物品 foreach (PropItem item in questItem.prize) { bool isGet = Random.Range(0, 100) < item.rate; if (isGet) { playerData.AddPropItem(item.id, item.count); } } //获得经验值 playerData.totalExp += questItem.exp; playerData.currExp += questItem.exp; //判断升级 config.LevelItem levelItem = GameMainManager.Instance.configManager.levelConfig.GetItem(playerData.level); while (levelItem != null && playerData.currExp >= levelItem.exp) { playerData.level++; playerData.currExp -= levelItem.exp; levelItem = GameMainManager.Instance.configManager.levelConfig.GetItem(playerData.level); } } //更新下个任务 qy.config.Ability ability = new config.Ability(); if (questItem.type == config.QuestItem.QuestType.Main) { playerData.nextQuestId = questItem.gotoId; storyID = questItem.storyID; } else if (questItem.type == config.QuestItem.QuestType.Branch) { foreach (SelectItem item in questItem.selectList) { if (item.id == selectedID) { playerData.nextQuestId = item.toQuestId; storyID = item.storyID; ability = item.ability; string selectID = questItem.id + "_" + item.id; if (!playerData.selectedItems.ContainsKey(selectID)) { playerData.selectedItems.Add(selectID, 0); } break; } } } else if (questItem.type == config.QuestItem.QuestType.Important) { if (playerData.survival < questItem.endingPoint.survival) { //进入分支任务 playerData.nextQuestId = questItem.endingPoint.questID; storyID = questItem.endingPoint.storyID; } else { //进入普通任务 playerData.nextQuestId = questItem.gotoId; storyID = questItem.storyID; } } if (string.IsNullOrEmpty(playerData.nextQuestId)) { return(PlayerModelErr.QUEST_ID_ERROR); } //增加属性值 config.Ability addAbilty = config.Ability.GetAddAbilty(playerData.ability, ability); playerData.ability += addAbilty; GameMainManager.Instance.netManager.ComplateQuestId(playerData.questId, addAbilty, (ret, res) => { }); playerData.questId = playerData.nextQuestId; //标记角色状态 config.QuestItem nextQuest = playerData.GetQuest(); if (nextQuest.type == config.QuestItem.QuestType.Ending) { GameMainManager.Instance.netManager.ComplateQuestId(nextQuest.id, new config.Ability(), (ret, res) => {}); GameMainManager.Instance.netManager.EndingRole(nextQuest.endingType, (ret, res) => { }); switch (nextQuest.endingType) { case 1: //死亡 playerData.SetRoleState(playerData.role.id, PlayerData.RoleState.Dide); break; case 2: //通关 playerData.SetRoleState(playerData.role.id, PlayerData.RoleState.Pass); break; } } playerData.dirty = true; SaveData(); Messenger.Broadcast(ELocalMsgID.RefreshBaseData); if (questItem.chapter != nextQuest.chapter) { Messenger.Broadcast <string>(ELocalMsgID.LoadScene, "Film"); } return(PlayerModelErr.NULL); }
private void UpdatePanel() { questItem = playerdata.GetQuest(); var sp = March.Core.ResourceManager.ResourceManager.instance.Load <Sprite>(Configure.StoryPerson, playerdata.role.headIcon); roleHeadImage.sprite = sp; GameUtils.Scaling(roleHeadImage.transform as RectTransform, new Vector2(sp.texture.width, sp.texture.height)); //string headUrl = FilePathTools.GetPersonHeadPath(playerdata.role.headIcon); //AssetsManager.Instance.LoadAssetAsync<Sprite>(headUrl, (sp) => //{ // roleHeadImage.sprite = sp; // GameUtils.Scaling(roleHeadImage.transform as RectTransform,new Vector2(sp.texture.width,sp.texture.height)); //}); roleNameText.text = playerdata.role.name; levelText.text = playerdata.level.ToString(); UpdateAbility(playerdata.ability); qy.config.LevelItem levelItem = GameMainManager.Instance.configManager.levelConfig.GetItem(playerdata.level); if (levelItem != null) { float expProgress = playerdata.currExp / (float)levelItem.exp; levelSlider.value = expProgress; levelProgressText.text = (expProgress * 100).ToString("f0") + "%"; } else { levelSlider.value = 0; levelProgressText.text = "0%"; } if (!string.IsNullOrEmpty(questItem.bg)) { taskImg.gameObject.SetActive(true); var sprite = March.Core.ResourceManager.ResourceManager.instance.Load <Sprite>(Configure.StoryBackground, questItem.bg); taskImg.sprite = sprite; GameUtils.ScalingFixedWithHeight(taskImg.transform as RectTransform, new Vector2(sprite.texture.width, sprite.texture.height)); //string taskBGUrl = FilePathTools.GetStorySpritePath(questItem.bg); //AssetsManager.Instance.LoadAssetAsync<Sprite>(taskBGUrl, (sp) => //{ // taskImg.sprite = sp; // GameUtils.ScalingFixedWithHeight(taskImg.transform as RectTransform, new Vector2(sp.texture.width, sp.texture.height)); //}); } else { taskImg.gameObject.SetActive(false); } taskTitle.text = questItem.sectionName; taskDesText.text = questItem.sectionDes; SetMainTask(); }