Inheritance: MonoBehaviour
Example #1
0
 public void EndDialog()
 {
     if (Parley.GetInstance().GetCurrentDialog() != null)
     {
         Parley.GetInstance().GetCurrentDialog().TriggerDialogEnd();
         GameObject.Find("Scripts").GetComponent <Global>().timeScale2 = 1;
     }
 }
Example #2
0
 /**
  * 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");
     }
 }
Example #3
0
 public void Update()
 {
     if (!showQuests && Input.GetButtonUp(showQuestsAction) && !Parley.GetInstance().IsInGui())
     {
         Parley.GetInstance().SetInGui(true);
         showQuests = true;
         SendMessage("QuestsStarted", SendMessageOptions.RequireReceiver);
     }
 }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ViewState[this.ClientID + "_ParleyId"] != null)
            {
                int parleyId = Int32.Parse((string)ViewState[this.ClientID + "_ParleyId"]);
                _parley = Parley.FromIdentity(parleyId);

                CreateDynamicControls();
            }
        }
Example #5
0
 public void OnTriggerEnter(Collider collider)
 {
     if (bumpon && "Player".Equals(collider.gameObject.tag))
     {
         bridge.rigidbody.useGravity = true;
         //RotateBridge();
         Parley.GetInstance().TriggerQuestEvent("BridgeKnocked");
         gameObject.SetActive(false);
     }
 }
Example #6
0
    public void SelectQuest(Quest q)
    {
        currentQuest = q;
        if (q != null)
        {
            questText = Parley.GetInstance().EmbedEnviromentalInformation(q.description + "\n\n" + q.GetObjectivesSummary());

            questTextStartSec = Time.time;
        }
    }
Example #7
0
 void Update()
 {
     if (!showMenu && Input.GetKey(KeyCode.Escape) && !Parley.GetInstance().IsInGui())
     {
         showMenu = true;
         state    = State.Menu;
         Parley.GetInstance().SetInGui(true);
     }
     //showMenu = true;
 }
Example #8
0
    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);
        }
    }
Example #9
0
 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;
 }
Example #10
0
 public void TriggerQuestEvent(string questEvent)
 {
     if (questEvent.Contains("!"))
     {
         Parley.GetInstance().GetQuestEventSet().Remove(questEvent.Replace("!", ""));
     }
     else
     {
         Parley.GetInstance().TriggerQuestEvent(questEvent);
     }
 }
Example #11
0
 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);
     }
 }
Example #12
0
 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;
 }
Example #13
0
 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");
     }
 }
Example #14
0
    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();
            }
        }
    }
Example #15
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        Parley parley = (Parley)target;

        bool showDebug = EditorGUILayout.Toggle("Show Debug Info", parley.showDebug, new GUILayoutOption[0]);
        bool clearFlag = EditorGUILayout.Toggle("Clear At Start", parley.clearAtStartOfScene, new GUILayoutOption[0]);

        int oldAct   = actProperty.intValue;
        int oldScene = sceneProperty.intValue;

        int newAct   = EditorGUILayout.Popup("Act", oldAct, ParleyMenu.GetActs(), new GUILayoutOption[0]);
        int newScene = EditorGUILayout.Popup("Scene", newAct != oldAct?0:oldScene, ParleyMenu.GetActsScenes()[ParleyMenu.GetActs()[newAct]], new GUILayoutOption[0]);

        if (oldAct != newAct || oldScene != newScene || showDebugProperty.boolValue != showDebug || clearDebugProperty.boolValue != clearFlag)
        {
            Undo.RegisterSceneUndo("Change Act and Scene");
            sceneProperty.intValue       = newScene;
            actProperty.intValue         = newAct;
            showDebugProperty.boolValue  = showDebug;
            clearDebugProperty.boolValue = clearFlag;

            // Set new resources
            LoadQuests();

            if (serializedObject.ApplyModifiedProperties() || (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed"))
            {
                serializedObject.Update();
            }
        }

        if (GUILayout.Button("Reload Quests for scene"))
        {
            Undo.RegisterSceneUndo("Reload Parley quests");
            LoadQuests();
            serializedObject.ApplyModifiedProperties();
        }

        parley.showEditorQuests = EditorGUILayout.Foldout(parley.showEditorQuests, "Quests");
        if (parley.showEditorQuests)
        {
            for (int x = 0; x < questListProperty.arraySize; x++)
            {
                EditorGUILayout.ObjectField((TextAsset)questListProperty.GetArrayElementAtIndex(x).objectReferenceValue, typeof(TextAsset));
            }
        }
    }
Example #16
0
 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);
         }
     }
 }
Example #17
0
 /**
  * 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);
 }
Example #18
0
        private void PopulateParleyData()
        {
            int parleyId = Int32.Parse(this.DropParleys.SelectedValue);
            _parley = Parley.FromIdentity(parleyId);

            Ledger.Accounts = FinancialAccounts.FromSingle(_parley.Budget);
            int year = DateTime.Today.Year;

            Ledger.DateStart = _parley.CreatedDateTime.Date;
            Ledger.DateEnd = new DateTime(year, 12, 31);
            Ledger.MaxAmount = 1.0e12m;

            Ledger.Populate();

            CreateDynamicControls();
        }
Example #19
0
        private void PopulateParleyData()
        {
            int parleyId = Int32.Parse(this.DropParleys.SelectedValue);

            _parley = Parley.FromIdentity(parleyId);

            Ledger.Accounts = FinancialAccounts.FromSingle(_parley.Budget);
            int year = DateTime.Today.Year;

            Ledger.DateStart = _parley.CreatedDateTime.Date;
            Ledger.DateEnd   = new DateTime(year, 12, 31);
            Ledger.MaxAmount = 1.0e12m;

            Ledger.Populate();

            CreateDynamicControls();
        }
Example #20
0
    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());
    }
Example #21
0
 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);
         }
     }
 }
Example #22
0
    /**
     * 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);
    }
Example #23
0
    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++;
            }
        }
    }
Example #24
0
    public void Awake()
    {
        instance=this;

        if (clearAtStartOfScene){
            ResetQuests();
        }

        // Add all known evalauations to list the order does matter as we must evaulate so that smaller string wont be confused to the longer ones.
        // EG = could easily be picked up with >= so we make sure >= is in the list first.
        evaluations.Add(new EvaluateEqualOrLessThen());
        evaluations.Add(new EvaluateEqualOrGreaterThen());
        evaluations.Add(new EvaluateLessThen());
        evaluations.Add(new EvaluateGreaterThen());
        evaluations.Add(new EvaluateNotEquals());
        evaluations.Add(new EvaluateEquals());

        LoadSceneQuests();
        SyncQuests();
    }
Example #25
0
    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();
        }
    }
Example #26
0
 private object GetTerm(string termString)
 {
     // Is this a string
     if (termString.StartsWith("'") || termString.StartsWith("\""))
     {
         return(termString.Substring(1, termString.Length - 2));
     }
     else if ("0123456789-+".IndexOf(termString.Substring(0, 1)) != -1)
     {
         // Ok we are a number
         // Int or float?
         if (termString.IndexOf(".") != -1)
         {
             return(float.Parse(termString));
         }
         else
         {
             return(int.Parse(termString));
         }
     }
     else
     {
         // This is hopefully an enviromental term
         ParleyEnviromentInfo info = Parley.GetInstance().GetParleyEnviromentInfo();
         if (info != null)
         {
             object o = info.GetEnviromentInfo(termString);
             if (o == null)
             {
                 Debug.LogWarning("Parley: Enviromental Term requested and not found '" + termString + "'");
                 return(-1);
             }
             return(o);
         }
         else
         {
             Debug.LogWarning("Parley: Enviromental Term requested but not ParleyEnviromentInfo service has been registered.");
             return(-1);
         }
     }
 }
Example #27
0
    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");
    }
Example #28
0
    public void Awake()
    {
        instance = this;

        if (clearAtStartOfScene)
        {
            ResetQuests();
        }

        // Add all known evalauations to list the order does matter as we must evaulate so that smaller string wont be confused to the longer ones.
        // EG = could easily be picked up with >= so we make sure >= is in the list first.
        evaluations.Add(new EvaluateEqualOrLessThen());
        evaluations.Add(new EvaluateEqualOrGreaterThen());
        evaluations.Add(new EvaluateLessThen());
        evaluations.Add(new EvaluateGreaterThen());
        evaluations.Add(new EvaluateNotEquals());
        evaluations.Add(new EvaluateEquals());

        LoadSceneQuests();
        SyncQuests();
    }
Example #29
0
    public void TriggerQuestEvent(string questEvent)
    {
        // Do nothing if this quest is finished allready
        if (completed)
        {
            return;
        }

        // Check if we can start this quest
        if (!open)
        {
            available = Parley.GetInstance().IsRequirementTrue(questrequirement);

            if (available && !boundInDialog)
            {
                StartQuest();
            }
        }

        TestQuestDone(questEvent);
    }
Example #30
0
    public void CompleteQuest()
    {
        if (playerCommands != null && playerCommands.Length > 0)
        {
            Parley.GetInstance().ExecutePlayerCommands(null, playerCommands);
        }
        GameObject.FindWithTag("Player").BroadcastMessage("FinishedQuest", this, SendMessageOptions.DontRequireReceiver);

        // Fire quest event
        if (questevent != null && questevent.Length > 0)
        {
            Parley.GetInstance().TriggerQuestEvent(questevent);
        }
        Parley.GetInstance().QuestCompleted(this);
        completed    = true;
        lastEffected = Time.time;

        if (activeevent != null && activeevent.Length > 0)
        {
            Parley.GetInstance().StopEventActive(activeevent);
        }
        FireQuestHasChanged();
    }
Example #31
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string parleyIdString = Request.QueryString["ParleyId"];
            int    parleyId       = Int32.Parse(parleyIdString);

            _parley = Parley.FromIdentity(parleyId);

            this.LabelConference.Text = _parley.Name;

            string bgColor = Request.QueryString["BackgroundColor"];

            if (!String.IsNullOrEmpty(bgColor))
            {
                this.BodyTag.Style["background-color"] = "#" + bgColor.Substring(0, 6); // safety net against code injection - cut to six chars
            }

            this.TextNameFirst.Style[HtmlTextWriterStyle.Width] = "100px";
            this.TextNameLast.Style[HtmlTextWriterStyle.Width]  = "150px";
            this.TextEmail.Style[HtmlTextWriterStyle.Width]     = "260px";
            this.TextEmail2.Style[HtmlTextWriterStyle.Width]    = "260px";

            PopulateOptions();
        }
Example #32
0
    public string GetObjectivesSummary(bool abridged = false)
    {
        string summary = "";

        ParleyEnviromentInfo[] infoSets = new ParleyEnviromentInfo[2];
        infoSets[1] = Parley.GetInstance().GetParleyEnviromentInfo();
        ParleyEnviromentInfoCombiner pic = new ParleyEnviromentInfoCombiner(infoSets);

        foreach (Objective o in objectives)
        {
            infoSets[0] = o;
            if (o.open)
            {
                if (abridged)
                {
                    if (!o.completed)
                    {
                        summary += Parley.GetInstance().EmbedEnviromentalInformation(o.GetStatus() + "\n", pic);
                    }
                }
                else
                {
                    if (o.completed)
                    {
                        summary += Parley.GetInstance().EmbedEnviromentalInformation(" - " + o.GetStatus() + " (" + (o.optional?"Optional, ":"") + "done)\n", pic);
                    }
                    else
                    {
                        summary += Parley.GetInstance().EmbedEnviromentalInformation(" - " + o.GetStatus() + (o.optional?" (Optional)":"") + "\n", pic);
                    }
                }
            }
        }

        return(summary);
    }