//This allows us to dynamically add in answers from other places, which means less complexity for us to deal with. public void addQuestion(string answer, eventScript newEvent) { string[] tempAnswer = new string[endAnswerArray.Length + 1];//Make a temp array, since we can't resize arrays. for (int i = 0; i < endAnswerArray.Length; i++) { tempAnswer[i] = endAnswerArray[i];//Add everything in. } endAnswerArray = tempAnswer;//Set the old to the new. if (endAnswerArray.Length != 0) { endAnswerArray[endAnswerArray.Length - 1] = answer;//Add in our new Answer } //Repeatthe process for the Event array. eventScript[] tempEvent = new eventScript[endEventArray.Length + 1]; for (int i = 0; i < endEventArray.Length; i++) { tempEvent[i] = endEventArray[i]; } endEventArray = tempEvent; if (endEventArray.Length != 0) { endEventArray[endEventArray.Length - 1] = newEvent; } }
//This takes in an event and then applies the changes from that event to every NPC in the scene. public void loadEvent(eventScript newEvent) { switch (newEvent.eventType) { case eventNodeType.NPCEvent://NPCEvents change the NPC's speeches, and they change the eventTracker's timer settings. doNPCEvent(newEvent); break; case eventNodeType.TimerEvent://TimerEvents only set up Events for the Timer to run later! doTimerEvent(newEvent); break; case eventNodeType.addQuestionEvent: doAddQuestionEvent(newEvent); break; case eventNodeType.addQuestionOneshotEvent: doAddQuestionOneshotEvent(newEvent); break; case eventNodeType.MultiEvent://TURNS OUT WE WANT TO DO MULTIPLE THINGS ALL AT ONCE. //Check the boxes you want to run. It'll skip the ones that aren't run. if (newEvent.Multi_AddQuestionEvent) { doAddQuestionEvent(newEvent); } if (newEvent.Multi_AddQuestionOneShotEvent) { doAddQuestionOneshotEvent(newEvent); } if (newEvent.Multi_NPCEvent) { doNPCEvent(newEvent); } if (newEvent.Multi_TimerEvent) { doTimerEvent(newEvent); } break; case eventNodeType.EndEvent: SceneManager.LoadScene("EndScreen", LoadSceneMode.Single); break; default: break; } eventCheck(newEvent); }
public void OnDrop(PointerEventData eventData) { Draggable d = eventData.pointerDrag.GetComponent <Draggable>(); if (d != null) { d.parentToReturnTo = this.transform; } if (dZone) { eventScript e = eventData.pointerDrag.GetComponent <eventScript> (); // need to take this feedback and communicate it to the hbar Debug.Log(e.cardAbility); Destroy(eventData.pointerDrag.gameObject); } }
// Start is called before the first frame update void Start() { eS = GameObject.Find("GOD").GetComponent <eventScript>(); stopStartText = GameObject.Find("Canvas/stopStartButton/Text").GetComponent <Text>(); nav = GetComponent <NavMeshAgent>(); citiesDropdown = GameObject.Find("Canvas/citiesDropdown").GetComponent <Dropdown>(); populateCitiesDropdown(); nav.isStopped = true; //we need this bit for the uhhhh dropdown i think citiesDropdown.onValueChanged.AddListener(delegate { DropdownValueChanged(citiesDropdown); } ); }
//In case we seriously need to add ALL THREE. public void addQuestion(string answer, eventScript newEvent, convoNode newConvoNode) { string[] tempAnswer = new string[endAnswerArray.Length + 1];//Make a temp array, since we can't resize arrays. for (int i = 0; i < endAnswerArray.Length; i++) { tempAnswer[i] = endAnswerArray[i];//Add everything in. } endAnswerArray = tempAnswer;//Set the old to the new. if (endAnswerArray.Length != 0) { endAnswerArray[endAnswerArray.Length - 1] = answer;//Add in our new Answer } //Repeatthe process for the Event array. eventScript[] tempEvent = new eventScript[endEventArray.Length + 1]; for (int i = 0; i < endEventArray.Length; i++) { tempEvent[i] = endEventArray[i]; } endEventArray = tempEvent; if (endEventArray.Length != 0) { endEventArray[endEventArray.Length - 1] = newEvent; } //Repeatthe process for the nextNode array. convoNode[] tempConvo = new convoNode[nextNodeArray.Length + 1]; for (int i = 0; i < nextNodeArray.Length; i++) { print("triple check number: " + i); tempConvo[i] = nextNodeArray[i]; } nextNodeArray = tempConvo; if (nextNodeArray.Length != 0) { nextNodeArray[nextNodeArray.Length - 1] = newConvoNode; } }
public void addQuestion(string answer)//Adds an Answer to the array without making it link to an event. { string[] tempAnswer = new string[endAnswerArray.Length + 1];//Make a temp array, since we can't resize arrays. for (int i = 0; i < endAnswerArray.Length; i++) { tempAnswer[i] = endAnswerArray[i];//Add everything in. } endAnswerArray = tempAnswer;//Set the old to the new. endAnswerArray[endAnswerArray.Length-1] = answer;//Add in our new Answer //We still have to resize the array anyways though. eventScript[] tempEvent = new eventScript[endEventArray.Length]; for (int i = 0; i < endEventArray.Length; i++) { tempEvent[i] = endEventArray[i]; } endEventArray = tempEvent; }
public void onEventRaised(eventScript incomingEvent) { Response.Invoke(); this.enabled = false; }
public void eventCheck( eventScript newEvent) { string tempName; //After we've done our Timer Math, check if our Event should be run! if (timeLeft <= 0 && timerActivated) { timerActivated = false; for (int i = 0; i < sceneInteractables.Length; i++)//We check every NPC in the scene to see if it should be changed. { tempName = sceneInteractables[i].name;//We take the name of our NPC if (newEvent.changeList.Contains(tempName))//If the name is found in the Event's list of NPCs who need stuff changed... { sceneInteractables[i].myConvo = (convoNode)newEvent.changeList[tempName];//...Then we change that NPC's convoNode. } } timeLeft += newEvent.adjustAmount;//We add/subtract any minutes the event gives us. if (timeLeft < 0) { timeLeft = 0; }//If the time subtracted was larger than the amount of time we had left, just set it to 0. timerActivated = newEvent.shouldActivateTimer;//Activate the timer, if we're told. } }
public void doAddQuestionOneshotEvent(eventScript newEvent) { NPC tempNPC; //If our keyList has Names AND all of its associated Arrays are of proper length, then do the checks. if (newEvent.keyList.Length > 0 && newEvent.answersToAdd.Length >= newEvent.keyList.Length && newEvent.eventsToAdd.Length >= newEvent.keyList.Length) { for (int i = 0; i < newEvent.keyList.Length; i++)//We check every NPC in the scene to see if it should be changed. { print(i); if (hashList.ContainsKey(newEvent.keyList[i]))//If the name in our keyList (which can contain multiples of the same name) is in the scene, add the answer to that node. { tempNPC = (NPC)(hashList[newEvent.keyList[i]]);//Make a TempNPC so we can edit it. if (newEvent.eventsToAdd[i] == null) //If there's not a corresponding event to our answer, just add the answer. { tempNPC.myConvo.addQuestion(newEvent.answersToAdd[i], newEvent.eventsToAdd[i], newEvent.nextNodesToAdd[i]); tempNPC.myConvo.hasNext = true; } else { tempNPC.myConvo.addQuestion(newEvent.answersToAdd[i], newEvent.eventsToAdd[i], newEvent.nextNodesToAdd[i]);//Otherwise add the answer and the event. tempNPC.myConvo.hasNext = true; } hashList[newEvent.keyList[i]] = tempNPC;//Then we make sure to put the tempNode back where it came from. } } } else//Else fail and tell us why. { print("Node [" + this.name + "] KeyList[]/answersToAdd[]/eventsToAdd[] array size mismatch. The array lengthss must be >= KeyList.Length!"); } timeLeft += newEvent.adjustAmount;//We add/subtract any minutes the event gives us. if (timeLeft < 0) { timeLeft = 0; }//If the time subtracted was larger than the amount of time we had left, just set it to 0. timerActivated = newEvent.shouldActivateTimer;//Activate the timer, if we're told. newEvent.oneshotClear();//Since we're passed a pointer, this makes the node passed to us INCAPABLE of adding answers again. }
public void doTimerEvent(eventScript newEvent) { timeEvent = newEvent; timeLeft += newEvent.adjustAmount;//We add/subtract any minutes the event gives us. if (timeLeft < 0) { timeLeft = 0; }//If the time subtracted was larger than the amount of time we had left, just set it to 0. timerActivated = newEvent.shouldActivateTimer;//Activate the timer, if we're told. Debug.Log(timeLeft); }