Ejemplo n.º 1
0
        public void BeginDialog(QuestCondition questCondition, InteractiveObjectMono dialogObject = null)
        {
            dialogQuestCondition = questCondition;

            if (questCondition.ConditionType == ConditionType.Interact)
            {
                BeginDialog((questCondition as InteractCondition).InteractionNodeTreeID, dialogObject);
            }
            else if (questCondition.ConditionType == ConditionType.Deliver)
            {
                //todo: deliverInteraction
                BeginDialog((questCondition as DeliverCondition).InteractionNodeTreeID, dialogObject);
            }
        }
        protected override void Eval(NodeChain nodeChain)
        {
            var dialogId        = (string)ValueOf("Dialog");
            var specifyObject   = (bool)ValueOf("Specify Interactable Object");
            var gameObjectToUse = Parameter("Specify Interactable Object").ValueOf("Interaction Object") as GameObject;

            if (!specifyObject)
            {
                gameObjectToUse = null;
            }

            var dialogName       = (string)Parameter("Specify Interactable Object").ValueOf("Name");
            var dialogSpritePath = (string)Parameter("Specify Interactable Object").ValueOf("Image");
            var dialogSprite     = string.IsNullOrEmpty(dialogSpritePath) ? null : (Texture2D)Resources.Load(dialogSpritePath);

            InteractiveObjectMono interactiveObject = null;

            if (gameObjectToUse != null)
            {
                interactiveObject = gameObjectToUse.GetComponent <InteractiveObjectMono>();
            }

            if (DialogHandler.Instance.Interacting)
            {
                Debug.LogWarning("[RPGAIO] Ending active dialog before running new one through node event.");
                DialogHandler.Instance.EndDialog();
            }

            if (interactiveObject == null && gameObjectToUse != null)
            {
                Debug.LogWarning("[RPGAIO] Specified an interactive object to use but it is not an NPC or Interactable Object.");
            }


            //Set values if gameObject is null
            DialogHandler.Instance.CustomDialogName   = "";
            DialogHandler.Instance.CustomDialogSprite = null;

            if (gameObjectToUse == null)
            {
                DialogHandler.Instance.CustomDialogName   = dialogName;
                DialogHandler.Instance.CustomDialogSprite = GeneralMethods.CreateSprite(dialogSprite);
            }

            DialogHandler.Instance.BeginDialog(dialogId, interactiveObject);
        }
Ejemplo n.º 3
0
        public void BeginQuestDialog(string nodeTreeId, InteractiveObjectMono dialogObject = null, bool isQuest = false, string questId = "")
        {
            var nodeTree = Rm_RPGHandler.Instance.Nodes.DialogNodeBank.NodeTrees.FirstOrDefault(n => n.ID == nodeTreeId);

            if (nodeTree != null)
            {
                if (isQuest)
                {
                    EvaluatingQuestDialog     = true;
                    EvaluatingQuestID         = questId;
                    PostQuestEvaluationNodeID = string.IsNullOrEmpty(CurrentNode.NextNodeLinks[0].ID) ? null : CurrentNode.NextNodeLinks[0].ID;
                }

                var nodeChain = new NodeChain(nodeTree, typeof(DialogStartNode));
                OldNodeChain    = DialogNodeChain;
                DialogNodeChain = nodeChain;
                DialogNodeChain.Evaluate();
            }
            //CheckForUpdate();
        }
Ejemplo n.º 4
0
        public void BeginDialog(string nodeTreeId, InteractiveObjectMono dialogObject = null)
        {
            if (DialogNodeChain != null)
            {
                EndDialog();
            }
            DialogNpc = dialogObject ?? InteractiveObjectMono.CurrentInteraction;

            //Debug.Log(nodeTreeId);
            var nodeTree = Rm_RPGHandler.Instance.Nodes.DialogNodeBank.NodeTrees.FirstOrDefault(n => n.ID == nodeTreeId);

            if (nodeTree != null)
            {
                var nodeChain = new NodeChain(nodeTree, typeof(DialogStartNode));
                DialogNodeChain = nodeChain;
                DialogNodeChain.Evaluate();
            }
            else
            {
                EndDialog();
            }

            CheckForUpdate();
        }
Ejemplo n.º 5
0
        public void EndDialog()
        {
            var cam = GetObject.RPGCamera;

            cam.cameraMode = Rm_RPGHandler.Instance.DefaultSettings.DefaultCameraMode;
            if (cam.cameraMode != CameraMode.Manual)
            {
                cam.transform.position = cam.desiredPosition;
            }

            DialogNpc = null;

            if (EvaluatingQuestDialog)
            {
                //todo: is this the right place?!
                if (!string.IsNullOrEmpty(PostQuestEvaluationNodeID))
                {
                    DialogNodeChain = OldNodeChain;
                    if (DialogNodeChain != null)
                    {
                        DialogNodeChain.Goto(PostQuestEvaluationNodeID);
                    }
                }
                else
                {
                    DialogNodeChain = null;
                    GetObject.PlayerMono.Controller.Interacting = false;
                }

                OldNodeChain          = null;
                EvaluatingQuestDialog = false;
            }
            else if (EvaluatingQuestCompleteDialog)
            {
                //todo: is this the right place?!
                QuestHandler.Instance.CompleteQuest(EvaluatingQuestID);
                if (!string.IsNullOrEmpty(PostQuestEvaluationNodeID))
                {
                    DialogNodeChain = OldNodeChain;
                    if (DialogNodeChain != null)
                    {
                        DialogNodeChain.Goto(PostQuestEvaluationNodeID);
                    }
                }
                else
                {
                    DialogNodeChain = null;
                    GetObject.PlayerMono.Controller.Interacting = false;
                }
                OldNodeChain = null;
                EvaluatingQuestCompleteDialog = false;
            }
            else
            {
                if (dialogQuestCondition != null)
                {
                    dialogQuestCondition.IsDone = true;
                    RPG.Events.OnQuestStatusUpdate();
                    var deliverCondition = dialogQuestCondition as DeliverCondition;
                    if (deliverCondition != null)
                    {
                        GetObject.PlayerCharacter.Inventory.RemoveItem(deliverCondition.ItemToDeliverID);
                    }
                    dialogQuestCondition = null;
                }

                DialogNodeChain = null;
                GetObject.PlayerMono.Controller.Interacting = false;
            }

            CheckForUpdate();
        }