internal override bool Handle(PlayerSyncDataCode syncCode, Dictionary <byte, object> parameters, out string errorMessage) { if (base.Handle(syncCode, parameters, out errorMessage)) { DataChangeCode changeCode = (DataChangeCode)parameters[(byte)SyncDeckChangedParameterCode.DataChangeCode]; int deckID = (int)parameters[(byte)SyncDeckChangedParameterCode.DeckID]; string deckName = (string)parameters[(byte)SyncDeckChangedParameterCode.DeckName]; int maxCardCount = (int)parameters[(byte)SyncDeckChangedParameterCode.MaxCardCount]; switch (changeCode) { case DataChangeCode.Add: subject.LoadDeck(new Deck(deckID, deckName, maxCardCount)); break; case DataChangeCode.Remove: subject.RemoveDeck(deckID); break; } return(true); } else { return(false); } }
internal override bool Handle(PlayerSyncDataCode syncCode, Dictionary <byte, object> parameters, out string errorMessage) { if (base.Handle(syncCode, parameters, out errorMessage)) { DataChangeCode changeCode = (DataChangeCode)parameters[(byte)SyncDeckCardChangedParameterCode.DataChangeCode]; int deckID = (int)parameters[(byte)SyncDeckCardChangedParameterCode.DeckID]; int cardID = (int)parameters[(byte)SyncDeckCardChangedParameterCode.CardID]; Deck deck; Card card; if (subject.FindDeck(deckID, out deck) && CardManager.Instance.FindCard(cardID, out card)) { switch (changeCode) { case DataChangeCode.Add: deck.AddCard(card); break; case DataChangeCode.Remove: deck.RemoveCard(cardID); break; } return(true); } else { return(false); } } else { return(false); } }
internal override bool Handle(GamePlayerSyncDataCode syncCode, Dictionary <byte, object> parameters, out string errorMessage) { if (base.Handle(syncCode, parameters, out errorMessage)) { DataChangeCode changeCode = (DataChangeCode)parameters[(byte)SyncHandCardsChangedParameterCode.DataChangeCode]; int cardRecordID = (int)parameters[(byte)SyncHandCardsChangedParameterCode.CardRecordID]; switch (changeCode) { case DataChangeCode.Add: subject.AddHandCard(cardRecordID); break; case DataChangeCode.Remove: subject.RemoveHandCard(cardRecordID); break; default: errorMessage = "Undefined changeCode"; return(false); } return(true); } else { return(false); } }
internal override bool Handle(FieldSyncDataCode syncCode, Dictionary <byte, object> parameters, out string errorMessage) { if (base.Handle(syncCode, parameters, out errorMessage)) { DataChangeCode changeCode = (DataChangeCode)parameters[(byte)SyncCardChangedParameterCode.DataChangeCode]; Library.Field.FieldCardRecord record = SerializationHelper.Deserialize <Library.Field.FieldCardRecord>((byte[])parameters[(byte)SyncCardChangedParameterCode.FieldCardRecordByteArray]); switch (changeCode) { case DataChangeCode.Add: subject.AddCard(record.CardRecordID, record.PositionIndex); break; case DataChangeCode.Remove: subject.RemoveCard(record.CardRecordID); break; case DataChangeCode.Update: subject.UpdateCard(record.CardRecordID, record.PositionIndex); break; default: errorMessage = "Undefined changeCode"; return(false); } return(true); } else { return(false); } }
private void ToGameScene(Game game, DataChangeCode changeCode) { if (changeCode == DataChangeCode.Add) { GameInstance.Game = game; SceneManager.LoadScene("Game"); } }
public void SyncDeckCardsChanged(GameDeck deck, int cardRecordID, DataChangeCode changeCode) { Dictionary <byte, object> eventData = new Dictionary <byte, object> { { (byte)SyncDeckCardsChangedParameterCode.DataChangeCode, (byte)changeCode }, { (byte)SyncDeckCardsChangedParameterCode.CardRecordID, cardRecordID } }; SendSyncData(GamePlayerSyncDataCode.DeckCardsChanged, eventData); }
public void SyncCardChanged(Library.Field.FieldCardRecord record, DataChangeCode changeCode) { Dictionary <byte, object> eventData = new Dictionary <byte, object> { { (byte)SyncCardChangedParameterCode.DataChangeCode, (byte)changeCode }, { (byte)SyncCardChangedParameterCode.FieldCardRecordByteArray, SerializationHelper.Serialize(record) }, }; SendSyncData(FieldSyncDataCode.FieldCardChanged, eventData); }
private void Hero_OnWeaponChanged(Hero hero, DataChangeCode changeCode) { if (changeCode == DataChangeCode.Remove) { CardRecord record; if (GameCardManager.FindCard(hero.WeaponCardRecordID, out record) && record is WeaponCardRecord) { (record as WeaponCardRecord).Destroy(); } } }
public void SyncDeckChanged(Deck deck, DataChangeCode changeCode) { Dictionary <byte, object> eventData = new Dictionary <byte, object> { { (byte)SyncDeckChangedParameterCode.DataChangeCode, (byte)changeCode }, { (byte)SyncDeckChangedParameterCode.DeckID, deck.DeckID }, { (byte)SyncDeckChangedParameterCode.DeckName, deck.DeckName }, { (byte)SyncDeckChangedParameterCode.MaxCardCount, deck.MaxCardCount } }; SendSyncData(PlayerSyncDataCode.DeckChanged, eventData); }
private void UpdateDeckCardCountText(GameDeck deck, int cardRecordID, DataChangeCode changeCode) { deckCardCountText.text = string.Format("{0}", deck.CardRecordIDs.Count()); }
private void OnDeckChanged(Deck deck, DataChangeCode changeCode) { RenderAllDeck(); }
private void OnSelfHandCardsChanged(GamePlayer gamePlayer, int cardRecordID, DataChangeCode changeCode) { selfSelectPanel.RenderCards(GameInstance.SelfGamePlayer.HandCardIDs, false); }
private void OnOpponentHandCardsChanged(GamePlayer gamePlayer, int cardRecordID, DataChangeCode changeCode) { opponentSelectPanel.RenderCards(GameInstance.OpponentGamePlayer.HandCardIDs, true); }
private void RenderHands(GamePlayer gamePlayer, int cardRecordID, DataChangeCode changeCode) { hand.RenderHand(gamePlayer, isOpponent); }
private void OnDeckCardChanged(Deck deck, Card card, DataChangeCode changeCode) { RenderAllDeckCards(); }