コード例 #1
0
 public Game1()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     _GameProxy            = new GameProxy(this);
     IsMouseVisible        = true;
 }
コード例 #2
0
        static void Main()
        {
            try
            {
                var bots = new List <IBot>
                {
                    new MediumBot(),
                    new EasyBot()
                };

                var fieldFactory = new FieldFactory();
                var board        = new Board(7, 6, fieldFactory);
                var gameFactory  = new GameFactory(board, bots.ToArray());

                var playerFactory = new PlayerFactory();
                var proxy         = new GameProxy();

                var logger = new Log4netAdapter("GameAPI");
                var api    = new GameAPI(gameFactory, playerFactory, logger, proxy);

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1(api));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                MessageBox.Show(e.ToString());
                Application.Exit();
            }
        }
コード例 #3
0
ファイル: Game.cs プロジェクト: aniltrue/BasicGameServer
 public Game(GameProxy gameProxy, String playerName, int playerID)
 {
     this.name         = gameProxy.Name;
     this.id           = gameProxy.ID;
     this.playerNumber = 0;
     this.playerName   = playerName;
     this.playerID     = playerID;
     this.isRunning    = true;
 }
コード例 #4
0
ファイル: BattleFieldViewModel.cs プロジェクト: Tatko95/Hero
 public BattleFieldViewModel(FieldViewModel fieldViewModel, User you, BattleFieldView battleFieldView)
 {
     BattleFieldView = battleFieldView;
     You             = you;
     FieldViewModel  = fieldViewModel;
     FieldViewModel.BattleFieldViewModel = this;
     Proxy = new GameProxy(this);
     Proxy.RegistrationGame(Game, you);
     BattleFieldView.Closed += BattleFieldView_Closed;
 }
コード例 #5
0
ファイル: GameCommand.cs プロジェクト: liuyongsz/bmobdemo
    public override void Execute(INotification notification)
    {
        GameProxy proxy = Facade.RetrieveProxy(ProxyID.Game) as GameProxy;

        switch (notification.Name)
        {
        case NotificationID.START_GAME:    //启动游戏
            proxy.StartGame();
            break;
        }
    }
コード例 #6
0
        private void OnAcceptTcpClient(IAsyncResult ar)
        {
            TcpClient tcpClient   = tcpListener.EndAcceptTcpClient(ar);
            BaseProxy proxyClient = null;

            try
            {
                tcpListener.BeginAcceptTcpClient(new AsyncCallback(OnAcceptTcpClient), null);
            }
            catch (Exception)
            {
                tcpListener = null;
                throw;
            }

            switch (proxyType)
            {
            case ProxyType.Bnet:
                proxyClient             = new BnetProxy(tcpClient);
                proxyClient.ProxyServer = this;
                BnetProxies.Add((BnetProxy)proxyClient);
                break;

            case ProxyType.Realm:
                proxyClient = new RealmProxy(tcpClient);
                RealmProxies.Add((RealmProxy)proxyClient);
                break;

            case ProxyType.Game:
                proxyClient = new GameProxy(tcpClient);
                GameProxies.Add((GameProxy)proxyClient);
                break;
            }

            this.ClientConnected(proxyClient, new EventArgs());
        }
コード例 #7
0
 private static string GameEndEnumToString(GameProxy.GameEndReason value)
 {
     switch (value)
     {
         case Lobby.GameProxy.GameEndReason.WON_THOUSAND_MILES:
         {
             return "Une équipe à parcouru 1000 bornes.";
         }
         case Lobby.GameProxy.GameEndReason.EXHAUSTED_DECK:
         {
             return "Toutes les cartes ont été jouées.";
         }
         case Lobby.GameProxy.GameEndReason.PLAYER_DISCONNECTION:
         {
             return "Un joueur s'est déconnecté et la partie s'est arrêtée ou il ne reste pas assez de joueurs.";
         }
         default:
         {
             return "La raison de fin est inconnue.";
         }
     }
 }
コード例 #8
0
        private void FillOpponentsTeamStates(GameProxy.GameState gameState)
        {
            for (int i = 0; i < _opponentsTeamStateControls.Length; i++)
            {
                var control = _opponentsTeamStateControls[i];

                if (i < gameState.OpponentsTeamStates.Length)
                {
                    var opponentState = gameState.OpponentsTeamStates[i];
                    control.SetTeamState(opponentState);
                    control.DataContext = opponentState.TeamIndex;
                }
                else
                {
                    control.ClearTeamState();
                    control.DataContext = null;
                }
            }
        }
