Skip to content

Commit

Permalink
Preformance text
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Mar 13, 2023
1 parent 8de98b2 commit d39bb03
Show file tree
Hide file tree
Showing 6 changed files with 472 additions and 14 deletions.
140 changes: 139 additions & 1 deletion Assets/Scenes/PlayScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Children:
- {fileID: 1164410252}
m_Father: {fileID: 1476172820}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -835,6 +836,142 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 484464889}
m_CullTransparentMesh: 1
--- !u!1 &1164410251
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1164410252}
- component: {fileID: 1164410254}
- component: {fileID: 1164410253}
m_Layer: 5
m_Name: Preformance Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1164410252
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1164410251}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 173411522}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 140, y: 0}
m_SizeDelta: {x: 200, y: 25}
m_Pivot: {x: 0, y: 1.0000002}
--- !u!114 &1164410253
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1164410251}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: ae170e91fd29a90479e906ddffb1d8ee, type: 2}
m_sharedMaterial: {fileID: -5480317595949376055, guid: ae170e91fd29a90479e906ddffb1d8ee,
type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 24
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &1164410254
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1164410251}
m_CullTransparentMesh: 1
--- !u!1 &1219849445
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1098,6 +1235,7 @@ MonoBehaviour:
songTitle: {fileID: 296535528}
lyric: {fileID: 484464891}
vocalTrack: {fileID: 173411523}
vocalPreformanceText: {fileID: 1164410253}
pauseMenu: {fileID: 137394070}
--- !u!1 &1489966284
GameObject:
Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public bool KaraokeMode {
set {
_karaokeMode = value;

vocalGroup.audioMixer.SetFloat("vocalVolume", _karaokeMode ? 5f : -5f);
vocalGroup.audioMixer.SetFloat("vocalVolume", _karaokeMode ? 5f : -10f);
}
}

Expand Down
29 changes: 28 additions & 1 deletion Assets/Script/PlayMode/MicPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,40 @@ private void Update() {
var eventInfo = events[eventChartIndex];

if (eventInfo.name == "vocal_endPhrase") {
float bestPercent = 0f;

// Reset and see if we failed or not
foreach (var playerInfo in micInputs) {
float mul = GetSingTimeMultiplier(playerInfo.player.chosenDifficulty);
if (playerInfo.singProgress / (sectionSingTime * mul) >= 1f) {
float percent = playerInfo.singProgress / (sectionSingTime * mul);

if (percent >= 1f) {
playerInfo.sectionsHit++;
} else {
playerInfo.secitonsFailed++;
}

if (playerInfo.singProgress / sectionSingTime >= 1f) {
bestPercent = float.PositiveInfinity;
} else if (percent > bestPercent) {
bestPercent = percent;
}

playerInfo.singProgress = 0f;
}

// Set preformance text
GameUI.Instance.vocalPreformanceText.text = bestPercent switch {
float.PositiveInfinity => "PERFECT!",
>= 1f => "AWESOME!",
>= 0.8f => "STRONG",
>= 0.7f => "GOOD",
>= 0.6f => "OKAY",
>= 0.1f => "MESSY",
_ => "AWFUL"
};
GameUI.Instance.vocalPreformanceText.color = Color.white;

// Calculate the new sing time
CalculateSectionSingTime(Play.Instance.SongTime);
}
Expand Down Expand Up @@ -317,6 +339,11 @@ private void Update() {
float singTimeModifier = GetSingTimeMultiplier(player.chosenDifficulty);
playerInfo.barMesh.material.SetFloat("Fill", playerInfo.singProgress / (sectionSingTime * singTimeModifier));
}

// Update preformance text fading
var c = GameUI.Instance.vocalPreformanceText.color;
c.a -= Time.deltaTime * 2f;
GameUI.Instance.vocalPreformanceText.color = c;
}

private void SpawnLyric(LyricInfo lyricInfo, float time) {
Expand Down
2 changes: 2 additions & 0 deletions Assets/Script/UI/GameUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class GameUI : MonoBehaviour {
[SerializeField]
private RawImage vocalTrack;

public TextMeshProUGUI vocalPreformanceText;

public GameObject pauseMenu;

public static GameUI Instance {
Expand Down
2 changes: 1 addition & 1 deletion Assets/Settings/AudioMixer.mixer
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ AudioMixerSnapshotController:
1f268c87cdfed0341a57c521e786ffb4: -2
ed4b3938ef7d7094e8e2de1cedb95d88: -359
2c14880c6e0e5c445a4fb4cc6e534609: -1686
8359e34ef32f4e44194fb41415e1c7d4: -5
8359e34ef32f4e44194fb41415e1c7d4: -10
m_TransitionOverrides: {}
--- !u!244 &1049282059411974768
AudioMixerEffectController:
Expand Down
Loading

0 comments on commit d39bb03

Please sign in to comment.