|
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class GameManager : MonoBehaviour
- {
- public GameObject[] item;
- public GameObject maskRed;
- public Button Go;
- public int roundCount;//转的圈数(元素一共22个)
- public int steps=-1;
- public float onceTime=0.2f;
- public int index=0;
- public int maskRedIndex = -1;
- public void StartGo()
- {
- RandomSteps();
- StartCoroutine("RunMarquee");
- }
- //随机多少步
- public void RandomSteps()
- {
- roundCount = Random.Range(1,6);
- steps = Random.Range(0,21);
- steps = steps + roundCount*item.Length;
- print(steps);
- }
- IEnumerator RunMarquee()
- {
- for (int i = 0; i < steps; i++)
- {
- index = (index + 1) % item.Length; // 更新当前图片索引
- maskRed.transform.position = item[index].transform.position; // 更新红纸位置
- yield return new WaitForSeconds(onceTime); // 等待一段时间
- }
- }
- }
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|