From 07a54c31c8663d271f5d37ab79537042578bd4f9 Mon Sep 17 00:00:00 2001 From: hani-sayegh Date: Thu, 2 Mar 2017 22:12:11 -0500 Subject: [PATCH] #5 Timer is done and networked --- .../Test/NetworkTestGroundController.prefab | 8 +- .../Scene/Test Scenes/Networking Test.unity | 182 +++++++++++++++++- Assets/Scripts/Networking/NetMessenger.cs | 14 +- Assets/Timer.cs | 4 +- ProjectSettings/TagManager.asset | 1 + 5 files changed, 187 insertions(+), 22 deletions(-) diff --git a/Assets/Prefabs/Test/NetworkTestGroundController.prefab b/Assets/Prefabs/Test/NetworkTestGroundController.prefab index c5582a0..859f92b 100644 --- a/Assets/Prefabs/Test/NetworkTestGroundController.prefab +++ b/Assets/Prefabs/Test/NetworkTestGroundController.prefab @@ -48,7 +48,7 @@ GameObject: - component: {fileID: 114207589162456876} m_Layer: 0 m_Name: NetworkTestGroundController - m_TagString: Untagged + m_TagString: PlayerGround m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -340,7 +340,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5dcd5b2ef063e084f9439dab4c8d20ca, type: 3} m_Name: m_EditorClassIdentifier: + DisableOnClientsHost: [] + clientsHost: 0 + hostsClient: 0 + client: 0 + host: 0 timer: {fileID: 0} + go: 0 --- !u!114 &114280900742100736 MonoBehaviour: m_ObjectHideFlags: 1 diff --git a/Assets/Scene/Test Scenes/Networking Test.unity b/Assets/Scene/Test Scenes/Networking Test.unity index d55da68..e41ae14 100644 --- a/Assets/Scene/Test Scenes/Networking Test.unity +++ b/Assets/Scene/Test Scenes/Networking Test.unity @@ -1244,6 +1244,99 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} +--- !u!1 &892924126 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 892924130} + - component: {fileID: 892924129} + - component: {fileID: 892924128} + - component: {fileID: 892924127} + m_Layer: 5 + m_Name: Canvas (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!114 &892924127 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 892924126} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &892924128 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 892924126} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &892924129 +Canvas: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 892924126} + m_Enabled: 1 + serializedVersion: 2 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &892924130 +RectTransform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 892924126} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 997685750} + m_Father: {fileID: 0} + m_RootOrder: 12 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} --- !u!1 &899852118 GameObject: m_ObjectHideFlags: 0 @@ -1411,6 +1504,82 @@ Transform: m_PrefabParentObject: {fileID: 4089799203499198, guid: 6c81921ea04bfc8478bbee993c344510, type: 2} m_PrefabInternal: {fileID: 1581271636} +--- !u!1 &997685749 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 997685750} + - component: {fileID: 997685752} + - component: {fileID: 997685751} + m_Layer: 5 + m_Name: Timer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &997685750 +RectTransform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 997685749} + 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: 892924130} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 1} + m_AnchorMax: {x: 0.5, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 160, y: 60} + m_Pivot: {x: 0.5, y: 1} +--- !u!114 &997685751 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 997685749} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.7352941, g: 0.7352941, b: 0.7352941, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 15 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 0 + m_MaxSize: 50 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 'Waiting for overseer to connect... + +' +--- !u!222 &997685752 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 997685749} --- !u!1 &1063355021 GameObject: m_ObjectHideFlags: 0 @@ -2238,7 +2407,7 @@ GameObject: - component: {fileID: 1681601058} m_Layer: 5 m_Name: Timer - m_TagString: Untagged + m_TagString: Timer m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -2259,7 +2428,7 @@ RectTransform: m_AnchorMin: {x: 0.5, y: 1} m_AnchorMax: {x: 0.5, y: 1} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 160, y: 60} + m_SizeDelta: {x: 400, y: 100} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1681601058 MonoBehaviour: @@ -2273,7 +2442,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0.7352941, g: 0.7352941, b: 0.7352941, a: 1} + m_Color: {r: 1, g: 0, b: 0, a: 1} m_RaycastTarget: 1 m_OnCullStateChanged: m_PersistentCalls: @@ -2282,10 +2451,10 @@ MonoBehaviour: Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 50 + m_FontSize: 40 m_FontStyle: 0 m_BestFit: 0 - m_MinSize: 5 + m_MinSize: 0 m_MaxSize: 50 m_Alignment: 4 m_AlignByGeometry: 0 @@ -2293,8 +2462,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: 'Timer - + m_Text: 'Waiting for overseer to connect... ' --- !u!222 &1681601059 diff --git a/Assets/Scripts/Networking/NetMessenger.cs b/Assets/Scripts/Networking/NetMessenger.cs index 57c8076..946f6ea 100644 --- a/Assets/Scripts/Networking/NetMessenger.cs +++ b/Assets/Scripts/Networking/NetMessenger.cs @@ -48,18 +48,6 @@ public void CmdOpenDoor(string color) [Command] public void CmdStartTimer() { - Debug.Log(gameObject.name); - var wat = GameObject.Find("host"); - Debug.Log(wat.name); - Debug.Break(); - if (wat == null) - { - Debug.Break(); - } - var ri = wat.GetComponent(); - print(ri.name); - if (ri == null) - Debug.Break(); - ri.StartTimer(); + GameObject.FindGameObjectWithTag("PlayerGround").GetComponent().StartTimer(); } } diff --git a/Assets/Timer.cs b/Assets/Timer.cs index f4b102e..4be4d9a 100644 --- a/Assets/Timer.cs +++ b/Assets/Timer.cs @@ -9,9 +9,11 @@ public class Timer : NetworkingCharacterAttachment public void StartTimer() { + timer = GameObject.FindGameObjectWithTag("Timer").GetComponent(); + go = true; spawnTime = Time.time; - timer = GameObject.Find("Timer").GetComponent(); + timer.color = Color.gray; if (clientsHost) NetMessenger.Instance.CmdStartTimer(); } diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 26579da..1473702 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -22,6 +22,7 @@ TagManager: - Timer Text - Home - Puppy + - Timer layers: - Default - TransparentFX