Ejemplo n.º 1
0
    void ExportPathSetInfo(string tablename, Transform parent, ref StreamWriter sw)
    {
        int    index = 1;
        string key   = tablename;

        for (int i = 0; i < parent.childCount; ++i)
        {
            Transform ChildTRF = parent.GetChild(i);
            BornInfo  info     = ChildTRF.GetComponent <BornInfo>();

            key = tablename + "[" + (index++).ToString() + "]";
            Vector2 mapPos = m_csPathGrid.GetMapPosByWordPos(ChildTRF.position.x, ChildTRF.position.y);
            int     id     = info.mi_Id;
            sw.WriteLine(key + "= {}");


            sw.WriteLine(key + "['ID']" + " = " + i);
            sw.WriteLine(key + "['GridX']" + " = " + info.mi_ObjId);
            sw.WriteLine(key + "['GridY'] = " + info.m_nRebornTime);
            sw.WriteLine(key + "['ActionID']" + " = " + 0);
            sw.WriteLine(key + "['RoundType']" + " = " + mapPos.x);
            sw.WriteLine(key + "['RoundMark']" + " = " + mapPos.y);
            int nRoundNum = 0;
            sw.WriteLine(key + "['RoundNum']  = " + nRoundNum);
            for (int k = 0; k < nRoundNum; k++)
            {
                sw.WriteLine(key + "['Round_" + k + "']  = {}");
                sw.WriteLine(key + "['Round_" + k + "']['ActionID'] = " + 0);
                sw.WriteLine(key + "['Round_" + k + "']['GridX'] = " + 0);
                sw.WriteLine(key + "['Round_" + k + "']['GridY'] = " + 0);
            }
        }
    }
Ejemplo n.º 2
0
    string GetShowInfo(Transform childtran, ref BornInfo info, int index)
    {
        string returnstring = "";

        //if (childtran.parent == InteractionTool.GetFixBornParent())
        //{
        //    string tempstring = childtran.name + getSpaceWithNameLenght(childtran.name.Length);
        //    string numberstring = info.mi_Lv + getSpaceWithNumberLenght(info.mi_Lv.Length);
        //    string numberstring2 = info.mi_Id.ToString() + getSpaceWithNumberLenght(info.mi_Id.ToString().Length);
        //    returnstring = tempstring + numberstring + numberstring2;
        //}
        //else if (childtran.parent == InteractionTool.GetBornParent())
        //{
        //    string tempstring = "场景刷怪点" + getSpaceWithNameLenght("场景刷怪点".Length);
        //    string numberstring = (info.mi_Id).ToString() + getSpaceWithNumberLenght((info.mi_Id).ToString().Length);
        //    returnstring = tempstring + "     " + numberstring;
        //}
        //else if (childtran.parent == InteractionTool.GetObjParent())
        //{
        //    string tempstring = childtran.name + getSpaceWithNumberLenght(childtran.name.Length);
        //    string numberstring2 = info.mi_Id.ToString() + getSpaceWithNumberLenght(info.mi_Id.ToString().Length);
        //    returnstring = tempstring + "     " + numberstring2;

        //}
        return(returnstring);
    }
    //获取当前选中目标的类型
    public static CreateMode GetChooseMode()
    {
        if (!_windowInstance)
        {
            _windowInstance.m_oEditorGameObj = null;
            return(CreateMode.enInvild);
        }
        if (Selection.activeGameObject)
        {
            GameObject[] objarrayElse = Selection.gameObjects;
            BornInfo     borninfo     = Selection.activeGameObject.GetComponent <BornInfo>();
            if (objarrayElse.Length != 1 || borninfo == null)
            {
                _windowInstance.m_oEditorGameObj = null;
                return(CreateMode.enInvild);
            }
            _windowInstance.m_oEditorGameObj = Selection.gameObjects[0];
            return(borninfo.me_Type);
        }
        //if (_windowInstance.m_enCreateMode == CreateMode.enDaoHang)
        //{
        //    _windowInstance.m_oEditorGameObj = _windowInstance.AllParent;
        //    return _windowInstance.m_enCreateMode;
        //}

        _windowInstance.m_oEditorGameObj = null;
        return(CreateMode.enInvild);
    }
    public GameObject AddNpcPatrolPoint(float posx, float posy, float posz, GameObject obj)
    {
        BornInfo borninfo = obj.GetComponent <BornInfo>();

        if (borninfo == null)
        {
            return(null);
        }
        if (!borninfo.CheckPatrolPoint((int)posx, (int)posy))
        {
            return(null);
        }
        GameObject patrolpoint = InstantiatePrefabWithpos(posx, posy, posz, ref PatrolBorn);

        patrolpoint.transform.SetParent(obj.transform);
        patrolpoint.transform.localScale = new Vector3(0.4f, 0.4f, 0.01f);
        patrolpoint.name = "巡逻点";
        PatrolPointInfo info = new PatrolPointInfo();

        info.m_GridX = (int)posx;
        info.m_GridY = (int)posy;
        borninfo.m_PatrolInfo.Add(info);

        PatrolInfo patrol = patrolpoint.GetComponent <PatrolInfo>();

        if (patrol != null)
        {
            patrol.m_GridX = info.m_GridX;
            patrol.m_GridY = info.m_GridY;
        }
        return(patrolpoint);
    }
