Example #1
0
        // 增加NPC任务
        static public void NewNpcTask(NPCData npc)
        {
            // 选择任务

            // 满足条件的数量
            int count = 0;

            Dictionary <string, NPCTask> dicttask = DataCenter.Instance.dictNPCTask;


            foreach (string id in dicttask.Keys)
            {
                if (npc.ID == dicttask[id].NpcId)
                {
                    if (GameData.nPlayerLv >= dicttask[id].Lv[0] && GameData.nPlayerLv <= dicttask[id].Lv[1])
                    {
                        if (npc.CurfavorabilityLv >= dicttask[id].Favor[0] && npc.CurfavorabilityLv <= dicttask[id].Favor[1])
                        {
                            if (npc.CurEmotion >= dicttask[id].Emtion[0] && npc.CurEmotion <= dicttask[id].Emtion[1])
                            {
                                count++;
                            }
                        }
                    }
                }
            }

            int rand = UnityEngine.Random.Range(0, count);

            if (count == 0)
            {
                npc.CurNpcTask = null;
                return;
            }

            count = 0;

            foreach (string id in dicttask.Keys)
            {
                if (npc.ID == dicttask[id].NpcId)
                {
                    if (GameData.nPlayerLv >= dicttask[id].Lv[0] && GameData.nPlayerLv <= dicttask[id].Lv[1])
                    {
                        if (npc.CurfavorabilityLv >= dicttask[id].Favor[0] && npc.CurfavorabilityLv <= dicttask[id].Favor[1])
                        {
                            if (npc.CurEmotion >= dicttask[id].Emtion[0] && npc.CurEmotion <= dicttask[id].Emtion[1])
                            {
                                if (count == rand)
                                {
                                    npc.CurNpcTask = dicttask[id];

                                    UIPanelManager.Instance.GetPanel("UIGameHUD").Repaint();

                                    Debug.Log(" NpcId = " + npc.ID + ": NpcTaskCount = " + count);
                                    return;
                                }
                                else
                                {
                                    count++;
                                }
                            }
                        }
                    }
                }
            }
        }
Example #2
0
 public void SetRoleData(NPCData data)
 {
 }