少年修仙传客户端代码仓库
hch
2025-03-03 28785d6ddf9c08e49527ede9405c7b6c93c6ed32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
using Spine.Unity;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    public class CycleHallMissionCell : CellView
    {
        [SerializeField] ImageEx imgFinish;
        [SerializeField] TextEx txtTitle;
        [SerializeField] ButtonEx btnMissionHave;
        [SerializeField] List<ItemCell> missionItemCells = new List<ItemCell>();
        [SerializeField] List<ImageEx> missionHaves = new List<ImageEx>();
        [SerializeField] List<ImageEx> missionGreys = new List<ImageEx>();
        [SerializeField] List<RotationTween> missionTweens = new List<RotationTween>();
        [SerializeField] Slider buyCountGiftSlider;
        [SerializeField] Text buyCountGiftSliderText;
        [SerializeField] SkeletonGraphic skeletonGraphic;
        int roundType;
        int tabType;
        int awardIndex;
        CycleHallActModel model { get { return ModelCenter.Instance.GetModel<CycleHallActModel>(); } }
 
        private void OnEnable()
        {
            model.PlayAnimationSync += OnPlaySyncAnimation;
            for (int i = 0; i < missionTweens.Count; i++)
            {
                missionTweens[i].Stop();
                missionTweens[i].SetStartState();
            }
 
            var act = model.GetOperationInfo();
            if (act == null || !act.TryGetRoundInfoByIndex(roundType, awardIndex, out var awardInfo, out int listIndex) || awardInfo.AwardItemList == null)
                return;
            int state = model.GetAwardState(roundType, awardIndex);
            for (int i = 0; i < missionTweens.Count; i++)
            {
                if (i < awardInfo.AwardItemList.Length)
                {
                    if (state == 1)
                    {
                        missionTweens[i].Play();
                    }
                }
            }
 
        }
 
        private void OnDisable()
        {
            model.PlayAnimationSync -= OnPlaySyncAnimation;
        }
 
        public void Display(int awardIndex, CellView cellView)
        {
            this.awardIndex = awardIndex;
            roundType = cellView.info.Value.infoInt1;
            tabType = cellView.info.Value.infoInt2;
            btnMissionHave.enabled = false;
            var act = model.GetOperationInfo();
            if (act == null || !act.TryGetRound(roundType, out var round))
                return;
            if (!act.TryGetRoundInfoByIndex(roundType, awardIndex, out var awardInfo, out int listIndex) || awardInfo.AwardItemList == null)
                return;
            if (model.playerInfoDict == null || !model.playerInfoDict.TryGetValue((byte)roundType, out var playerInfo) || playerInfo == null)
                return;
            int state = model.GetAwardState(roundType, awardIndex);
            imgFinish.SetActive(state == 2);
            skeletonGraphic.SetActive(state == 1);
            txtTitle.text = Language.Get(StringUtility.Contact("CycleHallMissionTitle", "_", round.AwardType, "_", round.AwardTypeValue), awardInfo.NeedValue);
            buyCountGiftSlider.value = playerInfo.CurValue / (float)awardInfo.NeedValue;
            buyCountGiftSliderText.text = string.Format("{0}/{1}", playerInfo.CurValue, awardInfo.NeedValue);
            btnMissionHave.enabled = true;
            btnMissionHave.SetListener(() =>
            {
                if (state == 1)
                {
                    model.HaveAllMissionAward(roundType);
                }
            });
            for (int i = 0; i < missionItemCells.Count; i++)
            {
                var itemBaisc = missionItemCells[i];
                if (i < awardInfo.AwardItemList.Length)
                {
                    var itemInfo = awardInfo.AwardItemList[i];
                    itemBaisc.SetActive(true);
                    missionHaves[i].SetActive(state == 2);
                    missionGreys[i].SetActive(state == 2);
                    ItemCellModel cellModel = new ItemCellModel((int)itemInfo.ItemID, false, (ulong)itemInfo.ItemCount);
                    itemBaisc.Init(cellModel);
                    itemBaisc.button.AddListener(() =>
                    {
                        if (state == 1)
                        {
                            model.HaveAllMissionAward(roundType);
                        }
                        else
                        {
                            ItemTipUtility.Show((int)itemInfo.ItemID);
                        }
                    });
                }
                else
                {
                    itemBaisc.SetActive(false);
                    missionHaves[i].SetActive(false);
                    missionGreys[i].SetActive(false);
                }
            }
            OnPlaySyncAnimation();
        }
 
        public void HaveMissionAward()
        {
            var act = model.GetOperationInfo();
            if (act == null || !act.TryGetRoundInfoByIndex(roundType, awardIndex, out var awardInfo, out int listIndex) || awardInfo.AwardItemList == null)
                return;
            int state = model.GetAwardState(roundType, awardIndex);
            if (state != 1)
                return;
            model.SendGetAward(roundType, (int)awardInfo.NeedValue);
        }
 
        private void OnPlaySyncAnimation()
        {
            if (tabType != 1)
                return;
            for (int i = 0; i < missionTweens.Count; i++)
            {
                missionTweens[i].Stop();
                missionTweens[i].SetStartState();
            }
            var act = model.GetOperationInfo();
            if (act == null || !act.TryGetRoundInfoByIndex(roundType, awardIndex, out var awardInfo, out int listIndex) || awardInfo.AwardItemList == null)
                return;
            int state = model.GetAwardState(roundType, awardIndex);
            for (int i = 0; i < missionTweens.Count; i++)
            {
                if (missionTweens[i].isActiveAndEnabled && state == 1)
                {
                    missionTweens[i].Play();
                }
            }
        }
    }
}