Ejemplo n.º 5
0
    void ExportRegionNpcInfo(string tablename, Transform parent, ref StreamWriter sw)
    {
        int index = 1;

        string key = tablename;

        for (int i = 0; i < parent.childCount; ++i)
        {
            Transform ChildTRF = parent.GetChild(i);
            BornInfo  info     = ChildTRF.GetComponent <BornInfo>();
            key = tablename + "[" + (index++).ToString() + "]";

            Vector2 mapPos = m_csPathGrid.GetMapPosByWordPos(ChildTRF.position.x, ChildTRF.position.y);
            int     id     = info.mi_Id;
            sw.WriteLine(key + "= {}");


            sw.WriteLine(key + "['ID']" + " = " + i);
            sw.WriteLine(key + "['Type']" + " = " + info.m_eObjType);
            sw.WriteLine(key + "['GridX']" + " = " + mapPos.x.ToString());
            sw.WriteLine(key + "['GridY']" + " = " + mapPos.y.ToString());
            sw.WriteLine(key + "['GridW']" + " = " + info.m_nWidth);
            sw.WriteLine(key + "['GridH']" + " = " + info.m_nHeight);
            sw.WriteLine(key + "['NpcSum']" + " = " + info.m_RegionNpcInfo.Count);
            for (int k = 0; k < info.m_RegionNpcInfo.Count; k++)
            {
                RegionObjInfo objinfo = info.m_RegionNpcInfo[k];
                int           showkey = k + 1;
                sw.WriteLine(key + "['npc_" + showkey + "']" + " = {}");
                sw.WriteLine(key + "['npc_" + showkey + "']['Nums']" + " = " + objinfo.Nums);
                sw.WriteLine(key + "['npc_" + showkey + "']['ObjId']" + " = " + objinfo.ObjId);
                sw.WriteLine(key + "['npc_" + showkey + "']['Dir']" + " = " + objinfo.Dir);
                sw.WriteLine(key + "['npc_" + showkey + "']['Per']" + " = " + 0);
                sw.WriteLine(key + "['npc_" + showkey + "']['Time']" + " = " + objinfo.Time);
                sw.WriteLine(key + "['npc_" + showkey + "']['Rate']" + " = " + objinfo.Rate);
            }

            sw.WriteLine(key + "['MinPower']" + " = " + info.m_minPower);
            sw.WriteLine(key + "['MaxPower']" + " = " + info.m_maxPower);
        }
    }
