Ejemplo n.º 1
0
    void DisplayNPCDialog()
    {
        EditorGUILayout.LabelField("Current Dialog", EditorStyles.boldLabel);
        EditorGUILayout.BeginVertical();

        // Show the currently-added dialog options...
        addedDialogScrollPos = EditorGUILayout.BeginScrollView(addedDialogScrollPos, false, true, GUILayout.Width(400), GUILayout.Height(150));
        for (int i = 0; i < npcDialog.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("X", GUILayout.Width(50)))
            {
                npcDialog.RemoveAt(i);
                break;
            }
            if (GUILayout.Button("E", GUILayout.Width(50)))
            {
                showEditDialog = true;
                showAddDialog  = false;
                //ResetQuestStageFields();
                selectedDialog = npcDialog[i];
                GetDialogData();
                break;
            }

            string links = " ";
            for (int j = 0; j < npcDialog[i].DialogNext.Count; j++)
            {
                links += npcDialog[i].DialogNext[j].ToString() + " ";
            }
            EditorGUILayout.LabelField(string.Format("#{0}: ->{1} \n'{2}' \n Links: {3}", npcDialog[i].DialogID, npcDialog[i].DialogOption,
                                                     npcDialog[i].DialogOutput, links),
                                       GUILayout.MinHeight(40));
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.EndScrollView();

        // Button for adding a new stage:
        if (!showAddDialog)
        {
            if (GUILayout.Button("New Quest Stage", GUILayout.Width(300)))
            {
                //ResetQuestStageFields();
                showAddDialog  = true;
                showEditDialog = false;
            }
        }
        else
        {
            ShowModifyDialog();
        }

        if (showEditDialog)
        {
            ShowModifyDialog();
        }

        EditorGUILayout.EndVertical();
    }
    private void Update()
    {
        Move();

        // 无敌状态下 => 累进无敌时间
        if (m_bIsInvincible)
        {
            m_fInvincibleTimer -= Time.deltaTime;
            // 无敌时间到
            if (m_fInvincibleTimer <= 0)
            {
                m_bIsInvincible = false;
            }
        }

        // 攻击
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Launch();
        }

        // 与NPC对话
        if (Input.GetKeyDown(KeyCode.E))
        {
            RaycastHit2D hit = Physics2D.Raycast(transform.position + new Vector3(0, 0.2f, 0), m_LookDirction, 1.5f, LayerMask.GetMask("NPC"));
            if (hit != null)
            {
                NPCDialog npcDialog = hit.collider.GetComponentInChildren(typeof(NPCDialog), true) as NPCDialog;
                if (npcDialog != null)
                {
                    npcDialog.DisplayDialog();
                }
            }
        }
    }
Ejemplo n.º 3
0
    public override void JobTick(NPC npc)
    {
        if (!Init)
        {
            Init     = true;
            ShopNode = new NPCDialogNode("What do you have for sale?", "Take a look");
            ShopNode.SetOnSelectFunction(() => {
                //Debug.Log("test?");
                GUIManager.Instance.StartShop(npc, WorkLocation.WorkBuilding.Inventory);
            });
            if (npc.Dialog == null)
            {
                NPCDialog dialog = new NPCDialog(npc, "Hello, how can I help you today?");
                dialog.AddNode(ShopNode);
                npc.SetDialog(dialog);
                NPCDialogNode exitNode = new NPCDialogNode("I'll be on my way", "");
                exitNode.IsExitNode = true;
                dialog.AddNode(exitNode);
            }
            else
            {
                npc.Dialog.AddNode(ShopNode);
            }
        }


        float deltaTime = Time.time - CurrentPositionTime;

        if (deltaTime > CurrentPositionTimeOut)
        {
            ChooseNewPosition();
        }
    }
Ejemplo n.º 4
0
 private void OnDestroy()
 {
     if (_instance != null)
     {
         _instance = null;
     }
 }
Ejemplo n.º 5
0
 void DisplayDialogOptions(List <int> options)
 {
     for (int i = 0; i < options.Count; i++)
     {
         NPCDialog option = dialog.Find(x => x.DialogID == options[i]);
         Debug.LogWarning("Option " + (i + 1) + ": " + option.DialogOption);
     }
 }
Ejemplo n.º 6
0
    private void CloseNPCWindow()
    {
        openedNPCDialog = null;

        selectedItem         = null;
        blackSmith           = null;
        _displayNPCWindow    = false;
        MyGUI.DisplayToolTip = false;
    }
Ejemplo n.º 7
0
 private void Awake()
 {
     if (_instance != this || _instance == null)
     {
         _instance = this;
     }
     acceptButton = transform.Find("AcceptButton").GetComponent <UIButton>();
     tween        = transform.GetComponent <TweenPosition>();
 }
Ejemplo n.º 8
0
    // Interacts with the NPC, i.e., opens dialog.
    public void Interact()
    {
        NPCDialog current = dialog.Find(x => x.DialogID == currentDialog);

        Debug.LogWarning(npc.NPCName + " says: " + current.DialogOutput); // FOR TESTING. Puts the dialog output as a warning in the debug window.

        DisplayDialogOptions(current.DialogNext);

        ChangeDialog(current.DialogNext[0]);
    }
