public void Update() { if (activeevent == null || activeevent.Length == 0) { return; } if (collectActive != Parley.GetInstance().IsEventActive(activeevent)) { collectActive = Parley.GetInstance().IsEventActive(activeevent); if (!collectActive) { BroadcastMessage("EndDialog", SendMessageOptions.DontRequireReceiver); } if (activeNotificationObject != null) { if (!collectActive) { BroadcastMessage("EndDialog", SendMessageOptions.DontRequireReceiver); activeNotificationObject.BroadcastMessage("EndDialog", SendMessageOptions.DontRequireReceiver); } activeNotificationObject.SetActive(collectActive); } } }
public bool TriggerQuestEvent(string questEvent) { if (!completed && questEvent.Equals(objectiveevent)) { // If this is a count quest then count down if (count > 0) { count--; } // If we are done then fire quest events and player events if (count == 0) { if (questevent != null && questevent.Length > 0) { Parley.GetInstance().TriggerQuestEvent(questevent); } Debug.Log("Parley: Completed quest objective " + description); completed = true; if (activeevent != null && activeevent.Length > 0) { Parley.GetInstance().StopEventActive(activeevent); } } // Send player event if (playerCommands != null && playerCommands.Length > 0) { Parley.GetInstance().ExecutePlayerCommands(null, playerCommands); } return(true); } return(false); }
public void StartQuest() { open = true; GameObject.FindWithTag("Player").BroadcastMessage("StartedQuest", this, SendMessageOptions.DontRequireReceiver); Parley.GetInstance().QuestStarted(this); TestQuestDone(); lastEffected = Time.time; if (activeevent != null && activeevent.Length > 0) { Parley.GetInstance().StartEventActive(activeevent); } FireQuestHasChanged(); Player player = GameObject.FindWithTag("Player").GetComponent <Player>(); for (int i = 0; i < player.messagesAfterQuestAccept.Count; i++) { string str = (string)player.messagesAfterQuestAccept[i]; int indexOfComma = str.IndexOf(","); string questName = str.Substring(indexOfComma + 1, str.Length - indexOfComma - 1); if (questName == "ALL" || name == questName) { str = str.Replace("@", "\""); string questNameAndComma = str.Substring(indexOfComma, str.Length - indexOfComma); player.SendMessage("Eval", str.Replace(questNameAndComma, "")); player.messagesAfterQuestAccept.RemoveAt(i); } } }
void OnTriggerStay(Collider other) { if (other.name == "PlayerSword" && player.attackTimer > player.attackRate && other.transform.position == transform.position) { player.attackTimer = 0; hp--; if (hp <= 0) { player.score += 1; if (player.score > PlayerPrefs.GetInt("Score", 0)) { if (player.survival) { PlayerPrefs.SetInt("Score", player.score); } } player.kills++; if (player.kills == 1) { Parley.GetInstance().TriggerQuestEvent("EnemyKilled"); } player.gold += gold; Destroy(gameObject); } } }
void OnTriggerEnter(Collider other) { if (other.tag == "Enemy") { enemies.Add(other); } else if (other.name == "Player") { if (!triggeredBeaconBeore) { Parley.GetInstance().TriggerQuestEvent("TriggeredBeacon"); triggeredBeaconBeore = true; } foreach (Collider c in enemies) { if (c != null) { if (c.name.Contains("Roach")) { c.GetComponent <Roach>().enabled = true; c.GetComponent <Roach>().awake = true; } else if (c.name.Contains("SkeletonArcher")) { c.GetComponent <SkeletonArcher>().enabled = true; c.GetComponent <SkeletonArcher>().awake = true; } } //c.transform.Find ("Vision").GetComponent<Vision>().enabled = false; } renderer.material.color = new Color(1f, 1f, 1f, 0f); } }
public void TriggerCombinedQuestEvent(string str) { int indexOfComma1 = str.IndexOf(","); int indexOfComma2 = str.IndexOf(",", indexOfComma1 + 1); int indexOfComma3 = str.IndexOf(",", indexOfComma2 + 1); string questEvent1 = str.Substring(0, indexOfComma1); string questEvent2 = str.Substring(indexOfComma1 + 1, indexOfComma2 - indexOfComma1); string questEvent3 = str.Substring(indexOfComma2 + 1, indexOfComma3 - indexOfComma2 - 1); string combineType = str.Substring(indexOfComma3 + 1, str.Length - indexOfComma3 - 1); bool questEvent1True = (Parley.GetInstance().GetQuestEventSet().Contains(questEvent1) || (questEvent1.Contains("!") && !Parley.GetInstance().GetQuestEventSet().Contains(questEvent1.Replace("!", "")))); bool questEvent2True = (Parley.GetInstance().GetQuestEventSet().Contains(questEvent2) || (questEvent2.Contains("!") && !Parley.GetInstance().GetQuestEventSet().Contains(questEvent2.Replace("!", "")))); if ((combineType.Contains("OR") && (questEvent1True || questEvent2True)) || (combineType.Contains("AND") && questEvent1True && questEvent2True)) { if (questEvent3.Contains("!")) { Parley.GetInstance().StopEventActive(questEvent3.Replace("!", "")); } else { Parley.GetInstance().TriggerQuestEvent(questEvent3); } if (combinedQuestEvents.Contains(str)) { combinedQuestEvents.Remove(str); } } }
/** * Start Dialog is called from Dialog as the trigger to get the DialogGui * going. * * This is broadcast into he GameObject after the DialogGui class is created * and added to the GameObject. You should not need to use extends or alter * this method if you are using the DialogGuiAbstract as your base. * * This broadcasts DialogStarted into the GameObject after it is called. * */ public void StartDialog(Dialog dialog) { Parley.GetInstance().SetInGui(true); this.dialog = dialog; // Change camera if (dialog.dialogCamera != null) { oldCamera = Camera.main; // Try calling the camera dolly dialog.dialogCamera.gameObject.SendMessage("SwitchCamera", SendMessageOptions.DontRequireReceiver); if (!dialog.dialogCamera.gameObject.activeSelf) { oldCamera.gameObject.SetActive(false); dialog.dialogCamera.gameObject.SetActive(true); } } // Broadcast to player and this object that we have started a dialog GameObject.FindWithTag("Player").BroadcastMessage("DialogStarted", dialog, SendMessageOptions.DontRequireReceiver); BroadcastMessage("DialogStarted", dialog, SendMessageOptions.DontRequireReceiver); Parley.GetInstance().SetCurrentDialog(dialog); // Start at the correct dialog GotoDialogue(null, dialog.GetConversationIndex()); }
void Start() { restartLocation = transform.localPosition; // Register this instance and the ParleyEnviromentInfo provider Parley.GetInstance().SetParleyEnviromentInfo(this); }
public void OnGUI() { if (Parley.GetInstance() == null) { return; } // Return if we are in a dialog if (hideStatusInDialog && Parley.GetInstance().GetCurrentDialog() != null) { return; } if (questSkin != null) { GUI.skin = questSkin; } if (MustShowQuests() && Parley.GetInstance().GetCurrentDialog() == null) { ShowQuestDetails(); } if (showQuestsSummary) { ShowQuestList(); } }
public void EndDialog() { if (Parley.GetInstance().GetCurrentDialog() != null) { Parley.GetInstance().GetCurrentDialog().TriggerDialogEnd(); GameObject.Find("Scripts").GetComponent <Global>().timeScale2 = 1; } }
/** * DidJump is fired from ThirdPersonControler when the player pressed Jump * * We want to fire an event "Jump" onto the quests each time the player jumps, but only when that quest is enabled for performance reasons. * */ void DidJump() { if (broadcastjumps) { // The code below fires a Quest Event "Jump" into Parley Parley.GetInstance().TriggerQuestEvent("Jump"); } }
public void Update() { if (!showQuests && Input.GetButtonUp(showQuestsAction) && !Parley.GetInstance().IsInGui()) { Parley.GetInstance().SetInGui(true); showQuests = true; SendMessage("QuestsStarted", SendMessageOptions.RequireReceiver); } }
public void SelectQuest(Quest q) { currentQuest = q; if (q != null) { questText = Parley.GetInstance().EmbedEnviromentalInformation(q.description + "\n\n" + q.GetObjectivesSummary()); questTextStartSec = Time.time; } }
public void OnTriggerEnter(Collider collider) { if (bumpon && "Player".Equals(collider.gameObject.tag)) { bridge.rigidbody.useGravity = true; //RotateBridge(); Parley.GetInstance().TriggerQuestEvent("BridgeKnocked"); gameObject.SetActive(false); } }
void Update() { if (!showMenu && Input.GetKey(KeyCode.Escape) && !Parley.GetInstance().IsInGui()) { showMenu = true; state = State.Menu; Parley.GetInstance().SetInGui(true); } //showMenu = true; }
public void Load() { if (noLoad) { return; } GameObject.Find("Loading Text").guiText.enabled = true; Parley.GetInstance().GetComponent <SaveLoadGui>().Load("DROD RPG Savefile 2.txt"); LevelSerializer.LoadSavedLevelFromFile("DROD RPG Savefile.txt"); GameObject.Find("Loading Text").guiText.enabled = false; }
public void TriggerQuestEvent(string questEvent) { if (questEvent.Contains("!")) { Parley.GetInstance().GetQuestEventSet().Remove(questEvent.Replace("!", "")); } else { Parley.GetInstance().TriggerQuestEvent(questEvent); } }
public void Awake() { LoadDialog(); playerObject = GameObject.FindWithTag("Player"); // Add this to the parley list if (!Parley.GetInstance().GetDialogs().ContainsKey(dialogname)) { Parley.GetInstance().GetDialogs().Add(dialogname, this); } }
public void StartDialog(string str) { if (GameObject.Find(str) != null) { GameObject.Find(str).GetComponent <Dialog>().TriggerDialog(); } else { Parley.GetInstance().SetCurrentDialog(int.Parse(str)); Debug.Log("YAY"); } }
public void UpdateAvailability() { _available = !_seen || !once; if (_available && questrequirement != null && questrequirement.Length > 0) { _available = Parley.GetInstance().IsRequirementTrue(questrequirement); } if (_available && environmentalrequirement != null && environmentalrequirement.Length > 0) { _available = Parley.GetInstance().IsEnvironmentalRequirementTrue(environmentalrequirement); } }
public void Save() { if (noSave) { return; } GameObject.Find("Saving Text").guiText.enabled = true; Parley.GetInstance().GetComponent <SaveLoadGui>().Save("DROD RPG Savefile 2.txt"); LevelSerializer.SerializeLevelToFile("DROD RPG Savefile.txt"); PlayerPrefs.SetInt("Saved", 1); GameObject.Find("Saving Text").guiText.enabled = false; }
public void TestQuestDone(string questEvent = null) { // If started test against each quest option if (open) { // Test each option bool done = true; foreach (Objective o in objectives) { if (o.open == false && Parley.GetInstance().IsRequirementTrue(o.questrequirement)) { o.open = true; if (o.activeevent != null && o.activeevent.Length > 0) { Parley.GetInstance().StartEventActive(o.activeevent); } } if (questEvent != null && o.TriggerQuestEvent(questEvent)) { lastEffected = Time.time; } if (!o.optional && !o.completed) { done = false; } } // Mark this quest as completed and fire events if (readyToHandIn == false && done == true) { Debug.Log("Parley: Completed quest " + name); readyToHandIn = done; lastEffected = Time.time; status = "Completed"; if (!boundInDialog) { CompleteQuest(); } else { FireQuestHasChanged(); } } else { UpdateStatus(); } } }
/** * This returns all the current Options available at this stage in the Dialog. * * These need to presented to the user. * */ protected List <Option> GetCurrentConversationOptions() { if (currentOptions == null && conversation.options != null) { currentOptions = new List <Option>(); foreach (Option o in conversation.options) { if (o._available) { o.displaytext = Parley.GetInstance().EmbedEnviromentalInformation(o.text); currentOptions.Add(o); } } } return(currentOptions); }
void OnTriggerEnter(Collider other) { if (other.name == "Player") { Parley.GetInstance().TriggerQuestEvent(questEvent); if (dialogGoName != "") { GameObject.Find(dialogGoName).GetComponent <Dialog>().TriggerDialog(); } renderer.enabled = false; if (destroy) { Destroy(gameObject); } } }
void OnTriggerStay(Collider other) { if (other.gameObject.name == "Player" && attackTimer > attackRate) { attackTimer = 0; player.hp--; if (player.hp <= 0) { if (Application.loadedLevelName == "Survival") { Application.LoadLevel(Application.loadedLevel); } if (PlayerPrefs.GetInt("Saved", 0) == 1) { player.Load(); } else { Application.LoadLevel(0); } } } else if (other.name == "PlayerSword" && player.attackTimer > player.attackRate && other.transform.position.normalized * Mathf.Round(other.transform.position.magnitude) == transform.position.normalized * Mathf.Round(transform.position.magnitude)) { player.attackTimer = 0; hp -= damage; if (hp <= 0) { player.score += 1; if (player.score > PlayerPrefs.GetInt("Score", 0)) { if (player.survival) { PlayerPrefs.SetInt("Score", player.score); } } player.kills++; if (player.kills == 1) { Parley.GetInstance().TriggerQuestEvent("EnemyKilled"); } player.gold += gold; Destroy(gameObject); } } }
public static void Load(StreamUnpacker su) { // Reset Scene quests Parley.GetInstance().LoadSceneQuests(); int n = su.ReadInt(); Parley.GetInstance().GetCompletedQuests().Clear(); for (int t = 0; t < n; t++) { Parley.GetInstance().GetCompletedQuests().Add(UnpackQuest(su)); } n = su.ReadInt(); Parley.GetInstance().GetCurrentQuests().Clear(); for (int t = 0; t < n; t++) { Parley.GetInstance().GetCurrentQuests().Add(UnpackQuest(su)); } // Bring quests in line Parley.GetInstance().SyncQuests(); Debug.LogError(su.ReadString()); // Unpack all events string[] allEvents = su.ReadStrings(); HashSet <string> questEvents = Parley.GetInstance().GetQuestEventSet(); questEvents.Clear(); foreach (string s in allEvents) { questEvents.Add(s); } Debug.LogError(su.ReadString()); int activeEvents = su.ReadInt(); Parley.GetInstance().GetActiveEvents().Clear(); for (int t = 0; t < activeEvents; t++) { Parley.GetInstance().GetActiveEvents().Add(su.ReadString()); } Debug.LogError(su.ReadString()); }
private void ShowQuestList() { int q = 0; List <Quest> quests = Parley.GetInstance().GetCurrentQuests(); for (int t = quests.Count - 1; t >= 0; t--) { Quest qq = quests[t]; if (qq.GetStatus() != "" && qq.GetStatus() != "Completed") { Rect currentQuestDisplay = new Rect(Screen.width - 190, Screen.height - 70 - 80 * q, 180, 60); GUI.BeginGroup(currentQuestDisplay, qq.name); GUI.Label(new Rect(3, 20, currentQuestDisplay.width - 6, currentQuestDisplay.height - 23), qq.GetStatus()); GUI.EndGroup(); q++; } } }
/** * End Dialog is called by you when the Player decides to End the Dialog. * * Either through a close button or by moving too far away. Any number of situations. * You can casually call EndDialog from within your code all Dialog end cleanup * code should be added to your method implementing DialogEnded. * */ public void EndDialog() { // change camera back if (oldCamera != null) { dialog.dialogCamera.gameObject.SetActive(false); oldCamera.gameObject.SetActive(true); } // Broadcast to player and this object that we have finished a dialog BroadcastMessage("DialogEnded", dialog, SendMessageOptions.DontRequireReceiver); GameObject.FindWithTag("Player").BroadcastMessage("DialogEnded", dialog, SendMessageOptions.DontRequireReceiver); Parley.GetInstance().SetCurrentDialog(null); Parley.GetInstance().SetInGui(false); SendMessage("TriggerDialogEnd", this, SendMessageOptions.RequireReceiver); }
private void DrawButtons() { List <Quest> quests = Parley.GetInstance().GetQuests(); foreach (Quest q in quests) { if (q.open) { if (GUILayout.Button(q.name)) { SelectQuest(q); } } } if (GUILayout.Button("Resume game")) { CloseQuestDialog(); } }
public static void Save(StreamPacker sp) { // Pack all quests List <Quest> quests = Parley.GetInstance().GetCompletedQuests(); sp.WriteInt(quests.Count); foreach (Quest q in quests) { PackQuest(sp, q); } quests = Parley.GetInstance().GetCurrentQuests(); sp.WriteInt(quests.Count); foreach (Quest q in quests) { PackQuest(sp, q); } sp.WriteString("Pack1"); // Pack all events HashSet <string> questEvents = Parley.GetInstance().GetQuestEventSet(); string[] allEvents = new string[questEvents.Count]; int c = 0; foreach (string s in questEvents) { allEvents[c++] = s; } sp.WriteStrings(allEvents); sp.WriteString("Pack2"); // Pack all active quest events sp.WriteInt(Parley.GetInstance().GetActiveEvents().Count); foreach (string s in Parley.GetInstance().GetActiveEvents()) { sp.WriteString(s); } sp.WriteString("Pack3"); }