1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using Jypeli; |
---|
4 | using Jypeli.Assets; |
---|
5 | using Jypeli.Controls; |
---|
6 | using Jypeli.Effects; |
---|
7 | using Jypeli.Widgets; |
---|
8 | |
---|
9 | public class G : PhysicsGame |
---|
10 | { |
---|
11 | public static G game; |
---|
12 | IntMeter scoreboard; |
---|
13 | public Player player; |
---|
14 | |
---|
15 | public override void Begin() |
---|
16 | { |
---|
17 | game = this; |
---|
18 | Mouse.IsCursorVisible = true; |
---|
19 | |
---|
20 | MultiSelectWindow menu = new MultiSelectWindow("TESTMODE", "Developer tools", "Start this thing", "Get me out of here"); |
---|
21 | menu.DefaultCancel = 2; |
---|
22 | menu.AddItemHandler(0, delegate() { MessageDisplay.Add("Starting game..."); StartGame(); DeveloperCommand(); }); |
---|
23 | menu.AddItemHandler(1, StartGame); |
---|
24 | menu.AddItemHandler(2, Exit); |
---|
25 | Add(menu); |
---|
26 | } |
---|
27 | |
---|
28 | private void DeveloperCommand() |
---|
29 | { |
---|
30 | IsPaused = true; |
---|
31 | InputWindow prompt = new InputWindow(""); |
---|
32 | prompt.TextEntered += delegate(InputWindow p) |
---|
33 | { |
---|
34 | if (p.InputBox.Text.Length == 0) { IsPaused = false; return; } |
---|
35 | string[] commands = p.InputBox.Text.Split(' '); |
---|
36 | |
---|
37 | if (commands[0] == "money") |
---|
38 | { |
---|
39 | if (commands[1] == "add") |
---|
40 | { |
---|
41 | MessageDisplay.Add("+$" + int.Parse(commands[2])); |
---|
42 | } |
---|
43 | else if (commands[1] == "reduce") |
---|
44 | { |
---|
45 | MessageDisplay.Add("-$" + int.Parse(commands[2]) + "!"); |
---|
46 | } |
---|
47 | } |
---|
48 | else if (commands[0] == "level") |
---|
49 | { |
---|
50 | if (commands[1] == "up") |
---|
51 | { |
---|
52 | MessageDisplay.Add("+" + int.Parse(commands[2]) + " levels"); |
---|
53 | } |
---|
54 | else if (commands[1] == "down") |
---|
55 | { |
---|
56 | MessageDisplay.Add("-" + int.Parse(commands[2]) + " levels"); |
---|
57 | } |
---|
58 | } |
---|
59 | else if (commands[0] == "item") |
---|
60 | { |
---|
61 | if (player.GiveWeapon(commands[1])) |
---|
62 | { |
---|
63 | MessageDisplay.Add("You got " + commands[1] + "!"); |
---|
64 | } |
---|
65 | else |
---|
66 | { |
---|
67 | MessageDisplay.Add("What " + commands[1] + "?"); |
---|
68 | } |
---|
69 | } |
---|
70 | else if (commands[0] == "powerup") |
---|
71 | { |
---|
72 | if (player.PowerUp(commands[1], int.Parse(commands[2]))) |
---|
73 | MessageDisplay.Add("Activated " + commands[1] + " powerup"); |
---|
74 | else |
---|
75 | MessageDisplay.Add("No such powerup"); |
---|
76 | } |
---|
77 | else if (commands[0] == "exit") |
---|
78 | { |
---|
79 | Exit(); |
---|
80 | } |
---|
81 | else { MessageDisplay.Add("Unknow command!"); } |
---|
82 | |
---|
83 | DeveloperCommand(); |
---|
84 | }; |
---|
85 | Add(prompt); |
---|
86 | } |
---|
87 | |
---|
88 | private void StartGame() |
---|
89 | { |
---|
90 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Lopeta peli"); |
---|
91 | Keyboard.Listen(Key.Tab, ButtonState.Pressed, DeveloperCommand, null); |
---|
92 | Keyboard.Listen(Key.Enter, ButtonState.Pressed, delegate() { MessageDisplay.Add("Pause toggled!"); Pause(); }, null); |
---|
93 | AddScoreMeter(); |
---|
94 | |
---|
95 | player = new Player(50, 50, 5, true); |
---|
96 | Add(player); |
---|
97 | |
---|
98 | } |
---|
99 | |
---|
100 | void createZ() |
---|
101 | { |
---|
102 | Add(new Zombie1(50, 50, 100, 100, 5)); |
---|
103 | } |
---|
104 | |
---|
105 | private void AddScoreMeter() |
---|
106 | { |
---|
107 | scoreboard = new IntMeter(0); |
---|
108 | scoreboard.AddOverTime(100, 10); |
---|
109 | |
---|
110 | Label ScoreScreen = new Label(); |
---|
111 | ScoreScreen.X = 0; |
---|
112 | ScoreScreen.Y = Screen.Bottom + 100; |
---|
113 | ScoreScreen.TextColor = Color.Black; |
---|
114 | ScoreScreen.Color = Color.White; |
---|
115 | ScoreScreen.BindTo(scoreboard); |
---|
116 | Add(ScoreScreen); |
---|
117 | } |
---|
118 | } |
---|