Ejemplo n.º 9
0
    // This extracts information from the JSON database (through conditionData)
    void CreateNPCDatabase()
    {
        for (int i = 0; i < npcData["NPCs"].Count; i++)
        {
            if (!Contains((int)npcData["NPCs"][i]["NPCID"]))
            {
                NPC newNPC = new NPC();

                // Map each line in the ith JSON entry to a variable:
                newNPC.NPCName = (string)npcData["NPCs"][i]["NPCName"];
                newNPC.NPCID   = (int)npcData["NPCs"][i]["NPCID"];

                // Load hostile factions list
                for (int j = 0; j < npcData["NPCs"][i]["NPCHostileTo"].Count; j++)
                {
                    newNPC.NPCHostileTo.Add((int)npcData["NPCs"][i]["NPCHostileTo"][j]);
                }

                // Load NPC inventory
                //Debug.Log(npcData["NPCs"][i]["NPCInventoryIDs"].Count);
                for (int k = 0; k < npcData["NPCs"][i]["NPCInventoryIDs"].Count; k++)
                {
                    int _id    = (int)npcData["NPCs"][i]["NPCInventoryIDs"][k];
                    int _quant = (int)npcData["NPCs"][i]["NPCInventoryStacks"][k];

                    newNPC.NPCInventoryIDs.Add(_id);
                    newNPC.NPCInventoryStacks.Add(_quant);
                }

                // Load NPC dialog
                for (int m = 0; m < npcData["NPCs"][i]["NPCDialogText"].Count; m++)
                {
                    NPCDialog _dialog = new NPCDialog();

                    _dialog.DialogID              = (int)npcData["NPCs"][i]["NPCDialogText"][m]["DialogID"];
                    _dialog.DialogOption          = (string)npcData["NPCs"][i]["NPCDialogText"][m]["DialogOption"];
                    _dialog.DialogOutput          = (string)npcData["NPCs"][i]["NPCDialogText"][m]["DialogOutput"];
                    _dialog.DialogTriggerID       = (int)npcData["NPCs"][i]["NPCDialogText"][m]["DialogTriggerID"];
                    _dialog.DialogTriggerOnFinish = (bool)npcData["NPCs"][i]["NPCDialogText"][m]["DialogTriggerOnFinish"];
                    _dialog.DialogType            = (NPCDialogType)((int)npcData["NPCs"][i]["NPCDialogText"][m]["DialogType"]);

                    for (int _m = 0; _m < npcData["NPCs"][i]["NPCDialogText"][m]["DialogNext"].Count; _m++)
                    {
                        _dialog.DialogNext.Add((int)npcData["NPCs"][i]["NPCDialogText"][m]["DialogNext"][_m]);
                    }

                    newNPC.NPCDialogText.Add(_dialog);
                }

                // Add this npc to the database.
                AddNPC(newNPC);
                //Debug.Log("(NPCDB) " + newNPC.NPCName + " loaded.");
            }
        }
    }
Ejemplo n.º 10
0
    // Update is called once per frame
    void Update()
    {
        horizontal = Input.GetAxis("Horizontal");
        vertical   = Input.GetAxis("Vertical");
        Vector2 move = new Vector2(horizontal, vertical);

        // Use Mathf.Approximately instead of == because the way computers store float numbers means there is a tiny loss in precision.
        if (!Mathf.Approximately(move.x, 0.0f) || !Mathf.Approximately(move.y, 0.0f))
        {
            lookDirection.Set(move.x, move.y);
            // you will normalize vectors that store direction because length is not important, only the direction is
            lookDirection.Normalize();
        }

        /*
         * Then you have the three lines that send the data to the Animator,
         * which is the direction you look in and the speed
         * (the length of the move vector).
         */
        animator.SetFloat("Look X", lookDirection.x);
        animator.SetFloat("Look Y", lookDirection.y);
        animator.SetFloat("Speed", move.magnitude);

        if (isInvincible)
        {
            invincibleTimer -= Time.deltaTime;
            Debug.Log(invincibleTimer);
            if (invincibleTimer < 0)
            {
                Debug.Log("i am in if condition");
                isInvincible = false;
            }
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            Launch();
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            // A layer mask which allows us to test only certain layers. Any layers that are not part of the mask will be ignored during the intersection test. Here, you will select the NPC layer, because that one contains your frog.
            RaycastHit2D hit = Physics2D.Raycast(rigidbody2d.position + Vector2.up * 0.2f, lookDirection, 1.5f, LayerMask.GetMask("NPC"));
            if (hit.collider != null)
            {
                NPCDialog character = hit.collider.GetComponent <NPCDialog>();
                if (character != null)
                {
                    character.DisplayDialog();
                }
            }
        }
    }
Ejemplo n.º 11
0
    // Start is called before the first frame update
    void Start()
    {
        rig           = this.GetComponent <Rigidbody2D>();
        animator      = this.GetComponent <Animator>();
        currentHealth = maxHealth;
        //audioSource = this.GetComponent<AudioSource>();
        respawnPosition = this.transform.position;

        shootTimer = shootTimeGap;

        taskNPC = GameObject.FindGameObjectWithTag("TaskNPC").GetComponent <NPCDialog>();
    }
