Skip to content

Commit

Permalink
Store now spawns on every connection. Loading bar added
Browse files Browse the repository at this point in the history
Needed loading bar to know when all connections have loaded all entities. Added PlayerManager for Managers that have one instance per player, but run on the server.  Store manager now spawns store when game is started. Added a client side Event Handler class that handles all Bolt Events
  • Loading branch information
mariuskilian committed May 1, 2020
1 parent d19895f commit 58cd27b
Show file tree
Hide file tree
Showing 51 changed files with 584 additions and 45 deletions.
37 changes: 37 additions & 0 deletions Assets/Data/Game Modes/4-Player-Debug.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61d58f53045ec6b4d9f09148f39c99fa, type: 3}
m_Name: 4-Player-Debug
m_EditorClassIdentifier:
arenaLayout:
array2D:
- row:
- active: 1
shared: 1
- active: 0
shared: 0
- active: 0
shared: 0
- row:
- active: 0
shared: 0
- active: 0
shared: 0
- active: 1
shared: 0
- row:
- active: 0
shared: 0
- active: 1
shared: 0
- active: 0
shared: 0
8 changes: 8 additions & 0 deletions Assets/Data/Game Modes/4-Player-Debug.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Assets/Data/Game Modes/Classic.asset
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ MonoBehaviour:
array2D:
- row:
- active: 1
shared: 1
shared: 0
- active: 1
shared: 1
shared: 0
- active: 1
shared: 0
- row:
Expand Down
17 changes: 17 additions & 0 deletions Assets/DebugDisplayTimeLoaded.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DebugDisplayTimeLoaded : MonoBehaviour
{
public Text Text;

void Update()
{
if (BoltNetwork.IsServer) {
if (GameMan.Instance == null) return;
Text.text = GameMan.Instance.LoadStatus.ToString() + "%";
}
}
}
11 changes: 11 additions & 0 deletions Assets/DebugDisplayTimeLoaded.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Assets/Photon/PhotonBolt/assemblies/bolt.user.dll
Binary file not shown.
100 changes: 96 additions & 4 deletions Assets/Photon/PhotonBolt/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
{
"Name": "Transform",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
Expand Down Expand Up @@ -470,7 +469,82 @@
"$type": "Bolt.Compiler.EventDefinition, bolt.compiler",
"Properties": [
{
"Name": "PlayerNetID",
"Name": "Unit1",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyEventSettings, bolt.compiler"
}
},
{
"Name": "Unit2",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyEventSettings, bolt.compiler"
}
},
{
"Name": "Unit3",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyEventSettings, bolt.compiler"
}
},
{
"Name": "Unit4",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyEventSettings, bolt.compiler"
}
},
{
"Name": "Unit5",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeNetworkId, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyEventSettings, bolt.compiler"
}
}
],
"EntitySenders": 3,
"GlobalSenders": 1,
"Name": "StoreNewStoreEvent",
"Guid": "c049009c-784f-4bfd-a7a0-99bede1ebcd7",
"Groups": []
},
{
"$type": "Bolt.Compiler.EventDefinition, bolt.compiler",
"Properties": [
{
"Name": "Unit",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
Expand All @@ -485,8 +559,26 @@
],
"EntitySenders": 3,
"GlobalSenders": 1,
"Name": "PlayerSpawnedEvent",
"Guid": "1b84d1ea-ad25-46dc-bc5a-0c238e4e530f",
"Name": "StoreDespawnUnitEvent",
"Guid": "af7458ca-3920-448a-9b8a-206b2b601898",
"Groups": []
},
{
"$type": "Bolt.Compiler.EventDefinition, bolt.compiler",
"Properties": [],
"EntitySenders": 3,
"GlobalSenders": 2,
"Name": "EventManClientInitializedEvent",
"Guid": "1d3f1b09-ed3e-419a-b995-a51b7a351e4f",
"Groups": []
},
{
"$type": "Bolt.Compiler.EventDefinition, bolt.compiler",
"Properties": [],
"EntitySenders": 3,
"GlobalSenders": 1,
"Name": "EventManServerInitializedEvent",
"Guid": "bc9bba5c-8de2-4661-85da-a010d863055e",
"Groups": []
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ MonoBehaviour:
logUncaughtExceptions: 0
debugEditorMode: 1
consoleToggleKey: 9
consoleVisibleByDefault: 1
consoleVisibleByDefault: 0
compilationWarnLevel: 4
editorSkin: 4
scopeModeHideWarningInGui: 0
Expand Down
98 changes: 97 additions & 1 deletion Assets/Scenes/Ingame.unity
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
GameModes:
- {fileID: 11400000, guid: 2fb9ad3723aaa82409b100dab1c3f930, type: 2}
- {fileID: 11400000, guid: 310c8d5b47708764f8e19ab4cafe58b8, type: 2}
- {fileID: 11400000, guid: 1dd23499ec684be44a9cb875180d7f36, type: 2}
- {fileID: 11400000, guid: 2fb9ad3723aaa82409b100dab1c3f930, type: 2}
GameSettings:
- {fileID: 11400000, guid: 76e94a074dddd7842ac620ec4c7324ed, type: 2}
BaseUnitPrefabs:
Expand All @@ -398,6 +399,97 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2047686401
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2047686402}
- component: {fileID: 2047686405}
- component: {fileID: 2047686404}
- component: {fileID: 2047686403}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2047686402
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2047686401}
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: 8362027053301982919}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: 101.20001}
m_SizeDelta: {x: 300, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2047686403
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2047686401}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6ef9edd3326f76d45a76bc68bc1f2fc9, type: 3}
m_Name:
m_EditorClassIdentifier:
Text: {fileID: 2047686404}
--- !u!114 &2047686404
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2047686401}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 50
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 0
m_MaxSize: 100
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: New Text
--- !u!222 &2047686405
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2047686401}
m_CullTransparentMesh: 0
--- !u!1 &2088224692
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1018,6 +1110,7 @@ RectTransform:
- {fileID: 8362027054317005764}
- {fileID: 8362027054184608460}
- {fileID: 8362027054968041473}
- {fileID: 2047686402}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -2539,3 +2632,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 01d37a37776683d49b32a0d4a4d8d76f, type: 3}
m_Name:
m_EditorClassIdentifier:
yOffset: 0.378
zOffset: 3
xOffsetMax: 1.8
17 changes: 13 additions & 4 deletions Assets/Scripts/Client/CameraMan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,26 @@
public class CameraMan : GlobalEventListener {

public static CameraMan Instance { get; private set; }
private void Awake() { if (Instance == null) Instance = this; }

public Vector3 CamOffset;
public Vector3 CamRotationEulers;

private void Awake() { if (Instance == null) Instance = this; }
public override void OnEvent(EventManClientInitializedEvent evnt) { if (evnt.RaisedBy == null) SubscribeLocalEventHandlers(); }

public override void OnEvent(PlayerSpawnedEvent evnt) {
var playerEntity = BoltNetwork.FindEntity(evnt.PlayerNetID);
transform.SetParent(playerEntity.transform);
private void AttachCameraToPlayer(Player player) {
transform.SetParent(player.transform);
transform.localPosition = CamOffset;
transform.localRotation = Quaternion.Euler(CamRotationEulers);
}

#region Local Event Handlers
private void SubscribeLocalEventHandlers() {
ClientEventMan eventMan = ClientEventMan.Instance;
eventMan.PlayerReceivedEvent += HandlePlayerReceivedEvent;
}

private void HandlePlayerReceivedEvent(Player player) { AttachCameraToPlayer(player); }
#endregion

}
Loading

0 comments on commit 58cd27b

Please sign in to comment.