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",
"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

6
.vscode/tasks.json vendored
View File

@ -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"
],

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

10
Game.cs
View File

@ -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());

View File

@ -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
{

View File

@ -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;
}

View File

@ -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
{

View File

@ -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

View File

@ -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)
{

View File

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