コード例 #1
0
 /// <summary>
 /// Dispatchs the event.
 /// </summary>
 /// <param name="eventObject">Event object.</param>
 public void DispatchEvent(NWEvent eventObject)
 {
     if (OnDispatchEvent != null)
     {
         OnDispatchEvent(eventObject);
     }
 }
コード例 #2
0
        public void ProcessEvent(NWEvent eventObject)
        {
            switch (eventObject.Type)
            {
            case NWEventType.PlayCard:
            {
                NWPlayer player = NWPlayer.GetPlayer((int)eventObject.Data[(int)eEventField.Player]);
                NWCard card = NWCard.GetCard((int)eventObject.Data[(int)eEventField.Card]);
                PlayCard(player, card);
                break;
            }
            case NWEventType.PutCardInResource:
            {
                NWPlayer player = NWPlayer.GetPlayer((int)eventObject.Data[(int)eEventField.Player]);
                NWCard card = NWCard.GetCard((int)eventObject.Data[(int)eEventField.Card]);
                PutCardInResources(player, card);
                break;
            }
            case NWEventType.DrawCard:
            {
                NWPlayer player = NWPlayer.GetPlayer((int)eventObject.Data[(int)eEventField.Player]);
                NWCard card = NWCard.GetCard((int)eventObject.Data[(int)eEventField.Card]);
                CardDraw(player, card);
                break;
            }
            case NWEventType.CardChangeZone:
            {
                NWZone fromZone = NWZone.GetZone((int)eventObject.Data[(int)eEventField.FromZone]);
                NWZone toZone = NWZone.GetZone((int)eventObject.Data[(int)eEventField.ToZone]);
                NWCard card = NWCard.GetCard((int)eventObject.Data[(int)eEventField.Card]);
                CardChangeZone(card, fromZone, toZone);
                break;
            }
            case NWEventType.StartTurn:
            {
                NWPlayer player = NWPlayer.GetPlayer((int)eventObject.Data[(int)eEventField.Player]);
                StartTurn(player);
                break;
            }
            case NWEventType.StartGame:
            {
                StartGame();
                break;
            }
            case NWEventType.EndTurn:
            {
                NWPlayer player = NWPlayer.GetPlayer((int)eventObject.Data[(int)eEventField.Player]);
                EndTurn(player);
                break;
            }
            case NWEventType.ZoneUpdated:
            {
                NWZone zone = NWZone.GetZone((int)eventObject.Data[(int)eEventField.Zone]);
                ZoneUpdated(zone);
                break;
            }
            case NWEventType.PayForCard:
            {
                NWPlayer player = NWPlayer.GetPlayer((int)eventObject.Data[(int)eEventField.Player]);
                NWCard card = NWCard.GetCard((int)eventObject.Data[(int)eEventField.Card]);
                PayForCard(player, card);
                break;
            }
            default:
            {
                Debug.LogError("ERROR - Unrecognized Event Type!");
                break;
            }
            }

            string eventString = "[" + eventObject.Type.ToString() + "] ";
            if (eventObject.Data != null)
            {
                foreach (int key in eventObject.Data.Keys)
                {
                    eventString += key + ": " + eventObject.Data[key].ToString() + ", ";
                }
            }
            Debug.Log(eventString);
        }
コード例 #3
0
ファイル: NWEvent.cs プロジェクト: Barnaff/NetherWars2
 public static NWEvent Draw(INWPlayer player, NWCard card)
 {
     Hashtable data = new Hashtable();
     data.Add((int)eEventField.Card, card.CardUniqueID);
     data.Add((int)eEventField.Player, player.PlayerID);
     NWEvent eventObject = new NWEvent(NWEventType.DrawCard, data);
     return eventObject;
 }
コード例 #4
0
ファイル: NWEvent.cs プロジェクト: Barnaff/NetherWars2
 public static NWEvent CardChangeZone(NWCard card, NWZone fromZone, NWZone toZone)
 {
     Hashtable data = new Hashtable();
     data.Add((int)eEventField.Card , card.CardUniqueID);
     data.Add((int)eEventField.FromZone, fromZone.ZoneID);
     data.Add((int)eEventField.ToZone, toZone.ZoneID);
     NWEvent eventObject = new NWEvent(NWEventType.CardChangeZone, data);
     return eventObject;
 }
コード例 #5
0
ファイル: NWEvent.cs プロジェクト: Barnaff/NetherWars2
 public static NWEvent ZoneUpdated(NWZone zone)
 {
     Hashtable data = new Hashtable();
     data.Add((int)eEventField.Zone, zone.ZoneID);
     NWEvent eventObject = new NWEvent(NWEventType.ZoneUpdated, data);
     return eventObject;
 }
コード例 #6
0
ファイル: NWEvent.cs プロジェクト: Barnaff/NetherWars2
 public static NWEvent StartTurn(INWPlayer player)
 {
     Hashtable data = new Hashtable();
     data.Add((int)eEventField.Player, player.PlayerID);
     NWEvent eventObject = new NWEvent(NWEventType.StartTurn, data);
     return eventObject;
 }
コード例 #7
0
ファイル: NWEvent.cs プロジェクト: Barnaff/NetherWars2
 public static NWEvent StartGame()
 {
     NWEvent eventObject = new NWEvent(NWEventType.StartGame);
     return eventObject;
 }