Ejemplo n.º 6
0
    //设置信息
    public void SetInfo(GameObject obj)
    {
        mo_ChooseObj = null;
        if (obj == null)
        {
            return;
        }

        mcs_Borninfo = obj.GetComponent <BornInfo>();
        if (mcs_Borninfo == null)
        {
            return;
        }
        mo_ChooseObj = obj;
        me_Direction = GetDirectionWithAngel(mcs_Borninfo.GetDiretionAngel());
        mi_ChooseId  = obj.GetInstanceID();
        if (me_Direction == enDirection.enInviled)
        {
            me_Direction = enDirection.enTop;
            mo_ChooseObj.transform.rotation = Quaternion.Euler(new Vector3(mo_ChooseObj.transform.rotation.x, 0, mo_ChooseObj.transform.rotation.z));
        }
    }
Ejemplo n.º 7
0
    //导出场景点(包括随机刷怪)
    void ExportScenePointInfo(string tablename, Transform parent, ref StreamWriter sw)
    {
        int    index = 1;
        string key   = tablename;

        for (int i = 0; i < parent.childCount; ++i)
        {
            Transform ChildTRF = parent.GetChild(i);
            BornInfo  info     = ChildTRF.GetComponent <BornInfo>();


            key = tablename + "[" + (index++).ToString() + "]";
            Vector2 mapPos = m_csPathGrid.GetMapPosByWordPos(ChildTRF.position.x, ChildTRF.position.y);
            int     id     = info.mi_Id;
            sw.WriteLine(key + "= {}");

            sw.WriteLine(key + "['ID']" + " = " + i);
            sw.WriteLine(key + "['Class']" + " = " + info.m_minPower);
            sw.WriteLine(key + "['ActionID']" + " = " + info.m_maxPower);
            sw.WriteLine(key + "['GridX']" + " = " + info.m_maxPower);
            sw.WriteLine(key + "['GridY']" + " = " + info.m_maxPower);
        }
    }
Ejemplo n.º 8
0
    bool DrawShowInfo(Transform childtran, bool foldout, ref Dictionary <int, bool> bornDic, int childCount, ref BornInfo info, int index)
    {
        int id = childtran.gameObject.GetInstanceID();

        string ShowString = GetShowInfo(childtran, ref info, index);

        GUILayout.BeginHorizontal();
        int offset = 3;

        if (childCount != 0)
        {
            offset = index * 3 + 3;
        }
        if (bornDic != null)
        {
            bornDic.TryGetValue(id, out foldout);
            foldout = EditorGUI.Foldout(new Rect(2, 17f * index + childCount * 18f + offset, 20, 20), foldout, GUIContent.none);
        }
        else
        {
            GUILayout.Space(5);
        }

        GUILayout.Space(20);
        GUILayout.BeginVertical();
        GUILayout.Space(4);

        if (mi_ChooseId != int.MaxValue && mi_ChooseId == id)
        {
            mgs_ButtonSkin.button.normal.textColor = Color.red;
            if (GUILayout.Button(ShowString, mgs_ButtonSkin.button))
            {
                ChangeChooseObj(id);
            }
            mgs_ButtonSkin.button.normal.textColor = Color.white;
        }
        else
        {
            if (GUILayout.Button(ShowString, mgs_ButtonSkin.button))
            {
                ChangeChooseObj(id);
            }
        }
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        SetMonstBornInDict(id, foldout);
        return(foldout);
    }
