void SpawnTuneCards() { float OffsetAngle = 360.0f / (float)TotalTuneCards; //Convert the angle from degree to radian OffsetAngle = (OffsetAngle * Mathf.PI) / 180.0f; float Angle = 0; for (int i = 0; i < TotalTuneCards; ++i) { GameObject Card = Instantiate(TuneCardPrefab, transform.position, Quaternion.identity); Card.transform.SetParent(GameplayPanel.transform, false); //Formula to get the position of a point along the circle //! y = r * sin(delta), x = r * cos(delta) RectTransform CardRT = Card.GetComponent <RectTransform>(); float x = DistanceFromCenter * Mathf.Sin(Angle); float y = DistanceFromCenter * Mathf.Cos(Angle); CardRT.anchoredPosition = new Vector2(x, y); Angle += OffsetAngle; //Setting up the script TuneCardScript CardScript = Card.GetComponent <TuneCardScript>(); CardScript.Key = CurrentLevelInfo.ShuffledSequence[i]; CardScript.CardIndex = i; CardScript.SetButtonColor(ChanceIndicator[ChancesLeft]); CardScript.GetButton().onClick.AddListener(delegate { OnMusicNoteClicked(CardScript.CardIndex); }); TuneCards.Add(CardScript); } }
void Update() { if (CurPlayingMode == EPlayingMode.InitialDelay) { InitialDelayTimer += Time.deltaTime; if (InitialDelayTimer > InitialDelay) { PlayingTuneCards[Iterator].SetGlow(true); AudioSourceComp.Play(); CurPlayingMode = NextPlayingMode; NextPlayingMode = EPlayingMode.None; } } else if (CurPlayingMode != EPlayingMode.None && CurPlayingMode != EPlayingMode.SingleNote) { LoopAudioList(); } else if (CurPlayingMode == EPlayingMode.SingleNote) { if (!AudioSourceComp.isPlaying) { if (!PlayingWrongNoteAnim && CurPlayingCard != null) { CurPlayingCard.SetGlow(false); CurPlayingMode = EPlayingMode.None; CurPlayingCard = null; } if (WinGame) { onEndSequencePlay(true); } } } }
public bool PlayTuneCard(TuneCardScript TuneCard) { if (CurPlayingMode != EPlayingMode.None) { return(false); } else { CurPlayingMode = EPlayingMode.SingleNote; CurPlayingCard = TuneCard; CurPlayingCard.SetGlow(true); PlayMusicNote((NoteType)CurPlayingCard.Key); return(true); } }