Ejemplo n.º 12
0
 void AddToNPC()
 {
     GameObject trans = (GameObject)NPC;
     NPCDialogControl npc_control = trans.GetComponent<NPCDialogControl>();
     if(npc_control==null)
     {
         npc_control = trans.AddComponent<NPCDialogControl>();
     }
     NPCDialog newNPCDialog=new NPCDialog();
     newNPCDialog.id=dialog_id;
     npc_control.Dialogs.Add(newNPCDialog);
 }
Ejemplo n.º 13
0
    public NPCDialog(NPCDialog dialog)
    {
        this.DialogID     = dialog.DialogID;
        this.DialogOption = dialog.DialogOption;
        this.DialogOutput = dialog.DialogOutput;
        this.DialogNext   = dialog.DialogNext;

        // NYI: Requirements

        this.DialogType            = dialog.DialogType;
        this.DialogTriggerID       = dialog.DialogTriggerID;
        this.DialogTriggerOnFinish = dialog.DialogTriggerOnFinish;
    }
Ejemplo n.º 14
0
        private void nPCDialoguebmdToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string fpath = OpenDialog();

            if (string.IsNullOrEmpty(fpath))
            {
                return;
            }

            NPCDialog    Decoder = new NPCDialog(fpath, BmdFile.FileType.NPCDialogue);
            ClientEditor editor  = new ClientEditor(Decoder, false);

            editor.Show();
        }
Ejemplo n.º 15
0
 // Use this for initialization
 void Start()
 {
     this.plotTrigger = this.GetComponent <PlotTrigger>();
     if (this.npcResponses.Count < 1)
     {
         foreach (Transform child in this.transform)
         {
             NPCDialog dialog = child.GetComponent <NPCDialog>();
             if (dialog)
             {
                 this.npcResponses.Add(dialog);
             }
         }
     }
 }
Ejemplo n.º 16
0
 // Update is called once per frame
 private void Update()
 {
     if (this.completed)
     {
         this.hidePlayerResponses();
         if (npcText.text != string.Empty)
         {
             Invoke("hideNpcResponse", 3);
         }
     }
     if (this.started && !this.completed)
     {
         this.currentNpcDialog.fixedUpdate();
         NPCDialog continuation = this.currentNpcDialog.getNPCCountinuation();
         if (continuation && this.canStartNextLine)
         {
             this.currentNpcDialog = continuation;
             StartCoroutine(fireNextLine(this.currentNpcDialog.npcResponse));
             this.completed        = !this.currentNpcDialog.HasPossibleResponses();
             this.canStartNextLine = false;
         }
         else if (!continuation && !this.currentNpcDialog.getPlayerResponse() && this.canStartNextLine)
         {
             this.updatePlayerResponses();
         }
         else if (this.currentNpcDialog.getPlayerResponse() && this.canStartNextLine)
         {
             this.hidePlayerResponses();
             PlayerDialog playerDialog = this.currentNpcDialog.getPlayerResponse();
             this.currentNpcDialog = playerDialog.getNpcResponse();
             if (this.currentNpcDialog)
             {
                 this.npcText.text = this.currentNpcDialog.npcResponse;
                 this.completed    = !this.currentNpcDialog.HasPossibleResponses();
             }
             else
             {
                 this.completed = true;
             }
             if (this.completed)
             {
                 Invoke("hideNpcResponse", 3);
                 this.hidePlayerResponses();
             }
         }
     }
 }
Ejemplo n.º 17
0
    public NPCDialog getNPCCountinuation()
    {
        NPCDialog defaultDialog = null;

        foreach (NPCDialog dialog in this.npcContinuations)
        {
            if (dialog.isNpcResponse() && dialog.hasPlotFilter())
            {
                return(dialog);
            }
            else if (dialog.isNpcResponse())
            {
                defaultDialog = dialog;
            }
        }
        return(defaultDialog);
    }
Ejemplo n.º 18
0
    // Update is called once per frame
    void Update()
    {
        NPCDialog npcDialog = this.gameObject.GetComponent <NPCDialog>();

        if (npcDialog)
        {
            NPC    npc     = this.gameObject.GetComponentInParent <Conversation>().getNPC();
            string npcName = npc ? npc.getName() : "NPC";
            this.name = npcName + ": " + npcDialog.npcResponse;
        }
        PlayerDialog playerDialog = this.gameObject.GetComponent <PlayerDialog>();

        if (playerDialog)
        {
            this.name = "PC:" + playerDialog.dialogOne;
        }
    }
Ejemplo n.º 19
0
 // Initializes variables and generates enemy health for the round.
 void Start()
 {
     ani         = GetComponent <Animator> ();
     capCollider = GetComponent <CapsuleCollider> ();
     eMove       = GetComponent <EnemyMovement> ();
     nav         = GetComponent <NavMeshAgent> ();
     if (!isBoss)
     {
         spawn = GameObject.FindWithTag("GameManager").GetComponent <Spawner> ();
     }
     else
     {
         npc = GameObject.FindWithTag("GameManager").GetComponent <NPCDialog> ();
     }
     pA         = GameObject.FindWithTag("Player").GetComponent <PlayerAbility> ();
     currHealth = startingHealth;
 }
