Refactor, changed some values, fixed server controls.

This commit is contained in:
Harrison Deng 2020-07-12 13:26:32 -05:00
parent 30afab7b05
commit dd0daa091d
16 changed files with 41 additions and 40 deletions

2
.vscode/launch.json vendored
View File

@ -10,7 +10,7 @@
"request": "launch", "request": "launch",
"preLaunchTask": "build", "preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path. // If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/SkinnerBox.dll", "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/WebsiteSim.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console

6
.vscode/tasks.json vendored
View File

@ -7,7 +7,7 @@
"type": "process", "type": "process",
"args": [ "args": [
"build", "build",
"${workspaceFolder}/SkinnerBox.csproj", "${workspaceFolder}/WebsiteSim.csproj",
"/property:GenerateFullPaths=true", "/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary" "/consoleloggerparameters:NoSummary"
], ],
@ -19,7 +19,7 @@
"type": "process", "type": "process",
"args": [ "args": [
"publish", "publish",
"${workspaceFolder}/SkinnerBox.csproj", "${workspaceFolder}/WebsiteSim.csproj",
"/property:GenerateFullPaths=true", "/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary" "/consoleloggerparameters:NoSummary"
], ],
@ -32,7 +32,7 @@
"args": [ "args": [
"watch", "watch",
"run", "run",
"${workspaceFolder}/SkinnerBox.csproj", "${workspaceFolder}/WebsiteSim.csproj",
"/property:GenerateFullPaths=true", "/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary" "/consoleloggerparameters:NoSummary"
], ],

View File