コード例 #9
0
        private void FillCards(GameProxy.GameState gameState)
        {
            for (int i = 0; i < _cardsInHandImages.Length; i++)
            {
                var image = _cardsInHandImages[i];

                if (i < gameState.CardsInHand.Length)
                {
                    var card = gameState.CardsInHand[i];
                    if (_imageLookup.ContainsKey(card.CardId))
                    {
                        image.Source = GetImageFromRessources(
                            "component/Images/" + _imageLookup[card.CardId]
                        );
                        image.DataContext = card.Token;
                    }
                    else
                    {
                        image.Source = GetImageFromRessources(PLACEHOLDER_CARD);
                        image.DataContext = null;
                    }
                }
                else
                {
                    image.Source = GetImageFromRessources(PLACEHOLDER_CARD);
                    image.DataContext = null;
                }
            }
        }
コード例 #10
0
 private void FillPlayers(GameProxy.GameState gameState)
 {
     dgPlayers.ItemsSource = gameState.Players.Select(gp => new Model.GamePlayerListItem() 
     {
         IsCurrent = gp.Order == gameState.CurrentPlayer,
         TeamIndex = gp.TeamIndex,
         Name = gp.Name,
         IsSelf = gp.Order == gameState.OwnPlayerOrder,
         IsConnected = gp.Order >= 0
     });
 }
コード例 #11
0
        private void SetGameState(GameProxy.GameState gameState)
        {
            _gameState = gameState;

            tscOwnTeam.SetTeamState(gameState.OwnTeamState);
            tscOwnTeam.DataContext = gameState.OwnTeamState.TeamIndex;

            FillOpponentsTeamStates(gameState);
            FillCards(gameState);
            FillPlayers(gameState);
        }
