少年修仙传客户端代码仓库
client_Wu Xijin
2018-09-26 4b5b3d0063a46c673cb7690327454d863febd519
Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
4个文件已添加
201 ■■■■■ 已修改文件
System/Vip/VipInvest/RotatePointer.cs 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Vip/VipInvest/RotatePointer.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Vip/VipInvest/WheelOfFortuneWin.cs 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Vip/VipInvest/WheelOfFortuneWin.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Vip/VipInvest/RotatePointer.cs
New file
@@ -0,0 +1,104 @@
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, September 21, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using DG.Tweening;
namespace Snxxz.UI {
    public class RotatePointer:MonoBehaviour {
        public bool _isRotate = false;//是否旋转
        public float Speed = 2000;//旋转速度
        public float Angle = 0; // 这个是设置停止的角度
        private float Acceleration = 0;//加速度
        private float _time;
        private bool IsRotateBool = false;//是否进行旋转
        [Header("总旋转时间")]
        public float ContinuousTime = 4;//旋转时间
        [Header("加速减速时间")]
        public float SpeedTime = 1;
        [Header("最小速度")]
        public float MinSpeed= 400;
        [Header("最大速度")]
        public float MaxSpeed = 800;
        private void OnEnable()
        {
            IsRotateBool = false;
            _time = 0;
            Acceleration = (MaxSpeed - MinSpeed) / SpeedTime;
        }
        void Update()
        {
            if (!_isRotate)
            {
              //  transform.DORotate(new Vector3(0, 0, 360 + Angle), 0.5f, RotateMode.FastBeyond360);
                return; //不旋转结束
            }
            if (IsRotateBool)
            {
                _time += Time.deltaTime;
                if (_time < SpeedTime)//匀加速
                {
                    Speed = MinSpeed + Acceleration * _time;
                    if (Speed >= MaxSpeed)
                    {
                        Speed = MaxSpeed;
                    }
                }
                else if (_time > ContinuousTime - SpeedTime)//匀减速
                {
                    Speed = MaxSpeed - Acceleration * (_time - (ContinuousTime - SpeedTime));
                    if (Speed <= MinSpeed)
                    {
                        Speed = MinSpeed;
                    }
                }
                else//匀速
                {
                    Speed = MaxSpeed;
                }
                if (_time < ContinuousTime) // 没结束
                {
                    transform.Rotate(Vector3.forward * Speed * Time.deltaTime);
                }
                else
                {
                    //结束,使用DoTween旋转到结束角度,耗时1秒
                    //这里有个360,使用来防止指针回转的,如果不加这个360,你会看到指针倒退
                    transform.DORotate(new Vector3(0, 0, 360 + Angle), 1f, RotateMode.FastBeyond360);
                    _isRotate = false; // 设置不旋转
                    IsRotateBool = false;
                }
            }
        }
        //外部调用,初始化时间和打开旋转
        public void SetTime()
        {
            _time =0;
            IsRotateBool = true;
            _isRotate = true;
        }
        //外部调用,设置停止角度
        public void SetAngle(float angle)
        {
            Angle = angle;
        }
    }
}
System/Vip/VipInvest/RotatePointer.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 172c3a5c67644144780312959c8d9b77
timeCreated: 1537517643
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
System/Vip/VipInvest/WheelOfFortuneWin.cs
New file
@@ -0,0 +1,73 @@
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, September 21, 2018
//--------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Snxxz.UI {
    public class WheelOfFortuneWin : Window
    {
        [SerializeField] Button m_LotteryBtn;
        [SerializeField] RotatePointer m_RotatePointer;
        [SerializeField] Toggle m_Toggle;
        [SerializeField] Button m_CloseBtn;
        #region Built-in
        protected override void BindController()
        {
        }
        protected override void AddListeners()
        {
            m_LotteryBtn.AddListener(OnClickButton);
            m_CloseBtn.AddListener(()=> { Close(); });
            m_Toggle.onValueChanged.AddListener(OnClickToggle);
        }
        protected override void OnPreOpen()
        {
        }
        protected override void OnAfterOpen()
        {
        }
        protected override void OnPreClose()
        {
        }
        protected override void OnAfterClose()
        {
        }
        private void OnClickButton()
        {
            m_RotatePointer.SetTime();
        }
        private void OnClickToggle(bool _bool)
        {
            if (_bool)
            {
                m_RotatePointer._isRotate = false;
                m_RotatePointer.SetAngle(m_RotatePointer.Angle);
            }
            else
            {
                m_RotatePointer._isRotate = true;
            }
        }
        #endregion
    }
}
System/Vip/VipInvest/WheelOfFortuneWin.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d96c4104107a562479b36326b574b15e
timeCreated: 1537517179
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant: