sync dice

dice synced for noplayableplayers
This commit is contained in:
AliIbnAbiTalib
2023-03-28 19:28:11 +02:00
parent 930fb5fa16
commit 07f499dc91
6 changed files with 59 additions and 37 deletions
+8
View File
@@ -225,6 +225,9 @@ public class Client : MonoBehaviour
players[job.data[1]].AddCoins(-items[job.data[3]].Cost);
players[job.data[1]].AddItem(items[job.data[3]]);
break;
case 10:
players[job.data[1]].ActivateItem(job.data[2]);
break;
case 126:
stream.Write(new byte[]{126, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 10);
break;
@@ -310,4 +313,9 @@ public class Client : MonoBehaviour
{
stream.Write(new byte[] { 9, (byte)item.type, 0, 0, 0, 0, 0, 0, 0, 0 });
}
public void SendActiveItem(byte index)
{
stream.Write(new byte[]{10, index, 0, 0, 0, 0, 0, 0, 0, 0});
}
}
@@ -22,8 +22,9 @@ public class NoPlayablePlayer : Player
private float timeSinceWurfeln = 0;
private Vector3 useLess = new Vector3();
private bool checkDoubleDice = false;
public override void Init()
{
@@ -59,11 +60,11 @@ public class NoPlayablePlayer : Player
{
wurfelt = true;
this.wurfelZahl = wurfelZahl;
if (activeItem == Item.Type.Mushroom)
switch (activeItem)
{
wurfelZahl += 3;
activeItem = Item.Type.None;
case Item.Type.Mushroom: wurfelZahl += 3; activeItem = Item.Type.None; break;
case Item.Type.DoubleDice: checkDoubleDice = true; activeItem = Item.Type.None; break;
}
//nächstes Feld anvisieren
@@ -125,9 +126,18 @@ public class NoPlayablePlayer : Player
if (!wurfelt)
{
StartDice();
}else if (activated)
}
else
{
StartDice();
if (!checkDoubleDice)
{
activated = false;
}
else
{
checkDoubleDice = false;
wurfelt = false;
}
}
}
}
@@ -73,7 +73,7 @@ public class PlayablePlayer : Player
switch (activeItem)
{
case Item.Type.Mushroom: wurfelZahl += 3; activeItem = Item.Type.None; break;
case Item.Type.DoubleDice: checkDoubleDice = true; break;
case Item.Type.DoubleDice: checkDoubleDice = true; activeItem = Item.Type.None; break;
}
/*
@@ -300,4 +300,11 @@ public class PlayablePlayer : Player
transform.position + Vector3.up * 2, ref useLess, 0.2f);
diceScript.StartRandom();
}
}
public void ActivateItem(int index)
{
activeItem = items[index].type;
items[index] = null;
client.SendActiveItem((byte)index);
}
}
+2 -1
View File
@@ -167,7 +167,8 @@ public class UIHandler : MonoBehaviour
public void ButtonSelectItem(int index)
{
currentPlayer.ActivateItem(index);
((PlayablePlayer)currentPlayer).ActivateItem(index);
ActivateLayout1();
}
}