@ -1,7 +1,7 @@
using SlatedGameToolkit.Framework.Graphics.Textures; using SlatedGameToolkit.Framework.Graphics.Textures;
using SlatedGameToolkit.Framework.Utilities.Collections.Pooling; using SlatedGameToolkit.Framework.Utilities.Collections.Pooling;
using System.Drawing; using System.Drawing;
namespace SkinnerBox.Entities namespace WebsiteSim.Entities
{ {
public class DDOSEntity : Entity, IPoolable public class DDOSEntity : Entity, IPoolable
{ {

View File

@ -1,10 +1,10 @@
using System.Drawing; using System.Drawing;
using SkinnerBox.Utilities; using WebsiteSim.Utilities;
using SlatedGameToolkit.Framework.Graphics.Render; using SlatedGameToolkit.Framework.Graphics.Render;
using SlatedGameToolkit.Framework.Graphics.Textures; using SlatedGameToolkit.Framework.Graphics.Textures;
using SlatedGameToolkit.Framework.Utilities.Collections.Pooling; using SlatedGameToolkit.Framework.Utilities.Collections.Pooling;
namespace SkinnerBox.Entities namespace WebsiteSim.Entities
{ {
public class DownloadEntity : Entity, IPoolable public class DownloadEntity : Entity, IPoolable
{ {

View File

@ -3,7 +3,7 @@ using System.Numerics;
using SlatedGameToolkit.Framework.Graphics.Render; using SlatedGameToolkit.Framework.Graphics.Render;
using SlatedGameToolkit.Framework.Graphics.Textures; using SlatedGameToolkit.Framework.Graphics.Textures;
namespace SkinnerBox.Entities namespace WebsiteSim.Entities
{ {
public abstract class Entity : IMesh, IPositionInterpolable public abstract class Entity : IMesh, IPositionInterpolable
{ {

View File

@ -4,7 +4,7 @@ using SlatedGameToolkit.Framework.Graphics.Render;
using SlatedGameToolkit.Framework.Graphics.Textures; using SlatedGameToolkit.Framework.Graphics.Textures;
using SlatedGameToolkit.Framework.Utilities.Collections.Pooling; using SlatedGameToolkit.Framework.Utilities.Collections.Pooling;
namespace SkinnerBox.Entities namespace WebsiteSim.Entities
{ {
public class PacketEntity : Entity, IPositionInterpolable, IPoolable public class PacketEntity : Entity, IPositionInterpolable, IPoolable
{ {

View File

@ -3,7 +3,7 @@ using SlatedGameToolkit.Framework.Graphics.Render;
using SlatedGameToolkit.Framework.Graphics.Textures; using SlatedGameToolkit.Framework.Graphics.Textures;
using SlatedGameToolkit.Framework.Graphics.Window; using SlatedGameToolkit.Framework.Graphics.Window;
namespace SkinnerBox.Entities namespace WebsiteSim.Entities
{ {
public class ServerEntity : Entity public class ServerEntity : Entity
{ {

View File

@ -1,10 +1,10 @@
using SkinnerBox.Utilities; using WebsiteSim.Utilities;
using SlatedGameToolkit.Framework.Graphics.Textures; using SlatedGameToolkit.Framework.Graphics.Textures;
using SlatedGameToolkit.Framework.Utilities.Collections.Pooling; using SlatedGameToolkit.Framework.Utilities.Collections.Pooling;
using System; using System;
using System.Drawing; using System.Drawing;
namespace SkinnerBox.Entities namespace WebsiteSim.Entities
{ {
public class WarningEntity : Entity, IPoolable public class WarningEntity : Entity, IPoolable
{ {

10
Game.cs
View File

@ -1,9 +1,9 @@
using SkinnerBox.States; using SlatedGameToolkit.Framework;
using SkinnerBox.Utilities;
using SlatedGameToolkit.Framework;
using SlatedGameToolkit.Framework.Logging; using SlatedGameToolkit.Framework.Logging;
using WebsiteSim.States;
using WebsiteSim.Utilities;
namespace SkinnerBox namespace WebsiteSim
{ {
class Game class Game
{ {
@ -11,7 +11,7 @@ namespace SkinnerBox
public const int HEIGHT_UNITS = 8; public const int HEIGHT_UNITS = 8;
static void Main(string[] args) static void Main(string[] args)
{ {
GameEngine.targetFPS = 0; GameEngine.targetFPS = 120;
GameEngine.UpdatesPerSecond = 40; GameEngine.UpdatesPerSecond = 40;
Logger.AddLogListener(new ConsoleLogger()); Logger.AddLogListener(new ConsoleLogger());
GameEngine.Ignite(new MenuState()); GameEngine.Ignite(new MenuState());

View File

@ -9,7 +9,7 @@ using SlatedGameToolkit.Framework.Input.Devices;
using SlatedGameToolkit.Framework.StateSystem; using SlatedGameToolkit.Framework.StateSystem;
using SlatedGameToolkit.Framework.StateSystem.States; using SlatedGameToolkit.Framework.StateSystem.States;
namespace SkinnerBox.States namespace WebsiteSim.States
{ {
public class GameOverState : IState public class GameOverState : IState
{ {

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Numerics; using System.Numerics;
using SDL2; using SDL2;
using SkinnerBox.Entities; using WebsiteSim.Entities;
using SlatedGameToolkit.Framework.AssetSystem; using SlatedGameToolkit.Framework.AssetSystem;
using SlatedGameToolkit.Framework.Graphics.Render; using SlatedGameToolkit.Framework.Graphics.Render;
using SlatedGameToolkit.Framework.Graphics.Textures; using SlatedGameToolkit.Framework.Graphics.Textures;
@ -14,9 +14,9 @@ using SlatedGameToolkit.Framework.StateSystem.States;
using SlatedGameToolkit.Framework.Utilities.Collections.Pooling; using SlatedGameToolkit.Framework.Utilities.Collections.Pooling;
using SlatedGameToolkit.Framework.Utilities; using SlatedGameToolkit.Framework.Utilities;
using SlatedGameToolkit.Framework.Graphics.Text; using SlatedGameToolkit.Framework.Graphics.Text;
using SkinnerBox.Utilities; using WebsiteSim.Utilities;
namespace SkinnerBox.States namespace WebsiteSim.States
{ {
public class GamePlayState : IState public class GamePlayState : IState
{ {
@ -102,7 +102,7 @@ namespace SkinnerBox.States
packetSpawnInfo = new PacketSpawnInfo(2, 1, (float)(random.NextDouble() * Game.WIDTH_UNITS), 1f, 0.2f, 0.75f); packetSpawnInfo = new PacketSpawnInfo(2, 1, (float)(random.NextDouble() * Game.WIDTH_UNITS), 1f, 0.2f, 0.75f);
downloadSpawnInfo = new DownloadSpawnInfo(4, 6, 3, 1, 4, 2); downloadSpawnInfo = new DownloadSpawnInfo(4, 6, 3, 1, 4, 2);
dDOSSpawnInfo = new DDOSSPawnInfo(28, 3f, 2f, 245f); dDOSSpawnInfo = new DDOSSPawnInfo(28, 3f, 2f, 200f);
score = 0; score = 0;
timeElapsed.HardSet(0); timeElapsed.HardSet(0);
server.Speed = 4; server.Speed = 4;
@ -245,14 +245,14 @@ namespace SkinnerBox.States
serverTargetPos = cursorWidthScale * Mouse.X; serverTargetPos = cursorWidthScale * Mouse.X;
} }
if (serverTargetPos < server.CenterX) if (serverTargetPos < server.CenterX - 0.02f)
{ {
server.CenterX -= ((float)timeStep * server.Speed); server.CenterX -= ((float)timeStep * server.Speed);
if (server.CenterX < serverTargetPos) server.CenterX = serverTargetPos; if (server.CenterX < serverTargetPos - 0.02f) server.CenterX = serverTargetPos - 0.02f;
} else if (serverTargetPos > server.CenterX) } else if (serverTargetPos > server.CenterX + 0.02f)
{ {
server.CenterX += ((float)timeStep * server.Speed); server.CenterX += ((float)timeStep * server.Speed);
if (server.X > serverTargetPos) server.CenterX = serverTargetPos; if (server.CenterX > serverTargetPos + 0.02f) server.CenterX = serverTargetPos + 0.02f;
} }
#endregion #endregion
#region PacketUpdate #region PacketUpdate
@ -433,7 +433,7 @@ namespace SkinnerBox.States
if (packetSpawnInfo.jumpDistance > 2.25f) packetSpawnInfo.jumpDistance = 2.25f; if (packetSpawnInfo.jumpDistance > 2.25f) packetSpawnInfo.jumpDistance = 2.25f;
} }
if (packetSpawnInfo.interval > 0f) { if (packetSpawnInfo.interval > 0f) {
packetSpawnInfo.interval = (float) (-0.0075 * timeElapsed.Value) + 2f; packetSpawnInfo.interval = (float) (-0.007 * timeElapsed.Value) + 2f;
if (packetSpawnInfo.interval < 0f) packetSpawnInfo.interval = 0f; if (packetSpawnInfo.interval < 0f) packetSpawnInfo.interval = 0f;
} }

View File

@ -13,7 +13,7 @@ using SlatedGameToolkit.Framework.Loaders;
using SlatedGameToolkit.Framework.StateSystem; using SlatedGameToolkit.Framework.StateSystem;
using SlatedGameToolkit.Framework.StateSystem.States; using SlatedGameToolkit.Framework.StateSystem.States;
namespace SkinnerBox.States namespace WebsiteSim.States
{ {
public class MenuState : IState public class MenuState : IState
{ {

View File

@ -2,7 +2,7 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Numerics; using System.Numerics;
using SDL2; using SDL2;
using SkinnerBox.Entities; using WebsiteSim.Entities;
using SlatedGameToolkit.Framework.AssetSystem; using SlatedGameToolkit.Framework.AssetSystem;
using SlatedGameToolkit.Framework.Graphics.Render; using SlatedGameToolkit.Framework.Graphics.Render;
using SlatedGameToolkit.Framework.Graphics.Text; using SlatedGameToolkit.Framework.Graphics.Text;
@ -13,7 +13,7 @@ using SlatedGameToolkit.Framework.StateSystem;
using SlatedGameToolkit.Framework.StateSystem.States; using SlatedGameToolkit.Framework.StateSystem.States;
using SlatedGameToolkit.Framework.Utilities.Collections.Pooling; using SlatedGameToolkit.Framework.Utilities.Collections.Pooling;
namespace SkinnerBox.States namespace WebsiteSim.States
{ {
public class TutorialState : IState public class TutorialState : IState
{ {
@ -55,7 +55,7 @@ namespace SkinnerBox.States
font.PixelHeight = 48; font.PixelHeight = 48;
font.PixelsPerUnitHeight = 80; font.PixelsPerUnitHeight = 80;
font.PixelsPerUnitWidth = 80; font.PixelsPerUnitWidth = 80;
font.PrepareCharacterGroup("abcdefghijklmnopqrstuvwy.:MSHIP+,DTY\'!".ToCharArray()); font.PrepareCharacterGroup("abcdefghijklmnopqrstuvwy.:MSHIP+,DTY\'!DDOSB".ToCharArray());
this.renderer = renderer; this.renderer = renderer;
} }
@ -149,6 +149,7 @@ namespace SkinnerBox.States
font.WriteLine(renderer, 0.1f, Game.HEIGHT_UNITS - 2.5f, "Hit the packets and serve the downloads.", Color.Purple); font.WriteLine(renderer, 0.1f, Game.HEIGHT_UNITS - 2.5f, "Hit the packets and serve the downloads.", Color.Purple);
font.WriteLine(renderer, 0.1f, Game.HEIGHT_UNITS - 3.0f, "Press shift + space to continue to game!", Color.DarkOrange); font.WriteLine(renderer, 0.1f, Game.HEIGHT_UNITS - 3.0f, "Press shift + space to continue to game!", Color.DarkOrange);
font.WriteLine(renderer, 0.1f, Game.HEIGHT_UNITS - 5f, "If a download fades, or\n packets pass the server, \nthe users will be disappointed!", Color.Black); font.WriteLine(renderer, 0.1f, Game.HEIGHT_UNITS - 5f, "If a download fades, or\n packets pass the server, \nthe users will be disappointed!", Color.Black);
font.WriteLine(renderer, 0.1f, 1, "Beware of the DDOS...", Color.Gray);
#endregion #endregion
renderer.End(); renderer.End();
} }
@ -233,14 +234,14 @@ namespace SkinnerBox.States
serverTargetPos = cursorWidthScale * Mouse.X; serverTargetPos = cursorWidthScale * Mouse.X;
} }
if (serverTargetPos < serverEntity.CenterX) if (serverTargetPos < server.CenterX - 0.02f)
{ {
serverEntity.CenterX -= ((float)timeStep * serverEntity.Speed); server.CenterX -= ((float)timeStep * server.Speed);
if (serverEntity.CenterX < serverTargetPos) serverEntity.CenterX = serverTargetPos; if (server.CenterX < serverTargetPos - 0.02f) server.CenterX = serverTargetPos - 0.02f;
} else if (serverTargetPos > serverEntity.CenterX) } else if (serverTargetPos > server.CenterX + 0.02f)
{ {
serverEntity.CenterX += ((float)timeStep * serverEntity.Speed); server.CenterX += ((float)timeStep * server.Speed);
if (serverEntity.X > serverTargetPos) serverEntity.CenterX = serverTargetPos; if (server.CenterX > serverTargetPos + 0.02f) server.CenterX = serverTargetPos + 0.02f;
} }
#endregion #endregion
#region WarningCleanup #region WarningCleanup

View File

@ -1,11 +1,11 @@
using System; using System;
using SlatedGameToolkit.Framework.Logging; using SlatedGameToolkit.Framework.Logging;
namespace SkinnerBox.Utilities namespace WebsiteSim.Utilities
{ {
public class ConsoleLogger : ILogListener public class ConsoleLogger : ILogListener
{ {
public LogLevel Level => LogLevel.DEBUG; public LogLevel Level => LogLevel.INFO;
public void LogMessage(string message, DateTime time, LogLevel level) public void LogMessage(string message, DateTime time, LogLevel level)
{ {

View File

@ -1,6 +1,6 @@
using SlatedGameToolkit.Framework.Graphics.Render; using SlatedGameToolkit.Framework.Graphics.Render;
namespace SkinnerBox.Utilities namespace WebsiteSim.Utilities
{ {
public struct TransitionValue : IPositionInterpolable public struct TransitionValue : IPositionInterpolable
{ {