private void Start() { if (SaveFileMgr.PlayerInfo.achievents != null) { achievementNames = SaveFileMgr.PlayerInfo.achievents; textCount.text = SaveFileMgr.PlayerInfo.achievents.Count + "/" + GameModels.GetAchievement("Achievement").Achievement.Count; ShowAchievement(); } }
/// <summary> /// 显示成就界面 /// </summary> /// <param name="achievementName">获得的成就名字</param> public void ShowAchievement(string achievementName) { Debug.Log("显示AchievementPanel"); AudioMgr._instance.PlayFx("Tip"); Transform tChild = achievementPanel.transform.Find("Text"); tChild.GetComponent <Text>().text = achievementName; RectTransform rt = achievementPanel.GetComponent <RectTransform>(); DOTween.To(() => { return(rt.anchoredPosition); }, v => { rt.anchoredPosition = v; }, new Vector2(0, -80f), 0.3f) .OnComplete( () => { Invoke("ResetAchievementPanel", 2f); if (SaveFileMgr.PlayerInfo.achievents.Count == GameModels.GetAchievement("Achievement").Achievement.Count - 1) { Invoke("AddLastAchievement", 2f); } }); }
/// <summary> /// 通过名字查找玩家所获得的成就 /// 用于显示成就界面 /// </summary> /// <returns></returns> private List <AchievementModel> FindAchievementsByName() { List <AchievementModel> achievements = new List <AchievementModel>(); List <AchievementModel> achievementsTemp = GameModels.GetAchievement("Achievement").Achievement; ///achievementNames为暂时测试用的 ///正式的是从存档中查询 for (int i = 0; i < achievementNames.Count; i++) { AchievementModel model = new AchievementModel(); model = achievementsTemp.Find(delegate(AchievementModel a) { if (a.Name.StartsWith("宅")) { a.Name = string.Format(a.Name, SaveFileMgr.PlayerInfo.playerName); } return(a.Name == achievementNames[i]); }); achievements.Add(model); } return(achievements); }