Ejemplo n.º 20
0
    /// <summary>
    /// Awake is called when the script instance is being loaded.
    /// </summary>
    void Awake()
    {
        this.playerResponses = new List <PlayerDialog>();
        int i = 0;

        foreach (Transform child in this.transform)
        {
            PlayerDialog dialog = child.GetComponent <PlayerDialog>();
            if (dialog)
            {
                dialog.setKeyCode(responseKeyCodes[i]);
                i += 1;
                this.playerResponses.Add(dialog);
            }
            NPCDialog npcContinuation = child.GetComponent <NPCDialog>();
            if (npcContinuation)
            {
                this.npcContinuations.Add(npcContinuation);
            }
        }
        this.plotFilter = this.GetComponent <PlotFilter>();
    }
Ejemplo n.º 21
0
    // Use this for initialization
    private void Awake()
    {
        NPCDialog startingDialog = null;

        foreach (Transform child in this.transform)
        {
            startingDialog = child.GetComponent <NPCDialog>();
            if (startingDialog && !startingDialog.isOnlyOnConversationCompletion())
            {
                this.currentNpcDialog = startingDialog;
            }
            if (startingDialog && startingDialog.isOnlyOnConversationCompletion())
            {
                this.completedResponses.Add(startingDialog);
            }
        }
        if (!this.currentNpcDialog)
        {
            this.completed = true;
        }
        this.plotFilters = new List <PlotFilter>(this.GetComponents <PlotFilter>());
        this.hidePlayerResponses();
    }
Ejemplo n.º 22
0
 // Use this for initialization
 void Start()
 {
     player       = GameObject.FindGameObjectWithTag("Player");
     textDialogue = GameObject.FindGameObjectWithTag("Dialog").GetComponent <NPCDialog>();
 }
