少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
namespace vnxbqy.UI
{
 
    public class FairyTreasureCollect : MonoBehaviour
    {
        protected int treasureId = 0;
 
        [SerializeField] protected Text m_TreasureStory;
        [SerializeField] protected Button m_GotoGet;
        [SerializeField] protected Text m_GotoBtnText;
        [SerializeField] protected RectTransform m_ContainerFight;
        [SerializeField] protected Text m_FightPower;
        [SerializeField] protected RectTransform m_ContainerLocked;
        [SerializeField] protected Text m_LockedDescription;
        [SerializeField] protected PositionTween m_StoryTween;
 
        protected TreasureEffectModel treasureEffect
        {
            get
            {
                return ModelCenter.Instance.GetModel<TreasureEffectModel>();
            }
        }
 
        protected TreasureModel model
        {
            get
            {
                return ModelCenter.Instance.GetModel<TreasureModel>();
            }
        }
 
        protected Treasure treasure;
 
        protected virtual void Awake()
        {
        }
 
        protected virtual void GotoGet()
        {
 
        }
 
        public virtual void Display(int _treasureId, bool _tween = false)
        {
            treasureId = _treasureId;
 
            m_GotoGet.onClick.RemoveAllListeners();
            m_GotoGet.onClick.AddListener(GotoGet);
 
            if (!model.TryGetTreasure(_treasureId, out treasure))
            {
                return;
            }
 
            if (_tween && m_StoryTween.gameObject.activeInHierarchy)
            {
                m_StoryTween.Play();
            }
            else
            {
                m_StoryTween.SetEndState();
            }
 
            m_GotoGet.SetActive(treasure.state == TreasureState.Locked);
            m_ContainerFight.SetActive(treasure.state == TreasureState.Collected);
            m_ContainerLocked.SetActive(treasure.state == TreasureState.Locked);
 
            var config = TreasureConfig.Get(_treasureId);
            m_TreasureStory.text = config.Story;
 
            model.treasureStateChangeEvent += OnTreasureStateChange;
        }
 
        protected virtual void OnTreasureStateChange(int _id)
        {
            if (_id != treasureId)
            {
                return;
            }
            m_GotoGet.SetActive(treasure.state == TreasureState.Locked);
            m_ContainerFight.SetActive(treasure.state == TreasureState.Collected);
            m_ContainerLocked.SetActive(treasure.state == TreasureState.Locked);
        }
 
        public virtual void Dispose()
        {
            m_GotoGet.onClick.RemoveAllListeners();
            model.treasureStateChangeEvent -= OnTreasureStateChange;
        }
    }
}