chenxin
2020-10-27 8d10b61b215a3fad7eb53a7e7ee4dc9e9987d262
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
/**
 * 无尽模式切换速度脚本
 * @Author: chenxin
 * @Date: 2020-10-19 16:34:56
 */
namespace KTGMGemClient
{
    public class EndlessSwitchSpeed : MonoBehaviour
    {
        /// <summary>
        /// 当前的倍速
        /// </summary>
        /// <value></value>
        public int Speed { get; private set; } = 1;
 
        public Image Icon;
 
        public List<Sprite> SpriteList;
 
        private void Start()
        {
            Icon.sprite = SpriteList[Speed - 1];
        }
 
        public void OnClick()
        {
            SwitchSpeed();
        }
 
        private void SwitchSpeed()
        {
            Speed = Speed == 1 ? 2 : 1;
            Time.timeScale = Speed;
            Icon.sprite = SpriteList[Speed - 1];
        }
    }
}