protected override void Start() { Instance = GetComponent <RhythmGameManager>(); SoundManager.Instance.StopMusic(); if (_startInfo) { _startInfo.SetActive(true); } if (_endGame) { _endGame.SetActive(false); } if (_countdownText) { _countdownText.gameObject.SetActive(false); } _timeLeft = _playTime; _canStart = false; _playing = false; _startCountdown = 3f; _endCountdown = 5f; }
// Start is called before the first frame update void Start() { instance = this; currentMultiplier = 1; totalNotes = FindObjectsOfType <Note>().Length; isPlaying = true; }
protected override void CheckActivateCondition() { if (rt.anchoredPosition.y < RhythmGameManager.GetBottom(panel) + BlockSize.y) { Activate(); } }
protected virtual void Score(int s, Vector2?pos = null, bool flashBottom = true, int sndIdx = 0) { int _score; string _text; Color _color; switch (s) { default: _score = badScore; _text = "Miss"; _color = Color.grey; ++Scoring.missCount; break; case 1: _score = goodScore; _text = "Good"; _color = Color.red; //green ++Scoring.goodCount; break; case 2: _score = perfectScore; _text = "Perfect"; _color = Color.yellow; ++Scoring.perfectCount; break; } RhythmGameManager.UpdateScore(_score); lastScorePos = pos == null?GetExit().center : pos.Value; if (coloringParts.Length > 0 && !noAnim && s >= 1) { BlockEnlarge.Create(noteImages[sndIdx], _color, lastScorePos.Value, lastScorePos.Value + new Vector2(panel == PanelType.Left ? BlockSize.x : -BlockSize.x, BlockSize.y), rt.parent); } if (s >= 1) { if (sound.Length > 0 && allScores.Count == 0 && s == 1) { sound[0].Play(1); // 按到good时声效不会按时播放 } if (flashBottom && coloringParts.Length > 0) { Bottom.SetColor(panel, coloringParts[0].color * 0.75f); // 底边变色 } } else { if (sound.Length > 0 && allScores.Count == 0) { sound[0].Play(0); // 按到miss时声效不会按时播放 } FlyingText.Create(_text, _color, lastScorePos.Value, rt.parent); } allScores.Add(new ScoreRecord(Time.time - createTime, s)); OnScored?.Invoke(s); }
// Start is called before the first frame update void Start() { instance = this; scoreText.text = "Score: " + 0; currentMultiplier = 1; gameMan = GameObject.Find("GameManager").GetComponent <GameManager>(); totalNotes = FindObjectsOfType <NoteObject>().Length; }
private void Awake() { if (instance != null) { Debug.LogWarning("More than one GameManager instance: destroying new one"); Destroy(gameObject); return; } instance = this; }
protected void Start() { type = NoteType.TAP; rhythmManagerInstance = RhythmGameManager.instance; gameManagerInstance = GameManager.instance; currentSong = gameManagerInstance.currentSong; if (currentSong) { float distance = Mathf.Abs(transform.position.x - rhythmManagerInstance.scanLine.transform.position.x); speed = distance / currentSong.secondsTillLine; } }
protected override void Update_Activated() { if (TouchedByBinggui()) { Score(2); Destroy(gameObject); } if (rt.anchoredPosition.y < RhythmGameManager.GetBottom(panel) - 1.5f * BlockSize.y) { Score(0); Destroy(gameObject); } }
void SyncSpeed() { RhythmGameManager managerInstance = RhythmGameManager.instance; float distance = Mathf.Abs(managerInstance.noteSpawnX - managerInstance.scanLine.transform.position.x); if (managerInstance.currentSong) { speed = distance / managerInstance.currentSong.secondsTillLine; } else { speed = 10; } }
private void Awake() { ins = this; exits = null; reload.onClick.AddListener(delegate { Timeline.Stop(); SceneManager.LoadScene(0); }); Panel.Left = leftPanel; Panel.Left.panelType = PanelType.Left; Panel.Right = rightPanel; Panel.Right.panelType = PanelType.Right; Panel.state = 0; }
protected float GetBottom() { return(RhythmGameManager.GetBottom(panel)); }
IEnumerator StartFalling(KeyData kd) { yield return(new WaitForSeconds(kd.startTime - GeneralSettings.musicStartTime + GeneralSettings.delay - GeneralSettings.fallingTime)); //print(kd.prop["Type"] + " is falling from Exit " + kd.prop["Exit"] + " in " + kd.prop["FallingTime"]); int exit = 0; PanelType panel = PanelType.Left; string str; string[] seg; if (kd.prop.TryGetValue("Exit", out str)) { exit = int.Parse(str); } if (kd.prop.TryGetValue("Panel", out str)) { if (str == "Right") { panel = PanelType.Right; } } string blockType = "None"; if (kd.prop.TryGetValue("Type", out str)) { blockType = str; } if (GeneralSettings.specialMode == 1) { blockType = "FallingBlock"; } // General Properties // if game layout needs to change bool generateNewExit = false; if (kd.prop.TryGetValue("NewExitCount", out str)) { int newExitCount = int.Parse(str); if (newExitCount != GeneralSettings.exitCount) { GeneralSettings.exitCount = newExitCount; print("Change number of Exits to " + GeneralSettings.exitCount); generateNewExit = true; } } if (kd.prop.TryGetValue("NewGameMode", out str)) { int newMode = int.Parse(str); if (newMode != GeneralSettings.mode) { GeneralSettings.mode = newMode; print("New game mode: " + GeneralSettings.mode); generateNewExit = true; } } if (generateNewExit) { RhythmGameManager.GenerateExits(); } if (kd.prop.TryGetValue("HideBottom", out str)) { if (str == "true") { RhythmGameManager.HideBottomBar(); } else if (str == "false") { RhythmGameManager.HideBottomBar(false); } } if (kd.prop.TryGetValue("HideExits", out str)) { if (str == "true") { RhythmGameManager.HideExit(); } else if (str == "false") { RhythmGameManager.HideExit(false); } else { seg = str.Split(','); HashSet <int> set = new HashSet <int>(); foreach (var s in seg) { set.Add(int.Parse(s)); } RhythmGameManager.HideExit(set); } } if (kd.prop.TryGetValue("SpecialMode", out str)) { GeneralSettings.specialMode = int.Parse(str); } if (kd.prop.TryGetValue("Enable3D", out str)) { if (str == "yes") { Road.ins.EnableDisplay(true); } else if (str == "no") { Road.ins.EnableDisplay(false); } } if (kd.prop.TryGetValue("SetParam", out str)) { seg = str.Split(','); vEventIns.setParameterByName(seg[0], float.Parse(seg[1])); } if (kd.prop.TryGetValue("SFX", out str)) { FMODUnity.RuntimeManager.PlayOneShot("event:/" + str); } if (kd.prop.TryGetValue("Image", out str)) { Instantiate(Resources.Load <GameObject>(str), RhythmGameManager.ins.imageNode); } if (kd.prop.TryGetValue("VideoVolumeFadeOut", out str)) { ins.StartCoroutine(FadeVideoVolume(float.Parse(str))); } if (kd.prop.TryGetValue("MusicFadeIn", out str)) { ins.StartCoroutine(MusicFadeIn(float.Parse(str))); } if (kd.prop.TryGetValue("MusicFadeOut", out str)) { ins.StartCoroutine(MusicFadeOut(float.Parse(str))); } if (kd.prop.TryGetValue("PreloadVideoClip", out str)) { int clipNum = int.Parse(str); int mode = kd.prop["Ratio"] == "16:9" ? 1 : 0; double time = 0; if (kd.prop.TryGetValue("VideoStartTime", out str)) { time = double.Parse(str); } PreloadVideo(clipNum, mode, time); } if (kd.prop.TryGetValue("ShowPreloadVideo", out str)) { StartCoroutine(SetPreloadVideoActive()); } if (kd.prop.TryGetValue("PlayVideoClip", out str)) { int clipNum = int.Parse(str); int mode = kd.prop["Ratio"] == "16:9" ? 1 : 0; double time = 0; if (kd.prop.TryGetValue("VideoStartTime", out str)) { time = double.Parse(str); } PlayVideo(clipNum, mode, time); } if (kd.prop.TryGetValue("PanelAlpha", out str)) { Panel.alpha = float.Parse(str); foreach (var e in RhythmGameManager.exits) { foreach (Graphic g in e.obj.GetComponentsInChildren <Graphic>()) { Color c = g.color; c.a = Panel.alpha; g.color = c; } foreach (Graphic g in e.idctor.GetComponentsInChildren <Graphic>()) { Color c = g.color; c.a = Panel.alpha; g.color = c; } } } if (blockType == "GameOver") { RhythmGameManager.HideContent(); // DebugMode.DestroyAllDebugObjects(); Instantiate(Resources.Load <GameObject>("结算画面"), GameObject.Find("Canvas").transform); } else if (blockType == "ShowLeftPanel") { Panel.ShowLeft(); } else if (blockType == "HideLeftPanel") { Panel.HideLeft(); } else if (blockType == "ShowRightPanel") { Panel.ShowRight(); } else if (blockType == "HideRightPanel") { Panel.HideRight(); } else if (blockType == "HideBothPanels") { Panel.HideBoth(); } // Generates block else if (blockType != "None" && (GeneralSettings.specialMode != 2 || IgnoresSpecialMode2(blockType))) { if (Harp.Contains(kd)) { if (Harp.ins.rouxian) { if (blockType == "Lyrics") { Harp.CreateLyrics(kd.prop["Lyrics"], float.Parse(kd.prop["TimeLast"])); } } } else { Color c = Utils.GetRandomColor(); if (kd.prop.TryGetValue("Color", out str)) { seg = str.Split(','); c = new Color32(byte.Parse(seg[0]), byte.Parse(seg[1]), byte.Parse(seg[2]), 255); } var block = RhythmGameManager.CreateBlock(exit, panel, blockType, c); block.fallingTime = GeneralSettings.fallingTime; if (kd.prop.TryGetValue("Note", out str)) { seg = str.Split(','); block.sound = new SoundStruct[seg.Length]; for (int i = 0; i < seg.Length; ++i) { block.sound[i].id = "MidiNotes/" + seg[i]; } } if (kd.prop.TryGetValue("Delays", out str)) { seg = str.Split(','); if (seg.Length > 1 && seg.Length == block.sound.Length - 1) { float val = 0; for (int i = 0; i < seg.Length; ++i) { float cur = float.Parse(seg[i]); val += cur; block.sound[i + 1].delay = val; } } else { float val = float.Parse(seg[0]); for (int i = 1; i < block.sound.Length; ++i) { block.sound[i].delay = val * i; } } } switch (blockType) { case "FallingBlock": break; case "Beat": Beat beat = (Beat)block; if (kd.prop.TryGetValue("Position", out str)) { seg = str.Split(','); beat.rt.anchoredPosition = new Vector2(float.Parse(seg[0]) * DefRes.x, float.Parse(seg[1]) * DefRes.y); } else { var pos = beat.rt.anchoredPosition; pos.y = 0; beat.rt.anchoredPosition = pos; } if (kd.prop.TryGetValue("Lifetime", out str)) { beat.lifetime = int.Parse(str); } else { beat.lifetime = 2; } break; case "LongFallingBlock": LongFallingBlock lfb = (LongFallingBlock)block; lfb.length = int.Parse(kd.prop["Length"]); break; case "HorizontalMove": HorizontalMove hrm = (HorizontalMove)block; hrm.width = int.Parse(kd.prop["Width"]); hrm.direction = kd.prop["Direction"] == "Up" ? Direction.Up : Direction.Down; break; case "Harp": Harp h = (Harp)block; h.width = int.Parse(kd.prop["Width"]); h.timeLast = float.Parse(kd.prop["TimeLast"]); if (kd.prop.TryGetValue("Rouxian", out str)) { h.rouxian = str == "yes"; } if (h.rouxian) { str = kd.prop["Roufa"]; if (str == "deep") { h.roufa = 0; } else if (str == "shallow") { h.roufa = 1; } str = kd.prop["Rousu"]; if (str == "quick") { h.rousu = 0; } else if (str == "slow") { h.rousu = 1; } if (kd.prop.TryGetValue("LimitTime", out str)) { h.limitTime = float.Parse(str); } else { h.limitTime = 0.5f; } if (kd.prop.TryGetValue("Cooldown", out str)) { h.cooldown = float.Parse(str); } else { h.cooldown = 0.6f; } } break; case "VocalText": VocalText vt = (VocalText)block; if (kd.prop.TryGetValue("Text", out str)) { vt.text = str; } seg = kd.prop["StartPosition"].Split(','); vt.startPos = new Vector2(float.Parse(seg[0]) * DefRes.x, float.Parse(seg[1]) * DefRes.y); seg = kd.prop["EndPosition"].Split(','); vt.endPos = new Vector2(float.Parse(seg[0]) * DefRes.x, float.Parse(seg[1]) * DefRes.y); vt.rotation = int.Parse(kd.prop["Rotation"]); vt.beatInterval = float.Parse(kd.prop["BeatInterval"]); vt.voEvent = kd.prop["Voice"]; vt.length = int.Parse(kd.prop["Length"]); vt.num = int.Parse(kd.prop["Num"]); if (kd.prop.TryGetValue("AnimColor", out str)) { seg = str.Split(','); vt.animColor = new Color32(byte.Parse(seg[0]), byte.Parse(seg[1]), byte.Parse(seg[2]), 255); } if (kd.prop.TryGetValue("MaxMiss", out str)) { vt.maxMiss = int.Parse(str); } else { vt.maxMiss = 1; } if (kd.prop.TryGetValue("BeatLifetime", out str)) { vt.beatLifetime = int.Parse(str); } else { vt.beatLifetime = 2; } if (kd.prop.TryGetValue("NoAnim", out str)) { if (str == "yes") { vt.noAnim = true; } } break; default: break; } OnBlockCreated?.Invoke(block); } } }