diff --git a/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs b/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs index 8c8c177e9cb9d8804d608b243680d833d5c40222..af6baf558b52c1f9380e67c652fdebeb09cb8237 100644 --- a/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs +++ b/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs @@ -516,79 +516,80 @@ public class Financial_Freedom : PhysicsGame Keyboard.Listen(Key.D5, ButtonState.Pressed, async () => await Coinflip(), "Menee peliin Coinflip"); Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Lopeta peli"); } - + public async Task PelinValinta() { ClearControls(); ClearGameObjects(); - string[] alkulogot = {"Plinko", "Blackjack", "Ruletti", "Slots", "Coinflip", "exit"}; - + string[] alkulogot = { "Plinko", "Blackjack", "Ruletti", "Slots", "Coinflip", "exit" }; + Gravity = new Vector(0, 0); Level.Background.Image = taustakuvaPV; Level.Background.FitToLevel(); - + LuoPistelaskuri(); var pakka = LuoPakka(); - SekoitaPakka(pakka); - + SekoitaPakka(pakka); + int ovicount = 6; - + // Tekee viis ovea ovet = new List<GameObject>(); - double doorSpacing = Screen.Width/7; - double startX = -Screen.Width/3; + double doorSpacing = Screen.Width / 7; + double startX = -Screen.Width / 3; for (int i = 0; i < ovicount; i++) { - PhysicsObject door = new PhysicsObject(Screen.Width/10, Screen.Height/3); - door.Shape = Shape.Rectangle; + PhysicsObject door = new PhysicsObject(Screen.Width / 10, Screen.Height / 3); + //door.Shape = Shape.Rectangle; door.Color = Color.Brown; door.Image = LoadImage("door.png"); - door.Position = new Vector(startX + i * doorSpacing, Screen.Bottom+0.75*(Screen.Height/3)); + door.Position = new Vector(startX + i * doorSpacing, Screen.Bottom + 0.75 * (Screen.Height / 3)); door.MakeStatic(); - - //door.Image = LoadImage(alkulogot[i]); - - MiniPeliLogo(this,door.Width, door.Height/2, door.X, door.Y+(0.8*door.Height), alkulogot[i], i); - door.Tag = "Door " + (i + 1) + ": " + GetDoorDescription(i + 1); - Console.WriteLine($"door {door.Tag} added"); Add(door); + MiniPeliLogo(this, door.Width, door.Height / 2, door.X, door.Y + (0.8 * door.Height), alkulogot[i], i); + Console.WriteLine($"door {door.Tag} added"); ovet.Add(door); + + if (i == ovicount-1){CreatePelaaja();} } - + // popup tekstit - doorPopupLabel = new Label(""){ - Position = new Vector(0, 200), + doorPopupLabel = new Label("") + { + Position = new Vector(0, 200), TextColor = Color.White, TextScale = new Vector(2, 2), Color = Color.Black, - Size = new Vector(300, 50) - }; - - await Task.Delay(10); - // Pelaaja - tero = new PhysicsObject(Screen.Width/6, Screen.Height/3){ - Shape = Shape.Rectangle, - Position = new Vector(Screen.Left+150, Screen.Bottom+0.6*(Screen.Height/3)), - IgnoresCollisionResponse = true, - Image = LoadImage("tero.png") , + Size = new Vector(300, 50) }; - Add(tero); - Console.WriteLine("tero added"); - - Remove(tero); - Add(tero); Keyboard.Listen(Key.Space, ButtonState.Pressed, SelectDoor, "Select a door"); Keyboard.Listen(Key.Enter, ButtonState.Pressed, SelectDoor, "Select a door"); - + // controllit Keyboard.Listen(Key.A, ButtonState.Down, () => tero.X -= 12, "Move left"); Keyboard.Listen(Key.D, ButtonState.Down, () => tero.X += 12, "Move right"); - } + void CreatePelaaja() + { + + tero = new PhysicsObject(Screen.Width / 6, Screen.Height / 3) + { + Shape = Shape.Rectangle, + Position = new Vector(Screen.Left + 150, Screen.Bottom + 0.6 * (Screen.Height / 3)), + IgnoresCollisionResponse = true, + Image = LoadImage("tero.png"), + }; + Add(tero); + Console.WriteLine("tero added"); + + Remove(tero); + Add(tero); + } + // Returns a sample description based on door number. private string GetDoorDescription(int doorNumber) {