private void UpdateUI(qy.config.QuestItem quest) { //string headUrl = FilePathTools.GetStorySpritePath(quest.bg); //AssetsManager.Instance.LoadAssetAsync<Sprite>(headUrl, (sp) => //{ // bgImg.sprite = sp; //}); if (!string.IsNullOrEmpty(quest.bg)) { var sp = March.Core.ResourceManager.ResourceManager.instance.Load <Sprite>(Configure.StoryBackground, quest.bg); bgImg.sprite = sp; } if (quest.endingType == 1) { titleText.text = "当前角色光荣牺牲"; resurrectionBtn.gameObject.SetActive(true); } else { titleText.text = "恭喜通关本角色"; resurrectionBtn.gameObject.SetActive(false); } endingDesText.text = quest.sectionDes; }
void Start() { story = transform.Find("Story").gameObject; storyText = transform.Find("Story/Text").GetComponent <Text>(); storyHead = transform.Find("StoryHead").gameObject; storyHeadText = transform.Find("StoryHead/Text").GetComponent <Text>(); background = GetComponent <Image>(); var clickButton = transform.Find("ClickButton").GetComponent <Button>(); clickButton.onClick.AddListener(PlayStory); var skipButton = transform.Find("SkipButton").GetComponent <Button>(); skipButton.onClick.AddListener(SkipStory); spriteMap = March.Core.ResourceManager.ResourceManager.instance.LoadAll <Sprite>(Configure.FilmBackgroundPath) .ToDictionary(v => v.name, v => v); qy.config.QuestItem quest = GameMainManager.Instance.playerData.GetQuest(); int chapter = quest != null?quest.chapter:1; storyItem = GameMainManager.Instance.configManager.StoryHeadConfig.GetFirstWithChapter(chapter); PlayStoryHead(); }
internal override void ReadItem(XmlElement item) { QuestItem quest = new QuestItem(); quest.id = item.GetAttribute("id"); quest.bg = item.GetAttribute("bg"); quest.type = (QuestItem.QuestType) int.Parse(item.GetAttribute("type")); quest.sectionName = GetLanguage(item.GetAttribute("sectionName")); quest.sectionDes = GetLanguage(item.GetAttribute("sectionDes")); quest.chapter = int.Parse(item.GetAttribute("chapter")); string exp = item.GetAttribute("exp"); quest.exp = String.IsNullOrEmpty(exp) ? 0 : int.Parse(exp); string star = item.GetAttribute("requireStar"); quest.requireStar = String.IsNullOrEmpty(star) ? 0 : int.Parse(star); string endingType = item.GetAttribute("endingType"); quest.endingType = String.IsNullOrEmpty(endingType)?0:int.Parse(endingType); quest.storyID = item.GetAttribute("storyId"); quest.gotoId = item.GetAttribute("gotoId"); quest.requireItem = ReadrequireItem(item.GetAttribute("requireItem")); quest.prize = ReadrequireItem(item.GetAttribute("prize")); quest.selectList = ReadSelectList(item.GetAttribute("selectList")); quest.endingPoint = ReadEnding(item.GetAttribute("endingPoint")); dic.Add(quest.id, quest); }
public void OnClickHandle() { if (isMoveing) { return; } if (DOTween.TotalPlayingTweens() > 0) { DOTween.CompleteAll(); DOTween.KillAll(); return; } qy.config.StoryItem story = curDialogue.next; if (story != null) { ShowStory(story); } else { qy.config.QuestItem nextQuest = qy.GameMainManager.Instance.playerData.GetQuest(); if (nextQuest.type == qy.config.QuestItem.QuestType.Ending) { qy.GameMainManager.Instance.uiManager.OpenWindow(qy.ui.UISettings.UIWindowID.UIEndingWindow, nextQuest); } else { qy.GameMainManager.Instance.uiManager.OpenWindow(qy.ui.UISettings.UIWindowID.UITaskWindow, qy.GameMainManager.Instance.playerData); } qy.GameMainManager.Instance.weatherManager.StopAll(); OnClickClose(); } }
protected override void StartShowWindow(object[] data) { this.data = data[0] as qy.config.QuestItem; if (this.data.type == qy.config.QuestItem.QuestType.Ending) { UpdateUI(this.data); } }
private void TrySelectRole() { config.QuestItem quest = GameMainManager.Instance.playerData.GetQuest(); PlayerData.RoleState state = GameMainManager.Instance.playerData.roleState; if (GameMainManager.Instance.playerData.role == null || quest == null || (quest != null && state == PlayerData.RoleState.Pass)) { GameMainManager.Instance.uiManager.OpenWindow(ui.UISettings.UIWindowID.UIRoleWindow); } else { GameMainManager.Instance.uiManager.OpenWindow(qy.ui.UISettings.UIWindowID.UIMainSceneWindow); if (GameMainManager.Instance.playerData.roleState == PlayerData.RoleState.Dide) { GameMainManager.Instance.uiManager.OpenWindow(qy.ui.UISettings.UIWindowID.UIEndingWindow, quest); } } }
public PlayerModelErr QuestComplateCondition() { config.QuestItem questItem = playerData.GetQuest(); 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); } } } return(PlayerModelErr.NULL); }
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(); }