Example #1
0
    void InitNPC()                                                                       //敌人加载
    {
        int          NPCNum      = 0;                                                    //NPC数量
        int          guanID      = PlayerData.Instance.GuanNow;
        XuanGuanData data        = XuanGuanDataManager.Instance.GetXuanGuanData(guanID); //获取关卡数据
        NPCGuanData  NPCGuanData = NPCGuanDataManager.Instance.GetNPCGuanData(data.npcGuanID);

        for (int i = 0; i < NPCGuanDataManager.NPCNumMax; i++)
        {
            if (NPCGuanData.npcID[i] == 0)
            {
                continue;
            }
            NPCData    npcData = NPCDataManager.Instance.GetNPCData(NPCGuanData.npcID[i]);
            GameObject prefab  = (GameObject)Resources.Load("Prefab/Animator/" + npcData.prefabName);
            GameObject objNPC  = Instantiate(prefab);
            objNPC.transform.parent = transform;
            objNPC.transform.Rotate(0, 180, 0);
            objNPC.transform.position = new Vector3(NPCNum * 1.5f, 0, 5);
            NPCNum++;

            Character cha = objNPC.AddComponent <Character>();
            cha.SetCharactorData(npcData.ID, 1);
            npcList.Add(objNPC);
        }
    }
Example #2
0
    public const int NPCNumMax = 4;//美观NPC最大数量
    public void LoadFile(string fileName)
    {
        MyLoad file = new MyLoad();

        file.LoadFile(fileName);
        for (int i = 0; i < file.dataList.Count; i++)
        {
            NPCGuanData data = new NPCGuanData((ArrayList)file.dataList[i]);
            dataList.Add(data);
        }
    }