PlayerName Validation and Start of SpawnPoint Logic

- Now check player names for empty strings
- Start handling spawn points for levels
This commit is contained in:
Julia Butenhoff 2021-10-25 11:53:54 -05:00
parent 0431cb4c4d
commit c984664a37
9 changed files with 269 additions and 137 deletions

View File

@ -1,125 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.3731193, g: 0.38073996, b: 0.35872698, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}

View File

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.3731193, g: 0.38073996, b: 0.35872698, a: 1}
m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@ -123,3 +123,99 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &1567091938
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1567091942}
- component: {fileID: 1567091941}
- component: {fileID: 1567091940}
- component: {fileID: 1567091939}
m_Layer: 0
m_Name: TempPlane
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!64 &1567091939
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1567091938}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 4
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &1567091940
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1567091938}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &1567091941
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1567091938}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1567091942
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1567091938}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.3731193, g: 0.38073996, b: 0.35872698, a: 1}
m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@ -166,6 +166,53 @@ Transform:
m_Father: {fileID: 1494071119}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &572064020
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 572064021}
- component: {fileID: 572064022}
m_Layer: 0
m_Name: SpawnPoints
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &572064021
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 572064020}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &572064022
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 572064020}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 14bce2f5a48481b40be1448120b12aee, type: 3}
m_Name:
m_EditorClassIdentifier:
runnerSpawnPoints:
- {x: 0, y: 0, z: 0}
- {x: 2, y: 0, z: 2}
kingSpawnPoint: {x: 0, y: 0, z: 0}
--- !u!1 &1494071116
GameObject:
m_ObjectHideFlags: 0
@ -341,7 +388,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1566574282}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1066.1622, y: 530.40906, z: -55.350334}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}

View File

@ -1,5 +1,6 @@
fileFormatVersion: 2
guid: fab29e43756b88448bd30040c42d2d36
guid: 933d31de907455e47bdec2a3c6489dff
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:

View File

@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnPoints : MonoBehaviour {
public static SpawnPoints Instance => instance;
private static SpawnPoints instance;
private void Awake() {
if (instance != null && instance != this) {
Destroy(gameObject);
return;
}
instance = this;
DontDestroyOnLoad(gameObject);
}
/*
* Level IDs for returning spawn points
* Mountain - 0
*
*/
[Header("Mountain")]
[SerializeField] private Vector3[] runnerSpawnPoints;
[SerializeField] private Vector3 kingSpawnPoint;
public Vector3[] getRunnerSpawnPoints(int levelID) {
switch(levelID) {
default:
case 0:
return runnerSpawnPoints;
}
}
public Vector3 getKingSpawnPoint(int levelID) {
switch (levelID) {
default:
case 0:
return kingSpawnPoint;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 14bce2f5a48481b40be1448120b12aee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -25,6 +25,8 @@ public class ServerGameNetPortal : MonoBehaviour {
private GameNetPortal gameNetPortal;
private int gameLevelLoaded = -1;
private void Awake()
{
if (instance != null && instance != this)
@ -87,7 +89,36 @@ public class ServerGameNetPortal : MonoBehaviour {
{
gameInProgress = true;
// Load the mountain level. Can add code to swap which level here
gameLevelLoaded = 0;
NetworkSceneManager.SwitchScene("Game-Mountain");
// Start the round
BeginRound();
}
// Code to handle the beginning of round logic where we do the camera movement and spawning in players
public void BeginRound() {
Vector3[] runnersSpawnPoints;
Vector3 kingSpawnPoint;
switch (gameLevelLoaded) {
default:
case 0:
runnersSpawnPoints = SpawnPoints.Instance.getRunnerSpawnPoints(gameLevelLoaded);
kingSpawnPoint = SpawnPoints.Instance.getKingSpawnPoint(gameLevelLoaded);
break;
}
// Spawn in the players, but make sure the character controllers are diabled
// Perform the intro cutscene camera movement
// Do a 3.2.1 countdown or ask team what we want to do here
// Re-enable the character controllers
// Start the game timer
}
public void EndRound()

View File

@ -37,6 +37,12 @@ public class ConnectButtons : MonoBehaviour {
// Set the players name
PlayerPrefs.SetString("PlayerName", playerNameField.text);
// Validate player name
if (!ValidatePlayerName(playerNameField.text)) {
ThrowError("Invalid Player Name! Please enter a new player name and try again!");
return;
}
// Start a server and join (hosting)
GameNetPortal.Instance.StartHost();
}
@ -57,6 +63,12 @@ public class ConnectButtons : MonoBehaviour {
// Set the players name
PlayerPrefs.SetString("PlayerName", playerNameField.text);
// Validate player name
if (!ValidatePlayerName(playerNameField.text)) {
ThrowError("Invalid Player Name! Please enter a new player name and try again!");
return;
}
// Start the game client
ClientGameNetPortal.Instance.StartClient(ipAddress, port);
@ -87,6 +99,17 @@ public class ConnectButtons : MonoBehaviour {
ErrorPanel.SetActive(false);
}
private bool ValidatePlayerName(string name) {
// Check for empty string
if (name == "" || name == " ") {
return false;
}
// Return true if no issues with name
return true;
}
// Method by: Habib (Stack Overflow)
// https://stackoverflow.com/questions/11412956/what-is-the-best-way-of-validating-an-ip-address
private bool ValidateIPv4(string ipString) {

View File

@ -6,30 +6,33 @@ EditorUserSettings:
serializedVersion: 4
m_ConfigSettings:
RecentlyUsedScenePath-0:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0
RecentlyUsedScenePath-1:
value: 22424703114646680e0b0227036c7b151b180b65082d2b3f6004083ff6e92434e3fe33fba92f31352d1b
flags: 0
RecentlyUsedScenePath-2:
RecentlyUsedScenePath-1:
value: 224247031146466f181a033019225303593b17282e3169032e2c1336f1af073be7e933d6cb353d3e204cfa320d2a18
flags: 0
RecentlyUsedScenePath-3:
RecentlyUsedScenePath-2:
value: 224247031146466f181a033019225303593b17282e3169032e2c1336f1af073be7e933d6ca3b36327717e1351027
flags: 0
RecentlyUsedScenePath-4:
RecentlyUsedScenePath-3:
value: 224247031146466f181a033019225303593b17282e3169032e2c1336f1af073be7e933d6ca3f31297717e1351027
flags: 0
RecentlyUsedScenePath-5:
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c6b19021b1d192f2d2835633c133af6f9
flags: 0
RecentlyUsedScenePath-6:
RecentlyUsedScenePath-5:
value: 22424703114646680e0b0227036c7b151b180b6505263035233d1221fbd33134e7e422e0e8347129370bfb25
flags: 0
RecentlyUsedScenePath-6:
value: 224247031146467c0c03096f3d2c4a1e02161124623d28393930
flags: 0
RecentlyUsedScenePath-7:
value: 22424703114646680e0b0227036c731f1415016439262f2434
flags: 0
RecentlyUsedScenePath-8:
value: 22424703114646680e0b0227036c78111b125507233d28242c20137df7ee3d2cfb
flags: 0
RecentlyUsedScenePath-9:
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
flags: 0
UnityRemoteCompression: