From dd0daa091d1f803d12465aa4f477e7fd25cf443a Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Sun, 12 Jul 2020 13:26:32 -0500 Subject: [PATCH] Refactor, changed some values, fixed server controls. --- .vscode/launch.json | 2 +- .vscode/tasks.json | 6 +++--- Entities/DDOSEntity.cs | 2 +- Entities/DownloadEntity.cs | 4 ++-- Entities/Entity.cs | 2 +- Entities/PacketEntity.cs | 2 +- Entities/ServerEntity.cs | 2 +- Entities/WarningEntity.cs | 4 ++-- Game.cs | 10 +++++----- States/GameOverState.cs | 2 +- States/GamePlayState.cs | 18 +++++++++--------- States/MenuState.cs | 2 +- States/TutorialState.cs | 19 ++++++++++--------- Utilities/ConsoleLogger.cs | 4 ++-- Utilities/TransitionValue.cs | 2 +- SkinnerBox.csproj => WebsiteSim.csproj | 0 16 files changed, 41 insertions(+), 40 deletions(-) rename SkinnerBox.csproj => WebsiteSim.csproj (100%) diff --git a/.vscode/launch.json b/.vscode/launch.json index ff30ec5..41d8c9a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "preLaunchTask": "build", // 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": [], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console diff --git a/.vscode/tasks.json b/.vscode/tasks.json index d8d64ba..6999861 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,7 +7,7 @@ "type": "process", "args": [ "build", - "${workspaceFolder}/SkinnerBox.csproj", + "${workspaceFolder}/WebsiteSim.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], @@ -19,7 +19,7 @@ "type": "process", "args": [ "publish", - "${workspaceFolder}/SkinnerBox.csproj", + "${workspaceFolder}/WebsiteSim.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], @@ -32,7 +32,7 @@ "args": [ "watch", "run", - "${workspaceFolder}/SkinnerBox.csproj", + "${workspaceFolder}/WebsiteSim.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], diff --git a/Entities/DDOSEntity.cs b/Entities/DDOSEntity.cs index dc893af..7638c21 100644 --- a/Entities/DDOSEntity.cs +++ b/Entities/DDOSEntity.cs @@ -1,7 +1,7 @@ using SlatedGameToolkit.Framework.Graphics.Textures; using SlatedGameToolkit.Framework.Utilities.Collections.Pooling; using System.Drawing; -namespace SkinnerBox.Entities +namespace WebsiteSim.Entities { public class DDOSEntity : Entity, IPoolable { diff --git a/Entities/DownloadEntity.cs b/Entities/DownloadEntity.cs index 601c480..26f0ba6 100644 --- a/Entities/DownloadEntity.cs +++ b/Entities/DownloadEntity.cs @@ -1,10 +1,10 @@ using System.Drawing; -using SkinnerBox.Utilities; +using WebsiteSim.Utilities; using SlatedGameToolkit.Framework.Graphics.Render; using SlatedGameToolkit.Framework.Graphics.Textures; using SlatedGameToolkit.Framework.Utilities.Collections.Pooling; -namespace SkinnerBox.Entities +namespace WebsiteSim.Entities { public class DownloadEntity : Entity, IPoolable { diff --git a/Entities/Entity.cs b/Entities/Entity.cs index 310ec39..ca4d682 100644 --- a/Entities/Entity.cs +++ b/Entities/Entity.cs @@ -3,7 +3,7 @@ using System.Numerics; using SlatedGameToolkit.Framework.Graphics.Render; using SlatedGameToolkit.Framework.Graphics.Textures; -namespace SkinnerBox.Entities +namespace WebsiteSim.Entities { public abstract class Entity : IMesh, IPositionInterpolable { diff --git a/Entities/PacketEntity.cs b/Entities/PacketEntity.cs index 9b37c17..695716d 100644 --- a/Entities/PacketEntity.cs +++ b/Entities/PacketEntity.cs @@ -4,7 +4,7 @@ using SlatedGameToolkit.Framework.Graphics.Render; using SlatedGameToolkit.Framework.Graphics.Textures; using SlatedGameToolkit.Framework.Utilities.Collections.Pooling; -namespace SkinnerBox.Entities +namespace WebsiteSim.Entities { public class PacketEntity : Entity, IPositionInterpolable, IPoolable { diff --git a/Entities/ServerEntity.cs b/Entities/ServerEntity.cs index 2c56f00..d0cece7 100644 --- a/Entities/ServerEntity.cs +++ b/Entities/ServerEntity.cs @@ -3,7 +3,7 @@ using SlatedGameToolkit.Framework.Graphics.Render; using SlatedGameToolkit.Framework.Graphics.Textures; using SlatedGameToolkit.Framework.Graphics.Window; -namespace SkinnerBox.Entities +namespace WebsiteSim.Entities { public class ServerEntity : Entity { diff --git a/Entities/WarningEntity.cs b/Entities/WarningEntity.cs index b23429f..ff39fc0 100644 --- a/Entities/WarningEntity.cs +++ b/Entities/WarningEntity.cs @@ -1,10 +1,10 @@ -using SkinnerBox.Utilities; +using WebsiteSim.Utilities; using SlatedGameToolkit.Framework.Graphics.Textures; using SlatedGameToolkit.Framework.Utilities.Collections.Pooling; using System; using System.Drawing; -namespace SkinnerBox.Entities +namespace WebsiteSim.Entities { public class WarningEntity : Entity, IPoolable { diff --git a/Game.cs b/Game.cs index a165af5..091325a 100644 --- a/Game.cs +++ b/Game.cs @@ -1,9 +1,9 @@ -using SkinnerBox.States; -using SkinnerBox.Utilities; -using SlatedGameToolkit.Framework; +using SlatedGameToolkit.Framework; using SlatedGameToolkit.Framework.Logging; +using WebsiteSim.States; +using WebsiteSim.Utilities; -namespace SkinnerBox +namespace WebsiteSim { class Game { @@ -11,7 +11,7 @@ namespace SkinnerBox public const int HEIGHT_UNITS = 8; static void Main(string[] args) { - GameEngine.targetFPS = 0; + GameEngine.targetFPS = 120; GameEngine.UpdatesPerSecond = 40; Logger.AddLogListener(new ConsoleLogger()); GameEngine.Ignite(new MenuState()); diff --git a/States/GameOverState.cs b/States/GameOverState.cs index 14f949b..fb57c61 100644 --- a/States/GameOverState.cs +++ b/States/GameOverState.cs @@ -9,7 +9,7 @@ using SlatedGameToolkit.Framework.Input.Devices; using SlatedGameToolkit.Framework.StateSystem; using SlatedGameToolkit.Framework.StateSystem.States; -namespace SkinnerBox.States +namespace WebsiteSim.States { public class GameOverState : IState { diff --git a/States/GamePlayState.cs b/States/GamePlayState.cs index 07fe76a..a992b91 100644 --- a/States/GamePlayState.cs +++ b/States/GamePlayState.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Drawing; using System.Numerics; using SDL2; -using SkinnerBox.Entities; +using WebsiteSim.Entities; using SlatedGameToolkit.Framework.AssetSystem; using SlatedGameToolkit.Framework.Graphics.Render; using SlatedGameToolkit.Framework.Graphics.Textures; @@ -14,9 +14,9 @@ using SlatedGameToolkit.Framework.StateSystem.States; using SlatedGameToolkit.Framework.Utilities.Collections.Pooling; using SlatedGameToolkit.Framework.Utilities; using SlatedGameToolkit.Framework.Graphics.Text; -using SkinnerBox.Utilities; +using WebsiteSim.Utilities; -namespace SkinnerBox.States +namespace WebsiteSim.States { 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); 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; timeElapsed.HardSet(0); server.Speed = 4; @@ -245,14 +245,14 @@ namespace SkinnerBox.States serverTargetPos = cursorWidthScale * Mouse.X; } - if (serverTargetPos < server.CenterX) + if (serverTargetPos < server.CenterX - 0.02f) { server.CenterX -= ((float)timeStep * server.Speed); - if (server.CenterX < serverTargetPos) server.CenterX = serverTargetPos; - } else if (serverTargetPos > server.CenterX) + if (server.CenterX < serverTargetPos - 0.02f) server.CenterX = serverTargetPos - 0.02f; + } else if (serverTargetPos > server.CenterX + 0.02f) { 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 #region PacketUpdate @@ -433,7 +433,7 @@ namespace SkinnerBox.States if (packetSpawnInfo.jumpDistance > 2.25f) packetSpawnInfo.jumpDistance = 2.25f; } 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; } diff --git a/States/MenuState.cs b/States/MenuState.cs index 4911fea..82846b5 100644 --- a/States/MenuState.cs +++ b/States/MenuState.cs @@ -13,7 +13,7 @@ using SlatedGameToolkit.Framework.Loaders; using SlatedGameToolkit.Framework.StateSystem; using SlatedGameToolkit.Framework.StateSystem.States; -namespace SkinnerBox.States +namespace WebsiteSim.States { public class MenuState : IState { diff --git a/States/TutorialState.cs b/States/TutorialState.cs index 17917c8..43de221 100644 --- a/States/TutorialState.cs +++ b/States/TutorialState.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Drawing; using System.Numerics; using SDL2; -using SkinnerBox.Entities; +using WebsiteSim.Entities; using SlatedGameToolkit.Framework.AssetSystem; using SlatedGameToolkit.Framework.Graphics.Render; using SlatedGameToolkit.Framework.Graphics.Text; @@ -13,7 +13,7 @@ using SlatedGameToolkit.Framework.StateSystem; using SlatedGameToolkit.Framework.StateSystem.States; using SlatedGameToolkit.Framework.Utilities.Collections.Pooling; -namespace SkinnerBox.States +namespace WebsiteSim.States { public class TutorialState : IState { @@ -55,7 +55,7 @@ namespace SkinnerBox.States font.PixelHeight = 48; font.PixelsPerUnitHeight = 80; font.PixelsPerUnitWidth = 80; - font.PrepareCharacterGroup("abcdefghijklmnopqrstuvwy.:MSHIP+,DTY\'!".ToCharArray()); + font.PrepareCharacterGroup("abcdefghijklmnopqrstuvwy.:MSHIP+,DTY\'!DDOSB".ToCharArray()); 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 - 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, 1, "Beware of the DDOS...", Color.Gray); #endregion renderer.End(); } @@ -233,14 +234,14 @@ namespace SkinnerBox.States serverTargetPos = cursorWidthScale * Mouse.X; } - if (serverTargetPos < serverEntity.CenterX) + if (serverTargetPos < server.CenterX - 0.02f) { - serverEntity.CenterX -= ((float)timeStep * serverEntity.Speed); - if (serverEntity.CenterX < serverTargetPos) serverEntity.CenterX = serverTargetPos; - } else if (serverTargetPos > serverEntity.CenterX) + server.CenterX -= ((float)timeStep * server.Speed); + if (server.CenterX < serverTargetPos - 0.02f) server.CenterX = serverTargetPos - 0.02f; + } else if (serverTargetPos > server.CenterX + 0.02f) { - serverEntity.CenterX += ((float)timeStep * serverEntity.Speed); - if (serverEntity.X > serverTargetPos) serverEntity.CenterX = serverTargetPos; + server.CenterX += ((float)timeStep * server.Speed); + if (server.CenterX > serverTargetPos + 0.02f) server.CenterX = serverTargetPos + 0.02f; } #endregion #region WarningCleanup diff --git a/Utilities/ConsoleLogger.cs b/Utilities/ConsoleLogger.cs index f411d01..4bdc9a1 100644 --- a/Utilities/ConsoleLogger.cs +++ b/Utilities/ConsoleLogger.cs @@ -1,11 +1,11 @@ using System; using SlatedGameToolkit.Framework.Logging; -namespace SkinnerBox.Utilities +namespace WebsiteSim.Utilities { public class ConsoleLogger : ILogListener { - public LogLevel Level => LogLevel.DEBUG; + public LogLevel Level => LogLevel.INFO; public void LogMessage(string message, DateTime time, LogLevel level) { diff --git a/Utilities/TransitionValue.cs b/Utilities/TransitionValue.cs index 8558a5a..e0c63ad 100644 --- a/Utilities/TransitionValue.cs +++ b/Utilities/TransitionValue.cs @@ -1,6 +1,6 @@ using SlatedGameToolkit.Framework.Graphics.Render; -namespace SkinnerBox.Utilities +namespace WebsiteSim.Utilities { public struct TransitionValue : IPositionInterpolable { diff --git a/SkinnerBox.csproj b/WebsiteSim.csproj similarity index 100% rename from SkinnerBox.csproj rename to WebsiteSim.csproj