|
|
@ -4,6 +4,7 @@ using UnityEngine; |
|
|
|
using UnityEngine.UI; |
|
|
|
using TMPro; |
|
|
|
using System; |
|
|
|
using Multiplayer; |
|
|
|
|
|
|
|
public class Recipe : MonoBehaviour { |
|
|
|
|
|
|
@ -31,13 +32,23 @@ public class Recipe : MonoBehaviour { |
|
|
|
Frames[i].VegetableSpot.sprite = Veggies[i].Image; |
|
|
|
Frames[i].Qty.text = Qtys[i] + ""; |
|
|
|
} |
|
|
|
localPlayer = Multiplayer.PlayersManager.Instance.LocalPlayer.GetComponent<Player>(); |
|
|
|
PlayerCount = Multiplayer.PlayersManager.Instance.RemotePlayers.Count + 1; |
|
|
|
localPlayer = PlayersManager.Instance.LocalPlayer.GetComponent<Player>(); |
|
|
|
PlayerCount = PlayersManager.Instance.RemotePlayers.Count + 1; |
|
|
|
|
|
|
|
localPlayer.GetComponent<LocalPlayer>().recipe = this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void OnEnable() |
|
|
|
{ |
|
|
|
ClientManager.Instance.Client.RegisterHandler(PlayerMsgID.Vegetable, recieveVeg); |
|
|
|
} |
|
|
|
|
|
|
|
private void OnDisable() |
|
|
|
{ |
|
|
|
ClientManager.Instance.Client.UnregisterHandler(PlayerMsgID.Vegetable); |
|
|
|
} |
|
|
|
|
|
|
|
//Button calls
|
|
|
|
public void OpenRecipe() |
|
|
|
{ |
|
|
@ -65,6 +76,19 @@ public class Recipe : MonoBehaviour { |
|
|
|
public void friendlyPickup(string VeggieName, int change) |
|
|
|
{ |
|
|
|
StartCoroutine(ItemLookup(VeggieName, change)); |
|
|
|
|
|
|
|
VegMsg msg = new VegMsg(ClientManager.Instance.ID, VeggieName, change); |
|
|
|
ClientManager.Instance.SendMessage(PlayerMsgID.Vegetable, msg); |
|
|
|
} |
|
|
|
|
|
|
|
public void recieveVeg(UnityEngine.Networking.NetworkMessage msg) |
|
|
|
{ |
|
|
|
|
|
|
|
VegMsg vegMsg; |
|
|
|
if (!Utility.ReadMessage<VegMsg>(msg, out vegMsg)) |
|
|
|
return; |
|
|
|
|
|
|
|
StartCoroutine(ItemLookup(vegMsg.String, vegMsg.Int)); |
|
|
|
} |
|
|
|
|
|
|
|
IEnumerator ItemLookup(string VeggieName, int change) |
|
|
|