Browse Source

Implement pile face down property on the client

new_protocol
KeyKoder 5 years ago
parent
commit
5a8eea1dc5
  1. 11
      unity/Assets/Scripts/GameLoader.cs

11
unity/Assets/Scripts/GameLoader.cs

@ -10,6 +10,7 @@ public class PileProperties {
public string name; public string name;
public string owner; public string owner;
public Game.GameStatus.Types.Card[] cards; public Game.GameStatus.Types.Card[] cards;
public bool faceDown;
public GameObject gameObject; public GameObject gameObject;
} }
@ -128,7 +129,7 @@ public class GameLoader : MonoBehaviour {
} }
} }
if(!visible) { if(!visible || pileProps.faceDown) {
card.transform.GetChild(1).Rotate(0, 180f, 0); card.transform.GetChild(1).Rotate(0, 180f, 0);
} }
@ -176,15 +177,15 @@ public class GameLoader : MonoBehaviour {
foreach(var pair in piles.Keys.Zip(piles.Values, (key, value) => new dynamic[] { key, value })) { foreach(var pair in piles.Keys.Zip(piles.Values, (key, value) => new dynamic[] { key, value })) {
string key = (string)pair[0]; string key = (string)pair[0];
Game.GameStatus.Types.Pile value = (Game.GameStatus.Types.Pile)pair[1]; Game.GameStatus.Types.Pile value = (Game.GameStatus.Types.Pile)pair[1];
if(GetPile(key+mmc.currentUsername) == null) RegisterPile(key + mmc.currentUsername, new PileProperties { name = key, owner = mmc.currentUsername, cards = value.Cards.ToArray(), gameObject = myself.handUI}); if(GetPile(key+mmc.currentUsername) == null) RegisterPile(key + mmc.currentUsername, new PileProperties { name = key, owner = mmc.currentUsername, cards = value.Cards.ToArray(), gameObject = myself.handUI, faceDown = value.FaceDown });
else UpdatePile(key + mmc.currentUsername, new PileProperties { name = key, owner = mmc.currentUsername, cards = value.Cards.ToArray(), gameObject = myself.handUI }); else UpdatePile(key + mmc.currentUsername, new PileProperties { name = key, owner = mmc.currentUsername, cards = value.Cards.ToArray(), gameObject = myself.handUI, faceDown = value.FaceDown });
} }
piles = myself.conn.GetCommonPiles(); piles = myself.conn.GetCommonPiles();
foreach (var pair in piles.Keys.Zip(piles.Values, (key, value) => new dynamic[] { key, value })) { foreach (var pair in piles.Keys.Zip(piles.Values, (key, value) => new dynamic[] { key, value })) {
string key = (string)pair[0]; string key = (string)pair[0];
Game.GameStatus.Types.Pile value = (Game.GameStatus.Types.Pile)pair[1]; Game.GameStatus.Types.Pile value = (Game.GameStatus.Types.Pile)pair[1];
if (GetPile(key + "_common") == null) RegisterPile(key + "_common", new PileProperties { name = key, owner = "", cards = value.Cards.ToArray(), gameObject = key == "placed" ? myself.thrownCards : myself.deck }); if (GetPile(key + "_common") == null) RegisterPile(key + "_common", new PileProperties { name = key, owner = "", cards = value.Cards.ToArray(), gameObject = key == "placed" ? myself.thrownCards : myself.deck, faceDown = value.FaceDown });
else UpdatePile(key+"_common", new PileProperties { name = key, owner = "", cards = value.Cards.ToArray(), gameObject = key == "placed" ? myself.thrownCards : myself.deck }); else UpdatePile(key+"_common", new PileProperties { name = key, owner = "", cards = value.Cards.ToArray(), gameObject = key == "placed" ? myself.thrownCards : myself.deck, faceDown = value.FaceDown });
} }
var cards = FindObjectsOfType<Card>(); var cards = FindObjectsOfType<Card>();
foreach (Card card in cards) { foreach (Card card in cards) {

Loading…
Cancel
Save