From 5415c58db2917ceb06bd01c121f8b7860f879303 Mon Sep 17 00:00:00 2001 From: MB Date: Sat, 26 Jan 2019 19:57:09 +1100 Subject: [PATCH] Bernard changes --- Assets/Scenes/ClientScene.unity | 4 +- Assets/Scenes/MainScene.unity | 131 ++++++++++++++++++++++++++++- Assets/Scipts/CharacterMovement.cs | 61 ++++++++++++++ Assets/Scipts/GameMode.cs | 12 ++- 4 files changed, 200 insertions(+), 8 deletions(-) diff --git a/Assets/Scenes/ClientScene.unity b/Assets/Scenes/ClientScene.unity index 36fe09f..71feaaf 100644 --- a/Assets/Scenes/ClientScene.unity +++ b/Assets/Scenes/ClientScene.unity @@ -146,8 +146,8 @@ MonoBehaviour: Port: 4444 ConnectOnStart: 0 LobbyScene: LobbyScene - GameScene: TestScene - Name: The Black Burrito + GameScene: MainScene + Name: It cannot wait IsConnected: 0 ID: 0 --- !u!4 &914867462 diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index 03da012..e158662 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -1303,7 +1303,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: recipe: {fileID: 340012152} - DistanceToWin: 0 + charMove: {fileID: 340012155} --- !u!114 &340012154 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1334,6 +1334,10 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Speed: 5 + Players: [] + Nearby: + DistanceToWin: 0 + cam: {fileID: 0} --- !u!1 &426060142 GameObject: m_ObjectHideFlags: 0 @@ -2668,7 +2672,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &1057999594 RectTransform: m_ObjectHideFlags: 0 @@ -2986,6 +2990,128 @@ CanvasRenderer: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1154906379} m_CullTransparentMesh: 0 +--- !u!1 &1190802516 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1190802517} + - component: {fileID: 1190802520} + - component: {fileID: 1190802519} + - component: {fileID: 1190802518} + m_Layer: 5 + m_Name: Button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1190802517 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1190802516} + 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: 1266934409} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 800, y: 480} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1190802518 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1190802516} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1190802519} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 340012155} + m_MethodName: mouseClick + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null +--- !u!114 &1190802519 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1190802516} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, 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_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 +--- !u!222 &1190802520 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1190802516} + m_CullTransparentMesh: 0 --- !u!1 &1195683498 GameObject: m_ObjectHideFlags: 0 @@ -3157,6 +3283,7 @@ RectTransform: - {fileID: 264010775} - {fileID: 1039419384} - {fileID: 35195569} + - {fileID: 1190802517} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scipts/CharacterMovement.cs b/Assets/Scipts/CharacterMovement.cs index 32f4c36..b18f717 100644 --- a/Assets/Scipts/CharacterMovement.cs +++ b/Assets/Scipts/CharacterMovement.cs @@ -6,10 +6,21 @@ public class CharacterMovement : MonoBehaviour { public float Speed; GameObject localPlayer; + public List Players = new List(); + public List Nearby = new List(); + public float DistanceToWin; + + Camera cam; private void Start() { localPlayer = Multiplayer.PlayersManager.Instance.LocalPlayer; + Players.Add(localPlayer); + foreach (GameObject curPlayer in Multiplayer.PlayersManager.Instance.RemotePlayers.Values) + { + Players.Add(curPlayer); + } + cam = localPlayer.GetComponentInChildren(); } @@ -33,4 +44,54 @@ public class CharacterMovement : MonoBehaviour { { localPlayer.GetComponent().AddForce(new Vector3(0.0f, 0.0f, -Speed)); } + + public void mouseClick() + { + Vector3 screenMouse = Input.mousePosition; + Vector3 mousePos = cam.ScreenToWorldPoint(screenMouse); + Vector3 moveVec = new Vector3(mousePos.x, 0.0f, mousePos.z) * Speed; + + localPlayer.GetComponent().AddForce(moveVec); + } + + public bool CheckNearby() + { + for (int i = 0; i < Players.Count; i++) + { + if ((localPlayer.transform.position - Players[i].transform.position).magnitude < DistanceToWin) + { + Greet(); + } + else + { + Player playerScript = Players[i].GetComponent(); + foreach (GameObject dummy in playerScript.dummies) + { + if ((localPlayer.transform.position - dummy.transform.position).magnitude < DistanceToWin) + { + Greet(); + } + } + } + } + return CheckWin(); + } + + bool CheckWin() + { + for (int i = 0; i < Nearby.Count; i++) + { + if (Nearby[i] == false) + { + return false; + } + } + return true; + } + + public void Greet() + { + //Play audio + //Trigger animation + } } diff --git a/Assets/Scipts/GameMode.cs b/Assets/Scipts/GameMode.cs index 7b34379..b92d82e 100644 --- a/Assets/Scipts/GameMode.cs +++ b/Assets/Scipts/GameMode.cs @@ -8,8 +8,7 @@ public class GameMode : MonoBehaviour { List Players = new List(); public Recipe recipe; GameObject LocalPlayer; - - public float DistanceToWin; + public CharacterMovement charMove; private void Start() @@ -25,10 +24,14 @@ public class GameMode : MonoBehaviour { void Update() { - CheckValues(); - + //CheckValues(); + if (charMove.CheckNearby()) + { + recipe.CheckVictory(); + } } + /* //Check the values for player to see if it changes the minimum or maximum values of all players void CheckValues() { @@ -58,4 +61,5 @@ public class GameMode : MonoBehaviour { } } } + */ }