Sync Items Buy

This commit is contained in:
brausjonas
2023-03-03 23:23:06 +01:00
parent 62ca8b3cef
commit 32f5b49c0d
12 changed files with 94 additions and 65 deletions
@@ -580,6 +580,8 @@ MonoBehaviour:
- {fileID: 1249572665}
- {fileID: 1294515963}
- {fileID: 2095535415}
items:
- {fileID: 8043942569442897806, guid: d00b626b793557643a67184af1354f88, type: 3}
--- !u!114 &47812149
MonoBehaviour:
m_ObjectHideFlags: 0
+9 -2
View File
@@ -29,6 +29,7 @@ public class Client : MonoBehaviour
private PlayerInfoElements[] playerInfoElements = new PlayerInfoElements[4];
[SerializeField] private GameObject layout2;
[SerializeField] private Image[] uiItems;
[SerializeField] private Item[] items;
private int playerAmount = 0;
@@ -215,6 +216,9 @@ public class Client : MonoBehaviour
case 8:
((NoPlayablePlayer)players[job.data[1]]).BuyStar();
break;
case 9:
players[job.data[1]].AddItem(items[job.data[3]]);
break;
case 126:
stream.Write(new byte[]{126, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 10);
break;
@@ -295,6 +299,9 @@ public class Client : MonoBehaviour
{
stream.Write(new byte[]{8, 0, 0, 0, 0, 0, 0, 0, 0, 0});
}
//TODO: SendBuyItem
public void SendBuyItem(Item item)
{
stream.Write(new byte[] { 9, (byte)item.type, 0, 0, 0, 0, 0, 0, 0, 0 });
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ public class UIItem : MonoBehaviour
{
player.AddCoins(-item.Cost);
UIHandler.GetInstance().ButtonBack();
player.AddItem(item);
((PlayablePlayer)player).AddItem(item);
}
}
}
@@ -253,4 +253,10 @@ public class PlayablePlayer : Player
{
client.SendEventStopFinished();
}
public new void AddItem(Item item)
{
base.AddItem(item);
client.SendBuyItem(item);
}
}