/** * Verifie que les devices sont connecté et si l'utilisateur a selectionné un bouton. */ IEnumerator CheckDevices() { cdbc.Start(this); while (cdbc.IsRunning()) { yield return(new WaitForSeconds(.3f)); } if (cdbc.GetIsSelect()) { EventSystem.current.currentSelectedGameObject.GetComponent <Button>().onClick.Invoke(); yield break; } if (cdbc.GetIsNeedMove()) { idButtonSelect = (++idButtonSelect) % buttons.Count; EventSystem.current.SetSelectedGameObject(buttons[idButtonSelect], null); } if (FinderDevicesBLS.Instance.NbDevicesBLS() == 0) { loaderScene.LoadLevelSelection(0); } isFinishLoopCheck = true; }
/** * Start est appelé avant la première actualisation de la frame * Il va créer un panel pour joueur pour que ceci puissent voir son score. */ void Start() { loaderScene = GameObject.Find("LoaderScene").GetComponent <LoaderScene>(); buttons = new List <GameObject>(); buttons.Add(GameObject.Find("RestartButton")); buttons.Add(GameObject.Find("SelectionGameButton")); buttons.Add(GameObject.Find("QuitButton")); EventSystem.current.SetSelectedGameObject(buttons[idButtonSelect], null); LinkedList <CommunicationDeviceBLS> ldb = FinderDevicesBLS.Instance.GetListDevicesBLS(); if (ldb.Count == 0) { loaderScene.LoadLevelSelection(0); return; } // Vérification que tous les devices se sont arretés bool isDeviceStopped = true; while (isDeviceStopped) { isDeviceStopped = false; foreach (var device in ldb) { isDeviceStopped |= device.isRunning; } } float widthCanvas = canvas.GetComponent <RectTransform>().rect.width; float sizeXPanel = widthCanvas / ldb.Count; float x = (widthCanvas - sizeXPanel) / -2; float y = panelScorePlayer.transform.position.y; float z = panelScorePlayer.transform.position.z; foreach (var device in ldb) { Vector3 position = new Vector3(x, y, z); x += sizeXPanel; GameObject go = Instantiate(panelScorePlayer, position, Quaternion.identity); go.transform.SetParent(canvas.transform, false); GameObject namePlayer = go.transform.GetChild(0).gameObject; GameObject scorePlayer = go.transform.GetChild(2).gameObject; GameObject hitPlayer = go.transform.GetChild(4).gameObject; GameObject maxHit = go.transform.GetChild(6).gameObject; GameObject comboPlayer = go.transform.GetChild(8).gameObject; GameObject imagePlayer = go.transform.GetChild(9).gameObject; go.GetComponent <Image>().color = device.colorPlayer; namePlayer.GetComponent <Text>().text = device.surnameDevice; scorePlayer.GetComponent <Text>().text = PlayerPrefs.GetInt("HeroScore" + device.surnameDevice) + ""; hitPlayer.GetComponent <Text>().text = PlayerPrefs.GetInt("HeroNotesHit" + device.surnameDevice) + ""; maxHit.GetComponent <Text>().text = PlayerPrefs.GetInt("HeroNotesMax") + ""; comboPlayer.GetComponent <Text>().text = PlayerPrefs.GetInt("HeroHighstreak" + device.surnameDevice) + ""; imagePlayer.GetComponent <Image>().sprite = device.characterPlayer; } isFinishLoopCheck = true; }
/** * Start est appelé avant la première actualisation de la frame * Il va créer un panel pour joueur pour que ceci puissent voir son score. */ void Start() { loaderScene = GameObject.Find("LoaderScene").GetComponent <LoaderScene>(); buttons = new List <GameObject>(); buttons.Add(GameObject.Find("RestartGame")); buttons.Add(GameObject.Find("SelectionGameButton")); buttons.Add(GameObject.Find("QuitButton")); EventSystem.current.SetSelectedGameObject(buttons[idButtonSelect], null); LinkedList <CommunicationDeviceBLS> ldb = FinderDevicesBLS.Instance.GetListDevicesBLS(); int nbPlayer = ldb.Count; if (nbPlayer == 0) { loaderScene.LoadLevelSelection(0); return; } // Vérification que tous les devices se sont arretés bool isDeviceStopped = true; while (isDeviceStopped) { isDeviceStopped = false; foreach (var device in ldb) { isDeviceStopped |= device.isRunning; } } int widthCanvas = (int)canvas.GetComponent <RectTransform>().rect.width; int sizeXPanel = widthCanvas / nbPlayer; int x = (widthCanvas - sizeXPanel) / -2; int y = (int)panelScorePlayer.transform.position.y; int z = (int)panelScorePlayer.transform.position.z; foreach (var device in ldb) { Vector3 position = new Vector3(x, y, z); x += sizeXPanel; GameObject go = Instantiate(panelScorePlayer, position, Quaternion.identity); go.transform.SetParent(canvas.transform, false); GameObject namePlayer = go.transform.GetChild(0).gameObject; GameObject timePlayer = go.transform.GetChild(2).gameObject; GameObject goodHitPlayer = go.transform.GetChild(5).gameObject; GameObject badHitPlayer = go.transform.GetChild(7).gameObject; GameObject comboPlayer = go.transform.GetChild(9).gameObject; GameObject imagePlayer = go.transform.GetChild(10).gameObject; go.GetComponent <Image>().color = device.colorPlayer; namePlayer.GetComponent <Text>().text = device.surnameDevice; goodHitPlayer.GetComponent <Text>().text = PlayerPrefs.GetInt("RaceGoodHit" + device.surnameDevice) + ""; badHitPlayer.GetComponent <Text>().text = PlayerPrefs.GetInt("RaceBadHit" + device.surnameDevice) + ""; comboPlayer.GetComponent <Text>().text = PlayerPrefs.GetInt("RaceHighstreak" + device.surnameDevice) + ""; imagePlayer.GetComponent <Image>().sprite = device.characterPlayer; timePlayer.GetComponent <Text>().text = PlayerPrefs.GetInt("RaceFinish" + device.surnameDevice) == 1 ? ConvertSecondToMS((int)PlayerPrefs.GetFloat("RaceScore" + device.surnameDevice)) : "Undefined"; } isFinishLoopCheck = true; }