// Create Subinteraction Panel public void CreateSubinteractionPanel(ISubinteractable iSubinteractable, SubInteraction subInt = null) { if (subinteractionPanelObject != null) { return; } subinteractable = iSubinteractable; subinteractionPanelObject = Instantiate(Resources.Load <GameObject> ("Prefabs/Editor/InteractionPanelPrefabs/SubinteractionPanel")); panel = subinteractionPanelObject.transform.Find("Panel"); subIntTypeDropdown = panel.Find("SubIntTypeDropdown").GetComponent <Dropdown> (); textInputBig = panel.Find("TextInput").GetComponent <InputField> (); textInputSmall = panel.Find("TextInputSmall").GetComponent <InputField> (); recieveItem = panel.Find("RecieveItem"); moveToRoom = panel.Find("MoveToRoom"); playAnimation = panel.Find("PlayAnimation"); playSound = panel.Find("PlaySound"); cancelButton = panel.Find("CancelButton").GetComponent <Button> (); submitButton = panel.Find("SubmitButton").GetComponent <Button> (); currentSubint = subInt; OpenSubinteractionPanel(currentSubint); }
// Constructor for flipped furniture public TileInteraction(Room room, TileInteraction tileInt) { this.x = room.MyGrid.myWidth - 1 - tileInt.x - ((int)tileInt.mySize.x - 1); this.y = tileInt.y; this.mySize = tileInt.mySize; this.walkable = tileInt.walkable; this.mySubInt = tileInt.mySubInt; }
// Create Players public void CreatePlayers() { // When first loading the game - create list and assign player if (playerList == null) { playerList = new List <Player> (); Player player_daniel = new Player("Daniel", new Vector2(2, 1)); player_daniel.startingRoom = "test_mom"; player_daniel.startingPos = new Vector3(15f, 3f, 0); // hardcoded stuff GraphicState defaultGraphicState = new GraphicState(); defaultGraphicState.graphicStateName = "default"; defaultGraphicState.frameExtents = new Vector2(1, 2); defaultGraphicState.frameOffsetX = 0; defaultGraphicState.frameOffsetY = 0; defaultGraphicState.coordsList = new List <Coords> (); player_daniel.graphicStates.Add(defaultGraphicState); Interaction interaction = new Interaction(); interaction.myVerb = "Look At"; SubInteraction subInt = new SubInteraction("showMonologue"); subInt.rawText = "hi daniel."; subInt.textList = Utilities.SeparateText(subInt.rawText); interaction.SubIntList.Add(subInt); player_daniel.myInteractionList.Add(interaction); Player player_llehctiM = new Player("llehctiM", new Vector2(2, 1)); player_llehctiM.startingRoom = "test_mom"; player_llehctiM.startingPos = new Vector3(15f, 6f, 0); playerList.Add(player_daniel); playerList.Add(player_llehctiM); myPlayer = player_llehctiM; myPlayer.isActive = true; } }
public void RemoveSubinteractionFromList(SubInteraction subInt) { if (subInt == null) { Debug.LogError("subInt is null"); return; } if (subInteractionList.Contains(subInt) == false) { Debug.LogError("subInt is not in list"); return; } subInteractionList.Remove(subInt); }
// ----- SUBMIT ----- // public void SubmitTileInteraction() { // create show dialogue if (textInputCheckBox.isOn == true && interactionTextInput.text != string.Empty) { SubInteraction subInteraction = new SubInteraction("showMonologue"); subInteraction.RawText = interactionTextInput.text; InspectorManager.instance.chosenTileInteraction.mySubInt = subInteraction; } else if (enterRoomCheckBox.isOn == true && destinationRoomInput.text != string.Empty) { // create enter room // default is 0 int x; int y; int.TryParse(entrancePointXInput.text, out x); int.TryParse(entrancePointYInput.text, out y); SubInteraction subInteraction = new SubInteraction("moveToRoom"); subInteraction.destinationRoomName = destinationRoomInput.text; Vector2 entrancePoint = new Vector2(x, y); subInteraction.entrancePoint = entrancePoint; Debug.Log(entrancePoint.x + entrancePoint.y); InspectorManager.instance.chosenTileInteraction.mySubInt = subInteraction; } // walkable if (walkableToggle.isOn) { InspectorManager.instance.chosenTileInteraction.walkable = true; } else { InspectorManager.instance.chosenTileInteraction.walkable = false; } DestroyTileInspector(); //CreateTileInspector (InspectorManager.instance.chosenTileInteraction); }
public void Initialize() { inventoryItemInteractionList = new List <Interaction>(); // Look at interaction Interaction interactionLookAt = new Interaction(); interactionLookAt.myVerb = "Look At"; SubInteraction subInt_displayInventoryText = new SubInteraction("showInventoryText"); subInt_displayInventoryText.textList = new List <string> (); // take the correct textList from the itemLookAtMap, and put it in the textList of the subinteraction if (GameManager.gameData.itemLookAtMap.ContainsKey(fileName)) { subInt_displayInventoryText.textList = GameManager.gameData.itemLookAtMap [fileName]; } interactionLookAt.subInteractionList.Add(subInt_displayInventoryText); // Combine interaction Interaction interactionCombine = new Interaction(); interactionCombine.myVerb = "Combine"; SubInteraction subInt_combine = new SubInteraction("combine"); interactionCombine.subInteractionList.Add(subInt_combine); Interaction interactionOpen = new Interaction(); interactionOpen.myVerb = "Open"; inventoryItemInteractionList.Add(interactionLookAt); inventoryItemInteractionList.Add(interactionCombine); inventoryItemInteractionList.Add(interactionOpen); }
// ----- SUBMIT ----- // public void SubmitTileInteraction() { // create show dialogue if (interactionTextInput.interactable == true) { SubInteraction subInteraction = new SubInteraction("showMonologue"); subInteraction.RawText = interactionTextInput.text; Debug.Log("raw " + subInteraction.RawText); InspectorManager.instance.chosenTileInteraction.mySubInt = subInteraction; } // create enter room if (destinationRoomInput.interactable == true) { SubInteraction subInteraction = new SubInteraction("moveToRoom"); subInteraction.destinationRoomName = destinationRoomInput.text; InspectorManager.instance.chosenTileInteraction.mySubInt = subInteraction; } // walkable if (walkableToggle.isOn) { InspectorManager.instance.chosenTileInteraction.walkable = true; } else { InspectorManager.instance.chosenTileInteraction.walkable = false; } DestroyTileInspector(); //CreateTileInspector (InspectorManager.instance.chosenTileInteraction); }
// Opening interaction panel after created void OpenInteractionPanel() { //interactionPanelObject.SetActive (true); if (loadedInteraction != null) { // interaction title input field interactionTitleInput.text = loadedInteraction.myVerb; // insert interaction conditions PopulateConditionContainer(loadedInteraction, conditionContainer); // Set title row height if (loadedInteraction.conditionList.Count >= 2) { Rect tempRect = titleRow.GetComponent <RectTransform> ().rect; titleRow.GetComponent <RectTransform> ().sizeDelta = new Vector2(tempRect.width, loadedInteraction.conditionList.Count * 25 + 10); } // Create row for each subinteraction in the interaction's subinterction list if (loadedInteraction.subInteractionList.Count > 0) { for (int i = 0; i < loadedInteraction.subInteractionList.Count; i++) { SubInteraction subInt = loadedInteraction.subInteractionList [i]; GameObject row = Instantiate(rowObjectPrefab, panel); row.name = ("Row_" + i); // Declerations Button removeSubIntButton = row.transform.Find("RemoveButton").GetComponent <Button>(); Button addSubIntConditionButton = row.transform.Find("AddConditionButton").GetComponent <Button>(); Button editSubIntButton = row.transform.Find("SubIntButton").GetComponent <Button>(); Transform subIntConditionContainer = row.transform.Find("Conditions"); // Populate condition container (with condition) PopulateConditionContainer(subInt, subIntConditionContainer); // Set row height if (subInt.conditionList.Count >= 2) { Rect tempRect = row.GetComponent <RectTransform> ().rect; row.GetComponent <RectTransform> ().sizeDelta = new Vector2(tempRect.width, subInt.conditionList.Count * 25 + 10); } // Remove subinteraction button removeSubIntButton.onClick.AddListener(() => RemoveSubinteraction(subInt)); // Add Condition button addSubIntConditionButton.onClick.AddListener(() => InspectorManager.conditionInspector.CreateConditionPanel(subInt)); // Edit subinteraction button editSubIntButton.transform.Find("Text").GetComponent <Text> ().text = subInt.interactionType; editSubIntButton.onClick.AddListener(() => InspectorManager.subinteractionInspector.CreateSubinteractionPanel(loadedInteraction, subInt)); } } // Take 2 last rows to bottom intButtonsPanel.transform.SetAsLastSibling(); } else { loadedInteraction = new Interaction(); } // If it's relevant both to null / not null interaction // Title input interactionTitleInput.onValueChanged.AddListener(ChangeTitleText); // New Condition Button interactionConditionButton.onClick.AddListener(() => InspectorManager.conditionInspector.CreateConditionPanel(loadedInteraction)); // New subinteraction button newSubIntButton.onClick.AddListener(() => InspectorManager.subinteractionInspector.CreateSubinteractionPanel(loadedInteraction)); // Cancel button cancelButton.onClick.AddListener(DestroyInteractionPanel); // Submit button submitButton.onClick.AddListener(SubmitInteraction); }
public void RemoveSubinteraction(SubInteraction subInt) { loadedInteraction.RemoveSubinteractionFromList(subInt); CreateInteractionPanel(); }
// OPEN // public void OpenSubinteractionPanel(SubInteraction subInt) { Debug.Log("open sub interaction panel"); // SubInteraction type dropdown subIntTypeDropdown.AddOptions(subIntTypeList); if (subInt != null) { // set dropdown value int i = subIntTypeList.IndexOf(subInt.interactionType); subIntTypeDropdown.value = i; // What's active? SetSubinteractionType(i); // Fill the active fields switch (subInt.interactionType) { case "showMonologue": textInputBig.text = subInt.RawText; break; case "showDialogue": textInputSmall.text = subInt.dialogueOptionTitle; break; case "showDialogueTree": textInputSmall.text = subInt.dialogueTreeName; break; case "PlaySound": playSound.Find("SoundNameInput").GetComponent <InputField>().text = subInt.soundToPlay; playSound.Find("NumberOfPlaysInput").GetComponent <InputField>().text = subInt.numberOfPlays.ToString(); break; case "StopSound": textInputSmall.text = subInt.soundToStop; break; case "PlayAnimation": Debug.Log("play animation"); // populating the animation dropdown according to the object's animations List <string> animationList = new List <string> (); Furniture furn = InspectorManager.instance.chosenFurniture; GameObject prefab = Resources.Load <GameObject> ("Prefabs/Furniture/" + furn.fileName); Debug.Log("create prefab"); animationList = Utilities.GetAnimationClipNames(prefab); /* * if (prefab != null) * { * Debug.Log ("prefab isn't null"); * Animator animator = prefab.GetComponent<Animator> (); * * if (animator != null) * { * Debug.Log ("animator isn't null"); * foreach (AnimationClip clip in animator.runtimeAnimatorController.animationClips) * { * animationList.Add (clip.name); * Debug.Log ("animation list " + animationList.Count); * } * } * } * */ playAnimation.Find("AnimationDropdown").GetComponent <Dropdown> ().AddOptions(animationList); if ((currentSubint.animationToPlay != string.Empty) && (animationList.Contains(currentSubint.animationToPlay))) { playAnimation.Find("AnimationDropdown").GetComponent <Dropdown> ().value = animationList.IndexOf(currentSubint.animationToPlay); } playAnimation.Find("FurnitureNameInput").GetComponent <InputField>().text = subInt.targetFurniture; break; case "moveToRoom": moveToRoom.Find("TextInputSmall1").GetComponent <InputField> ().text = subInt.destinationRoomName; moveToRoom.Find("InputX").GetComponent <InputField> ().text = subInt.entrancePoint.x.ToString(); moveToRoom.Find("InputY").GetComponent <InputField> ().text = subInt.entrancePoint.y.ToString(); break; case "intoShadows": case "outOfShadows": break; case "pickUpItem": recieveItem.Find("TextInputSmall1").GetComponent <InputField> ().text = subInt.inventoryItem.fileName; recieveItem.Find("TextInputSmall2").GetComponent <InputField> ().text = subInt.inventoryItem.titleName; break; case "useItem": break; case "addEvent": textInputSmall.text = subInt.eventToAdd; break; case "removeEvent": textInputSmall.text = subInt.eventToRemove; break; } } else { // If subint is null, set first value on dropdown SetSubinteractionType(0); } // add listener to dropdown subIntTypeDropdown.onValueChanged.AddListener(SetSubinteractionType); // Cancel button cancelButton.onClick.AddListener(DestroySubinteractionInspector); // Submit button submitButton.onClick.AddListener(SubmitSubinteraction); }
// Submit // public void SubmitSubinteraction() { if (currentSubint == null) { Debug.Log("SubmitSubinteraction: currentSubInt is null"); int i = subIntTypeDropdown.value; string subIntType = subIntTypeList [i]; currentSubint = new SubInteraction(subIntType); subinteractable.SubIntList.Add(currentSubint); } // Reseting data fields, then filling them again currentSubint.ResetDataFields(); switch (currentSubint.interactionType) { case "showMonologue": currentSubint.RawText = textInputBig.text; break; case "showDialogue": currentSubint.dialogueOptionTitle = textInputSmall.text; break; case "showDialogueTree": currentSubint.dialogueTreeName = textInputSmall.text; break; case "PlaySound": currentSubint.soundToPlay = playSound.Find("SoundNameInput").GetComponent <InputField> ().text; string numberOfPlaysString = playSound.Find("NumberOfPlaysInput").GetComponent <InputField> ().text; if ((numberOfPlaysString == null) || (numberOfPlaysString == string.Empty)) { currentSubint.numberOfPlays = 1; break; } currentSubint.numberOfPlays = int.Parse(numberOfPlaysString); break; case "StopSound": currentSubint.soundToStop = textInputSmall.text; break; case "PlayAnimation": int i = playAnimation.Find("AnimationDropdown").GetComponent <Dropdown> ().value; currentSubint.animationToPlay = playAnimation.Find("AnimationDropdown").GetComponent <Dropdown> ().options [i].text; currentSubint.targetFurniture = playAnimation.Find("FurnitureNameInput").GetComponent <InputField> ().text; break; case "moveToRoom": currentSubint.destinationRoomName = moveToRoom.Find("TextInputSmall1").GetComponent <InputField> ().text; Vector2 entrancePoint = new Vector2(int.Parse(moveToRoom.Find("InputX").GetComponent <InputField> ().text), int.Parse(moveToRoom.Find("InputY").GetComponent <InputField> ().text)); currentSubint.entrancePoint = entrancePoint; break; case "intoShadows": case "outOfShadows": break; case "pickUpItem": string itemFileName = recieveItem.Find("TextInputSmall1").GetComponent <InputField> ().text; string itemTitleName = recieveItem.Find("TextInputSmall2").GetComponent <InputField> ().text; currentSubint.inventoryItem = new InventoryItem(itemFileName, itemTitleName); break; case "useItem": break; case "addEvent": currentSubint.eventToAdd = textInputSmall.text; break; case "removeEvent": currentSubint.eventToRemove = textInputSmall.text; break; } EventsHandler.Invoke_cb_subinteractionChanged(); Destroy(subinteractionPanelObject); }
// Submit // public void SubmitSubinteraction() { if (currentSubint == null) { int i = subIntTypeDropdown.value; string subIntType = subIntTypeList [i]; currentSubint = new SubInteraction(subIntType); subinteractable.SubIntList.Add(currentSubint); } // Reseting data fields, then filling them again currentSubint.ResetDataFields(); switch (currentSubint.interactionType) { case "showMonologue": currentSubint.RawText = textInputBig.text; currentSubint.isImportant = importantToggle.isOn; break; case "showDialogue": currentSubint.dialogueOptionTitle = textInputSmall.text; break; case "showDialogueTree": currentSubint.dialogueTreeName = textInputSmall.text; break; case "PlaySound": currentSubint.soundToPlay = playSound.Find("SoundNameInput").GetComponent <InputField> ().text; string numberOfPlaysString = playSound.Find("NumberOfPlaysInput").GetComponent <InputField> ().text; if ((numberOfPlaysString == null) || (numberOfPlaysString == string.Empty)) { currentSubint.numberOfPlays = 1; break; } int.TryParse(numberOfPlaysString, out currentSubint.numberOfPlays); // FIXME: what happens if it is a vlid format? will it change anything? break; case "StopSound": currentSubint.soundToStop = textInputSmall.text; break; case "PlayAnimation": int i = playAnimation.Find("AnimationDropdown").GetComponent <Dropdown> ().value; currentSubint.animationToPlay = playAnimation.Find("AnimationDropdown").GetComponent <Dropdown> ().options [i].text; currentSubint.targetFurniture = InspectorManager.instance.chosenFurniture.identificationName; break; case "PlayAnimationOn": currentSubint.animationToPlayOn = playAnimationOn.Find("AnimationNameInput").GetComponent <InputField> ().text; currentSubint.targetFurniture = playAnimationOn.Find("FurnitureNameInput").GetComponent <InputField> ().text; break; case "moveToRoom": currentSubint.destinationRoomName = moveToRoom.Find("TextInputSmall1").GetComponent <InputField> ().text; // currently if the format is invalid, it will give it a default value of 0 int x = 0; int y = 0; int.TryParse(moveToRoom.Find("InputX").GetComponent <InputField> ().text, out x); int.TryParse(moveToRoom.Find("InputY").GetComponent <InputField> ().text, out y); currentSubint.entrancePoint = new Vector2(x, y); break; case "intoShadows": case "outOfShadows": break; case "pickUpItem": string itemFileName = recieveItem.Find("TextInputSmall1").GetComponent <InputField> ().text; string itemTitleName = recieveItem.Find("TextInputSmall2").GetComponent <InputField> ().text; currentSubint.inventoryItem = new InventoryItem(itemFileName, itemTitleName); break; case "useItem": break; case "addEvent": currentSubint.eventToAdd = textInputSmall.text; break; case "removeEvent": currentSubint.eventToRemove = textInputSmall.text; break; case "PlayCutscene": currentSubint.cutsceneToPlay = textInputSmall.text; break; case "hidePI": currentSubint.PItoHide = textInputSmall.text; break; case "showPI": currentSubint.PItoShow = textInputSmall.text; break; case "special": currentSubint.specialSubInt = textInputSmall.text; break; } EventsHandler.Invoke_cb_subinteractionChanged(); Destroy(subinteractionPanelObject); }
// OPEN // public void OpenSubinteractionPanel(SubInteraction subInt) { // SubInteraction type dropdown subIntTypeDropdown.AddOptions(subIntTypeList); if (subInt != null) { // set dropdown value int i = subIntTypeList.IndexOf(subInt.interactionType); subIntTypeDropdown.value = i; // What's active? SetSubinteractionType(i); // Fill the active fields switch (subInt.interactionType) { case "showMonologue": textInputBig.text = subInt.RawText; importantToggle.isOn = subInt.isImportant; break; case "showDialogue": textInputSmall.text = subInt.dialogueOptionTitle; break; case "showDialogueTree": textInputSmall.text = subInt.dialogueTreeName; break; case "PlaySound": playSound.Find("SoundNameInput").GetComponent <InputField>().text = subInt.soundToPlay; playSound.Find("NumberOfPlaysInput").GetComponent <InputField>().text = subInt.numberOfPlays.ToString(); break; case "StopSound": textInputSmall.text = subInt.soundToStop; break; case "PlayAnimation": // populating the animation dropdown according to the object's animations List <string> animationList = new List <string> (); Furniture furn = InspectorManager.instance.chosenFurniture; GameObject prefab = Resources.Load <GameObject> ("Prefabs/Furniture/" + furn.fileName); animationList = Utilities.GetAnimationClipNames(prefab); playAnimation.Find("AnimationDropdown").GetComponent <Dropdown> ().AddOptions(animationList); if ((currentSubint.animationToPlay != string.Empty) && (animationList.Contains(currentSubint.animationToPlay))) { playAnimation.Find("AnimationDropdown").GetComponent <Dropdown> ().value = animationList.IndexOf(currentSubint.animationToPlay); } playAnimation.Find("FurnitureNameInput").GetComponent <InputField>().text = InspectorManager.instance.chosenFurniture.identificationName; break; case "PlayAnimationOn": playAnimationOn.Find("AnimationNameInput").GetComponent <InputField>().text = subInt.animationToPlayOn; playAnimationOn.Find("FurnitureNameInput").GetComponent <InputField>().text = subInt.targetFurniture; break; case "moveToRoom": moveToRoom.Find("TextInputSmall1").GetComponent <InputField> ().text = subInt.destinationRoomName; moveToRoom.Find("InputX").GetComponent <InputField> ().text = subInt.entrancePoint.x.ToString(); moveToRoom.Find("InputY").GetComponent <InputField> ().text = subInt.entrancePoint.y.ToString(); break; case "intoShadows": case "outOfShadows": break; case "pickUpItem": recieveItem.Find("TextInputSmall1").GetComponent <InputField> ().text = subInt.inventoryItem.fileName; recieveItem.Find("TextInputSmall2").GetComponent <InputField> ().text = subInt.inventoryItem.titleName; break; case "useItem": break; case "addEvent": textInputSmall.text = subInt.eventToAdd; break; case "removeEvent": textInputSmall.text = subInt.eventToRemove; break; case "PlayCutscene": textInputSmall.text = subInt.cutsceneToPlay; break; case "hidePI": textInputSmall.text = subInt.PItoHide; break; case "showPI": textInputSmall.text = subInt.PItoShow; break; case "special": textInputSmall.text = subInt.specialSubInt; break; } } else { // If subint is null, set first value on dropdown SetSubinteractionType(0); } // add listener to dropdown subIntTypeDropdown.onValueChanged.AddListener(SetSubinteractionType); // Cancel button cancelButton.onClick.AddListener(DestroySubinteractionInspector); // Submit button submitButton.onClick.AddListener(SubmitSubinteraction); }