找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
游戏黄埔已经开课啦,大家速速报名赶快上车
查看: 1857|回复: 0

Lottery素材

[复制链接]

162

主题

33

回帖

891

积分

管理员

积分
891
发表于 2025-2-11 14:16:05 | 显示全部楼层 |阅读模式
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;

  5. public class GameManager : MonoBehaviour
  6. {
  7.     public GameObject[] item;
  8.     public GameObject maskRed;
  9.     public Button Go;
  10.     public int roundCount;//转的圈数(元素一共22个)
  11.     public int steps=-1;
  12.     public float onceTime=0.2f;
  13.     public int index=0;
  14.     public int maskRedIndex = -1;
  15.     public void StartGo()
  16.     {
  17.         RandomSteps();
  18.         StartCoroutine("RunMarquee");
  19.     }

  20.     //随机多少步
  21.     public void RandomSteps()
  22.     {
  23.         roundCount = Random.Range(1,6);
  24.         steps = Random.Range(0,21);
  25.         steps = steps + roundCount*item.Length;
  26.         print(steps);
  27.     }
  28.     IEnumerator RunMarquee()
  29.     {
  30.         for (int i = 0; i < steps; i++)
  31.         {
  32.             index = (index + 1) % item.Length; // 更新当前图片索引
  33.             maskRed.transform.position = item[index].transform.position; // 更新红纸位置
  34.             yield return new WaitForSeconds(onceTime); // 等待一段时间
  35.         }
  36.     }


  37. }
复制代码


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|平顶山市图灵科技 ( 豫ICP备2024088136号-1| 豫公网安备41040202000275号 )

GMT+8, 2025-5-23 06:14 , Processed in 0.047819 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表