Ejemplo n.º 9
0
    void ExportPointNpcInfo(string tablename, Transform parent, ref StreamWriter sw)
    {
        int    index = 1;
        string key   = tablename;

        for (int i = 0; i < parent.childCount; ++i)
        {
            Transform ChildTRF = parent.GetChild(i);
            BornInfo  info     = ChildTRF.GetComponent <BornInfo>();


            key = tablename + "[" + (index++).ToString() + "]";
            Vector2 mapPos = m_csPathGrid.GetMapPosByWordPos(ChildTRF.position.x, ChildTRF.position.y);
            int     id     = info.mi_Id;
            sw.WriteLine(key + "= {}");

            sw.WriteLine(key + "['ID']" + " = " + i);
            sw.WriteLine(key + "['Type']" + " = " + info.m_eObjType);

            if (info.m_eObjType != 1)
            {
                sw.WriteLine(key + "['MinPower']" + " = " + info.m_minPower);
                sw.WriteLine(key + "['MaxPower']" + " = " + info.m_maxPower);
            }

            sw.WriteLine(key + "['ObjId']" + " = " + info.mi_ObjId);
            sw.WriteLine(key + "['Time'] = " + info.m_nRebornTime);
            sw.WriteLine(key + "['Dir']" + " = " + info.rotation);
            if (info.m_eObjType == 1)
            {
                sw.WriteLine(key + "['GraphicDir']" + " = " + info.graphDir);
            }
            sw.WriteLine(key + "['GridX']" + " = " + mapPos.x);
            sw.WriteLine(key + "['GridY']" + " = " + mapPos.y);
            sw.WriteLine(key + "['LiveTime']  = " + info.m_nLiveTime);
            sw.WriteLine(key + "['DelayBornTime']  = " + info.m_nDelayBornTime);
            sw.WriteLine(key + "['Rate']  = " + info.m_nRate);
            sw.WriteLine(key + "['RoundType'] = " + info.m_RoundType);
            sw.WriteLine(key + "['LinkID'] = " + info.mi_Group);
            sw.WriteLine(key + "['RoundNum'] = " + info.m_PatrolInfo.Count);
            if (info.m_PatrolInfo.Count > 0)
            {
                for (int k = 0; k < info.m_PatrolInfo.Count; k++)
                {
                    int             showKey    = k;
                    PatrolPointInfo patrolinfo = info.m_PatrolInfo[k];
                    sw.WriteLine(key + "['Round_" + showKey + "'] = {}");
                    sw.WriteLine(key + "['Round_" + showKey + "']['WaitTime'] = " + patrolinfo.m_WaitTime);
                    sw.WriteLine(key + "['Round_" + showKey + "']['ActionID'] = " + patrolinfo.m_ActionId);
                    sw.WriteLine(key + "['Round_" + showKey + "']['GridX'] = " + patrolinfo.m_GridX);
                    sw.WriteLine(key + "['Round_" + showKey + "']['GridY'] = " + patrolinfo.m_GridY);
                }
            }
            else
            {
                sw.WriteLine(key + "['MoveMode'] = " + info.m_nMoveMode);
                sw.WriteLine(key + "['MoveRadius'] = " + info.m_nMoveRadius);
            }

            if (info.m_nTrapSceneId > 0)
            {
                sw.WriteLine(key + "['Tranp_SceneID'] = " + info.m_nTrapSceneId);
                sw.WriteLine(key + "['Tranp_PosX'] = " + info.m_nPosX);
                sw.WriteLine(key + "['Tranp_PosY'] = " + info.m_nPosY);
                sw.WriteLine(key + "['Tranp_Dir'] = " + 0);
            }
        }
    }
