LogicProject/System/Achievement/AchievementTipWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
LogicProject/System/Achievement/ILAchievementModel.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
System/LoopAct/CycleHall/CycleHallAchievementTipWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
System/LoopAct/CycleHall/CycleHallAchievementTipWin.cs.meta | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
System/LoopAct/CycleHall/CycleHallActModel.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
LogicProject/System/Achievement/AchievementTipWin.cs
@@ -1,68 +1,151 @@ //-------------------------------------------------------- // [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(); } } } } LogicProject/System/Achievement/ILAchievementModel.cs
@@ -91,7 +91,7 @@ if (!idList.Contains(succID)) return; newSuccID = succID; WindowCenter.Instance.OpenIL<AchievementTipWin>(); WindowCenter.Instance.Open<AchievementTipWin>(); } System/LoopAct/CycleHall/CycleHallAchievementTipWin.cs
New file @@ -0,0 +1,151 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace vnxbqy.UI { public class CycleHallAchievementTipWin : 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; // 挂载往上移动位置的游戏物体 int roundType; int awardType; int awardTypeValue; int awardIndex; float openTime; CycleHallActModel model { get { return ModelCenter.Instance.GetModelEx<CycleHallActModel>(); } } private enum MoveState { MovingDown, Staying, MovingUp, Finished } MoveState currentState; #region Built-in protected override void AddListeners() { awardBtn.SetListener(() => { //WindowCenter.Instance.Close<CycleHallAchievementTipWin>(); }); } protected override void BindController() { } protected override void OnAfterClose() { StopAllCoroutines(); } protected override void OnAfterOpen() { ResetAnimation(); } protected override void OnPreClose() { model.UpdateNewAwardHave -= OnUpdateNewAwardHave; } protected override void OnPreOpen() { model.UpdateNewAwardHave += OnUpdateNewAwardHave; 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<CycleHallAchievementTipWin>(); } private void Display() { roundType = model.newRoundType; awardType = model.newAwardType; awardTypeValue = model.newAwardTypeValue; awardIndex = model.newAwardIndex; var act = model.GetOperationInfo(); if (act == null || !act.TryGetRoundInfoByIndex(roundType, awardIndex, out var award, out int listIndex) || award.AwardItemList == null) return; awardtip.text = Language.Get(StringUtility.Contact("CycleHallMissionTitle", "_", awardType, "_", awardTypeValue), award.NeedValue); ; for (int i = 0; i < itemCells.Count; i++) { var itemBaisc = itemCells[i]; if (i < award.AwardItemList.Length) { var itemInfo = award.AwardItemList[i]; itemBaisc.SetActive(true); ItemCellModel cellModel = new ItemCellModel((int)itemInfo.ItemID, false, (ulong)itemInfo.ItemCount); itemBaisc.Init(cellModel); } else { itemBaisc.SetActive(false); } } } private void OnUpdateNewAwardHave() { ResetAnimation(); } 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(); } } } System/LoopAct/CycleHall/CycleHallAchievementTipWin.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: 4fd19fbb768061d4491c5284c9421cc4 MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: System/LoopAct/CycleHall/CycleHallActModel.cs
@@ -54,12 +54,24 @@ //<轮回类型,功能ID> public Dictionary<int, int> funcIdDict = new Dictionary<int, int>(); // <轮回类型,上次的 CurRound> private Dictionary<int, int> lastCurRoundDict = new Dictionary<int, int>(); // <轮回类型,上次的 CurValue> private Dictionary<int, int> lastCurValueDict = new Dictionary<int, int>(); public const int activityType = (int)OpenServerActivityCenter.ActivityType.AT_Activity2; public const int activityID = (int)NewDayActivityID.CycleHallAct; public static Operation operaType = Operation.default47; public int actNum = 10; //对应界面 public event Action UpdatePlayerInfoAction; public int newRoundType; public int newAwardType; public int newAwardTypeValue; public int newAwardIndex; public event Action UpdateNewAwardHave; StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } } public override void Init() @@ -125,6 +137,8 @@ public void OnBeforePlayerDataInitialize() { playerInfoDict.Clear(); lastCurRoundDict.Clear(); lastCurValueDict.Clear(); } public void OnPlayerLoginOk() @@ -308,6 +322,47 @@ } } public void CheckNewAwardHave(int roundType, int curRound, int curValue) { if (lastCurRoundDict.ContainsKey(roundType) && lastCurValueDict.ContainsKey(roundType)) { int lastCurRound = lastCurRoundDict[roundType]; int lastCurValue = lastCurValueDict[roundType]; if (lastCurRound < curRound) { lastCurValueDict[roundType] = 0; } lastCurValue = lastCurValueDict[roundType]; if (lastCurValue < curValue) { var act = GetOperationInfo(); if (act != null && act.TryGetRound(roundType, out var round) && round.AwardList != null) { for (int i = 0; i < round.AwardList.Length; i++) { var Award = round.AwardList[i]; int state = GetAwardState(roundType, Award.AwardIndex); if (Award.NeedValue > lastCurValue && Award.NeedValue <= curValue && state == 1) { newRoundType = roundType; newAwardType = round.AwardType; newAwardTypeValue = (int)round.AwardTypeValue; newAwardIndex = Award.AwardIndex; if (!DTC0403_tagPlayerLoginLoadOK.neverLoginOk && !WindowCenter.Instance.IsOpen<CycleHallAchievementTipWin>()) { WindowCenter.Instance.Open<CycleHallAchievementTipWin>(); } UpdateNewAwardHave?.Invoke(); } } } } } lastCurRoundDict[roundType] = curRound; lastCurValueDict[roundType] = curValue; } public void UpdatePlayerInfo(HAA89_tagMCActLunhuidianPlayerInfo netPack) { if (actNum != netPack.ActNum) @@ -318,6 +373,7 @@ playerInfoDict[netPack.RoundType].CurRound = netPack.CurRound; playerInfoDict[netPack.RoundType].CurValue = netPack.CurValue; playerInfoDict[netPack.RoundType].AwardRecord = netPack.AwardRecord; CheckNewAwardHave(netPack.RoundType, (int)netPack.CurRound, (int)netPack.CurValue); UpdatePlayerInfoAction?.Invoke(); UpdateRedpoint(); }