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 DebugQuestionController(QuestionScope scope,ClientDebugManagerService clientDebugManagerService) { myScope = scope; myClientDebugManagerService = clientDebugManagerService; myScope.Model.AnswerQuestion = AnswerQuestionFn; myScope.Visible = false; myScope.OnReady += () => { myScope.SwingAway(SwingDirection.TopLeft, true, null); myScope.SwingBack(null); }; }
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); */ }
public DebugGameController(DebugGameControllerScope scope, ClientDebugManagerService clientDebugManagerService, GameContentManagerService gameContentManagerService, CreateUIService createUIService) { this.scope = scope; myClientDebugManagerService = clientDebugManagerService; myGameContentManagerService = gameContentManagerService; this.createUIService = createUIService; scope.GameModel = new DebugGameModel(); CreatedUI<QuestionScope> lastQuestion = null; myClientDebugManagerService.OnAskQuestion += (user, gameSendAnswerModel) => { lastQuestion = createUIService.CreateSingleton<QuestionScope>(DebugQuestionController.View, (myScope, elem) => { myScope.Model = new QuestionScopeModel(); myScope.Model.Question = gameSendAnswerModel.Question; myScope.Model.Answers = gameSendAnswerModel.Answers; myScope.Model.SelectedAnswer = gameSendAnswerModel.Answers[0]; }); }; scope.OnDestroy += () => { if (lastQuestion != null) { lastQuestion.Destroy(); } }; /* effectManager.Effects =new List<GameEffectModel>(); effectManager.Effects.Add(GameEffectsEditorController.makeEffect("bend", EffectType.Bend)); */ /* myClientDebugManagerService.OnAskQuestion += (user, gameSendAnswerModel) => { PageHandler.QuestionUI.Load(gameSendAnswerModel); //alert(JSON.stringify(data)); PageHandler.TimeTracker.EndTime = new DateTime(); var time = PageHandler.TimeTracker.EndTime - PageHandler.TimeTracker.StartTime; PageHandler. DebugUI.lblHowFast.Text = ( "how long: " + time ); }; */ var sheet = ClientHelpers.CreateCSSSheet(); for (int i = 0; i < 4; i++) { for (int j = 0; j < 13; j++) { ClientHelpers.AddCSSRule(sheet, ".card" + i + "-" + j + "", new JsDictionary<string, object>()); ClientHelpers.AddCSSRule(sheet, ".card" + i + "-" + j + "::before", new JsDictionary<string, object>()); ClientHelpers.AddCSSRule(sheet, ".card" + i + "-" + j + "::after", new JsDictionary<string, object>()); } } ClientHelpers.AddCSSRule(sheet, ".card" + -1 + "-" + -1 + "", new JsDictionary<string, object>()); ClientHelpers.AddCSSRule(sheet, ".card" + -1 + "-" + -1 + "::before", new JsDictionary<string, object>()); ClientHelpers.AddCSSRule(sheet, ".card" + -1 + "-" + -1 + "::after", new JsDictionary<string, object>()); var spaceLookups = new JsDictionary<string, DebugSpace>(); myClientDebugManagerService.OnUpdateState += (user, update) => { GoodConsole.Time("Render"); var data = Json.Parse<GameCardGame>(new Compressor().DecompressText(update)); bool create = scope.GameModel.MainArea == null; scope.GameModel.MainArea = data; if (create) { scope.GameModel.Scale = new Point(jQuery.Window.GetWidth()/(double) scope.GameModel.MainArea.Size.Width*.9, ((jQuery.Window.GetHeight())/(double) scope.GameModel.MainArea.Size.Height)*.9); foreach (var cardGameTableSpace in scope.GameModel.MainArea.Spaces) { ClientHelpers.AddCSSRule(sheet, ".space" + cardGameTableSpace.Name + "", new JsDictionary<string, object>()); ClientHelpers.AddCSSRule(sheet, ".space" + cardGameTableSpace.Name + "::before", new JsDictionary<string, object>()); ClientHelpers.AddCSSRule(sheet, ".space" + cardGameTableSpace.Name + "::after", new JsDictionary<string, object>()); } } scope.GameModel.Spaces = scope.GameModel.MainArea.Spaces.Map(space => { DebugSpace debugSpace = spaceLookups[space.Name] ?? (spaceLookups[space.Name] = new DebugSpace()); debugSpace.GameSpace = space; return debugSpace; }); scope.Broadcast("spaceUpdated"); scope.Apply(); GoodConsole.TimeEnd("Render"); // myGameContentManagerService.Redraw(); }; jQuery.Window.Bind("resize", (a) => { scope.GameModel.Scale = new Point(jQuery.Window.GetWidth()/(double) scope.GameModel.MainArea.Size.Width*.9, ((jQuery.Window.GetHeight())/(double) scope.GameModel.MainArea.Size.Height)*.9); scope.Broadcast("redraw"); scope.Apply(); }); myClientDebugManagerService.OnGameStarted += (user, room) => { //alert(JSON.stringify(data)); }; myClientDebugManagerService.OnGameOver += (user, room) => { //alert(JSON.stringify(data)); }; scope.GameModel.MainArea = null; //new Action<string,JsDictionary<string,object>>() /* scope.MoveCard = () => { for (var i = 0; i < 1; i++) { CardGameCard card = null; while (card == null) { var pile = scope.MainArea.Spaces.RandomElement().Pile; card = pile.Cards.RandomElement(); var _pile = scope.MainArea.Spaces.RandomElement(); if (card != null && _pile != null) { card.Appearance.EffectNames.Remove("bend"); if (_pile.Name.StartsWith("User")) { card.Appearance.EffectNames.Add("bend"); } pile.Cards.Remove(card); _pile.Pile.Cards.Add(card); } } } }; scope.AnimateCard = () => { for (var i = 0; i < 1; i++) { CardGameCard card = null; while (card == null) { var pile = scope.MainArea.Spaces.RandomElement().Pile; card = pile.Cards.RandomElement(); var _pile = scope.MainArea.Spaces.RandomElement(); if (card != null && _pile != null) { var css = string.Format(".card{0}-{1}", card.Type, card.Value); var clone = jQueryApi.jQuery.Select(css).FuckingClone(); var space = jQuery.Select(string.Format(".space{0}", _pile.Name)); var off = space.GetOffset(); clone.CSS("z-index", 1000); JsDictionary ops = new JsDictionary(); ops["left"] = off.Left + space.GetWidth() / 2 - 71 / 2; ops["top"] = off.Top + space.GetHeight() / 2 - 96 / 2; ops["rotate"] = "0deg"; pile.Cards.Remove(card); clone.Animate(ops, 700, (EffectEasing)(dynamic)("easeInOutQuart"), () => { card.Appearance.EffectNames.Remove("bend"); if (_pile.Name.StartsWith("User")) { card.Appearance.EffectNames.Add("bend"); } clone.Remove(); _pile.Pile.Cards.Add(card); scope.Apply(); }); } } } };*/ }
public ClientManagerService(ClientSiteManagerService clientSiteManagerService, ClientGameManagerService clientGameManagerService, ClientDebugManagerService clientDebugManagerService, ClientChatManagerService clientChatManagerService) { ClientSiteManagerService = clientSiteManagerService; ClientGameManagerService = clientGameManagerService; ClientDebugManagerService = clientDebugManagerService; ClientChatManagerService = clientChatManagerService; }