Ejemplo n.º 10
0
    public void ImportNpcMapInfo(string filePath)
    {
        m_bOnImport = true;

        CreateMode mode = InteractionTool.GetNowCreateMode();
        BornInfo   info;
        int        preid = InteractionTool.m_iChooseFunNpcId;

        InteractionTool.SetCanDraw(false);


        //fileName = fileName.Substring(filename.IndexOf("/Scene/") + "/Scene/".Length).Replace(".lua", "");
        string fileName = filePath.Substring(filePath.IndexOf("/Map/") + 1).Replace(".lua", "");

        object[] objarray         = m_fLoadFunNpcFun.LazyCall(fileName);
        string   sRegionNpcIdInfo = objarray[0].ToString();
        LuaTable tRegionNpcInfo   = (LuaTable)objarray[1];
        string   sPointNpcIdInfo  = objarray[2].ToString();
        LuaTable tPointNpcInfo    = (LuaTable)objarray[3];
        string   sPathSetInfo     = objarray[4].ToString();
        LuaTable tPathSetInfo     = (LuaTable)objarray[5];
        string   sScenePointInfo  = objarray[6].ToString();
        LuaTable tScenenPointInfo = (LuaTable)objarray[7];



        string[] npcIdList = sRegionNpcIdInfo.Split(',');
        for (int i = 0; i < npcIdList.Length; i++)
        {
            int id = -1;
            if (!int.TryParse(npcIdList[i], out id))
            {
                continue;
            }

            LuaTable npcInfo = (LuaTable)tRegionNpcInfo[id];

            int Type      = int.Parse(npcInfo["Type"].ToString());
            int ID        = int.Parse(npcInfo["ID"].ToString());
            int GridX     = int.Parse(npcInfo["GridX"].ToString());
            int GridY     = int.Parse(npcInfo["GridY"].ToString());
            int GridW     = int.Parse(npcInfo["GridW"].ToString());
            int GridH     = int.Parse(npcInfo["GridH"].ToString());
            int summonNum = int.Parse(npcInfo["NpcSum"].ToString());
            List <RegionObjInfo> regionObjInfo = new List <RegionObjInfo>();
            int ObjId = 0;
            int Dir   = 0;
            for (int key = 0; key < summonNum; key++)
            {
                int      showkey = key + 1;
                LuaTable tNpc    = (LuaTable)npcInfo["npc_" + showkey];
                ObjId = int.Parse(tNpc["ObjId"].ToString());
                int Nums = int.Parse(tNpc["Nums"].ToString());
                Dir = int.Parse(tNpc["Dir"].ToString());
                int Time = int.Parse(tNpc["Time"].ToString());

                int nRate = 0;
                if (tNpc["Rate"] != null && tNpc["Rate"].ToString() != "")
                {
                    nRate = int.Parse(tNpc["Rate"].ToString());
                }

                RegionObjInfo newobj = new RegionObjInfo();
                newobj.ObjId = ObjId;
                newobj.Nums  = Nums;
                newobj.Dir   = Dir;
                newobj.Time  = Time;
                newobj.Per   = 0;
                newobj.Rate  = nRate;
                regionObjInfo.Add(newobj);
            }


            int minPower = 1;
            if (npcInfo["MinPower"] != null && npcInfo["MinPower"].ToString() != "")
            {
                minPower = int.Parse(npcInfo["MinPower"].ToString());
            }
            int maxPower = 99;
            if (npcInfo["MaxPower"] != null && npcInfo["MaxPower"].ToString() != "")
            {
                maxPower = int.Parse(npcInfo["MaxPower"].ToString());
            }


            GameObject obj = InteractionTool.AddReginNpc(GridX, GridY, -1, ObjId, (CreateObjType)Type, Dir);
            if (obj != null)
            {
                BornInfo bornInfo = obj.GetComponent <BornInfo>();
                bornInfo.m_minPower      = minPower;
                bornInfo.m_maxPower      = maxPower;
                bornInfo.m_nWidth        = GridW;
                bornInfo.m_nHeight       = GridH;
                bornInfo.m_RegionNpcInfo = regionObjInfo;
            }
        }


        string[] funNpcIdList = sPointNpcIdInfo.Split(',');
        for (int i = 0; i < funNpcIdList.Length; i++)
        {
            int funnpcid = -1;
            if (!int.TryParse(funNpcIdList[i], out funnpcid))
            {
                continue;
            }
            LuaTable funNpcInfo = (LuaTable)tPointNpcInfo[funnpcid];
            int      Type       = int.Parse(funNpcInfo["Type"].ToString());
            int      ID         = int.Parse(funNpcInfo["ID"].ToString());
            int      nTime      = 0;
            if (funNpcInfo["Time"] != null && funNpcInfo["Time"].ToString() != "")
            {
                nTime = int.Parse(funNpcInfo["Time"].ToString());
            }

            int nLiveTime = 0;
            if (funNpcInfo["LiveTime"] != null && funNpcInfo["LiveTime"].ToString() != "")
            {
                nLiveTime = int.Parse(funNpcInfo["LiveTime"].ToString());
            }

            int nDelayBornTime = 0;
            if (funNpcInfo["DelayBornTime"] != null && funNpcInfo["DelayBornTime"].ToString() != "")
            {
                nLiveTime = int.Parse(funNpcInfo["DelayBornTime"].ToString());
            }

            int nRate = 0;
            if (funNpcInfo["Rate"] != null && funNpcInfo["Rate"].ToString() != "")
            {
                nRate = int.Parse(funNpcInfo["Rate"].ToString());
            }

            int nGraphicDir = 0;
            if (funNpcInfo["GraphicDir"] != null && funNpcInfo["GraphicDir"].ToString() != "")
            {
                nGraphicDir = int.Parse(funNpcInfo["GraphicDir"].ToString());
            }
            int ObjId        = int.Parse(funNpcInfo["ObjId"].ToString());
            int GridX        = int.Parse(funNpcInfo["GridX"].ToString());
            int GridY        = int.Parse(funNpcInfo["GridY"].ToString());
            int Dir          = int.Parse(funNpcInfo["Dir"].ToString());
            int nTrapSceneId = 0;
            int nTrapPosX    = 0;
            int nTrapPosY    = 0;
            if (funNpcInfo["Tranp_SceneID"] != null && funNpcInfo["Tranp_SceneID"].ToString() != "")
            {
                nTrapSceneId = int.Parse(funNpcInfo["Tranp_SceneID"].ToString());
                nTrapPosX    = int.Parse(funNpcInfo["Tranp_PosX"].ToString());
                nTrapPosY    = int.Parse(funNpcInfo["Tranp_PosY"].ToString());
            }
            int minPower = 1;
            if (funNpcInfo["MinPower"] != null && funNpcInfo["MinPower"].ToString() != "")
            {
                minPower = int.Parse(funNpcInfo["MinPower"].ToString());
            }
            int maxPower = 99;
            if (funNpcInfo["MaxPower"] != null && funNpcInfo["MaxPower"].ToString() != "")
            {
                maxPower = int.Parse(funNpcInfo["MaxPower"].ToString());
            }

            int RoundType = 0;
            if (funNpcInfo["RoundType"] != null && funNpcInfo["RoundType"].ToString() != "")
            {
                RoundType = int.Parse(funNpcInfo["RoundType"].ToString());
            }
            int LinkID = 0;
            if (funNpcInfo["LinkID"] != null && funNpcInfo["LinkID"].ToString() != "")
            {
                LinkID = int.Parse(funNpcInfo["LinkID"].ToString());
            }


            int RoundNum = 0;
            if (funNpcInfo["RoundNum"] != null && funNpcInfo["RoundNum"].ToString() != "")
            {
                RoundNum = int.Parse(funNpcInfo["RoundNum"].ToString());
            }



            List <PatrolPointInfo> patrolInfo = new List <PatrolPointInfo>();
            int MoveMode   = 0;
            int MoveRadius = 0;
            if (RoundNum > 0)
            {
                for (int key = 0; key < RoundNum; key++)
                {
                    LuaTable        tRoundInfo  = (LuaTable)funNpcInfo["Round_" + key.ToString()];
                    PatrolPointInfo patrolpoint = new PatrolPointInfo();
                    patrolpoint.m_WaitTime = int.Parse(tRoundInfo["WaitTime"].ToString());
                    patrolpoint.m_ActionId = int.Parse(tRoundInfo["ActionID"].ToString());
                    patrolpoint.m_GridX    = int.Parse(tRoundInfo["GridX"].ToString());
                    patrolpoint.m_GridY    = int.Parse(tRoundInfo["GridY"].ToString());
                    patrolInfo.Add(patrolpoint);
                }
            }
            else
            {
                if (funNpcInfo["MoveMode"] != null && funNpcInfo["MoveMode"].ToString() != "")
                {
                    MoveMode = int.Parse(funNpcInfo["MoveMode"].ToString());
                }

                if (funNpcInfo["MoveRadius"] != null && funNpcInfo["MoveRadius"].ToString() != "")
                {
                    MoveRadius = int.Parse(funNpcInfo["MoveRadius"].ToString());
                }
            }

            GameObject obj = InteractionTool.AddPointNpc(GridX, GridY, -1, ObjId, (CreateObjType)Type, Dir);
            if (obj != null)
            {
                BornInfo bornInfo = obj.GetComponent <BornInfo>();
                bornInfo.m_nRebornTime  = nTime;
                bornInfo.m_nTrapSceneId = nTrapSceneId;
                bornInfo.m_nPosX        = nTrapPosX;
                bornInfo.m_nPosY        = nTrapPosY;

                bornInfo.m_minPower  = minPower;
                bornInfo.m_maxPower  = maxPower;
                bornInfo.mi_Group    = LinkID;
                bornInfo.m_RoundType = RoundType;

                bornInfo.m_nMoveMode      = MoveMode;
                bornInfo.m_nMoveRadius    = MoveRadius;
                bornInfo.m_nLiveTime      = nLiveTime;
                bornInfo.m_nDelayBornTime = nDelayBornTime;
                bornInfo.m_nRate          = nRate;
                bornInfo.graphDir         = nGraphicDir;
                for (int n = 0; n < patrolInfo.Count; n++)
                {
                    PatrolPointInfo point = patrolInfo[n];
                    InteractionTool.AddNpcPatrolPoint(point.m_GridX, point.m_GridY, -1, obj);
                }
                bornInfo.m_PatrolInfo = patrolInfo;
            }
        }


        Debug.Log("导入功能NPC文件完成:" + filePath);

        InteractionTool.SetCanDraw(true);
        InteractionTool.SetCreateMode(mode);
        m_bOnImport = false;
        SceneEditorWindow._windowInstance.m_sBornListPath = filePath;
    }
