From 44b611a70ef798e269a4a112d2b115bbf060b302 Mon Sep 17 00:00:00 2001 From: MB Date: Sat, 26 Jan 2019 17:38:12 +1100 Subject: [PATCH] Hooked up lobby to game manager scripts --- Assets/Scipts/CharacterMovement.cs | 8 +++++++- Assets/Scipts/GameMode.cs | 9 +++++++-- Assets/Scipts/Map.cs | 4 +++- Assets/Scipts/Recipe.cs | 8 ++++++-- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Assets/Scipts/CharacterMovement.cs b/Assets/Scipts/CharacterMovement.cs index d1ca25d..32f4c36 100644 --- a/Assets/Scipts/CharacterMovement.cs +++ b/Assets/Scipts/CharacterMovement.cs @@ -5,7 +5,13 @@ using UnityEngine; public class CharacterMovement : MonoBehaviour { public float Speed; - public GameObject localPlayer; + GameObject localPlayer; + + private void Start() + { + localPlayer = Multiplayer.PlayersManager.Instance.LocalPlayer; + } + //Public movement functions :) public void MoveLeft() diff --git a/Assets/Scipts/GameMode.cs b/Assets/Scipts/GameMode.cs index e457788..7b34379 100644 --- a/Assets/Scipts/GameMode.cs +++ b/Assets/Scipts/GameMode.cs @@ -7,14 +7,19 @@ public class GameMode : MonoBehaviour { //references to all players List Players = new List(); public Recipe recipe; - public GameObject LocalPlayer; + GameObject LocalPlayer; public float DistanceToWin; private void Start() { - // Player + LocalPlayer = Multiplayer.PlayersManager.Instance.LocalPlayer; + Players.Add(LocalPlayer); + foreach (GameObject curPlayer in Multiplayer.PlayersManager.Instance.RemotePlayers.Values) + { + Players.Add(curPlayer); + } } void Update() diff --git a/Assets/Scipts/Map.cs b/Assets/Scipts/Map.cs index 63eda29..daba4b4 100644 --- a/Assets/Scipts/Map.cs +++ b/Assets/Scipts/Map.cs @@ -4,7 +4,7 @@ using UnityEngine; public class Map : MonoBehaviour { - public GameObject LocalPlayer; + GameObject LocalPlayer; public GameObject[] Tiles; public List Landmarks; @@ -31,6 +31,8 @@ public class Map : MonoBehaviour { { //GenerateMap(); CreateDummys(); + LocalPlayer = Multiplayer.PlayersManager.Instance.LocalPlayer; + } //Create dummy players for the world wrapping diff --git a/Assets/Scipts/Recipe.cs b/Assets/Scipts/Recipe.cs index ba8aee7..0664835 100644 --- a/Assets/Scipts/Recipe.cs +++ b/Assets/Scipts/Recipe.cs @@ -7,7 +7,7 @@ using System; public class Recipe : MonoBehaviour { - public Player localPlayer; + Player localPlayer; int PlayerCount; public Vegetable[] Veggies; public Frame[] Frames; @@ -31,7 +31,11 @@ public class Recipe : MonoBehaviour { Frames[i].VegetableSpot.sprite = Veggies[i].Image; Frames[i].Qty.text = Qtys[i] + ""; } - } + localPlayer = Multiplayer.PlayersManager.Instance.LocalPlayer.GetComponent(); + PlayerCount = Multiplayer.PlayersManager.Instance.RemotePlayers.Count + 1; + + + } //Button calls public void OpenRecipe()