public GameManagerController(GameManagerScope scope, UIManagerService uiManager, CreateUIService createUIService,
            ClientSiteManagerService clientSiteManagerService, MessageService messageService)
        {
            myScope = scope;
            myUIManager = uiManager;
            this.createUIService = createUIService;
            myClientSiteManagerService = clientSiteManagerService;
            myMessageService = messageService;
            myScope.Model = new GameManagerModel();
            myScope.Visible = true;
            myClientSiteManagerService.GetGamesByUser(myUIManager.ClientInfo.LoggedInUser.Hash);

            myClientSiteManagerService.OnGetGamesByUserReceived += OnOnGetGamesByUserReceivedFn;
            myClientSiteManagerService.OnDeveloperCreateGameReceived += OnDeveloperCreateGameReceivedFn;
            myClientSiteManagerService.OnDoesGameNameExistReceived += OnDoesGameNameExistReceivedFn;

            myScope.Model.CreateGame += CreateGameFn;
            myScope.Model.DeleteGame += DeleteGameFn;
            myScope.Watch("model.selectedGame",
                () =>
                {
                    if (myScope.Model.SelectedGame == null) return;

                    createUIService.CreateSingleton<GameEditorScope>(GameEditorController.View,
                        (_scope, elem) =>
                        {
                            _scope.Model = new GameEditorModel();
                            _scope.Model.Game = myScope.Model.SelectedGame;
                        });
                    if (!scope.Minimized)
                        scope.Minimize();
                });
        }
