渐眠于深
- UID
- 10303
- 主题
- 帖子
- 经验
- 点
- 棉棒
- 根
- 人气
- 点
- 在线时间
- 小时
- 最后登录
- 1970-1-1
|
本帖最后由 45646712 于 2020-2-24 00:32 编辑
終於差不多搞定了 花了兩天 近48小時
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dice : MonoBehaviour
{
public GameObject progress;
public GameObject backbtn;
[HideInInspector] public int counter = 1;
static int dicenumber;
static float timer;
public GameObject[] voicebot;
public GameObject[] freeplaybot;
public void count()
{
Invoke("throwdice", 0);
//mechanics on 31 (debugger)
if (counter >= 31)
{
counter = 31;
voicebot[counter].SetActive(true);
}
voicebot[counter].SetActive(true);
if (voicebot[counter].activeInHierarchy == true)
{
gameObject.SetActive(false);
}
//cancel existing voicebot after they had played the audio
Invoke("cancellorv0", 3f);
Invoke("cancellorv1", 3f);
Invoke("cancellorv2", 3f);
Invoke("cancellorv3", 3f);
Invoke("cancellorv4", 3f);
Invoke("cancellorv5", 3f);
Invoke("cancellorv6", 3f);
Invoke("cancellorv7", 3f);
Invoke("cancellorv8", 3f);
Invoke("cancellorv9", 3f);
Invoke("cancellorv10", 3f);
Invoke("cancellorv11", 3f);
Invoke("cancellorv12", 3f);
Invoke("cancellorv13", 3f);
Invoke("cancellorv14", 3f);
Invoke("cancellorv15", 3f);
Invoke("cancellorv16", 3f);
Invoke("cancellorv17", 3f);
Invoke("cancellorv18", 3f);
Invoke("cancellorv19", 3f);
Invoke("cancellorv20", 3f);
Invoke("cancellorv21", 3f);
Invoke("cancellorv22", 3f);
Invoke("cancellorv23", 3f);
Invoke("cancellorv24", 3f);
Invoke("cancellorv25", 3f);
Invoke("cancellorv26", 3f);
Invoke("cancellorv27", 3f);
Invoke("cancellorv28", 3f);
Invoke("cancellorv29", 3f);
Invoke("cancellorv30", 3f);
Invoke("cancellorv31", 3f);
Invoke("cancellorf0", 3f);
Invoke("cancellorf1", 3f);
Invoke("cancellorf2", 3f);
Invoke("cancellorf3", 3f);
Invoke("cancellorf4", 3f);
Invoke("cancellorf5", 3f);
Invoke("cancellorf6", 3f);
Invoke("cancellorf7", 3f);
Invoke("cancellorf8", 3f);
Invoke("cancellorf9", 3f);
progress.GetComponent<UnityEngine.UI.Text>().text = counter.ToString();
}
void throwdice()
{
dicenumber = Random.Range(1, 7);
//mechanics on 10
if (counter == 10)
{
if (dicenumber == 1)
{
dicenumber = 0;
freeplaybot[0].SetActive(true);
}
if (dicenumber == 2)
{
dicenumber = 0;
freeplaybot[1].SetActive(true);
}
if (dicenumber == 3)
{
dicenumber = 0;
freeplaybot[2].SetActive(true);
}
if (dicenumber == 4)
{
dicenumber = 0;
freeplaybot[3].SetActive(true);
}
if (dicenumber == 5)
{
dicenumber = 0;
freeplaybot[4].SetActive(true);
}
if (dicenumber == 6)
{
dicenumber = Random.Range(1, 7);
counter += dicenumber;
counter -= dicenumber;
}
}
//mechanics on 20
if (counter == 20)
{
if (dicenumber == 1)
{
dicenumber = 0;
freeplaybot[5].SetActive(true);
}
if (dicenumber == 2)
{
dicenumber = 0;
freeplaybot[6].SetActive(true);
}
if (dicenumber == 3)
{
dicenumber = 0;
freeplaybot[7].SetActive(true);
}
if (dicenumber == 4)
{
dicenumber = 0;
freeplaybot[8].SetActive(true);
}
if (dicenumber == 5)
{
dicenumber = 0;
freeplaybot[9].SetActive(true);
}
if (dicenumber == 6)
{
dicenumber = Random.Range(1, 7);
counter += dicenumber;
counter -= dicenumber;
}
}
//mechanics on 22-24
if (counter >= 22 && counter <= 24)
{
counter--;
}
//mechanics on 25-27
if (counter >= 25 && counter <= 27)
{
counter -= 2;
}
//mechanics on 28-30
if (counter >= 28 && counter <= 30)
{
counter -= 3;
}
counter += dicenumber;
}
void cancellorv0()
{
if (voicebot[0].activeSelf == true)
{
voicebot[0].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv1()
{
if(voicebot[1].activeSelf == true)
{
voicebot[1].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv2()
{
if (voicebot[2].activeSelf == true)
{
voicebot[2].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv3()
{
if (voicebot[3].activeSelf == true)
{
voicebot[3].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv4()
{
if (voicebot[4].activeSelf == true)
{
voicebot[4].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv5()
{
if (voicebot[5].activeSelf == true)
{
voicebot[5].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv6()
{
if (voicebot[6].activeSelf == true)
{
voicebot[6].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv7()
{
if (voicebot[7].activeSelf == true)
{
voicebot[7].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv8()
{
if (voicebot[8].activeSelf == true)
{
voicebot[8].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv9()
{
if (voicebot[9].activeSelf == true)
{
voicebot[9].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv10()
{
if (voicebot[10].activeSelf == true)
{
voicebot[10].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv11()
{
if (voicebot[11].activeSelf == true)
{
voicebot[11].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv12()
{
if (voicebot[12].activeSelf == true)
{
voicebot[12].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv13()
{
if (voicebot[13].activeSelf == true)
{
voicebot[13].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv14()
{
if (voicebot[14].activeSelf == true)
{
voicebot[14].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv15()
{
if (voicebot[15].activeSelf == true)
{
voicebot[15].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv16()
{
if (voicebot[16].activeSelf == true)
{
voicebot[16].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv17()
{
if (voicebot[17].activeSelf == true)
{
voicebot[17].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv18()
{
if (voicebot[18].activeSelf == true)
{
voicebot[18].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv19()
{
if (voicebot[19].activeSelf == true)
{
voicebot[19].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv20()
{
if (voicebot[20].activeSelf == true)
{
voicebot[20].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv21()
{
if (voicebot[21].activeSelf == true)
{
voicebot[21].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv22()
{
if (voicebot[22].activeSelf == true)
{
voicebot[22].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv23()
{
if (voicebot[23].activeSelf == true)
{
voicebot[23].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv24()
{
if (voicebot[24].activeSelf == true)
{
voicebot[24].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv25()
{
if (voicebot[25].activeSelf == true)
{
voicebot[25].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv26()
{
if (voicebot[26].activeSelf == true)
{
voicebot[26].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv27()
{
if (voicebot[27].activeSelf == true)
{
voicebot[27].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv28()
{
if (voicebot[28].activeSelf == true)
{
voicebot[28].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv29()
{
if (voicebot[29].activeSelf == true)
{
voicebot[29].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv30()
{
if (voicebot[30].activeSelf == true)
{
voicebot[30].SetActive(false);
gameObject.SetActive(true);
}
}
void cancellorv31()
{
if (voicebot[31].activeSelf == true)
{
voicebot[31].SetActive(false);
backbtn.SetActive(true);
gameObject.SetActive(false);
}
}
void cancellorf0()
{
if (freeplaybot[0].activeSelf == true)
{
freeplaybot[0].SetActive(false);
}
}
void cancellorf1()
{
if (freeplaybot[1].activeSelf == true)
{
freeplaybot[1].SetActive(false);
}
}
void cancellorf2()
{
if (freeplaybot[2].activeSelf == true)
{
freeplaybot[2].SetActive(false);
}
}
void cancellorf3()
{
if (freeplaybot[3].activeSelf == true)
{
freeplaybot[3].SetActive(false);
}
}
void cancellorf4()
{
if (freeplaybot[4].activeSelf == true)
{
freeplaybot[4].SetActive(false);
}
}
void cancellorf5()
{
if (freeplaybot[5].activeSelf == true)
{
freeplaybot[5].SetActive(false);
}
}
void cancellorf6()
{
if (freeplaybot[6].activeSelf == true)
{
freeplaybot[6].SetActive(false);
}
}
void cancellorf7()
{
if (freeplaybot[7].activeSelf == true)
{
freeplaybot[7].SetActive(false);
}
}
void cancellorf8()
{
if (freeplaybot[8].activeSelf == true)
{
freeplaybot[8].SetActive(false);
}
}
void cancellorf9()
{
if (freeplaybot[9].activeSelf == true)
{
freeplaybot[9].SetActive(false);
}
}
}
------------------------------------------------------------------------------------------
public class Gamecontrol : dice
{
void Start()
{
backbtn.SetActive(false);
voicebot = GameObject.FindGameObjectsWithTag("bot");
freeplaybot = GameObject.FindGameObjectsWithTag("fbot");
foreach (GameObject voicebots in voicebot)
{
voicebots.SetActive(false);
}
foreach (GameObject freeplaybots in freeplaybot)
{
freeplaybots.SetActive(false);
}
}
}
|
|