Пример #1
0
        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);
            }
        }
Пример #5
0
 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);
        }
Пример #7
0
        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);
        }
Пример #8
0
 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();
         }
     }
 }
Пример #9
0
        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);
        }
Пример #10
0
 private void UpdateDeckCardCountText(GameDeck deck, int cardRecordID, DataChangeCode changeCode)
 {
     deckCardCountText.text = string.Format("{0}", deck.CardRecordIDs.Count());
 }
Пример #11
0
 private void OnDeckChanged(Deck deck, DataChangeCode changeCode)
 {
     RenderAllDeck();
 }
Пример #12
0
 private void OnSelfHandCardsChanged(GamePlayer gamePlayer, int cardRecordID, DataChangeCode changeCode)
 {
     selfSelectPanel.RenderCards(GameInstance.SelfGamePlayer.HandCardIDs, false);
 }
Пример #13
0
 private void OnOpponentHandCardsChanged(GamePlayer gamePlayer, int cardRecordID, DataChangeCode changeCode)
 {
     opponentSelectPanel.RenderCards(GameInstance.OpponentGamePlayer.HandCardIDs, true);
 }
Пример #14
0
 private void RenderHands(GamePlayer gamePlayer, int cardRecordID, DataChangeCode changeCode)
 {
     hand.RenderHand(gamePlayer, isOpponent);
 }
Пример #15
0
 private void OnDeckCardChanged(Deck deck, Card card, DataChangeCode changeCode)
 {
     RenderAllDeckCards();
 }