少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
150
151
152
153
154
155
156
157
158
159
160
161
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, November 27, 2017
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
//战斗力增加
namespace Snxxz.UI {
 
    public class PowerAddWin : Window
    {
        [SerializeField] Text m_PowerText;//用来获取战斗力
        private int prowNum = 0;
        #region Built-in
        private  int Length = 0;//所需长度
        private  int Finalvalue = 0;//最终值
        int Default = 0;
        int Value = -1;
        private  float lastTime = 0;
        [Header("停留速度")]
        public float StaySpeed = 1.5f;
        [Header("滚动速度")]
        public double RollingSpeed = 0.1f;
        private float lastTime1 = 0;
 
        [SerializeField] RectTransform m_ContainerDisplay;
        [SerializeField] List<PowerUpPosition> powerUpPositions;
 
        PlayerMainDate m_MainModel;
        PlayerMainDate onMainModel { get { return m_MainModel ?? (m_MainModel = ModelCenter.Instance.GetModel<PlayerMainDate>()); } }
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
  
        }
 
       
        protected override void OnPreOpen()
        {
            lastTime = 0;
            lastTime1 = 0;
            Length = onMainModel.ProwNumAdd.ToString().Length;
            Finalvalue = onMainModel.ProwNumAdd;
            BFairyAuRewards(Finalvalue);
            CheckPosition();
        }
 
        protected override void OnAfterOpen()
        {
           
        }
 
        protected override void OnPreClose()
        {
        }
 
        protected override void OnAfterClose()
        {
        }
 
        StringBuilder theTarget = new StringBuilder();//目标值
        StringBuilder variation = new StringBuilder();//变化值
        void BFairyAuRewards(int Number)
        {
            Finalvalue = Number;
            Value = Length - 1;
            Default = 0;
            int length = 0;
            length = Finalvalue.ToString().Length;
            theTarget.Length = 0;
            theTarget.Append('0', Length - length);
            theTarget.Append(Finalvalue);
            theTarget.ToString();
            variation.Length = 0;
            variation.Append('0', Length);
 
        }
 
        protected override void LateUpdate()
        {
 
            if (Value < 0)
            {
                lastTime += Time.deltaTime;
                if (lastTime >= StaySpeed)
                {
                    Close();
                }
              
                return;
            }
            lastTime1 += Time.deltaTime;
            if (lastTime1>= RollingSpeed)
            {
                if (theTarget[Value] != variation[Value])
                {
                    Default += (int)Mathf.Pow(10, Length - 1 - Value);
                    variation.Length = 0;
                    int length = Default.ToString().Length;
                    variation.Append('0', Length - length);
                    variation.Append(Default);
                    variation.ToString();
                    m_PowerText.text = "+" + variation.ToString();
                }
                else Value--;
                lastTime1 = 0;
            }
           
        }
 
        #endregion
 
        void CheckPosition()
        {
            var type = WindowType.None;
            if (WindowCenter.Instance.IsOpen<TreasureBaseWin>())
            {
                type = WindowType.TreasureLevelUp;
            }
            else if (WindowCenter.Instance.IsOpen<RealmWin>())
            {
                type = WindowType.Realm;
            }
            var _index = powerUpPositions.FindIndex((x)=> 
            {
                return x.windowType == type;
            });
            if (_index != -1)
            {
                m_ContainerDisplay.transform.localPosition = powerUpPositions[_index].position;
            }
        }
 
        [Serializable]
        public struct PowerUpPosition
        {
            public WindowType windowType;
            public Vector3 position;
        }
 
        public enum WindowType
        {
            None,
            TreasureLevelUp,
            Realm,
        }
    }
 
}