Beispiel #1
0
 public void CardChoiceCallBack(CardRearrangement arrange)
 {
     CommandItem item = new CommandItem();
     item.command = Command.Interrupt;
     item.type = ItemType.CardRearrangement;
     item.data = arrange;
     sender.Send(item);
     sender.Flush();
 }
Beispiel #2
0
 public void MoveHandCard(int from, int to)
 {
     HandCardMovement move = new HandCardMovement();
     move.playerId = SelfId;
     move.from = from;
     move.to = to;
     CommandItem item = new CommandItem();
     item.command = Command.Interrupt;
     item.type = ItemType.HandCardMovement;
     item.data = move;
     sender.Send(item);
     sender.Flush();
 }
Beispiel #3
0
 public void CardChoiceCallBack(object obj)
 {
     CommandItem item = new CommandItem();
     item.command = Command.Interrupt;
     item.obj = new CardChoiceCallback() { o = obj };
     sender.Send(item);
 }
Beispiel #4
0
 public object Receive()
 {
     object o = null;
     ItemType type = ItemType.Serializable;
     try
     {
         type = (ItemType)deserializer.DeserializeInt();
         Trace.TraceInformation("Trying to parse a {0}", type);
         switch (type)
         {
             case ItemType.CardItem:
                 var cardItem = new CardItem();
                 cardItem.playerId = deserializer.DeserializeInt();
                 cardItem.place = deserializer.DeserializeInt();
                 cardItem.rank = deserializer.DeserializeInt();
                 cardItem.suit = deserializer.DeserializeInt();
                 cardItem.id = deserializer.DeserializeInt();
                 cardItem.deckName = deserializer.DeserializeString();
                 cardItem.typeName = deserializer.DeserializeString();
                 cardItem.typeHorseName = deserializer.DeserializeString();
                 o = cardItem;
                 break;
             case ItemType.Player:
                 int? id = deserializer.DeserializeNInt();
                 o = (id == null ? null : Game.CurrentGame.Players[(int)id]);
                 break;
             case ItemType.Int:
                 o = deserializer.DeserializeInt();
                 break;
             case ItemType.SkillItem:
                 var skillItem = new SkillItem();
                 skillItem.playerId = deserializer.DeserializeInt();
                 skillItem.skillId = deserializer.DeserializeInt();
                 skillItem.name = deserializer.DeserializeString();
                 skillItem.additionalTypeName = deserializer.DeserializeString();
                 skillItem.additionalTypeHorseName = deserializer.DeserializeString();
                 o = skillItem;
                 break;
             case ItemType.CommandItem:
                 CommandItem item = new CommandItem();
                 item.command = (Command)deserializer.DeserializeInt();
                 item.type = (ItemType)deserializer.DeserializeInt();
                 if (item.type == ItemType.Int)
                     item.data = deserializer.DeserializeInt();
                 else if (item.type == ItemType.HandCardMovement)
                     item.data = deserializer.Deserialize(typeof(HandCardMovement));
                 else if (item.type == ItemType.CardRearrangement)
                     item.data = deserializer.Deserialize(typeof(CardRearrangement));
                 else if (item.type == ItemType.CardUsageResponded)
                     item.data = deserializer.Deserialize(typeof(CardUsageResponded));
                 o = item;
                 break;
             case ItemType.ValueType:
                 Type objectType = Type.GetType(deserializer.DeserializeString());
                 o = deserializer.Deserialize(objectType);
                 break;
             case ItemType.Serializable:
                 o = formatter.Deserialize(stream);
                 break;
             default:
                 o = null;
                 Trace.TraceError("Unknown item type: {0}", type);
                 break;
         }
     }
     catch (Exception e)
     {
         Trace.TraceError("Error occured when trying to deserialize an {0}, {1}. ", type, e.StackTrace);
         return null;
     }
     return o;
 }
Beispiel #5
0
 private void QueueCommand(CommandItem c)
 {
     serializer.Serialize(ItemType.CommandItem);
     serializer.Serialize(c.command);
     serializer.Serialize(c.type);
     serializer.Serialize(c.data);
 }
Beispiel #6
0
 private void QueueCommand(CommandItem c)
 {
     formatter.Serialize(stream, c);
 }
Beispiel #7
0
 public void SendMultipleCardUsageResponded(int id)
 {
     var o = new CommandItem() { command = Command.Interrupt };
     o.obj = new CardUsageResponded() { playerId = id };
     for (int ec = 0; ec < maxClients; ec++)
     {
         SendInterruptedObject(ec, o);
     }
 }