From c32891d868b83b17d89cda5a32ce0d6d1e9877a5 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 27 Dec 2015 20:47:18 +1100 Subject: [PATCH] Sync sounds with leg animations when applicable. --- ClassicalSharp/Entities/LocalPlayer.cs | 17 ++++++++++++++--- Launcher2/Gui/Screens/MainScreen.Classicube.cs | 4 ++-- Launcher2/Utils/LauncherSkin.cs | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ClassicalSharp/Entities/LocalPlayer.cs b/ClassicalSharp/Entities/LocalPlayer.cs index 8047ae15a..32be6f0cf 100644 --- a/ClassicalSharp/Entities/LocalPlayer.cs +++ b/ClassicalSharp/Entities/LocalPlayer.cs @@ -117,14 +117,25 @@ namespace ClassicalSharp { bool anyNonAir = false; SoundType type = GetSoundUnder( ref anyNonAir ); if( !anyNonAir ) soundPos = new Vector3( -100000 ); - - float distSq = (lastSoundPos - soundPos).LengthSquared; - if( onGround && (distSq > 1.75f * 1.75f || !wasOnGround) ) { + + if( onGround && (DoPlaySound( soundPos ) || !wasOnGround) ) { game.AudioPlayer.PlayStepSound( type ); lastSoundPos = soundPos; } } + bool DoPlaySound( Vector3 soundPos ) { + float distSq = (lastSoundPos - soundPos).LengthSquared; + // just play every certain block interval when not animating + if( curSwing < 0.999f ) + return distSq > 1.75f * 1.75f; + + // have our legs just crossed over the '0' point? + float oldLegRot = (float)Math.Sin( walkTimeO ); + float newLegRot = (float)Math.Sin( walkTimeN ); + return Math.Sign( oldLegRot ) != Math.Sign( newLegRot ); + } + SoundType GetSoundUnder( ref bool anyNonAir ) { Vector3 pos = new Vector3( nextPos.X, nextPos.Y - 0.01f, nextPos.Z ); Vector3 size = CollisionSize; diff --git a/Launcher2/Gui/Screens/MainScreen.Classicube.cs b/Launcher2/Gui/Screens/MainScreen.Classicube.cs index 446836578..7c89c5f29 100644 --- a/Launcher2/Gui/Screens/MainScreen.Classicube.cs +++ b/Launcher2/Gui/Screens/MainScreen.Classicube.cs @@ -73,8 +73,8 @@ namespace Launcher2 { } void DrawClassicube() { - MakeLabelAt( "Username", titleFont, Anchor.Centre, Anchor.Centre, -180, -150 ); - MakeLabelAt( "Password", titleFont, Anchor.Centre, Anchor.Centre, -180, -100 ); + MakeLabelAt( "Username", titleFont, Anchor.Centre, Anchor.Centre, -170, -150 ); + MakeLabelAt( "Password", titleFont, Anchor.Centre, Anchor.Centre, -170, -100 ); MakeInput( Get(), 280, Anchor.Centre, false, 30, -150, 32 ); MakeInput( Get(), 280, Anchor.Centre, true, 30, -100, 32 ); diff --git a/Launcher2/Utils/LauncherSkin.cs b/Launcher2/Utils/LauncherSkin.cs index 4731cf930..60019be31 100644 --- a/Launcher2/Utils/LauncherSkin.cs +++ b/Launcher2/Utils/LauncherSkin.cs @@ -10,7 +10,7 @@ namespace Launcher2 { //new FastColour( 104, 87, 119 ); public static FastColour ButtonBackCol = new FastColour( 97, 81, 110 ); - public static FastColour ButtonForeActiveCol = new FastColour( 185, 162, 204 ); + public static FastColour ButtonForeActiveCol = new FastColour( 189, 168, 206 ); public static FastColour ButtonForeCol = new FastColour( 164, 138, 186 ); public static FastColour ButtonHighlightCol = new FastColour( 182, 158, 201 );