public void AddCommandAddsCommandsToQueue() { ICommandQueue commandQueue = new CommandQueue(); ICommand command1 = new Command { Verb = VerbCodes.Go, Noun = "west", FullTextCommand = "walk west" }; ICommand command2 = new Command { Verb = VerbCodes.Go, Noun = "north", FullTextCommand = "flop forwqard" }; ICommand command3 = new Command { Verb = VerbCodes.Go, Noun = "east", FullTextCommand = "scuffle east" }; commandQueue.AddCommand(command1); commandQueue.AddCommand(command2); commandQueue.AddCommand(command3); var queue = commandQueue.Commands; Assert.AreEqual(3, queue.Count); Assert.AreEqual(command1, queue[0]); Assert.AreEqual(command2, queue[1]); Assert.AreEqual(command3, queue[2]); }
public void AddNewCommand() { //Vector3 pos = Vector3.zero; //Quaternion rot = Quaternion.identity; Vector3 newVector3 = new Vector3(); newVector3.x = 24; if (commandQueue != null) { commandQueue = GameObject.Find("CommandQueue").GetComponent <CommandQueue>(); } Spawn c = new Spawn("testiprefab", newVector3, Quaternion.identity); commandQueue.AddCommand(c); }
protected override void OnEnter() { TrackerEventSender.SendEvaluationEvent(TrackerEvalautionEvent.GameFlow, new Dictionary <TrackerEvaluationKey, string> { { TrackerEvaluationKey.PieceType, "LevelSelectState" }, { TrackerEvaluationKey.PieceId, "0" }, { TrackerEvaluationKey.PieceCompleted, "success" } }); _scenarioController.RefreshSuccessEvent += UpdateLevelList; _scenarioController.SetLevelSuccessEvent += LevelLoaded; ConfigureGridSize(3); _panel.SetActive(true); _background.SetActive(true); CommandQueue.AddCommand(new RefreshLevelDataCommand()); }
private void OnCreateClick() { var details = _createGamePanel.GetComponent <CreateGamePopupBehaviour>().GetGameDetails(); CommandQueue.AddCommand(new CreateGameCommand(new CreateRoomSettings { Name = details.GameName, MinPlayers = _scenarioController.SelectedScenario.MinPlayerCount, MaxPlayers = details.MaxPlayers, CloseOnStarted = true, OpenOnEnded = true, GameScenario = _scenarioController.SelectedScenario.Key, TimeLimitSeconds = _scenarioController.SelectedScenario.TimeLimitSeconds ?? 0 })); PlayGen.Unity.Utilities.Loading.Loading.Start(); }
/// <summary> /// Iterate through the provided levels and populate the grid layout /// </summary> /// <param name="levels"></param> public void UpdateLevelList(ScenarioController.LevelObject[] levels) { for (var i = 0; i < levels.Length; i++) { var levelItem = UnityEngine.Object.Instantiate(_itemPrefab, _gridLayout.transform, false); levelItem.GetComponent <LevelItemBehaviour>().SetupItem(levels[i].Stars, Localization.GetAndFormat("LINE", true, levels[i].Id)); var index = i; levelItem.GetComponent <Button>().onClick.AddListener(() => CommandQueue.AddCommand(new SetLevelCommand(levels[index].Id))); } var contentView = _gridLayout.Parent().RectTransform(); var cellHeight = _gridLayout.cellSize.y; var rows = Mathf.Ceil(levels.Length / (float)_columns); var contentHieght = cellHeight * rows; contentView.sizeDelta = new Vector2(1f, contentHieght); }
protected override void OnEnter() { _scenarioController.GetPlayerDialogueSuccessEvent += UpdatePlayerDialogue; _scenarioController.GetCharacterDialogueSuccessEvent += UpdateCharacterDialogue; _scenarioController.FinalStateEvent += HandleFinalState; TrackerEventSender.SendEvaluationEvent(TrackerEvalautionEvent.GameFlow, new Dictionary <TrackerEvaluationKey, string> { { TrackerEvaluationKey.PieceType, "QuestionnaireState" }, { TrackerEvaluationKey.PieceId, "0" }, { TrackerEvaluationKey.PieceCompleted, "success" } }); _panel.SetActive(true); _background.SetActive(true); CommandQueue.AddCommand(new RefreshPlayerDialogueCommand()); CommandQueue.AddCommand(new RefreshCharacterResponseCommand()); _questionText.text = string.Empty; ShowCharacter(); }
public void Transfer(ITransferable receiver, decimal transferAmount) { Console.WriteLine("Transaction: account " + _accountNumber + " sending " + transferAmount + " to account " + receiver.GetAccountNumber()); Console.WriteLine("Account " + _accountNumber + " balance: " + _moneyAmount); Console.WriteLine("Account " + receiver.GetAccountNumber() + " balance: " + receiver.GetBalance()); if (transferAmount < _moneyAmount) { _moneyAmount -= transferAmount; receiver.AddMoney(transferAmount); Console.WriteLine("Account " + _accountNumber + " balance: " + _moneyAmount); Console.WriteLine("Account " + receiver.GetAccountNumber() + " balance: " + receiver.GetBalance()); Console.WriteLine("Transaction successful\n"); } else { CommandQueue commands = CommandQueue.GetInstance(); commands.AddCommand(new TransferCommand(receiver.GetAccount(), this, transferAmount)); Console.WriteLine("Transaction unsuccessful\n"); } }
public void UpdatePlayerDialogue(DialogueStateActionDTO[] dialogueActions) { foreach (Transform child in _dialoguePanel) { UnityEngine.Object.Destroy(child.gameObject); } var rnd = new System.Random(); var randomDialogueActions = dialogueActions.OrderBy(dto => rnd.Next()).ToArray(); var dialogueObject = UnityEngine.Object.Instantiate(_listChoicePrefab, _dialoguePanel, false); var contentTotalHeight = 0f; for (var i = 0; i < randomDialogueActions.Length; i++) { var dialogueAction = randomDialogueActions[i]; var choiceItem = UnityEngine.Object.Instantiate(_choiceItemPrefab, dialogueObject.content, false); choiceItem.GetComponentInChildren <Text>().text = Localization.GetAndFormat(dialogueAction.FileName, false, _scenarioController.ScenarioCode); contentTotalHeight += choiceItem.GetComponent <RectTransform>().rect.height; choiceItem.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -i * choiceItem.GetComponent <RectTransform>().rect.height); choiceItem.GetComponent <Button>().onClick.AddListener(() => CommandQueue.AddCommand(new SetPlayerActionCommand(dialogueAction.Id))); } dialogueObject.content.sizeDelta = new Vector2(0, contentTotalHeight); dialogueObject.content.BestFit(); }
protected override void OnInitialize() { _panel = GameObjectUtilities.FindGameObject(_panelRoute); _background = GameObjectUtilities.FindGameObject("BackgroundContainer/GameBackgroundImage"); _characterFemalePrefab = Resources.Load <CharacterFaceController>("Prefabs/Characters/Female"); _characterMalePrefab = Resources.Load <CharacterFaceController>("Prefabs/Characters/Male"); _characterPanel = GameObjectUtilities.FindGameObject(_panelRoute + "/CharacterPanel").transform; _choiceItemPrefab = Resources.Load <GameObject>("Prefabs/DialogueItemScroll"); _listChoicePrefab = Resources.Load <ScrollRect>("Prefabs/ListChoiceGroup"); _dialoguePanel = GameObjectUtilities.FindGameObject(_panelRoute + "/GameUI/BottomPanel/DialogueOptionPanel").transform; _npcDialoguePanel = GameObjectUtilities.FindGameObject(_panelRoute + "/GameUI/BottomPanel/NPCTextHolder/NPCText").GetComponent <Text>(); _characterMood = GameObjectUtilities.FindGameObject(_panelRoute + "/GameUI/TopBarPanel/StatusBar/Image").GetComponent <Image>(); _feedbackPanel = GameObjectUtilities.FindGameObject(_panelRoute + "/GameUI/FeedbackPanel/IconHolder"); _feedbackElementPrefab = Resources.Load <GameObject>("Prefabs/FeedbackElement"); GameObjectUtilities.FindGameObject(_panelRoute + "/GameUI/TopBarPanel/ModulesButton").GetComponent <Button>().onClick.AddListener(() => CommandQueue.AddCommand(new ToggleModulesCommand())); }
public bool AddCommand(Commands function) { return(commandQueue.AddCommand(function)); }
public void AddCommand(MenuBehaviourCommand.Type type) { DisplayCommandQueue(); commandQ.AddCommand(new MenuBehaviourCommand(this, type)); }
private void JoinGame(string name) { CommandQueue.AddCommand(new JoinGameCommand(name)); PlayGen.Unity.Utilities.Loading.Loading.Start(); }
private void OnRefreshClick() { CommandQueue.AddCommand(new RefreshGamesListCommand()); PlayGen.Unity.Utilities.Loading.Loading.Start(); _timeSinceLastRefresh = 0; }
private void ConfirmScenario(ScenarioInfo scenario) { CommandQueue.AddCommand(new SelectScenarioCommand(scenario)); PlayGen.Unity.Utilities.Loading.Loading.Start(); }
private void PlayerColourChanged(PlayerColour playerColour) { CommandQueue.AddCommand(new ChangePlayerColorCommand(playerColour)); }
public void UpdateCharacterDialogue(string text) { _questionText.text = text; CommandQueue.AddCommand(new RefreshPlayerDialogueCommand()); }
public void UpdateCharacterDialogue(string text) { _npcDialoguePanel.text = text; CommandQueue.AddCommand(new RefreshPlayerDialogueCommand()); }