private void DestoryNullReference(System.Object sender, GameUIEventArgs args)
 {
     // ReSharper disable once ConditionIsAlwaysTrueOrFalse
     if (this == null)
     {
         Channel.GameEvent -= DestoryNullReference;
     }
     else
     {
         OnSubscribedUiControllerEvents(sender, args);
     }
 }
        private void OnSubscribedUiControllerEvents(System.Object sender, GameUIEventArgs args)
        {
            //只有在刷新时才会出现,否则定时请求刷新
            if (args.EventType == GameUIEventType.Refresh)
            {
                Channel.Broadcast(new ManagerGameUIEventArgs(GameUIEventType.CancelWaitingNetwork, "PCBoard"));
                VerifyState();
            }

            if (Handlers.ContainsKey(State))
            {
                var hand = Handlers[State];
                if (hand != null)
                {
                    foreach (var handler in hand)
                    {
                        handler.ProcessGameEvents(sender, args);
                    }
                }
            }
        }
 public void Broadcast(GameUIEventArgs args)
 {
     EventQueue.Enqueue(args);
 }
Пример #4
0
        private void OnSubscribedGameEvents(object sender, GameUIEventArgs args)
        {
            if (Manager == null)
            {
                Channel.GameEvent -= OnSubscribedGameEvents;
                return;
            }
            if (args.UIKey != "NetworkManager")
            {
                return;
            }

            if (args.EventType == GameUIEventType.ForceRefresh)
            {
                //通知界面暗转等待网络
                Channel.Broadcast(new ManagerGameUIEventArgs(GameUIEventType.WaitingNetwork, "PCBoard"));

                Manager.StartCoroutine(Server.RefreshBoard(Manager.CurrentGame, () =>
                {
                    Manager.CurrentDisplayingBoardNo = Manager.CurrentGame.MyPlayerIndex;

                    var msg = new ServerGameUIEventArgs(GameUIEventType.Refresh, "PCBoard");
                    Channel.Broadcast(msg);
                }));
            }
            else if (args.EventType == GameUIEventType.TakeAction)
            {
                //通知界面暗转等待网络
                Channel.Broadcast(new ManagerGameUIEventArgs(GameUIEventType.WaitingNetwork, "PCBoard"));

                var action = (PlayerAction)args.AttachedData["PlayerAction"];
                if (action.Internal)
                {
                    Manager.StartCoroutine(Server.TakeInternalAction(Manager.CurrentGame,
                                                                     action, (actions) =>
                    {
                        Channel.Broadcast(new ManagerGameUIEventArgs(GameUIEventType.CancelWaitingNetwork, "PCBoard"));


                        var msg = new ManagerGameUIEventArgs(GameUIEventType.ReportInternalAction, "PCBoard");
                        msg.AttachedData["Actions"] = actions;
                        Channel.Broadcast(msg);

                        /*
                         * PlayerAction actionToPerform =null;
                         * foreach (var candidateAction in actions)
                         * {
                         *  if (candidateAction.ActionType == PlayerActionType.DevelopTechCard)
                         *  {
                         *      //选出Action
                         *      if (args.AttachedData.ContainsKey("AdditionalCard1") &&
                         *          candidateAction.Data[0] as CardInfo == args.AttachedData["AdditionalCard1"] as CardInfo)
                         *      {
                         *          actionToPerform = candidateAction;
                         *      }
                         *  }
                         *
                         * }
                         *
                         *
                         * if (actionToPerform == null)
                         * {
                         *  LogRecorder.Log("Selection invalid!");
                         *  //GameManager提交过来的选择无效
                         *  Channel.Broadcast(new ServerGameUIEventArgs(GameUIEventType.Refresh, "PCBoard"));
                         * }
                         * else
                         * {
                         *  Manager.StartCoroutine(Server.TakeAction(Manager.CurrentGame,
                         *      actionToPerform, () =>
                         *      {
                         *          Channel.Broadcast(new ServerGameUIEventArgs(GameUIEventType.Refresh, "PCBoard"));
                         *      }));
                         * }*/
                    }));
                }
                else
                {
                    Manager.StartCoroutine(Server.TakeAction(Manager.CurrentGame,
                                                             action, () =>
                    {
                        var msg = new ServerGameUIEventArgs(GameUIEventType.Refresh, "PCBoard");
                        Channel.Broadcast(msg);
                    }));
                }
            }
        }
Пример #5
0
 public abstract void ProcessGameEvents(System.Object sender, GameUIEventArgs args);