Пример #1
0
 public Quest(Quest q)
 {
     id = q.ID;
     name = q.Name;
     talk = q.Talk;
     talk_completed = q.Talk_Completed;
     talk_noncompleted = q.Talk_Noncompleted;
     //script = Activator.CreateInstance(q.Script.GetType()) as QuestScript;
     Type type = Type.GetType("demo.quest." + q.scriptname);
     if (type != null)
     {
         QuestScript s = type.Assembly.CreateInstance("demo.quest." + q.scriptname) as QuestScript;
         if (s != null)
         {
             s.Quest = this;
             s.Initialize();
             script = s;
         }
     }
     next = NextQuest;
 }
Пример #2
0
 public static Quest GetQuestFromStorageByName(string name)
 {
     if (queststorage.ContainsKey(name))
     {
         return queststorage[name];
     }
     else
     {
         try
         {
             QuestDefinition.QuestDef qd = GameConst.Content.Load<QuestDefinition.QuestDef>(@"quest/" + name);
             if (qd != null)
             {
                 Quest q = new Quest(qd);
                 queststorage[name] = q;
                 return q;
             }
             return null;
         }
         catch
         {
             return null;
         }
     }
 }
Пример #3
0
 private bool DeliveryQuest(Quest q)
 {
     return q.Script.Delivery();
 }
Пример #4
0
        private void MakeQuestUI(Quest quest)
        {
            UIDialog dialog = UIMgr.GetUIControlByName("dialognpc") as UIDialog;
            if (dialog == null)
                dialog = UIMgr.AddUIControl("Dialog_Npc", "dialognpc", (int)UILayout.Center, (int)UILayout.Bottom, 0, 0, -1, 99, this) as UIDialog;
            if (dialog != null)
            {
                UITextBlock text = dialog.GetUIControlByName("npctalk") as UITextBlock;
                if (text == null)
                {
                    text = UIMgr.CreateUIControl("UITextBlock") as UITextBlock;
                }
                if (text != null)
                {
                    if (quests_completed.ContainsKey(quest.ID))
                    {
                        text.Text = quest.Talk_Noncompleted;
                    }
                    else if (quests.ContainsKey(quest.ID))
                    {
                        text.Text = quest.Talk_Noncompleted;
                    }
                    else
                    {
                        text.Text = quest.Talk;
                    }

                    text.FontColor = Color.Black;
                    dialog.AddUIControl(text, "npctalk", 18, 47, 441, 138, -1, this);
                }


                UITextButton btn = dialog.GetUIControlByName("okbtn") as UITextButton;
                if (btn == null)
                {
                    btn = UIMgr.CreateUIControl("UITextButton") as UITextButton;
                }
                if (btn != null)
                {
                    if (quests_completed.ContainsKey(quest.ID))
                    {
                        if (quest.ID == 3)
                            btn.Text = "真不敢相信,我做到了!";
                        else
                            btn.Text = "已经消灭殆尽了!";
                    }
                    else if (quests.ContainsKey(quest.ID))
                    {
                        btn.Text = "我这就去!";
                    }
                    else
                    {
                        btn.Text = quest.OKContent; ;
                    }
                    btn.UserData = quest;
                    btn.FontColor = Color.DeepSkyBlue;
                    dialog.AddUIControl(btn, "okbtn", 20, 200, 300, 20, -1, this);
                }

                UITextButton btn1 = dialog.GetUIControlByName("cancelbtn") as UITextButton;
                if (btn1 == null)
                {
                    btn1 = UIMgr.CreateUIControl("UITextButton") as UITextButton;
                }
                if (btn1 != null)
                {
                    if (quests_completed.ContainsKey(quest.ID))
                    {
                        btn1.Text = "";
                        btn1.State = RenderChunk.RenderChunkState.Hide;
                    }
                    else if (quests.ContainsKey(quest.ID))
                    {
                        btn1.Text = "";
                        btn1.State = RenderChunk.RenderChunkState.Hide;
                    }
                    else
                    {
                        if (quest.CancelContent != "")
                        {
                            btn1.Text = quest.CancelContent;
                            btn1.State = RenderChunk.RenderChunkState.Show;
                        }
                        else
                        {
                            btn1.Text = "";
                            btn1.State = RenderChunk.RenderChunkState.Hide;
                        }
                    }

                    btn.FontColor = Color.DeepSkyBlue;
                    dialog.AddUIControl(btn1, "cancelbtn", 20, 221, 300, 20, -1, this);
                }




                UIImage npcface1 = dialog.GetUIControlByName("testimage") as UIImage;
                if (npcface1 == null)
                {
                    npcface1 = UIMgr.CreateUIControl("UIImage") as UIImage;
                }
                if (npcface1 != null)
                {
                    npcface1.Texture = GameConst.Content.Load<Texture2D>(@"npcface/NPC01");
                    dialog.AddUIControl(npcface1, "testimage", 0, -npcface1.Texture.Height, 0, 0, -1, this);
                }

            }

        }
Пример #5
0
        public void AddQuest(Quest q)
        {
            if (!quests.ContainsKey(q.ID))
            {
                Quest qnew = new Quest(q);
                qnew.Script.Player = this;
                if (qnew.Script.GetTakeable())
                {
                    quests.Add(q.ID, qnew);
                    qnew.Script.Takeup();
                    UpdateQuestTrack(qnew);
                }
                else
                    qnew = null;
            }

        }
Пример #6
0
 private void UpdateQuestTrack(Quest q)
 {
     UIElement trackd = UIMgr.GetUIControlByName("dlg_questtrck");
     if (trackd != null)
     {
         if (scene.State == demo.Scene.SceneState.Map)
         {
             if (trackd.State == RenderChunk.RenderChunkState.Hide)
                 trackd.State = RenderChunk.RenderChunkState.FadeIn;
         }
         UITextBlock t = trackd.GetUIControlByName("text_questname") as UITextBlock;
         if (t != null)
         {
             t.Text = q.Name;
         }
         t = trackd.GetUIControlByName("text_questtrack") as UITextBlock;
         if (t != null)
         {
             t.Text = q.Script.GetTrackString(0);
         }
     }
 }