少年修仙传客户端代码仓库
client_linchunjie
2018-09-06 619a37b0c8c78845a034d1e36a5d77654f88a23e
System/MainInterfacePanel/PowerAddWin.cs
@@ -1,156 +1,156 @@
//--------------------------------------------------------
//    [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.CheckOpen<TreasureLevelUpWin>())
            {
                type = WindowType.TreasureLevelUp;
            }
            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,
        }
    }
}
//--------------------------------------------------------
//    [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.CheckOpen<TreasureLevelUpWin>())
            {
                type = WindowType.TreasureLevelUp;
            }
            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,
        }
    }
}