TopCommand spawnCommand(TopCommand.Code code) { TopCommand cloneCommand = null; switch (code) { case TopCommand.Code.Inbox: cloneCommand = Instantiate(Resources.Load("InboxPrefab", typeof(TopCommand))) as TopCommand; break; case TopCommand.Code.Outbox: cloneCommand = Instantiate(Resources.Load("OutboxPrefab", typeof(TopCommand))) as TopCommand; break; case TopCommand.Code.Load: cloneCommand = Instantiate(Resources.Load("LoadPrefab", typeof(TopCommand))) as TopCommand; break; case TopCommand.Code.Store: cloneCommand = Instantiate(Resources.Load("StorePrefab", typeof(TopCommand))) as TopCommand; break; } cloneCommand.gameObject.AddComponent <DragHandler> (); return(cloneCommand); }
/// <summary> /// Handler for when slide manipulation is complete /// </summary> private void ContentGrid_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e) { if (SwipeStatus == SwipeStatus.Idle) { return; } var y = _transform.TranslateY; _contentAnimation.From = y; _commandContainerClipTranslateAnimation.From = 0; _commandContainerClipTranslateAnimation.To = -y; _contentStoryboard.Begin(); if (SwipeStatus == SwipeStatus.SwipingPassedTopThreshold) { BottomCommandRequested?.Invoke(this, EventArgs.Empty); BottomCommand?.Execute(BottomCommandParameter); } else if (SwipeStatus == SwipeStatus.SwipingPassedBottomThreshold) { TopCommandRequested?.Invoke(this, EventArgs.Empty); TopCommand?.Execute(TopCommandParameter); } Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { SwipeStatus = SwipeStatus.Idle; }).AsTask(); }
void IBeginDragHandler.OnBeginDrag(PointerEventData eventData) { commandBeingSpawned = spawnCommand(gameObject.GetComponent <TopCommand> ().myCode); commandBeingSpawned.transform.SetParent(transform.parent); commandBeingSpawned.GetComponent <CanvasGroup> ().blocksRaycasts = false; AttackInstructionPanel.outsidePanel = true; }
public SidePOPMailMessage Top(int messageId, int lineCount) { if (messageId < 1) { throw new ArgumentOutOfRangeException("messageId"); } if (lineCount < 0) { throw new ArgumentOutOfRangeException("lineCount"); } RetrieveResponse response; using (TopCommand command = new TopCommand(_clientStream, messageId, lineCount)) { response = ExecuteCommand <RetrieveResponse, TopCommand>(command); } MimeReader reader = new MimeReader(response.RawBytes); MimeEntity entity = reader.CreateMimeEntity(); entity.RawBytes = response.RawBytes; SidePOPMailMessage message = entity.ToMailMessageEx(); message.Octets = response.Octets; message.MessageNumber = messageId; return(entity.ToMailMessageEx()); }
virtual protected bool RunPlayerCommand() { if (!CheckPlayerReady()) { return(false); } if (FinishWithoutSucceed()) { return(false); } if (!DistrustMoves()) { return(false); } if (playerState != RunningState.Inactive) { playerState = RunningState.NotReady; playerOldCounter = player.counter; TopCommand topCommandToRun = instructionPan.GetTopCommandAt(playerCMDNo); if (topCommandToRun.myCode == TopCommand.Code.Inbox) { player.SetEndPosition(playerInbox.playerPos); } else if (topCommandToRun.myCode == TopCommand.Code.NoAction) { player.counter += 1; } else if (topCommandToRun.subCommandRef) { SetEndPositionBySubCMD(player, topCommandToRun.subCommandRef.myCode); } } return(true); }
void IBeginDragHandler.OnBeginDrag(PointerEventData eventData) { commandBeingDragged = GetComponent <TopCommand> (); commandBeingDragged.GetComponent <CanvasGroup> ().blocksRaycasts = false; AttackInstructionPanel.outsidePanel = false; originalSlotHost = commandBeingDragged.GetComponentInParent <AttackTopCommandSlot> (); }
public void ValidateTests(string channelId, string userId) { var validateResult = new TopCommand(null) .Validate(new UserId(channelId, userId.ToString())); Assert.IsTrue(validateResult); }
public void destructCommand() { c.DestructSubCMD(); Destroy(c.gameObject); TopCommand newC = Instantiate(Resources.Load("NoActionPrefab", typeof(TopCommand))) as TopCommand; newC.transform.SetParent(transform); }
protected override void ExecuteCommand() { Logging(); Data d; TopCommand runTopCommand = instructionPan.GetTopCommandAt(playerCMDNo); switch (runTopCommand.myCode) { case TopCommand.Code.Inbox: d = playerInbox.sendFirstData(); if (d) { player.PickupData(d); ExecuteNextIfNotPaused(); } else { FailFeedback("There is no data on the line. Try \"Give\" what you had to me.", playerFeedback); } break; case TopCommand.Code.Outbox: if (runTopCommand.subCommandRef.myCode == SubCommand.Code.Boss) { d = player.SendData(); if (d) { playerOutbox.AcceptData(d); if (hasSolved == 0 && d.dataStr == "O") { hasSolved += 1; ExecuteNextIfNotPaused(); } else if (hasSolved == 0 && d.dataStr == "K") { FailFeedback("You have dropped letter \"O\". Please send both letters to me.", playerFeedback); } else if (hasSolved == 1 && d.dataStr == "K") { hasSolved += 1; SucceedFeedback("Well done!", playerFeedback, "Challenge2"); } } else { FailFeedback("No data can you give to me. Please \"Take\" before \"Giving\" me data.", playerFeedback); } } else { Debug.Log("Should not reach here @ 1 Update, Challenge One."); } break; default: throw new System.Exception("An unexpected command: " + runTopCommand.myCode); } }
void IPointerClickHandler.OnPointerClick(PointerEventData eventData) { if (subCommandToBeChanged && animator.enabled) { isUpdated = 1; ExecuteEvents.Execute <IUpdateSubCMDChoice>(subCommandToBeChanged.gameObject, null, (x, y) => x.FinaliseSubCMDChoice(myCode)); subCommandToBeChanged = null; } }
public void EnsureMessageDoesNotContainSixthHighestUsers_GivenTestData() { List <ChatUser> users = GetTestUsers(); SetUpTest(users); List <ChatUser> topUsers = _topCommand.GetTopUsers(); string message = TopCommand.GenerateMessage(topUsers); Assert.DoesNotContain("Rock", message); }
public void CheckIfTopCommandConstructorWorksProperly() { IMatrixField field = FieldFactory.Instance.GetField(5); IScoreboard scoreboard = new ScoreboardProxy(); IRandomNumberGenerator random = new RandomNumberGenerator(); IGameEngine gameEngine = new GameFifteenEngine(field, scoreboard, random); TopCommand topCommand = new TopCommand(gameEngine); Assert.IsInstanceOfType(topCommand, typeof(Command)); }
public void DisplayTopUsers_GivenTestData() { List <ChatUser> users = GetTestUsers(); SetUpTest(users); _topCommand.DisplayTopUsers(_chatClientMock.Object); List <ChatUser> topUsers = _topCommand.GetTopUsers(); string message = TopCommand.GenerateMessage(topUsers); Assert.DoesNotContain("Rock", message); }
void IEndDragHandler.OnEndDrag(PointerEventData eventData) { if (InstructionPanel.outsidePanel) { ExecuteEvents.Execute <IUpdateNumbers> (numberPanel.gameObject, null, (x, y) => x.UpdateNumbers(false)); } else { commandBeingDragged.GetComponent <CanvasGroup> ().blocksRaycasts = true; } ExecuteEvents.Execute <IHasFinalised> (playerInstructionPanel.gameObject, null, (x, y) => x.HasFinalised()); commandBeingDragged = null; }
public bool AcceptCommand(TopCommand newCommand) { if (c.myCode != TopCommand.Code.NoAction) { return(false); } else { Destroy(c.gameObject); newCommand.transform.SetParent(transform); return(true); } }
public void CheckIfMethodTopExecuteReturnsProperEmptyString() { IMatrixField field = FieldFactory.Instance.GetField(5); IScoreboard scoreboard = new ScoreboardProxy(); IRandomNumberGenerator random = new RandomNumberGenerator(); IGameEngine gameEngine = new GameFifteenEngine(field, scoreboard, random); TopCommand topCommand = new TopCommand(gameEngine); string result = topCommand.Execute(); Assert.IsInstanceOfType(result, typeof(String)); }
public void IncludeNameAndTokens_GivenOnePerson() { ChatUser chatUser = new ChatUser { DisplayName = "Brendan", Tokens = 10 }; List <ChatUser> topUsers = new List <ChatUser> { chatUser }; string message = TopCommand.GenerateMessage(topUsers); message.Should().Contain(chatUser.DisplayName); message.Should().Contain(chatUser.Tokens.ToString()); }
void IEndDragHandler.OnEndDrag(PointerEventData eventData) { if (InstructionPanel.acceptingNewCommand) { commandBeingSpawned.GetComponent <CanvasGroup> ().blocksRaycasts = true; InstantiateSubCommand(); ExecuteEvents.Execute <IHasFinalised> (targetPanel.gameObject, null, (x, y) => x.HasFinalised()); } else { Destroy(commandBeingSpawned.gameObject); } commandBeingSpawned = null; }
public bool AcceptCommand(TopCommand newCommand) { if (c) { return(false); } else { newCommand.transform.SetParent(transform); if (newCommand.subCommandRef) { newCommand.subCommandRef.startArguUpdate(); } return(true); } }
public DataTemplateTestViewModel(IPageDialogService pageDlg) { ItemsSource = new ObservableCollection <Person>( new List <Person> { new Person { Name = "ABC", Days = "1,2,3,4" }, new Person { Name = "DEF", Days = "5,6,7,8" }, } ); DoCommand.Subscribe(async _ => { await pageDlg.DisplayAlertAsync("", "Command", "OK"); }); AddCommand.Subscribe(_ => { ItemsSource.Add(new Person { Name = "Add", Days = "9,9,9,9" }); }); DelCommand.Subscribe(_ => { ItemsSource.Remove(ItemsSource.Last()); }); RepCommand.Subscribe(_ => { ItemsSource[0] = new Person { Name = "Rep", Days = "1,1,1,1" }; }); ClrCommand.Subscribe(_ => { ItemsSource.Clear(); }); BtmCommand.Subscribe(_ => { ScrollToBottom.Value = true; }); TopCommand.Subscribe(_ => { ScrollToTop.Value = true; }); }
public void ReturnCorrectMessageFromProcessMethod_GivenTestData() { List <ChatUser> users = GetTestUsers(); SetUpTest(users); var commandReceivedEventArgs = new CommandReceivedEventArgs { Arguments = null, CommandWord = "top" }; _topCommand.Process(_chatClientMock.Object, commandReceivedEventArgs); List <ChatUser> topUsers = _topCommand.GetTopUsers(); string message = TopCommand.GenerateMessage(topUsers); _chatClientMock.Verify(x => x.SendMessage(message)); }
void IEndDragHandler.OnEndDrag(PointerEventData eventData) { if (commandBeingSpawned.transform.parent == transform.parent) { Destroy(commandBeingSpawned.gameObject); } else { commandBeingSpawned.GetComponent <CanvasGroup> ().blocksRaycasts = true; InstantiateSubCommand(); if (commandBeingSpawned.subCommandRef) { commandBeingSpawned.subCommandRef.startArguUpdate(); } } commandBeingSpawned = null; }
public virtual ICommand CreateCommand(IGameEngine gameEngine, string commandArgs) { int row; int col; string commandName = commandArgs; if (commandArgs.Length >= 3) { bool isRowSet = int.TryParse(commandArgs[0].ToString(), out row); bool isColSet = int.TryParse(commandArgs[2].ToString(), out col); bool isRowInRange = row <= gameEngine.GameField.GetLength(0); bool isColInRange = col <= gameEngine.GameField.GetLength(1); if ((isRowSet && isColSet) && isRowInRange && isColInRange) { commandName = "turn"; } } ICommand command = null; string[] inputArgs = commandArgs.Split(' '); switch (commandName.ToLower()) { case "top": command = new TopCommand(gameEngine); break; case "restart": command = new RestartCommand(gameEngine); break; case "turn": command = new TurnCommand(gameEngine, inputArgs); break; case "exit": command = new ExitCommand(gameEngine); break; default: break; } return(command); }
void AdjustEmptySpace(TopCommandSlot moveSlot, TopCommand movingCommand) { //Dynamically adjust the position of emptySpace int emptySpaceIndex = (((int)movingCommand.transform.position.y) - offset) / spacing; if (emptySpaceIndex < 0) { moveSlot.transform.SetAsFirstSibling(); } else if (emptySpaceIndex >= GetComponentsInChildren <TopCommandSlot>().Length) { moveSlot.transform.SetSiblingIndex(GetComponentsInChildren <TopCommandSlot>().Length - 1); } else { moveSlot.transform.SetSiblingIndex(emptySpaceIndex); } }
public void IncludeNameAndTokens_GivenTwoPeople() { ChatUser chatUser1 = new ChatUser { DisplayName = "Brendan", Tokens = 1213 }; ChatUser chatUser2 = new ChatUser { DisplayName = "Pritchett", Tokens = 521 }; List <ChatUser> topUsers = new List <ChatUser> { chatUser1, chatUser2 }; string message = TopCommand.GenerateMessage(topUsers); message.Should().Contain(chatUser1.DisplayName); message.Should().Contain(chatUser1.Tokens.ToString()); message.Should().Contain(chatUser2.DisplayName); message.Should().Contain(chatUser2.Tokens.ToString()); }
void IEndDragHandler.OnEndDrag(PointerEventData eventData) { if (AttackInstructionPanel.outsidePanel) { originalSlotHost.destructCommand(); } else if (commandBeingDragged.GetComponentInParent <AttackTopCommandSlot> () != originalSlotHost) { TopCommand newC = Instantiate(Resources.Load("NoActionPrefab", typeof(TopCommand))) as TopCommand; newC.transform.SetParent(originalSlotHost.transform); commandBeingDragged.GetComponent <CanvasGroup> ().blocksRaycasts = true; } else { commandBeingDragged.transform.localPosition = Vector2.zero; commandBeingDragged.GetComponent <CanvasGroup> ().blocksRaycasts = true; } commandBeingDragged = null; originalSlotHost = null; }
virtual protected bool RunPlayerCommand() { if (!CheckPlayerReady()) { return(false); } if (FinishWithoutSucceed()) { return(false); } enumPan.SetRunningState(playerCMDNo, EnumPanel.Status.Executing); if (playerState == RunningState.Ready) { playerState = RunningState.NotReady; } else if (playerState == RunningState.Step) { playerState = RunningState.Pause; } playerOldCounter = player.counter; TopCommand topCommandToRun = instructionPan.GetTopCommandAt(playerCMDNo); if (topCommandToRun.myCode == TopCommand.Code.Inbox) { player.SetEndPosition(playerInbox.playerPos); } else if (topCommandToRun.myCode == TopCommand.Code.NoAction) { player.counter += 1; } else if (topCommandToRun.subCommandRef) { SetEndPositionBySubCMD(player, topCommandToRun.subCommandRef.myCode); } return(true); }
/// <summary> /// Process the game. /// </summary> /// <param name="playBoard">Current play board value.</param> /// <param name="playerMoves">Current player moves.</param> public void ProcessGame(ref char[,] playBoard, ref int playerMoves) { byte rowLenght = (byte)playBoard.GetLength(0); byte columnLenght = (byte)playBoard.GetLength(1); Board boardGenerator = new Board(rowLenght, columnLenght); ScoreBoardFormatter formatter = new ScoreBoardFormatter(); // ILogger fileLogger = new FileLogger("scorebord.txt", formatter); ILogger consoleLogger = new ConsoleLogger(formatter); ScoreBoard scoreBoard = new ScoreBoard(consoleLogger); var printer = PrintingManager.Instance; switch (this.currentCommand) { case "RESTART": IInputCommand restart = new RestartCommand(boardGenerator, printer); restart.Execute(ref playBoard, ref playerMoves); break; case "TOP": IInputCommand topscoreBoard = new TopCommand(scoreBoard, this.topPlayers); topscoreBoard.Execute(ref playBoard, ref playerMoves); break; case "EXIT": break; default: InputCommandValidator validator = new InputCommandValidator(); if (validator.IsValidInputCommand(this.currentCommand)) { IInputCommand play = new PlayCommand(this.currentCommand, this.topPlayers, scoreBoard, boardGenerator, printer); play.Execute(ref playBoard, ref playerMoves); break; } Console.WriteLine("Wrong input ! Try Again ! "); break; } }
void IBeginDragHandler.OnBeginDrag(PointerEventData eventData) { commandBeingDragged = gameObject.GetComponent <TopCommand> (); commandBeingDragged.GetComponent <CanvasGroup> ().blocksRaycasts = false; }
protected override void ExecuteCommand() { Logging(); Data d; TopCommand runTopCommand = instructionPan.GetTopCommandAt(playerCMDNo); switch (runTopCommand.myCode) { case TopCommand.Code.Inbox: d = playerInbox.sendFirstData(); if (d) { player.PickupData(d); ExecuteNextIfNotPaused(); } else { FailFeedback("There's no more data to \"Take\" off your line.", playerFeedback); } break; case TopCommand.Code.Outbox: d = player.SendData(); if (runTopCommand.subCommandRef.myCode == SubCommand.Code.Boss) { if (d) { playerOutbox.AcceptData(d); if (hasSolved == 0 && d.dataStr == "O") { hasSolved = 1; InformFeedback("Thanks, I got what I need.", playerFeedback); StartCoroutine(DiminishAfterSec(playerFeedback, 1f)); ExecuteNextIfNotPaused(); } else if (hasSolved == 2 && d.dataStr == "O") { hasSolved = 3; SucceedFeedback("Well done!", playerFeedback, "Challenge4"); } else if (hasSolved == 1 && d.dataStr == "O") { FailFeedback("I was not expecting more letters", playerFeedback); } } else { FailFeedback("Hmm? Please \"Load\" before \"Giving\" me data.", playerFeedback); } } else if (runTopCommand.subCommandRef.myCode == SubCommand.Code.Distrust) { if (d) { distrustOutbox.AcceptData(d); if (hasSolved == 0 && d.dataStr == "O") { hasSolved = 2; InformFeedback("Thanks, I got what I need.", distrustFeedback); StartCoroutine(DiminishAfterSec(distrustFeedback, 1f)); ExecuteNextIfNotPaused(); } else if (hasSolved == 2 && d.dataStr == "O") { FailFeedback("I was not expecting to receive \"O\" twice.", distrustFeedback); } else if (hasSolved == 1 && d.dataStr == "O") { hasSolved = 3; SucceedFeedback("Nice work.", distrustFeedback, "Challenge4"); } } else { FailFeedback("You're empty handed? \"Load\" before \"Giving\" me data.", distrustFeedback); } } break; case TopCommand.Code.Load: if (runTopCommand.subCommandRef.myCode == SubCommand.Code.Zero) { d = memoryBar.CloneDataAt(0); } else { d = memoryBar.CloneDataAt(1); } if (d) { player.PickupData(d); ExecuteNextIfNotPaused(); } else { FailFeedback("No data to load there!", playerFeedback); } break; } }
public void NotThrow_GivenNoUsers() { List <ChatUser> topUsers = new List <ChatUser>(); string message = TopCommand.GenerateMessage(topUsers); }