diff --git a/Financial_Freedom/Financial_Freedom/Data/toplistsave.txt b/Financial_Freedom/Financial_Freedom/Data/toplistsave.txt index 22e5108c733ca39682e053936109172e8ce43cc9..d68a3e65f486ffdf045a755a5655562dc7825966 100644 --- a/Financial_Freedom/Financial_Freedom/Data/toplistsave.txt +++ b/Financial_Freedom/Financial_Freedom/Data/toplistsave.txt @@ -29,7 +29,7 @@ </Item> <Item Index="3" Type="Jypeli.ScoreItem, Jypeli, Version=11.3.7.0, Culture=neutral, PublicKeyToken=null"> <Field Name="Name" Type="System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"> - <Value>miku</Value> + <Value>jonttu</Value> </Field> <Field Name="Score" Type="System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"> <Value>24999749975</Value> diff --git a/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs b/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs index 6acc36b9614d110349bb3bba1496c4bf9498b000..99d04846455d13f4c8ff29136f517ddfad66ac17 100644 --- a/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs +++ b/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs @@ -200,7 +200,11 @@ public class Financial_Freedom : PhysicsGame IsFullScreen = true; Level.Size = Screen.Size; Camera.ZoomToLevel(); + + tavoiteSaavutettu = false; + Valikko(); + } public void Valikko() // lore @@ -229,6 +233,7 @@ public class Financial_Freedom : PhysicsGame pistelaskuri.Value += 1000; AloitusRaha = true; + topLista.EnterText = "Onnittelut, olet päässyt kymmenen parhaimman uhkapelaajan joukkoon! Syötä nimesi niin jäät historian kirjoihin."; topLista.Text = "Parhaat uhkapelaajat"; topLista.HighScoreWindow.Size = new Vector(300,400); @@ -376,7 +381,6 @@ public class Financial_Freedom : PhysicsGame Keyboard.Listen(Key.D4, ButtonState.Pressed, async () => await Slots(), "Menee peliin Slots"); Keyboard.Listen(Key.D5, ButtonState.Pressed, async () => await Coinflip(), "Menee peliin Coinflip"); Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Lopeta peli"); - } @@ -1440,6 +1444,8 @@ public class Financial_Freedom : PhysicsGame ohjeet.Position = new Vector(Screen.Right-575, Screen.Top-25); Add(ohjeet); + + // Tausta panostusalueelle GameObject panostusAlue = new GameObject(Screen.Width / 4, Screen.Height / 2, Shape.Rectangle); panostusAlue.Color = Color.DarkGreen; @@ -1678,17 +1684,118 @@ public class Financial_Freedom : PhysicsGame MessageDisplay.Add($"Panokset on jaettu kohtiin:{string.Join(", ", Betit)}"); Console.WriteLine($"Panokset on jaettu kohtiin:{string.Join(", ", Betit)}"); Console.WriteLine($"Panos per kohde on {panos} jaettuna {clickLog.Count} on {panos/clickLog.Count}"); + RulettiLauta(this, 850, 25, 40, 0, 0); var rulettitaskut = CreateRouletteBets(); Console.WriteLine($"lista kohdista: {string.Join(", ", rulettitaskut)}"); RulettiAnimaatio(); TakaisinPV(); } - void RulettiAnimaatio() + + /// <summary> + /// + /// </summary> + /// <param name="peli">peli johon "animaatio" luodaan</param> + /// <param name="ph">halkaisian pituus jolla pallo pyörii</param> + /// <param name="betpalloH">näkyvän pyörivän pallon koko</param> + /// <param name="pn">pyörimis nopeus</param> + public async Task RulettiLauta(Game peli, double ph,double betpalloH , double pn, double x, double y ) + { + bool pyorii = false; + + PhysicsObject pelilauta = new PhysicsObject(ph + 2 * betpalloH, ph + 2 * betpalloH, Shape.Circle, x, y); + pelilauta.AddCollisionIgnoreGroup(1); + pelilauta.Image = LoadImage("rulettipöytä.png"); + peli.Add(pelilauta); + + PhysicsObject transpallo = new PhysicsObject(ph, ph, Shape.Circle, x, y); + transpallo.Color = Color.Transparent; + transpallo.AddCollisionIgnoreGroup(1); + peli.Add(transpallo); + + + PhysicsObject betpallo = new PhysicsObject(betpalloH, betpalloH,Shape.Circle, ph/2 - ph/10 , y); + betpallo.Color = Color.Gold; + transpallo.Add(betpallo); + + + PhysicsObject pistePallo = new PhysicsObject(10,10,Shape.Circle, x-10, y+10); + pistePallo.AddCollisionIgnoreGroup(1); + pelilauta.Add(pistePallo); + + List<Angle> checkAngles = new List<Angle>(); + + + Keyboard.Listen(Key.Space, ButtonState.Pressed, async () => await pyorautalauta(transpallo, pelilauta, pn, pyorii, checkAngles),"pyöräyttää laudan ja pallon"); + } + + public async Task pyorautalauta(PhysicsObject transpallo, PhysicsObject pelilauta, double pn, bool pyorii, List<Angle> checkAngles) { + transpallo.AngularDamping = RandomGen.NextDouble(0.7,2);// molemmat hidastuu eri nopeuksilla + pelilauta.AngularDamping = RandomGen.NextDouble(0.3,0.5); + transpallo.AngularVelocity = pn + RandomGen.NextDouble(4, 10); + pelilauta.AngularVelocity = -pn + RandomGen.NextDouble(-10, -5); + pyorii = true; + peliKesken += 1; + bool samaNopeus = false; + while (pyorii) + { + if (transpallo.AngularVelocity <= 1 && !samaNopeus) + { + transpallo.AngularDamping += 2; + if (transpallo.AngularVelocity == 0) + { + transpallo.AngularVelocity = pelilauta.AngularVelocity; + transpallo.AngularDamping = pelilauta.AngularDamping; + samaNopeus = true; + } + + } + + if (pelilauta.AngularVelocity == 0) + { + pyorii = false; + rulepisteenlasku(transpallo, pelilauta, checkAngles); + } + await Task.Delay(100); + } + } + public async Task rulepisteenlasku(PhysicsObject transpallo, PhysicsObject pelilauta, List<Angle> checkAngles) + { + double realangle = (transpallo.Angle.Degrees - pelilauta.Angle.Degrees) % 360; + Console.WriteLine(transpallo.Angle.GetPositiveDegrees()); + Console.WriteLine(pelilauta.Angle.GetPositiveDegrees()); + if (realangle < 0) { realangle += 360; } + Console.WriteLine(realangle); + MessageDisplay.Add("aloitetaan tarkistus"); + Console.WriteLine("aloitetaan tarkistus"); + + palloangle(realangle); + + peliKesken -= 1; } + public static double palloangle(double realangle) + { + + bool tarkastettu = false; + while (tarkastettu == false) + { + foreach (var angle in rulettitaskut) + { + if (realangle > angle.kulmat) + { + Console.WriteLine(angle.arvo); + tarkastettu = true; + return angle.numerot; + } + } + } + return -1; + } + + public async Task Slots() { panosAsetettu = new TaskCompletionSource<bool>(false); @@ -2322,6 +2429,7 @@ public class Financial_Freedom : PhysicsGame peliKesken = 0; peliOhi = false; pistelaskuri = null; + highScore = 0; Begin(); }, "uus kiesi"); } diff --git a/Financial_Freedom/Financial_Freedom/Financial_Freedom.csproj b/Financial_Freedom/Financial_Freedom/Financial_Freedom.csproj index be0bc21f222962a431953a7c5e9c0d402a8a2b05..b9e7be8adf1c53893e675cb366f10402dd08dd69 100644 --- a/Financial_Freedom/Financial_Freedom/Financial_Freedom.csproj +++ b/Financial_Freedom/Financial_Freedom/Financial_Freedom.csproj @@ -335,6 +335,9 @@ <None Update="Content\RouletteBG.png"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Update="Content\rulettipöytä.png"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> </ItemGroup> <ItemGroup>