|
|
|
@ -135,7 +135,7 @@ public class GameLoader : MonoBehaviour { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(!visible || pileProps.faceDown) { |
|
|
|
if (!visible || pileProps.faceDown) { |
|
|
|
card.transform.GetChild(1).Rotate(0, 180f, 0); |
|
|
|
} |
|
|
|
|
|
|
|
@ -154,6 +154,26 @@ public class GameLoader : MonoBehaviour { |
|
|
|
} |
|
|
|
|
|
|
|
void SpawnCards() { |
|
|
|
List<Client.Card> cards = new List<Client.Card>(); |
|
|
|
foreach (string key in pileRegistry.Keys) { |
|
|
|
foreach (Game.GameStatus.Types.Card card in pileRegistry[key].cards) { |
|
|
|
if (!cardImages.ContainsKey(card.Kind.Kind)) { |
|
|
|
// string uuid = card.Uuid;
|
|
|
|
// string kind = card.Kind.Kind;
|
|
|
|
// int idx2 = idx;
|
|
|
|
// string key2 = key;
|
|
|
|
// bool visible = card.Visible;
|
|
|
|
// conn.eventManager.AddHandler("game_card_image_" + uuid, (Game.Image image) => {
|
|
|
|
// if(!SpawnCard(uuid, kind, idx2, key2, visible, image)) return;
|
|
|
|
// conn.eventManager.RemoveHandler(Protocol.ServerClientPacket.DataOneofCase.ReturnCardImage, "game_card_image_" + uuid);
|
|
|
|
// });
|
|
|
|
// conn.GetCardImage(card.Kind.Kind);
|
|
|
|
cards.Add(new Client.Card(card.Kind.Kind)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
string handlerName = "game_cards_images_" + (DateTime.Now - Client.UnixEpoch()).TotalMilliseconds; |
|
|
|
conn.eventManager.AddHandler(handlerName, (Images i) => { |
|
|
|
foreach (string key in pileRegistry.Keys) { |
|
|
|
int idx = 0; |
|
|
|
foreach (Game.GameStatus.Types.Card card in pileRegistry[key].cards) { |
|
|
|
@ -165,15 +185,20 @@ public class GameLoader : MonoBehaviour { |
|
|
|
int idx2 = idx; |
|
|
|
string key2 = key; |
|
|
|
bool visible = card.Visible; |
|
|
|
conn.eventManager.AddHandler("game_card_image_" + uuid, (Game.Image image) => { |
|
|
|
if(!SpawnCard(uuid, kind, idx2, key2, visible, image)) return; |
|
|
|
conn.eventManager.RemoveHandler(Protocol.ServerClientPacket.DataOneofCase.ReturnCardImage, "game_card_image_" + uuid); |
|
|
|
}); |
|
|
|
conn.GetCardImage(card.Kind.Kind); |
|
|
|
// conn.eventManager.AddHandler("game_card_image_" + uuid, (Game.Image image) => {
|
|
|
|
// if (!SpawnCard(uuid, kind, idx2, key2, visible, image)) return;
|
|
|
|
// conn.eventManager.RemoveHandler(Protocol.ServerClientPacket.DataOneofCase.ReturnCardImage, "game_card_image_" + uuid);
|
|
|
|
// });
|
|
|
|
// conn.GetCardImage(card.Kind.Kind);
|
|
|
|
Game.Image image = i.GetImage(kind); |
|
|
|
SpawnCard(uuid, kind, idx2, key2, visible, image); |
|
|
|
} |
|
|
|
idx++; |
|
|
|
} |
|
|
|
} |
|
|
|
conn.eventManager.RemoveHandler(Protocol.ServerClientPacket.DataOneofCase.ReturnCardsImages, handlerName); |
|
|
|
}); |
|
|
|
conn.GetCardImages(cards.ToArray()); |
|
|
|
} |
|
|
|
public static void ReloadPiles() { |
|
|
|
if (instance == null) return; |
|
|
|
@ -198,7 +223,7 @@ public class GameLoader : MonoBehaviour { |
|
|
|
pileEntry.tab.SetActive(value.Visible); |
|
|
|
pileEntry.gameObject.SetActive(value.Visible); |
|
|
|
} |
|
|
|
if((instance.firstReload && instance.pileTabs.GetComponentInChildren<Button>() != null) || instance.pileTabs.GetComponentsInChildren<Button>().Length == 1) instance.pileTabs.GetComponentInChildren<Button>().onClick.Invoke(); |
|
|
|
if ((instance.firstReload && instance.pileTabs.GetComponentInChildren<Button>() != null) || instance.pileTabs.GetComponentsInChildren<Button>().Length == 1) instance.pileTabs.GetComponentInChildren<Button>().onClick.Invoke(); |
|
|
|
|
|
|
|
// Hardcoded values for pile gameobjects
|
|
|
|
piles = instance.conn.GetCommonPiles(); |
|
|
|
@ -206,7 +231,7 @@ public class GameLoader : MonoBehaviour { |
|
|
|
string key = (string)pair[0]; |
|
|
|
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" ? instance.thrownCards : instance.deck, faceDown = value.FaceDown }); |
|
|
|
else UpdatePile(key+"_common", new PileProperties { name = key, owner = "", cards = value.Cards.ToArray(), gameObject = key == "placed" ? instance.thrownCards : instance.deck, faceDown = value.FaceDown }); |
|
|
|
else UpdatePile(key + "_common", new PileProperties { name = key, owner = "", cards = value.Cards.ToArray(), gameObject = key == "placed" ? instance.thrownCards : instance.deck, faceDown = value.FaceDown }); |
|
|
|
} |
|
|
|
var cards = FindObjectsOfType<Card>(true); |
|
|
|
foreach (Card card in cards) { |
|
|
|
|