Ejemplo n.º 11
0
 // Use this for initialization
 void Start()
 {
     parentBornInfo = this.transform.parent.GetComponent <BornInfo>();
 }
    public GameObject AddPatrolPoint(GameObject parent, float posx, float posy, float posz)
    {
        BornInfo borninfo = parent.GetComponent <BornInfo>();

        return(null);
    }
    public GameObject AddPointNpc(float posx, float posy, float posz, int id, CreateObjType eType, int rotation)
    {
        GameObject obj = InstantiatePrefabWithpos(posx, posy, posz, ref PointBorn);

        obj.transform.SetParent(PointParent);
        obj.name = "定点刷怪点";

        if (eType == CreateObjType.eFunNpc)
        {
            FunNpcInfo funnpcinfo;
            if (EditerDataClass._Instance.GetFunNpcInfo().TryGetValue(id, out funnpcinfo))
            {
                BornInfo bornInfo = obj.GetComponent <BornInfo>();
                if (bornInfo != null)
                {
                    bornInfo.m_eObjType = 1;
                    bornInfo.me_Type    = CreateMode.enPointObj;
                    bornInfo.mi_ObjId   = id;
                    bornInfo.ms_Name    = funnpcinfo.name;
                    bornInfo.rotation   = rotation;
                }
            }
        }

        if (eType == CreateObjType.eMonster)
        {
            NpcInfo npcinfo;
            if (EditerDataClass._Instance.GetNpcInfo().TryGetValue(id, out npcinfo))
            {
                BornInfo bornInfo = obj.GetComponent <BornInfo>();
                if (bornInfo != null)
                {
                    bornInfo.m_eObjType = 0;
                    bornInfo.me_Type    = CreateMode.enPointObj;
                    bornInfo.mi_ObjId   = id;
                    bornInfo.ms_Name    = npcinfo.name;
                    bornInfo.rotation   = rotation;
                }
            }
        }

        if (eType == CreateObjType.eObj)
        {
            ObjInfo objinfo;
            if (EditerDataClass._Instance.GetObjInfo().TryGetValue(id, out objinfo))
            {
                BornInfo bornInfo = obj.GetComponent <BornInfo>();
                if (bornInfo != null)
                {
                    bornInfo.m_eObjType = 2;
                    bornInfo.me_Type    = CreateMode.enPointObj;
                    bornInfo.mi_ObjId   = id;
                    bornInfo.ms_Name    = objinfo.name;
                    bornInfo.rotation   = rotation;
                }
            }
        }


        obj.transform.localScale = new Vector3(0.2f, 0.2f, 0.01f);
        return(obj);
    }
 //删除路径键H按下
 void OnKeyHDown()
 {
     GameObject Chooseobj = m_oEditorGameObj;
     BornInfo   info      = Chooseobj.GetComponent <BornInfo>();
 }
    //生成键G按下
    void OnKeyGDown()
    {
        if (mb_IsHaveObStacle)
        {
            return;
        }
        GameObject    obj   = null;
        CreateObjType eType = CreateObjType.eInvalid;

        if (m_bShowFunNpc)
        {
            eType = CreateObjType.eFunNpc;
        }
        if (m_bShowNpc)
        {
            eType = CreateObjType.eMonster;
        }
        if (m_bShowObj)
        {
            eType = CreateObjType.eObj;
        }
        switch (m_enCreateMode)
        {
        case CreateMode.enObstcale:
            obj = AddPosToObstacle(mp_MousPos.x, mp_MousPos.y, mp_MousPos.z);
            break;

        case CreateMode.enScenePoint:     //场景点(可能是随机刷怪点)
            Vector2 ScenePointPos = GetMapPosWith3DPos(mp_MousPos.x, mp_MousPos.y);
            //obj = AddScenePointToMap(ScenePointPos.x, ScenePointPos.y, -1);
            break;

        case CreateMode.enPathPoint:    //路径点
            //Vector2 pathPointPos = GetMapPosWith3DPos(mp_MousPos.x, mp_MousPos.y);
            //obj = AddPathPointToMap(pathPointPos.x, pathPointPos.y, -1);
            break;

        case CreateMode.enRegionObj:    //范围怪
            Vector2 regionNpcPos = GetMapPosWith3DPos(mp_MousPos.x, mp_MousPos.y);
            obj = AddReginNpc(regionNpcPos.x, regionNpcPos.y, -1, m_nChooseId, eType, 0);
            break;

        case CreateMode.enPointObj:    //定点怪
            Vector2 pointNpcPos = GetMapPosWith3DPos(mp_MousPos.x, mp_MousPos.y);
            obj = AddPointNpc(pointNpcPos.x, pointNpcPos.y, -1, m_nChooseId, eType, 0);
            break;

        case CreateMode.enPatrolPoint:    //npc巡逻点
            Vector2 objPos = GetMapPosWith3DPos(mp_MousPos.x, mp_MousPos.y);
            if (Selection.gameObjects.Length == 1)
            {
                BornInfo info = Selection.gameObjects[0].GetComponent <BornInfo>();
                if (info == null)
                {
                    return;
                }
                obj = AddNpcPatrolPoint(objPos.x, objPos.y, -1, Selection.gameObjects[0]);
            }

            break;

        default:
            break;
        }


        if (obj != null)
        {
            Undo.RegisterCreatedObjectUndo(obj, "InstantiatePrefabWithpos");
        }
    }