| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: 第二世界
|
| | | // [ Date ]: Tuesday, June 11, 2019
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using LitJson;
|
| | | using vnxbqy.UI;
|
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using System.Linq;
|
| | | using System.Collections.Generic;
|
| | | using UnityEngine;
|
| | | using UnityEngine.UI;
|
| | |
|
| | |
|
| | |
|
| | | public class AchievementTipWin : ILWindow
|
| | | namespace vnxbqy.UI
|
| | | {
|
| | | ButtonEx awardBtn;
|
| | | Text awardtip;
|
| | |
|
| | | float openTime;
|
| | | #region Built-in
|
| | | protected override void BindController()
|
| | | public class AchievementTipWin : Window
|
| | | {
|
| | | [SerializeField] RectTransform winShow;
|
| | | [SerializeField] ButtonEx awardBtn;
|
| | | [SerializeField] Text awardtip;
|
| | | [SerializeField] List<ItemCell> itemCells = new List<ItemCell>();
|
| | | [SerializeField] PositionTween positionTween;
|
| | | [SerializeField] float waitTime = 1.0f;
|
| | | [SerializeField] float moveDurationTime = 1.0f; // 移动持续时间
|
| | | [SerializeField] RectTransform startPosObject; // 挂载初始位置的游戏物体
|
| | | [SerializeField] RectTransform downPosObject; // 挂载往下移动位置的游戏物体
|
| | | [SerializeField] RectTransform upPosObject; // 挂载往上移动位置的游戏物体
|
| | | float openTime;
|
| | | AchievementModel model { get { return ModelCenter.Instance.GetModelEx<AchievementModel>(); } }
|
| | |
|
| | | awardBtn = proxy.GetWidgtEx<ButtonEx>("Button");
|
| | | awardtip = proxy.GetWidgtEx<Text>("TextEx");
|
| | |
|
| | | }
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | | ILAchievementModel.Instance.OnNewSuccAward += OnNewSuccAward;
|
| | | Display();
|
| | | }
|
| | |
|
| | |
|
| | | protected override void OnPreClose()
|
| | | {
|
| | | ILAchievementModel.Instance.OnNewSuccAward -= OnNewSuccAward;
|
| | | }
|
| | |
|
| | |
|
| | | #endregion
|
| | |
|
| | | void OnNewSuccAward()
|
| | | {
|
| | | Display();
|
| | | }
|
| | |
|
| | | void Display()
|
| | | {
|
| | | openTime = Time.time;
|
| | | awardtip.text = AchievementModel.ParseAchievementDescription(ILAchievementModel.Instance.newSuccID);
|
| | | awardBtn.SetListener(() => {
|
| | | ILAchievementModel.Instance.GetAchievementReward(ILAchievementModel.Instance.newSuccID);
|
| | | WindowCenter.Instance.CloseIL<AchievementTipWin>();
|
| | | });
|
| | | }
|
| | |
|
| | | protected override void LateUpdate()
|
| | | {
|
| | | if (Time.time - openTime > 4)
|
| | | private enum MoveState
|
| | | {
|
| | | WindowCenter.Instance.CloseIL<AchievementTipWin>();
|
| | | MovingDown,
|
| | | Staying,
|
| | | MovingUp,
|
| | | Finished
|
| | | }
|
| | |
|
| | | MoveState currentState;
|
| | |
|
| | | #region Built-in
|
| | |
|
| | | protected override void AddListeners()
|
| | | {
|
| | | awardBtn.SetListener(() =>
|
| | | {
|
| | | ILAchievementModel.Instance.GetAchievementReward(ILAchievementModel.Instance.newSuccID);
|
| | | WindowCenter.Instance.Close<AchievementTipWin>();
|
| | | });
|
| | | }
|
| | |
|
| | | protected override void BindController()
|
| | | {
|
| | | }
|
| | |
|
| | | protected override void OnAfterClose()
|
| | | {
|
| | | StopAllCoroutines();
|
| | | }
|
| | |
|
| | | protected override void OnAfterOpen()
|
| | | {
|
| | | ResetAnimation();
|
| | | }
|
| | |
|
| | | protected override void OnPreClose()
|
| | | {
|
| | | ILAchievementModel.Instance.OnNewSuccAward -= OnNewSuccAward;
|
| | | |
| | | }
|
| | |
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | | ILAchievementModel.Instance.OnNewSuccAward += OnNewSuccAward;
|
| | | winShow.anchoredPosition = startPosObject.anchoredPosition;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | protected override void LateUpdate()
|
| | | {
|
| | | base.LateUpdate();
|
| | |
|
| | | if (currentState == MoveState.Staying)
|
| | | {
|
| | | if (Time.time - openTime > waitTime)
|
| | | {
|
| | | currentState = MoveState.MovingUp;
|
| | | positionTween.reversal = true;
|
| | | positionTween.from = downPosObject.anchoredPosition;
|
| | | positionTween.to = upPosObject.anchoredPosition;
|
| | | positionTween.duration = moveDurationTime;
|
| | | positionTween.Play(OnMoveUpComplete);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnMoveDownComplete()
|
| | | {
|
| | | currentState = MoveState.Staying;
|
| | | openTime = Time.time;
|
| | | }
|
| | |
|
| | | private void OnMoveUpComplete()
|
| | | {
|
| | | currentState = MoveState.Finished;
|
| | | WindowCenter.Instance.Close<AchievementTipWin>();
|
| | | }
|
| | |
|
| | | private void Display()
|
| | | {
|
| | | awardtip.text = AchievementModel.ParseAchievementDescription(ILAchievementModel.Instance.newSuccID);
|
| | |
|
| | | DisplayItemCell();
|
| | | }
|
| | |
|
| | | private void OnNewSuccAward()
|
| | | {
|
| | | ResetAnimation();
|
| | | }
|
| | |
|
| | | private void DisplayItemCell()
|
| | | {
|
| | | int successID = ILAchievementModel.Instance.newSuccID;
|
| | | Achievement achievement;
|
| | | model.TryGetAchievement(successID, out achievement);
|
| | | if (achievement != null)
|
| | | {
|
| | | var config = SuccessConfig.Get(successID);
|
| | | for (int i = 0; i < itemCells.Count; i++)
|
| | | {
|
| | | if (i < achievement.rewardItem.Length)
|
| | | {
|
| | | itemCells[i].SetActive(true);
|
| | | var _item = achievement.rewardItem[i];
|
| | | ItemCellModel _ItemData = new ItemCellModel(_item.id, true, (ulong)_item.count);
|
| | | itemCells[i].Init(_ItemData);
|
| | | }
|
| | | else
|
| | | {
|
| | | itemCells[i].SetActive(false);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void ResetAnimation()
|
| | | {
|
| | | currentState = MoveState.MovingDown;
|
| | | openTime = Time.time;
|
| | | winShow.anchoredPosition = startPosObject.anchoredPosition;
|
| | | positionTween.reversal = false;
|
| | | positionTween.from = startPosObject.anchoredPosition;
|
| | | positionTween.to = downPosObject.anchoredPosition;
|
| | | positionTween.duration = moveDurationTime;
|
| | | positionTween.Play(OnMoveDownComplete);
|
| | | Display();
|
| | | }
|
| | | }
|
| | | }
|
| | | } |