private void UDPMessageReceivedHandler(NetInMessage message) { message.ResetIndex(); MessageType.Command command = (MessageType.Command)message.ReadInt32(); if (command == MessageType.Command.Data) { for (int i = 0; i < 5; i++) { int fingerIndex = message.ReadInt32(); float plotValue = message.ReadFloat(); FingerForceGraphs[fingerIndex].value = Mathf.FloorToInt(plotValue); forceScalingNoteActivators[fingerIndex].GetComponent <ForceScalingNoteActivatorController>().SetForcePercentage(plotValue); } } else if (command == MessageType.Command.Control) { MessageType.ControlType controlType = (MessageType.ControlType)message.ReadInt32(); if (controlType == MessageType.ControlType.PlaySong) { int songIndex = message.ReadInt32(); audioSource.clip = songList.songs[songIndex].audioClip; audioSource.loop = false; audioSource.Play(); } else if (controlType == MessageType.ControlType.StopSong) { audioSource.Stop(); noteSpawner.DeleteAllNotes(); } else if (controlType == MessageType.ControlType.SpawnNote) { int spawnIndex = message.ReadInt32(); float duration = message.ReadFloat(); Vector3 locationInNoteLane = message.ReadVector3(); noteSpawner.SpawnHoldNote(spawnIndex, locationInNoteLane, duration); } else if (controlType == MessageType.ControlType.SpawnForceScalingNote) { int spawnIndex = message.ReadInt32(); float duration = message.ReadFloat(); Vector3 locationInNoteLane = message.ReadVector3(); float noteScaleX = message.ReadFloat(); noteSpawner.SpawnForceScalingNote(spawnIndex, locationInNoteLane, noteScaleX, duration); } else if (controlType == MessageType.ControlType.InitVisualizations) { for (int i = 0; i < 5; i++) { int fingerIndex = message.ReadInt32(); float minTargetValuePercentage = message.ReadFloat(); float maxTargetValuePercentage = message.ReadFloat(); FingerForceGraphs[fingerIndex].minTargetValue = Mathf.FloorToInt(minTargetValuePercentage); FingerForceGraphs[fingerIndex].maxTargetValue = Mathf.FloorToInt(maxTargetValuePercentage); forceScalingNoteActivators[fingerIndex].GetComponent <ForceScalingNoteActivatorController>().SetForceRangePercentage(minTargetValuePercentage, maxTargetValuePercentage); } } else if (controlType == MessageType.ControlType.PressKey) { KeyCode key = (KeyCode)message.ReadInt32(); CustomInput.PressKey(key); } else if (controlType == MessageType.ControlType.ReleaseKey) { KeyCode key = (KeyCode)message.ReadInt32(); CustomInput.ReleaseKey(key); } else if (controlType == MessageType.ControlType.ChangeForceScalingMode) { int isForceScalingMode = message.ReadInt32(); SetForceScalingModeValue(isForceScalingMode == 1); } } }
protected virtual void Update() { bool isPressed = CustomInput.GetKey(key); UpdateGraphics(); if (m_collidingNote != null) { if (m_collidingNote.action == NoteAction.Hold) { m_collidingNote.duration -= Time.deltaTime; if (m_collidingNote.duration <= 0.0f) { Destroy(m_collidingNote.gameObject); m_collidingNote = null; if (activatorParticleSystem != null) { activatorParticleSystem.Stop(); } } else { Vector3 scale = m_collidingNote.gameObject.transform.localScale; scale.y -= Time.deltaTime; m_collidingNote.gameObject.transform.localScale = scale; Vector3 position = m_collidingNote.gameObject.transform.localPosition; position.y += Time.deltaTime; m_collidingNote.gameObject.transform.localPosition = position; if (isPressed) { if (m_gameController != null) { // Add score, make effect, whatever m_gameController.score.Value += m_collidingNote.baseScore; } if (activatorParticleSystem != null) { ParticleSystem.MainModule main = activatorParticleSystem.main; main.startColor = Color.cyan; } } else { ParticleSystem.MainModule main = activatorParticleSystem.main; main.startColor = Color.red; } } } else if (m_collidingNote.action == NoteAction.Tap) { if (CustomInput.GetKey(key)) { // Add score, make effect, whatever if (m_gameController != null) { m_gameController.score.Value += m_collidingNote.baseScore; } } Destroy(m_collidingNote.gameObject); m_collidingNote = null; } } }
protected override void UpdateGraphics() { bool isPressed = CustomInput.GetKey(key); m_barSpriteRenderer.color = isPressed ? pressedColor : defaultColor; }
protected virtual void UpdateGraphics() { bool isPressed = CustomInput.GetKey(key); m_spriteRenderer.color = isPressed ? pressedColor : defaultColor; }