コード例 #12
0
        private void RegisterGameProxyEvents(GameProxy proxy)
        {
            // Bnet Events
            proxy.OnAboutPlayer           += this.OnAboutPlayer;
            proxy.OnAcceptTrade           += this.OnAcceptTrade;
            proxy.OnAddUnit               += this.OnAddUnit;
            proxy.OnAssignGameObject      += this.OnAssignGameObject;
            proxy.OnAssignMerc            += this.OnAssignMerc;
            proxy.OnAssignNPC             += this.OnAssignNPC;
            proxy.OnAssignPlayer          += this.OnAssignPlayer;
            proxy.OnAssignPlayerCorpse    += this.OnAssignPlayerCorpse;
            proxy.OnAssignPlayerToParty   += this.OnAssignPlayerToParty;
            proxy.OnAssignSkill           += this.OnAssignSkill;
            proxy.OnAssignSkillHotkey     += this.OnAssignSkillHotkey;
            proxy.OnAssignWarp            += this.OnAssignWarp;
            proxy.OnAttributeNotification += this.OnAttributeNotification;
            proxy.OnDelayedState          += this.OnDelayedState;
            proxy.OnEndState              += this.OnEndState;
            proxy.OnGainExperience        += this.OnGainExperience;
            proxy.OnGameHandshake         += this.OnGameHandshake;
            proxy.OnGameLoading           += this.OnGameLoading;
            proxy.OnGameLogonReceipt      += this.OnGameLogonReceipt;
            proxy.OnGameLogonSuccess      += this.OnGameLogonSuccess;
            proxy.OnGameLogoutSuccess     += this.OnGameLogoutSuccess;
            proxy.OnGameOver              += this.OnGameOver;
            proxy.OnGoldTrade             += this.OnGoldTrade;
            proxy.OnInformationMessage    += this.OnInformationMessage;
            proxy.OnItemTriggerSkill      += this.OnItemTriggerSkill;
            proxy.OnLoadAct               += this.OnLoadAct;
            proxy.OnLoadDone              += this.OnLoadDone;
            proxy.OnMapAdd    += this.OnMapAdd;
            proxy.OnMapRemove += this.OnMapRemove;
            proxy.OnMercAttributeNotification += this.OnMercAttributeNotification;
            proxy.OnMercForHire          += this.OnMercForHire;
            proxy.OnMercForHireListStart += this.OnMercForHireListStart;
            proxy.OnMercGainExperience   += this.OnMercGainExperience;
            proxy.OnMonsterAttack        += this.OnMonsterAttack;
            proxy.OnNPCAction            += this.OnNPCAction;
            proxy.OnNPCGetHit            += this.OnNPCGetHit;
            proxy.OnNPCHeal                     += this.OnNPCHeal;
            proxy.OnNPCInfo                     += this.OnNPCInfo;
            proxy.OnNPCMove                     += this.OnNPCMove;
            proxy.OnNPCMoveToTarget             += this.OnNPCMoveToTarget;
            proxy.OnNPCStop                     += this.OnNPCStop;
            proxy.OnNPCWantsInteract            += this.OnNPCWantsInteract;
            proxy.OnOpenWaypoint                += this.OnOpenWaypoint;
            proxy.OnOwnedItemAction             += this.OnOwnedItemAction;
            proxy.OnPartyMemberPulse            += this.OnPartyMemberPulse;
            proxy.OnPartyMemberUpdate           += this.OnPartyMemberUpdate;
            proxy.OnPartyRefresh                += this.OnPartyRefresh;
            proxy.OnPlayerAttributeNotification += this.OnPlayerAttributeNotification;
            proxy.OnPlayerClearCursor           += this.OnPlayerClearCursor;
            proxy.OnPlayerCorpseVisible         += this.OnPlayerCorpseVisible;
            proxy.OnPlayerInGame                += this.OnPlayerInGame;
            proxy.OnPlayerInSight               += this.OnPlayerInSight;
            proxy.OnPlayerKillCount             += this.OnPlayerKillCount;
            proxy.OnPlayerLeaveGame             += this.OnPlayerLeaveGame;
            proxy.OnPlayerLifeManaChange        += this.OnPlayerLifeManaChange;
            proxy.OnPlayerMove                  += this.OnPlayerMove;
            proxy.OnPlayerMoveToTarget          += this.OnPlayerMoveToTarget;
            proxy.OnPlayerPartyRelationship     += this.OnPlayerPartyRelationship;
            proxy.OnPlayerReassign              += this.OnPlayerReassign;
            proxy.OnPlayerRelationship          += this.OnPlayerRelationship;
            proxy.OnPlayerStop                  += this.OnPlayerStop;
            proxy.OnPlaySound                   += this.OnPlaySound;
            proxy.OnPong                  += this.OnPong;
            proxy.OnPortalInfo            += this.OnPortalInfo;
            proxy.OnPortalOwnership       += this.OnPortalOwnership;
            proxy.OnQuestItemState        += this.OnQuestItemState;
            proxy.OnReceiveMessage        += this.OnReceiveMessage;
            proxy.OnRelator1              += this.OnRelator1;
            proxy.OnRelator2              += this.OnRelator2;
            proxy.OnRemoveGroundUnit      += this.OnRemoveGroundUnit;
            proxy.OnReportKill            += this.OnReportKill;
            proxy.OnRequestLogonInfo      += this.OnRequestLogonInfo;
            proxy.OnSetGameObjectMode     += this.OnSetGameObjectMode;
            proxy.OnSetItemState          += this.OnSetItemState;
            proxy.OnSetNPCMode            += this.OnSetNPCMode;
            proxy.OnSetState              += this.OnSetState;
            proxy.OnSkillsLog             += this.OnSkillsLog;
            proxy.OnSmallGoldAdd          += this.OnSmallGoldAdd;
            proxy.OnSummonAction          += this.OnSummonAction;
            proxy.OnSwitchWeaponSet       += this.OnSwitchWeaponSet;
            proxy.OnTransactionComplete   += this.OnTransactionComplete;
            proxy.OnUnitUseSkill          += this.OnUnitUseSkill;
            proxy.OnUnitUseSkillOnTarget  += this.OnUnitUseSkillOnTarget;
            proxy.OnUnloadDone            += this.OnUnloadDone;
            proxy.OnUpdateGameQuestLog    += this.OnUpdateGameQuestLog;
            proxy.OnUpdateItemStats       += this.OnUpdateItemStats;
            proxy.OnUpdateItemUI          += this.OnUpdateItemUI;
            proxy.OnUpdatePlayerItemSkill += this.OnUpdatePlayerItemSkill;
            proxy.OnUpdateQuestInfo       += this.OnUpdateQuestInfo;
            proxy.OnUpdateQuestLog        += this.OnUpdateQuestLog;
            proxy.OnUpdateSkill           += this.OnUpdateSkill;
            proxy.OnUseSpecialItem        += this.OnUseSpecialItem;
            proxy.OnUseStackableItem      += this.OnUseStackableItem;
            proxy.OnWalkVerify            += this.OnWalkVerify;
            proxy.OnWardenCheck           += this.OnWardenCheck;
            proxy.OnWorldItemAction       += this.OnWorldItemAction;

            //TODO: Add Diablo events here
            proxy.OnExitGame += this.OnExitGame;
        }
