-
Notifications
You must be signed in to change notification settings - Fork 0
/
InterMissionState.cs
103 lines (84 loc) · 3.87 KB
/
InterMissionState.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MetalLib;
using MetalLib.GameStructure;
using MetalLib.GameWorld;
using MetalLib.Pencil.Gaming;
using Pencil.Gaming;
using Pencil.Gaming.Graphics;
using Pencil.Gaming.MathUtils;
using Pencil.Gaming.Audio;
namespace MiniLD50
{
class InterMissionState : GameState
{
private GameState parent;
private int totalKills, totalPotentionalKills, currentKillPercentage;
private double percentageDelay = 0.025, percentageCounter;
public InterMissionState(GameState parent)
{
this.parent = parent;
totalKills = RayCaster.ActorList.Where(x => (x.ShootAble && x.Dead)).ToList().Count;
totalPotentionalKills = RayCaster.ActorList.Where(x => x.ShootAble).ToList().Count;
}
public override void Update(GameLoop gameLoop)
{
Program.TotalTime += (float)Glfw.GetTime();
double delta = Glfw.GetTime();
if (Program.TotalTime > 1f)
{
Glfw.SetTime(0.0);
}
if (currentKillPercentage < (int)(((double)totalKills / (double)totalPotentionalKills) * 100.0))
{
percentageCounter += delta;
if (percentageCounter > percentageDelay)
{
percentageCounter = 0;
currentKillPercentage++;
}
}
else
{
if (Input.GetState(0).Keyboard[Key.Enter] && !Input.GetState(1).Keyboard[Key.Enter])
{
((GamePlayState)parent).rayCaster = new RayCaster();
gameLoop.ActiveGameState = parent;
}
}
}
public override void Draw()
{
for (int x = 0; x < 640; x++)
{
for (int y = 0; y < 480 - 72; y++)
{
ScreenBuffer.screenBuffer[y * 640 + x] = ScreenBuffer.GetUintFromARGB(255, 120, 120, 120);
}
}
ScreenBuffer.InsertSprite(((GamePlayState)parent).hudBar);
ScreenBuffer.InsertSprite(((GamePlayState)parent).CurrentWeapon);
ScreenBuffer.InsertSprite(((GamePlayState)parent).CurrentFace);
Font.TextList = new List<Text>();
Font.AddText(new Text("Floor", "floor", new Vector2(15, 422.5f), 0.55f, true));
Font.AddText(new Text(RayCaster.Floor.ToString(), "floorval", new Vector2(35f, 450f), 0.65f, true));
Font.AddText(new Text("Score", "score", new Vector2(110, 422.5f), 0.55f, true));
Font.AddText(new Text("1337", "scoreval", new Vector2(120, 450f), 0.65f, true));
Font.AddText(new Text("Lives", "lives", new Vector2(200, 422.5f), 0.55f, true));
Font.AddText(new Text("1", "livesval", new Vector2(225, 450f), 0.65f, true));
Font.AddText(new Text("Health", "health", new Vector2(350f, 422.5f), 0.55f, true));
Font.AddText(new Text(Player.Health + "%", "healthval", new Vector2(355f, 450f), 0.65f, true));
Font.AddText(new Text("Ammo", "ammo", new Vector2(450f, 422.5f), 0.55f, true));
Font.AddText(new Text(Player.Ammo.ToString(), "ammoval", new Vector2(462.5f, 450f), 0.65f, true));
Font.AddText(new Text("Floor: " + RayCaster.Floor + " Completed!", "floorcomplete", new Vector2(50, 75), 1f));
Font.AddText(new Text("Time: " + Math.Round(RayCaster.CurrentTime, 2) + " seconds.", "time", new Vector2(50, 125), 1f));
Font.AddText(new Text("Kill Ratio: " + currentKillPercentage + "%", "killpercentage", new Vector2(50, 175), 1f));
Font.AddText(new Text("Press Enter!", "entertext", new Vector2(50, 225), 1f));
Font.Draw();
ScreenBuffer.Draw();
ScreenBuffer.Clear();
}
}
}