예제 #2
0
        public LoginController(LoginScope scope, UIManagerService uiManager,
            ClientSiteManagerService clientSiteManagerService, MessageService messageService,
            CreateUIService createUIService, ClientManagerService clientManagerService)
        {
            myScope = scope;
            myScope.Visible = true;
            myUIManager = uiManager;
            myclientSiteManagerService = clientSiteManagerService;
            myMessageService = messageService;
            myCreateUIService = createUIService;
            this.clientManagerService = clientManagerService;
            myScope.Model = new LoginScopeModel();
/*
            scope.Model.dosomething += (o) =>
            {
                Console.WriteLine(o);
            };
*/
            scope.Model.Username = "******";
            scope.Model.Password = "******";


            myScope.Model.WindowClosed = () => { Window.Alert("woooo"); };
            myScope.Model.LoginAccount = LoginAccountFn;
            myScope.Model.CreateAccount = CreateAccountFn;
            myclientSiteManagerService.OnLogin += OnLoginFn;
            myclientSiteManagerService.OnUserCreate += OnUserCreateFn;

            /* myScope.Model.Username = "******";
            myScope.Model.Password = "******";

            */
//            Window.SetTimeout(LoginAccountFn, 250);
        }
        public GameTestEditorController(GameTestEditorScope scope, ClientSiteManagerService clientSiteManagerService, ClientDebugManagerService clientDebugManagerService, MessageService messageService, CreateUIService createUIService)
        {
            this.scope = scope;
            myClientSiteManagerService = clientSiteManagerService;
            this.clientDebugManagerService = clientDebugManagerService;
            myMessageService = messageService;
            myCreateUIService = createUIService;
            this.scope.Visible = false;
            scope.Model.Log = new List<string>();

            this.scope.OnReady += () =>
            {
                this.scope.SwingAway(SwingDirection.Right, true, null);
                this.scope.SwingBack(null);
            };

            this.scope.Model.StartGame = StartGameFn;
            this.scope.Model.DestroyGame = DestroyGameFn;

            this.scope.Model.GameRunning = false;



            this.scope.Watch("model.game", () => { this.scope.Model.UpdateStatus = UpdateStatusType.Dirty; }, true);
            myClientSiteManagerService.OnDeveloperUpdateGameReceived += OnDeveloperUpdateGameReceivedFn;
            this.scope.Model.UpdateStatus = UpdateStatusType.Synced;
            this.scope.Model.UpdateGame = UpdateGameFn;


            clientDebugManagerService.OnGetDebugLog += clientDebugManagerService_OnGetDebugLog;
            clientDebugManagerService.OnGameStarted += (user, roomModel) =>
            {
                this.scope.Model.GameRunning = true;
                this.scope.Model.Room = roomModel;
                if (this.scope.Model.CodeEditor != null)
                    this.scope.Model.CodeEditor.Scope.Model.Room = roomModel;
            };

            this.scope.Model.DebugCode = () =>
                                         {
                                             this.scope.Model.CodeEditor = myCreateUIService.CreateSingleton<DebugGameCodeScope>(DebugGameCodeController.View, (innerScope, elem) =>
                                                                                                                                        {
                                                                                                                                            innerScope.Model = new DebugGameCodeScopeModel();
                                                                                                                                            innerScope.Model.Game = this.scope.Model.Game;
                                                                                                                                            innerScope.Model.Selection = this.scope.Model.Selection;
                                                                                                                                        });
                                         };


            /*
                        Window.SetTimeout(() =>
                                          {
                                              StartGameFn();
                                              scope.Minimize();
                                          }, 250);
            */


        }
        public GameEditorController(GameEditorScope scope,
            ClientSiteManagerService clientSiteManagerService, ClientDebugManagerService clientDebugManagerService,
            MessageService messageService, CreateUIService createUIService)
        {
            myScope = scope;
            myClientSiteManagerService = clientSiteManagerService;
            this.clientDebugManagerService = clientDebugManagerService;
            myMessageService = messageService;
            myCreateUIService = createUIService;
            myScope.Model.OpenCode = OpenCodeFn;
            myScope.Model.OpenEffects = OpenEffectsFn;
            myScope.Model.OpenLayout = OpenLayoutFn;
            myScope.Model.OpenTest = OpenTestFn;
            myScope.Model.Selection = new GameEditorSelectionScopeModel()
                                      {
                                          ShowGrid = true,
                                          ShowCards = true,
                                          SelectedScenarioPieces = new SelectedScenarioPieces()
                                                                   {
                                                                       Piece = SelectedScenarioPieceType.None
                                                                   }
                                      };

            myScope.Visible = false;
            myScope.OnClose += () =>
                               {
                                   //todo destroy spawned
                               };
            myScope.Watch("model.game",
                () => { myScope.Model.UpdateStatus = UpdateStatusType.Dirty; },
                true);
            myClientSiteManagerService.OnDeveloperUpdateGameReceived += OnDeveloperUpdateGameReceivedFn;
            myScope.Model.UpdateStatus = UpdateStatusType.Synced;
            myScope.Model.UpdateGame = UpdateGameFn;
            myScope.OnReady += () =>
                               {
                                   myScope.SwingAway(SwingDirection.TopRight, true, null);
                                   myScope.SwingBack(null);
                               };
/*
            Window.SetTimeout(() =>
                              {
                                  OpenTestFn();
                                  scope.Minimize();
                              }, 100);
*/

        }