コード例 #13
0
 public ServerProxy(Socket socket, int clientId, bool isStopReceive) : base(socket, clientId, isStopReceive)
 {
     GameProxy = new GameProxy(clientId, "", Server.ServerVersion, SendMessage, ServerLog.Instance);
     GameProxy.SendClientIDRequest();
 }
コード例 #14
0
    public override void Execute(INotification notification)
    {
        GameProxy    _proxy    = (GameProxy)this.Facade.RetrieveProxy(GameProxy.NAME);
        GameMediator _mediator = (GameMediator)this.Facade.RetrieveMediator(GameMediator.NAME);

        switch (notification.Name)
        {
        case GameNotify.OpenPlayerDialog:
        {
            Player entity = (Player)notification.Body;
            Debug.Log(entity);
            break;
        }

        case GameNotify.OpenWait:
        {
            _mediator.ShowWaitUI(true);
            break;
        }

        case GameNotify.CloseWait:
        {
            _mediator.ShowWaitUI(false);
            break;
        }

        case GameNotify.OpenTalk:
        {
            TalkData[] entity = (TalkData[])notification.Body;
            _proxy.SetTalkDatas(entity);
            _mediator.ShowTalkUI(true);
            _mediator.InitTalkUI(_proxy.GetTalkData());
            break;
        }

        case GameNotify.TalkClick:
        {
            bool isend = _proxy.IsTalkEnd();
            if (isend)
            {
                _mediator.ShowTalkUI(false);
                if (_proxy.IsTalkChangeArea())         //场景切换
                {
                    TalkData talkData = _proxy.GetTalkData(1);
                    NpcHandler.Inst.ChangeArea(talkData.target);
                }
            }
            else
            {
                _mediator.InitTalkUI(_proxy.GetTalkData());
            }
            break;
        }

        case GameNotify.LoadChageArea:
        {
            _mediator.LoadChageArea();
            break;
        }
        }
    }
コード例 #15
0
        public void SetTeamState(GameProxy.TeamState teamState)
        {
            foreach (var def in _effectDefinitions)
            {
                bool hasState = def.StateGetter(teamState);
                bool hasInvincibility = def.InvincibilityGetter(teamState);
                Image targetImage = def.TargetImage(this);

                if (def.FlipState)
                {
                    hasState = !hasState;
                }

                if (!hasState)
                {
                    if (!hasInvincibility && teamState.PlayedCardEffects.HasFlag(def.CardEffect))
                    {
                        targetImage.Source = GetImageFromRessources(
                            "component/Images/" + def.PositiveImage
                        );
                    }
                    else
                    {
                        targetImage.Source = GetImageFromRessources(PLACEHOLDER_CARD);
                    }
                }
                else
                {
                    if (teamState.PlayedCardEffects.HasFlag(def.CardEffect))
                    {
                        targetImage.Source = GetImageFromRessources(
                            "component/Images/" + def.NegativeImage
                        );
                    }
                    else
                    {
                        targetImage.Source = GetImageFromRessources(PLACEHOLDER_CARD);
                    }
                }
            }

            foreach (var def in _invicibilityDefinitions)
            {
                bool hasInvincibility = def.InvincibilityGetter(teamState);
                Image targetImage = def.TargetImage(this);

                if (hasInvincibility)
                {
                    targetImage.Source = GetImageFromRessources(
                       "component/Images/" + def.Image
                   );
                }
                else 
                {
                    targetImage.Source = GetImageFromRessources(PLACEHOLDER_CARD);
                }
            }

            tbDistance.Text = string.Format("{0} km", teamState.DistanceTraveled);
        }