private void DrawHealthBar() { // health bar float startPosition = MainClass.ScreenWidth / 2 - 15 * 2.5f; for (int i = (int)startPosition; i < startPosition + 32f; ++i) { Game.Game.Screen.Set(i, MainClass.ScreenHeight - 21, MathUtils3D.GetColor(0.5f, 0.5f, 0.5f, 1f)); Game.Game.Screen.Set(i, MainClass.ScreenHeight - 20, MathUtils3D.GetColor(0.5f, 0.5f, 0.5f, 1f)); Game.Game.Screen.Set(i, MainClass.ScreenHeight - 19, MathUtils3D.GetColor(0.5f, 0.5f, 0.5f, 1f)); } for (int i = (int)startPosition + 1; i < startPosition + Health * 31f; ++i) { Game.Game.Screen.Set(i, MainClass.ScreenHeight - 20, MathUtils3D.GetColor(1f, 0f, 0f, 1f)); } for (int i = (int)Math.Ceiling(startPosition + Health * 31f); i < startPosition + 31f; ++i) { Game.Game.Screen.Set(i, MainClass.ScreenHeight - 20, MathUtils3D.GetColor(.2f, .2f, .2f, 1f)); } }
private void PostProcess() { float zBufferFlicker = ((float)MainClass.Random.NextDouble() - .5f) / 50f; Game.Screen.Fill((x, y) => { float r, g, b, a; MathUtils3D.GetFloatsFromColor(Game.Screen.Get(x, y), out r, out g, out b, out a); float zBuffer = 1f - Game.ZBuffer.Get(x, y); zBuffer *= WallsDisappearAt; zBuffer -= Flash; zBuffer += zBufferFlicker; if (zBuffer > 1f) { zBuffer = 1f; } zBuffer = 1f - zBuffer; return(MathUtils3D.GetColor(r * zBuffer, g * zBuffer, b * zBuffer, a)); }); }
public void Shoot(MainGameState game) { if (Ammo > 0) { --Ammo; game.Flash = FlashTime; if (!MainGameState.IsServer) { Shot.Play(); } Tuple <object, float, float> crossHairWall = game.CurrentPlayer.AtCrossHair as Tuple <object, float, float>; if (crossHairWall != null) { Wall wall = crossHairWall.Item1 as Wall; Enemy e = crossHairWall.Item1 as Enemy; Player p = crossHairWall.Item1 as Player; if (wall != null) { Door door = wall.Owner as Door; if (OpensDoors && door != null) { door.Open(); } int s = (int)(crossHairWall.Item2 * wall.DecalTexture.Width); int t = (int)(crossHairWall.Item3 * wall.DecalTexture.Width); wall.DecalTexture.Set(s, t, MathUtils3D.GetColor(0f, 0f, 0f, .25f)); } else if (e != null) { e.Health -= Damage; } else if (p != null) { p.Health -= Damage / 5f; Server.Current.SendUpdateHealthMessage(p.Client, p.Health); } } } }