예제 #5
0
        public HomeController(HomeScope scope, UIManagerService uiManager,
            ClientSiteManagerService clientSiteManagerService, CreateUIService createUIService)
        {
            myScope = scope;
            myUIManager = uiManager;
            myClientSiteManagerService = clientSiteManagerService;
            myCreateUIService = createUIService;
            myScope.Model = new HomeModel();
            myScope.Visible = false;
            scope.Model.GameTypeSelected += GameTypeSelectedFn;
            scope.Model.RoomSelected += RoomSelectedFn;
            scope.Model.CreateRoom += CreateRoomFn;
            scope.Model.CreateGame += CreateGameFn;
            scope.Model.JoinRoom += JoinRoomFn;
            scope.Watch<HomeScope>((_scope) => { return myScope.Model.SelectedGameType; },
                () => { scope.Model.GameTypeSelected(); });
            /*  scope.Watch<HomeScope>((_scope) => { return myScope.Model.SelectedRoom; },
                                 () =>
                                   {
                                       scope.Model.RoomSelected();
                                   });*/


            myClientSiteManagerService.OnGetGameTypesReceived += PopulateGames;
            myClientSiteManagerService.OnGetRoomsReceived += PopulateRooms;
            myClientSiteManagerService.OnRoomJoined += RoomJoined;
            myClientSiteManagerService.OnGetRoomInfoReceived += GetRoomInfoReceived;

            scope.OnReady += () =>
                             {
                                 myScope.SwingAway(SwingDirection.BottomLeft, true, null);
                                 myScope.SwingBack(null);
                                 myScope.Apply();
                                 myScope.Model.User = myUIManager.ClientInfo.LoggedInUser;
                                 myClientSiteManagerService.GetGameTypes();
                             };

            //Window.SetTimeout(CreateGameFn, 100);
        }
        public GameLayoutEditorController(GameLayoutEditorScope scope,
            ClientSiteManagerService clientSiteManagerService, MessageService messageService,
            CreateUIService createUIService)
        {
            myScope = scope;
            myClientSiteManagerService = clientSiteManagerService;
            myMessageService = messageService;
            myCreateUIService = createUIService;
            myScope.Visible = true;
            myScope.Model.ToggleGrid = ToggleGridFn;
            myScope.Model.ToggleCards = ToggleCardsFn;
            myScope.Model.AddText = AddTextFn;
            myScope.Model.AddArea = AddAreaFn;
            myScope.Model.AddSpace = AddSpaceFn;
            myScope.Model.RemoveArea = RemoveAreaFn;
            myScope.Model.RemoveSpace = RemoveSpaceFn;
            myScope.Model.RemoveText = RemoveTextFn;
            myScope.Model.OpenScenarios = OpenScenariosFn;
            myScope.Model.Selection.SelectedLayoutPiece = SelectedGameLayoutPiece.None;
            myScope.Watch("model.selection.selectedSpace", () =>
                                                           {
                                                               if (myScope.Model.Selection.SelectedSpace == null)
                                                                   return;
                                                               myScope.Model.Selection.SelectedText = null;
                                                               myScope.Model.Selection.SelectedArea = null;
                                                               myScope.Model.Selection.SelectedLayoutPiece = SelectedGameLayoutPiece.Space;
                                                               myScope.Model.Selection.SelectedCard = null;
                                                           });
            myScope.Watch("model.selection.selectedText", () =>
                                                          {
                                                              if (myScope.Model.Selection.SelectedText == null) return;
                                                              myScope.Model.Selection.SelectedSpace = null;
                                                              myScope.Model.Selection.SelectedArea = null;
                                                              myScope.Model.Selection.SelectedLayoutPiece = SelectedGameLayoutPiece.Text;
                                                          });
            myScope.Watch("model.selection.selectedArea", () =>
                                                          {
                                                              if (myScope.Model.Selection.SelectedArea == null) return;
                                                              myScope.Model.Selection.SelectedText = null;
                                                              myScope.Model.Selection.SelectedSpace = null;
                                                              myScope.Model.Selection.SelectedLayoutPiece = SelectedGameLayoutPiece.Area;
                                                          });
            myScope.Watch("model.game", () => { myScope.Model.UpdateStatus = UpdateStatusType.Dirty; }, true);
            myClientSiteManagerService.OnDeveloperUpdateGameReceived += OnDeveloperUpdateGameReceivedFn;
            myScope.Model.UpdateStatus = UpdateStatusType.Synced;
            myScope.Model.UpdateGame = UpdateGameFn;

            var testgame = myCreateUIService.CreateSingleton<TestGameControllerScope>(TestGameController.View, (_scope, elem) =>
                                                                                                            {
                                                                                                                _scope.Model = new TestGameControllerScopeModel();
                                                                                                                _scope.Model.Game = myScope.Model.Game;
                                                                                                                _scope.Model.Selection = myScope.Model.Selection;
                                                                                                            });
            myScope.OnClose += () =>
                               {
                                   testgame.Destroy();
                                   if (scenario != null)
                                   {
                                       scenario.Destroy();
                                   }
                               };

        }
        public GameScenarioEditorController(GameScenarioEditorScope scope,
            ClientSiteManagerService clientSiteManagerService, MessageService messageService,
            CreateUIService createUIService)
        {
            myScope = scope;
            myClientSiteManagerService = clientSiteManagerService;
            myMessageService = messageService;
            myCreateUIService = createUIService;
            myScope.Visible = true;

            myScope.Watch("model.game",
                () => { myScope.Model.UpdateStatus = UpdateStatusType.Dirty; },
                true);

            myScope.Watch("model.selection.selectedScenario", () =>
                                                              {
                                                                  if (myScope.Model.Selection.SelectedScenario == null)
                                                                      return;
                                                                  myScope.Model.Selection.SelectedScenarioEffect = null;
                                                                  myScope.Model.Selection.SelectedScenarioSpace = null;
                                                                  if (myScope.Model.Selection.SelectedSpace == null)
                                                                      return;

                                                                  foreach (
                                                                      var gameLayoutScenarioSpace in
                                                                          myScope.Model.Selection.SelectedScenario
                                                                              .Spaces)
                                                                  {
                                                                      if (gameLayoutScenarioSpace.SpaceGuid ==
                                                                          myScope.Model.Selection.SelectedSpace.Guid)
                                                                      {
                                                                          myScope.Model.Selection.SelectedScenarioSpace
                                                                              = gameLayoutScenarioSpace;
                                                                          break;
                                                                      }
                                                                  }
                                                              });

            myScope.Watch("model.selection.selectedScenarioSpace", () =>
                                                                   {
                                                                       if (
                                                                           myScope.Model.Selection.SelectedScenarioSpace ==
                                                                           null) return;
                                                                       myScope.Model.Selection.SelectedScenarioEffect =
                                                                           null;
                                                                       myScope.Model.Selection.SelectedScenarioPiece =
                                                                           SelectedGameScenarioPiece.Space;
                                                                   });
            myScope.Watch("model.selection.selectedScenarioEffect", () =>
                                                                    {
                                                                        if (
                                                                            myScope.Model.Selection
                                                                                .SelectedScenarioEffect == null) return;
                                                                        myScope.Model.Selection.SelectedScenarioSpace =
                                                                            null;
                                                                        myScope.Model.Selection.SelectedScenarioPiece =
                                                                            SelectedGameScenarioPiece.Effect;
                                                                    });

            myScope.Model.GetSpaceBySpaceGuid = GetSpaceBySpaceGuidFn;
            myScope.Model.GetAreaByAreaGuid = GetAreaByAreaGuidFn;
            myScope.Model.GetTextByTextGuid = GetTextByTextGuidFn;
            myScope.Model.GetCardByCardGuid = GetCardByCardGuidFn;

            myScope.Model.RemoveSpaceFromEffect = RemoveSpaceFromEffectFn;
            myScope.Model.RemoveAreaFromEffect = RemoveAreaFromEffectFn;
            myScope.Model.RemoveCardFromEffect = RemoveCardFromEffectFn;
            myScope.Model.RemoveTextFromEffect = RemoveTextFromEffectFn;

            myScope.Model.GetEffectByScenarioEffect = GetEffectByScenarioEffectFn;
            myScope.Model.AddCardToSpace = AddCardToSpaceFn;
            myScope.Model.RemoveCardFromSpace = RemoveCardFromSpaceFn;
            myScope.Model.AddNewScenario = AddNewScenarioFn;
            myScope.Model.CloneNewScenario = CloneNewScenarioFn;
            myScope.Model.DeleteScenario = DeleteScenarioFn;
            myScope.Model.GetCurrentlySelected = GetCurrentlySelectedFn;
            myScope.Model.ApplyEffectToCurrentlySelected = ApplyEffectToCurrentlySelectedFn;


            myClientSiteManagerService.OnDeveloperUpdateGameReceived += OnDeveloperUpdateGameReceivedFn;
            myScope.Model.UpdateStatus = UpdateStatusType.Synced;
            myScope.Model.UpdateGame = UpdateGameFn;
        }
 public ClientManagerService(ClientSiteManagerService clientSiteManagerService, ClientGameManagerService clientGameManagerService, ClientDebugManagerService clientDebugManagerService, ClientChatManagerService clientChatManagerService)
 {
     ClientSiteManagerService = clientSiteManagerService;
     ClientGameManagerService = clientGameManagerService;
     ClientDebugManagerService = clientDebugManagerService;
     ClientChatManagerService = clientChatManagerService;
 }