public void SetHistoryInput(Mobile_GridButton gridButton) { InputBackground.color = gridButton.background.color; InputBackground.sprite = gridButton.background.sprite; InputIcon.color = gridButton.icon.color; InputIcon.sprite = gridButton.icon.sprite; InputText.text = gridButton.text.text; }
public void CheckWithSequence(Mobile_GridButton mobileGridButton) { #if !UNITY_STANDALONE int playerIndex = playerIconsController.ActivePlayerIndex; iconsController.SetFront(mobileGridButton); if (currentSequenceIndex >= sequence.Count) { int trend = sequence.FindAll(button => button == mobileGridButton).Count; Debug.Log("new element " + trend + "'th time"); if (trend == 0) { Debug.Log("added player nr." + playerIndex + " 1 point"); playerIconsController.AddPoints(1); } else { Debug.Log("added nr." + playerIndex + " " + (1 - trend / (float)sequence.Count) + " points"); playerIconsController.AddPoints(1 - trend / (float)sequence.Count); } if (mobileGridButton.audioSource.clip != null) { mobileGridButton.audioSource.Play(); } sequence.Add(mobileGridButton); NextPlayer(); } else { if (sequence[currentSequenceIndex] == mobileGridButton) { Debug.Log("old element good choice"); Debug.Log("added nr." + playerIndex + " 1 point"); playerIconsController.AddPoints(1); currentSequenceIndex++; iconsController.Push(mobileGridButton); if (mobileGridButton.audioSource.clip != null) { mobileGridButton.audioSource.Play(); } } else { audioSource.clip = failClip; audioSource.Play(); // Debug.Log("old element wrong choice"); Handheld.Vibrate(); playerIconsController.AddPoints(-1); iconsController.Push(mobileGridButton); sequence.Clear(); //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } } counterPanel.UpdateText(currentSequenceIndex, sequence.Count); #endif }
public void Push(Mobile_GridButton button) { var go = Instantiate(prefab, transform); HistoryInput historyInput = go.GetComponent <HistoryInput>(); historyInput.SetHistoryInput(button); if (this.buttons.Count >= 4) { var d = this.buttons.Dequeue(); Destroy(d); } this.buttons.Enqueue(go); }