Ejemplo n.º 23
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Scene = null;
                User = null;

                MoveTime = 0;
                AttackTime = 0;
                NextRunTime = 0;
                CanMove = false;
                CanRun = false;

                MapControl = null;
                MainDialog = null;
                ChatDialog = null;
                ChatControl = null;
                InventoryDialog = null;
                CharacterDialog = null;
                StorageDialog = null;
                BeltDialog = null;
                MiniMapDialog = null;
                InspectDialog = null;
                OptionDialog = null;
                MenuDialog = null;
                NPCDialog = null;
                QuestDetailDialog = null;
                QuestListDialog = null;
                QuestLogDialog = null;
                QuestTrackingDialog = null;
                GameShopDialog = null;
                MentorDialog = null;

                RelationshipDialog = null;
                CharacterDuraPanel = null;
                DuraStatusPanel = null;

                HoverItem = null;
                SelectedCell = null;
                PickedUpGold = false;

                UseItemTime = 0;
                PickUpTime = 0;
                InspectTime = 0;

                DisposeItemLabel();

                AMode = 0;
                PMode = 0;
                Lights = 0;

                NPCTime = 0;
                NPCID = 0;
                DefaultNPCID = 0;

                for (int i = 0; i < OutputLines.Length; i++)
                    if (OutputLines[i] != null && OutputLines[i].IsDisposed)
                        OutputLines[i].Dispose();

                OutputMessages.Clear();
                OutputMessages = null;
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 24
0
        public GameScene()
        {
            MapControl.AutoRun = false;
            MapControl.AutoHit = false;
            Slaying = false;
            Thrusting = false;
            HalfMoon = false;
            CrossHalfMoon = false;
            DoubleSlash = false;
            TwinDrakeBlade = false;
            FlamingSword = false;

            GroupDialog.GroupList.Clear();

            Scene = this;
            BackColour = Color.Transparent;
            MoveTime = CMain.Time;

            KeyDown += GameScene_KeyDown;

            MainDialog = new MainDialog { Parent = this };
            ChatDialog = new ChatDialog { Parent = this };
            ChatControl = new ChatControlBar { Parent = this };
            InventoryDialog = new InventoryDialog { Parent = this };
            CharacterDialog = new CharacterDialog { Parent = this, Visible = false };
            BeltDialog = new BeltDialog { Parent = this };
            StorageDialog = new StorageDialog { Parent = this, Visible = false };
            MiniMapDialog = new MiniMapDialog { Parent = this };
            InspectDialog = new InspectDialog { Parent = this, Visible = false };
            OptionDialog = new OptionDialog { Parent = this, Visible = false };
            MenuDialog = new MenuDialog { Parent = this, Visible = false };
            NPCDialog = new NPCDialog { Parent = this, Visible = false };
            NPCGoodsDialog = new NPCGoodsDialog { Parent = this, Visible = false };
            NPCDropDialog = new NPCDropDialog { Parent = this, Visible = false };
            NPCAwakeDialog = new NPCAwakeDialog { Parent = this, Visible = false };

            HelpDialog = new HelpDialog { Parent = this, Visible = false };
            
            MountDialog = new MountDialog { Parent = this, Visible = false };
            FishingDialog = new FishingDialog { Parent = this, Visible = false };
            FishingStatusDialog = new FishingStatusDialog { Parent = this, Visible = false };
            
            GroupDialog = new GroupDialog { Parent = this, Visible = false };
            GuildDialog = new GuildDialog { Parent = this, Visible = false };
            GuildBuffDialog = new GuildBuffDialog { Parent = this, Visible = false };
            BigMapDialog = new BigMapDialog { Parent = this, Visible = false };
            TrustMerchantDialog = new TrustMerchantDialog { Parent = this, Visible = false };
            CharacterDuraPanel = new CharacterDuraPanel { Parent = this, Visible = false };
            DuraStatusPanel = new DuraStatusDialog { Parent = this, Visible = true };
            TradeDialog = new TradeDialog { Parent = this, Visible = false };
            GuestTradeDialog = new GuestTradeDialog { Parent = this, Visible = false };

            SkillBarDialog = new SkillBarDialog { Parent = this, Visible = false };
            ChatOptionDialog = new ChatOptionDialog { Parent = this, Visible = false };
            ChatNoticeDialog = new ChatNoticeDialog { Parent = this, Visible = false };

            QuestListDialog = new QuestListDialog { Parent = this, Visible = false };
            QuestDetailDialog = new QuestDetailDialog {Parent = this, Visible = false};
            QuestTrackingDialog = new QuestTrackingDialog { Parent = this, Visible = false };
            QuestLogDialog = new QuestDiaryDialog {Parent = this, Visible = false};

            RankingDialog = new RankingDialog { Parent = this, Visible = false };

            MailListDialog = new MailListDialog { Parent = this, Visible = false };
            MailComposeLetterDialog = new MailComposeLetterDialog { Parent = this, Visible = false };
            MailComposeParcelDialog = new MailComposeParcelDialog { Parent = this, Visible = false };
            MailReadLetterDialog = new MailReadLetterDialog { Parent = this, Visible = false };
            MailReadParcelDialog = new MailReadParcelDialog { Parent = this, Visible = false };

            IntelligentCreatureDialog = new IntelligentCreatureDialog { Parent = this, Visible = false };//IntelligentCreature
            IntelligentCreatureOptionsDialog = new IntelligentCreatureOptionsDialog { Parent = this, Visible = false };//IntelligentCreature
            IntelligentCreatureOptionsGradeDialog = new IntelligentCreatureOptionsGradeDialog { Parent = this, Visible = false };//IntelligentCreature

            RefineDialog = new RefineDialog { Parent = this, Visible = false };
            RelationshipDialog = new RelationshipDialog { Parent = this, Visible = false };
            FriendDialog = new FriendDialog { Parent = this, Visible = false };
            MemoDialog = new MemoDialog { Parent = this, Visible = false };
            MentorDialog = new MentorDialog { Parent = this, Visible = false };
            GameShopDialog = new GameShopDialog { Parent = this, Visible = false };

            //not added yet
            KeyboardLayoutDialog = new KeyboardLayoutDialog { Parent = this, Visible = false };
            

            

            for (int i = 0; i < OutputLines.Length; i++)
                OutputLines[i] = new MirLabel
                {
                    AutoSize = true,
                    BackColour = Color.Transparent,
                    Font = new Font(Settings.FontName, 10F),
                    ForeColour = Color.LimeGreen,
                    Location = new Point(20, 25 + i * 13),
                    OutLine = true,
                };
        }
Ejemplo n.º 25
0
    public void RightMouseButton()
    {
        if (LookObject != null)
        {
            LoadedEntity lEnt = LookObject.GetComponent <LoadedEntity>();
            if (lEnt != null)
            {
                Entity ent = lEnt.Entity;
                if (ent is NPC)
                {
                    NPC npc = ent as NPC;

                    if (npc.HasDialog())
                    {
                        StartDialog(npc);
                    }
                }
            }
        }
        return;

        Ray  ray       = PlayerCamera.ScreenPointToRay(Input.mousePosition);
        bool entSelect = false;

        Debug.Log("hmmm");
        RaycastHit[] raycasthit = Physics.RaycastAll(ray);
        foreach (RaycastHit hit in raycasthit)
        {
            Debug.Log(hit);
            LoadedEntity hitEnt = hit.transform.gameObject.GetComponent <LoadedEntity>();
            if (hitEnt != null)
            {
                entSelect = true;
                //GameManager.DebugGUI.SetSelectedEntity(hitEnt);
                Entity hitEntity = hitEnt.Entity;
                if (hitEntity is NPC)
                {
                    NPC npc = hitEntity as NPC;
                    //If we have selected a different entities
                    if (npc != CurrentlySelected)
                    {
                        Debug.Log(hitEntity.Name + " has been clicked by the player");
                        GameManager.EventManager.InvokeNewEvent(new PlayerTalkToNPC(npc));
                        CurrentlySelected = npc;

                        if (npc.HasDialog())
                        {
                            Debug.Log("TRUE DIALOG");
                            GameManager.GUIManager.StartDialog(npc);
                            if (!Player.InConversation())
                            {
                                if (Player.CurrentDialogNPC() != npc)
                                {
                                    NPCDialog dial = npc.Dialog;
                                    dial.StartDialog();
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                CurrentlySelected = null;
            }
            Debug.Log(hit.collider.gameObject);
            if (hit.collider.gameObject.GetComponent <WorldObject>() != null)
            {
                WorldObject obj = hit.collider.gameObject.GetComponent <WorldObject>();
                Debug.Log(obj);
                Debug.Log(obj.Data);
                if (obj.Data is IOnEntityInteract)
                {
                    Debug.Log("here2");
                    (obj.Data as IOnEntityInteract).OnEntityInteract(Player);
                }
            }
        }

        if (!entSelect)
        {
            GameManager.DebugGUI.SetSelectedEntity(null);
        }
    }
Ejemplo n.º 26
0
 public void SetDialog(NPCDialog di)
 {
     Dialog = di;
 }
Ejemplo n.º 27
0
    void OnGUI()
    {
        if(!inited)
        {
            dialog_list = dr.GetDialogsShortcut();
            inited = true;
        }
        EditorGUILayout.BeginVertical();
            EditorGUILayout.LabelField("Search Information:");
            searchid=EditorGUILayout.TextField("Search ID:",searchid);
            if(GUILayout.Button("SEARCH"))
            {
                Search(searchid);
            }
            EditorGUILayout.LabelField("Dialog List:");
        EditorGUILayout.EndVertical();
        scrollposition = EditorGUILayout.BeginScrollView(scrollposition,false,true,GUILayout.Height(300f),GUILayout.Width(500f));
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("CB", GUILayout.Width(20f));
            EditorGUILayout.LabelField("ID", GUILayout.Width(80f));
            EditorGUILayout.LabelField("Comment", GUILayout.Width(150f));
            EditorGUILayout.LabelField("First Text");
            EditorGUILayout.EndHorizontal();
            if (dialog_list.Count >= 1)
                for (int i = 0; i < dialog_list.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    SetSelection(i, EditorGUILayout.Toggle(GetSelection(i), GUILayout.Width(20f)));
                    EditorGUILayout.LabelField(dialog_list[i].id, GUILayout.Width(80f));
                    EditorGUILayout.LabelField(dialog_list[i].comment, GUILayout.Width(150f));
                    EditorGUILayout.LabelField(dialog_list[i].firsttext);
                    EditorGUILayout.EndHorizontal();
                }
            else
            {

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Toggle(false, GUILayout.Width(20f));
                EditorGUILayout.LabelField("NULL", GUILayout.Width(80f));
                EditorGUILayout.LabelField("Cannot find any dialog.");
                EditorGUILayout.EndHorizontal();
            }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.BeginHorizontal();
            if(GUILayout.Button("Delete"))
            {
                if(selection==-1)
                {
                    SwNotification("Please select a dialog first.");
                }
                else
                {
                    int result= dw.RemoveFromXML(dialog_list[selection].id);
                    if(result== DialogWriter.IDNOTEXIST || result == DialogWriter.WRITEFAILED)
                    {
                        SwNotification("Something wrong in the delete process.");
                        selection = -1;
                    }
                    else
                    {
                        selection = -1;
                        Refresh();
                        SwNotification("Delete Success.");
                    }
                }

            }
            if(GUILayout.Button("Edit"))
            {
                if(selection==-1)
                {
                    SwNotification("Please select a dialog first.");
                }
                else
                {
                    EditDialog.edit_id = dialog_list[selection].id;
                    EditDialog.StartEdit();
                }
            }
            if(GUILayout.Button("Add to Current NPC"))
            {
                if(selection==-1)
                {
                    SwNotification("Please select a dialog first.");
                }
                else if(Selection.activeGameObject==null)
                {
                    SwNotification("Please select a GameObject that you want to make it a NPC.");
                }
                else
                {
                    GameObject trans = Selection.activeGameObject;
                    NPCDialogControl npc_control = trans.GetComponent<NPCDialogControl>();
                    if (npc_control == null)
                    {
                        npc_control = trans.AddComponent<NPCDialogControl>();
                    }
                    NPCDialog newNPCDialog = new NPCDialog();
                    newNPCDialog.id = dialog_list[selection].id;
                    npc_control.Dialogs.Add(newNPCDialog);
                }
            }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Refresh"))
            {
                Refresh();
            }
            if(GUILayout.Button("Close the Window"))
            {
                this.Close();
            }
            EditorGUILayout.EndHorizontal();
    }
Ejemplo n.º 28
0
 void Start()
 {
     InvokeRepeating("Spawn", spawnDelay, spawnRate);
     UpdateEnemies("ENEMIES REMAINING: " + (levelEnemies - killedEnemies), enemiesRemaining);
     npc = GetComponent <NPCDialog> ();
 }
Ejemplo n.º 29
0
    void GetDialogData()
    {
        dialogID     = EditorGUILayout.IntField("ID: ", selectedDialog.DialogID, GUILayout.Width(295));
        dialogOption = EditorGUILayout.TextField("Option: ", selectedDialog.DialogOption, GUILayout.Width(295));
        EditorGUILayout.LabelField("Dialog text:");
        dialogOutput = EditorGUILayout.TextArea(selectedDialog.DialogOutput, GUILayout.Width(350), GUILayout.MinHeight(90));

        EditorGUILayout.Space();
        // What the dialog links to...
        EditorGUILayout.LabelField("Dialog links to...");

        for (int h = 0; h < selectedDialog.DialogNext.Count; h++)
        {
            dialogNext.Add(selectedDialog.DialogNext[h]);
        }


        for (int i = 0; i < dialogNext.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("X", GUILayout.Width(50)))
            {
                dialogNext.RemoveAt(i);
                break;
            }

            string label = string.Format("#{0}: ", dialogNext[i].ToString());
            if (selectedNPC != null)
            {
                if (selectedNPC.HasDialogWithID(dialogNext[i]))
                {
                    label += selectedNPC.GetDialogWithID(dialogNext[i]).DialogOption;
                }
            }
            EditorGUILayout.LabelField(label, GUILayout.ExpandHeight(true));
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.BeginHorizontal();
        dialogNextID = EditorGUILayout.IntField("New Link: ", dialogNextID, GUILayout.Width(295));
        if (GUILayout.Button("+", GUILayout.Width(50)))
        {
            dialogNext.Add(dialogNextID);
            dialogNextID = 0;
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        // Dialog type, target item/quest...
        dialogType = (NPCDialogType)EditorGUILayout.EnumPopup("Type: ", selectedDialog.DialogType, GUILayout.Width(480));
        switch (dialogType)
        {
        case (NPCDialogType.Dialog):
            break;

        case (NPCDialogType.Player_GiveItem):
        case (NPCDialogType.Player_ReceiveItem):
            EditorGUILayout.BeginHorizontal();
            string itemLabel = string.Format("#{0}: ", dialogTriggerID.ToString());
            if (_itemDatabase.Contains(dialogTriggerID))
            {
                itemLabel += _itemDatabase.Item(dialogTriggerID).ItemName;
            }

            EditorGUILayout.LabelField(itemLabel);
            EditorGUILayout.EndHorizontal();
            break;

        case (NPCDialogType.Quest_Start):
        case (NPCDialogType.Quest_Advance):
        case (NPCDialogType.Quest_Finish):
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("X", GUILayout.Width(50)))
            {
                dialogTriggerID = -1;
                break;
            }

            string questLabel = string.Format("#{0}: ", dialogTriggerID.ToString());
            if (_questDatabase.Contains(dialogTriggerID))
            {
                questLabel += _questDatabase.quest(dialogTriggerID);
            }

            EditorGUILayout.LabelField(questLabel);
            EditorGUILayout.EndHorizontal();
            break;
        }

        dialogTriggerOnFinish = EditorGUILayout.Toggle("Trigger on Finish: ", selectedDialog.DialogTriggerOnFinish);
        dialogTriggerID       = EditorGUILayout.IntField("Item/NPC ID: ", selectedDialog.DialogTriggerID, GUILayout.Width(295));

        if (showEditDialog)
        {
            if (GUILayout.Button("Save Dialog", GUILayout.Width(300)))
            {
                if (selectedNPC.HasDialogWithID(dialogID))
                {
                    Debug.LogWarning("NPC already contains a dialog with ID  " + dialogID);
                    return;
                }

                selectedDialog.DialogID              = dialogID;
                selectedDialog.DialogOption          = dialogOption;
                selectedDialog.DialogOutput          = dialogOutput;
                selectedDialog.DialogType            = dialogType;
                selectedDialog.DialogTriggerOnFinish = dialogTriggerOnFinish;
                selectedDialog.DialogTriggerID       = dialogTriggerID;

                List <int> _next = new List <int>();
                for (int i = 0; i < dialogNext.Count; i++)
                {
                    _next.Add(dialogNext[i]);
                }

                selectedDialog.SetDialogLinks(_next);

                // Sorts the list by dialog number then resets the fields.
                // npcDialog = npcDialog.OrderBy(o => o.DialogID).ToList();
                ResetDialogFields();

                selectedDialog = null;
                showEditDialog = false;
            }

            if (GUILayout.Button("Cancel", GUILayout.Width(300)))
            {
                ResetDialogFields();
                selectedDialog = null;
                showEditDialog = false;
            }
        }
        else if (showAddDialog)
        {
            if (GUILayout.Button("Save Dialog", GUILayout.Width(300)))
            {
                if (selectedNPC.HasDialogWithID(dialogID))
                {
                    Debug.LogWarning("NPC already contains a dialog with ID " + dialogID);
                    return;
                }

                NPCDialog _dialog = new NPCDialog();

                _dialog.DialogID              = dialogID;
                _dialog.DialogOption          = dialogOption;
                _dialog.DialogOutput          = dialogOutput;
                _dialog.DialogType            = dialogType;
                _dialog.DialogTriggerOnFinish = dialogTriggerOnFinish;
                _dialog.DialogTriggerID       = dialogTriggerID;
                _dialog.SetDialogLinks(dialogNext);

                List <int> _next = new List <int>();
                for (int i = 0; i < dialogNext.Count; i++)
                {
                    _next.Add(dialogNext[i]);
                }

                _dialog.SetDialogLinks(_next);

                // Sorts the list by dialog number then resets the fields.
                // npcDialog = npcDialog.OrderBy(o => o.DialogID).ToList();
                ResetDialogFields();

                selectedDialog = null;
                showEditDialog = false;
            }
        }
    }
Ejemplo n.º 30
0
 public void SetParent(NPCDialog dialog)
 {
     Parent = dialog;
 }
Ejemplo n.º 31
0
 void Awake()
 {
     instance = this;
     npcCam = GameObject.FindWithTag("NPCCamera").GetComponent<Camera>();
     gameObject.SetActive(false);
 }
Ejemplo n.º 32
0
 void Start()
 {
     currentDialogLine = 0;
     playerController  = FindObjectOfType <PlayerController>();
     npcManager        = GetComponentInChildren <NPCDialog>();
 }
Ejemplo n.º 33
0
    // Use this for initialization
    void Start()
    {
        enteredTime = Time.time;

        textDialogue = GameObject.FindGameObjectWithTag("Dialog").GetComponent <NPCDialog>();
    }
Ejemplo n.º 34
0
 void Awake()
 {
     instance = this;
     npcCam   = GameObject.FindWithTag("NPCCamera").GetComponent <Camera>();
     gameObject.SetActive(false);
 }
Ejemplo n.º 35
0
    /// <summary>
    /// Places the dungeon key in a random structure.
    ///
    /// </summary>
    /// <param name="dungeonPos"></param>
    /// <param name="chunkStructure"></param>
    /// <param name="endTasks"></param>
    /// <returns></returns>
    private Quest GenerateDungeonKeyQuest_RandomStructure(Vec2i dungeonPos, Dungeon dungeon, List <QuestTask> endTasks)
    {
        //Find a random chunk structure
        ChunkStructure ranStruct = GetRandomFreeStructure(dungeonPos, 3);

        if (ranStruct == null)
        {
            throw new System.Exception("We need to fix this");
        }
        //We add the dungeon key to the loot chest of this structure
        ranStruct.FinalLootChest.GetInventory().AddItem(dungeon.GetKey());
        //Add the item finding task


        endTasks.Add(new QuestTask("Go to " + ranStruct.Name + " and collect the key", QuestTask.QuestTaskType.PICK_UP_ITEM,
                                   new object[] { dungeon.GetKey(), ranStruct.WorldMapLocation, (ranStruct.FinalLootChest as WorldObjectData).WorldPosition }));

        //Quest initiator will be a random entity
        //Therefore, we choose a random settlement
        Settlement set = GetRandomSettlement(dungeonPos, 5);
        //Then take a random npc from it.
        NPC            npc       = GameManager.EntityManager.GetEntityFromID(GenRan.RandomFromList(set.SettlementNPCIDs)) as NPC;
        QuestInitiator questInit = new QuestInitiator(QuestInitiator.InitiationType.TALK_TO_NPC, new object[] { npc, false });



        //We now reverse the tasks to get in correct order
        endTasks.Reverse();
        Quest quest = new Quest("Clear dungeon " + questCount, questInit, endTasks.ToArray(), QuestType.clear_dungeon);



        if (npc.Dialog == null)
        {
            NPCDialog dialog = new NPCDialog(npc, "Hello adventurer! How can I help you today?");

            NPCDialogNode exitNode = new NPCDialogNode("Don't worry, I'll be on my way", "");
            exitNode.IsExitNode = true;

            dialog.AddNode(exitNode);
            npc.SetDialog(dialog);
        }
        NPCDialogNode startQuestNode = new NPCDialogNode("Have you heard of any quests for an adventurer such as myself?", "I've heard of a dungeon that may be full of sweet shit." +
                                                         " It's probably locked though, last I heard the key was at " + ranStruct.Name);

        NPCDialogNode exitNode2 = new NPCDialogNode("Thanks! I'll be on my way", "");

        exitNode2.IsExitNode = true;
        startQuestNode.AddNode(exitNode2);
        npc.Dialog.AddNode(startQuestNode);

        startQuestNode.SetOnSelectFunction(() => {
            GameManager.QuestManager.StartQuest(quest);
        });
        startQuestNode.SetShouldDisplayFunction(() =>
        {
            if (GameManager.QuestManager.Unstarted.Contains(quest))
            {
                return(true);
            }
            return(false);
        });


        NPCDialogNode questRewardNode = new NPCDialogNode("I killed " + dungeon.Boss.Name, "I didn't think it was possible. Here, take this as a reward");

        questRewardNode.AddNode(exitNode2);
        questRewardNode.SetShouldDisplayFunction(() => {
            return(GameManager.QuestManager.Completed.Contains(quest));
        });
        questRewardNode.SetOnSelectFunction(() =>
        {
            Inventory playerInv = GameManager.PlayerManager.Player.Inventory;
            playerInv.AddItem(new SteelLongSword());
        });
        npc.Dialog.AddNode(questRewardNode);

        return(quest);
    }