예제 #1
0
        protected override void OnInnerGUI(XCutSceneData data)
        {
            EditorGUILayout.Space();

            if (!data.GeneralShow)
            {
                EditorGUI.BeginChangeCheck();
                _id = EditorGUILayout.IntField("ID", _id);
                if (EditorGUI.EndChangeCheck())
                {
                    XEntityStatistics.RowData row = XTableMgr.GetTable <XEntityStatistics>().GetByID(_id);
                    if (row != null)
                    {
                        _name = row.Name;
                    }
                }
                _name = EditorGUILayout.TextField("Name", _name);
            }

            _discription = EditorGUILayout.TextArea(_discription, GUILayout.Height(80));
            EditorGUILayout.BeginHorizontal();
            _duration = EditorGUILayout.FloatField("Length", _duration);
            GUILayout.Label("(s)");
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            _x = EditorGUILayout.FloatField("X", _x);
            _y = EditorGUILayout.FloatField("Y", _y);
        }
예제 #2
0
        public void Init()
        {
            combineConfig = FbxEditor.GetConfig();
            TempEquipSuit fashions = new TempEquipSuit();

            m_FashionList = new List <EquipPart>();
            m_EquipList   = new List <EquipPart>();
            var fashionsuit = XTableMgr.GetTable <FashionSuit>();

            for (int i = 0, max = fashionsuit.length; i < max; ++i)
            {
                FashionSuit.RowData row = fashionsuit[i];
                if (row.FashionID != null)
                {
                    XEquipUtil.MakeEquip(row.SuitName, row.FashionID, m_FashionList, fashions, (int)row.SuitID);
                }
            }
            var equipsuit = XTableMgr.GetTable <EquipSuit>();

            for (int i = 0; i < equipsuit.length; ++i)
            {
                EquipSuit.RowData row = equipsuit[i];
                if (row.EquipID != null)
                {
                    XEquipUtil.MakeEquip(row.SuitName, row.EquipID, m_EquipList, fashions, -1);
                }
            }
        }
예제 #3
0
    private IEnumerator PreLoadMonster()
    {
        XLevelSpawnInfo spawner = XLevelSpawnMgr.singleton.currSpawn;

        if (spawner != null)
        {
            _sub_progress = 0;
            float per = 1f / spawner.preloadInfo.Count;
            foreach (var item in spawner.preloadInfo)
            {
                var entity = XTableMgr.GetTable <XEntityStatistics>().GetByID(item.Key);
                if (entity == null)
                {
                    continue;
                }
                var pres = XTableMgr.GetTable <XEntityPresentation>().GetItemID(entity.PresentID);
                if (pres == null)
                {
                    continue;
                }
                XResources.CreateInAdvance("Prefabs/" + pres.Prefab, item.Value);
                _sub_progress += per;
                yield return(null);
            }
        }
    }
예제 #4
0
    private void TestAvatar()
    {
        role = XEntityMgr.singleton.CreateTestRole();
        role.EntityObject.AddComponent <XRotation>();

        //时装
        TempEquipSuit fashions = new TempEquipSuit();

        m_FashionList = new List <EquipPart>();
        var fashionsuit = XTableMgr.GetTable <FashionSuit>();

        for (int i = 0, max = fashionsuit.length; i < max; ++i)
        {
            FashionSuit.RowData row = fashionsuit[i];
            if (row.FashionID != null)
            {
                XEquipUtil.MakeEquip(row.SuitName, row.FashionID, m_FashionList, fashions, (int)row.SuitID);
            }
        }

        //装备
        m_EquipList = new List <EquipPart>();
        var equipsuit = XTableMgr.GetTable <EquipSuit>();

        for (int i = 0, max = equipsuit.length; i < max; ++i)
        {
            EquipSuit.RowData row = equipsuit[i];
            if (row.EquipID != null)
            {
                XEquipUtil.MakeEquip(row.SuitName, row.EquipID, m_EquipList, fashions, -1);
            }
        }
    }
예제 #5
0
 protected override void OnInitial()
 {
     base.OnInitial();
     defEquip           = XTableMgr.GetTable <DefaultEquip>().GetByUID(2);
     controller         = EntityObject.GetComponent <CharacterController>();
     controller.enabled = false;
     AttachComponent <NativeEquipComponent>();
 }
예제 #6
0
 public static GameObject GetStatics(uint statictid)
 {
     XEntityStatistics.RowData row = XTableMgr.GetTable <XEntityStatistics>().GetByID((int)statictid);
     if (row != null)
     {
         return(GetDummy(row.PresentID));
     }
     return(null);
 }
예제 #7
0
파일: XScene.cs 프로젝트: xfilson/dn_asset
    private void OnEnterScene(uint sceneid)
    {
        _sceneid   = sceneid;
        _scene_row = XTableMgr.GetTable <SceneList>().GetByUID((int)_sceneid);
        GameObject camera = GameObject.FindGameObjectWithTag("MainCamera");

        GameCamera.Initial(camera);
        Documents.singleton.OnEnterScene();
        XLevelSpawnMgr.singleton.OnEnterScene(sceneid);
    }
예제 #8
0
    public override void OnInitial(XEntity enty)
    {
        base.OnInitial(enty);
        XEntity e = enty;

        //时装
        TempEquipSuit fashions = new TempEquipSuit();

        m_FashionList = new List <EquipPart>();
        var fashionsuit = XTableMgr.GetTable <FashionSuit>();

        for (int i = 0, max = fashionsuit.length; i < max; ++i)
        {
            FashionSuit.RowData row = fashionsuit[i];
            if (row.FashionID != null)
            {
                XEquipUtil.MakeEquip(row.SuitName, row.FashionID, m_FashionList, fashions, (int)row.SuitID);
            }
        }

        //装备
        m_EquipList = new List <EquipPart>();
        var equipsuit = XTableMgr.GetTable <EquipSuit>();

        for (int i = 0, max = equipsuit.length; i < max; ++i)
        {
            EquipSuit.RowData row = equipsuit[i];
            if (row.EquipID != null)
            {
                XEquipUtil.MakeEquip(row.SuitName, row.EquipID, m_EquipList, fashions, -1);
            }
        }

        Transform skinmesh = e.EntityObject.transform;

        skin = skinmesh.GetComponent <SkinnedMeshRenderer>();
        if (skin == null)
        {
            skin = skinmesh.gameObject.AddComponent <SkinnedMeshRenderer>();
        }
        skin.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
        e.skin = skin;

        for (EPartType part = EPartType.ECombinePartStart; part < EPartType.ECombinePartEnd; ++part)
        {
            parts[(int)part] = new PartLoadTask(part, this);
        }
        for (EPartType part = EPartType.ECombinePartEnd; part < EPartType.EMountEnd; ++part)
        {
            parts[(int)part] = new MountLoadTask(part, this);
        }
        RegisterEvent(XEventDefine.XEvent_Detach_Host, OnDetachHost);

        EquipPart(m_FashionList[0]);
    }
예제 #9
0
파일: XNPC.cs 프로젝트: xfilson/dn_asset
 public override void OnInitial()
 {
     _eEntity_Type |= EntityType.Npc;
     base.OnInitial();
     _layer       = LayerMask.NameToLayer("Npc");
     _target      = XEntityMgr.singleton.Player;
     _head_rotate = EntityTransfer.forward;
     _uGazing     = XTableMgr.GetTable <XNpcList>().GetByUID((int)_attr.id).Gazing;
     FindHead();
     EnableShadow(true);
 }
예제 #10
0
파일: XActor.cs 프로젝트: xfilson/dn_asset
 public GameObject GetDummy(uint statictid)
 {
     XEntityStatistics.RowData row = XTableMgr.GetTable<XEntityStatistics>().GetByID((int)statictid);
     if (row != null)
     {
         XEntityPresentation.RowData raw_data = XTableMgr.GetTable<XEntityPresentation>().GetItemID(row.PresentID);
         if (raw_data == null) return null;
         string prefab = raw_data.Prefab;
         return XResources.Load<GameObject>("Prefabs/" + prefab, AssetType.Prefab);
     }
     return null;
 }
예제 #11
0
파일: XEntity.cs 프로젝트: xfilson/dn_asset
 public void Initilize(GameObject o, XAttributes attr)
 {
     base.Initilize();
     _object    = o;
     _transf    = o.transform;
     _attr      = attr;
     _present   = XTableMgr.GetTable <XEntityPresentation>().GetItemID(_attr.PresentID);
     components = new Dictionary <uint, XComponent>();
     anim       = AttachComponent <XAnimComponent>();
     OnInitial();
     InitAnim();
 }
예제 #12
0
    void Update()
    {
        XTableMgr.Update();

        if (start)
        {
            GameEnine.Update(Time.deltaTime);

#if TEST
            TestManager.Get().Update();
#endif
        }
    }
예제 #13
0
    static Welcome()
    {
        XConfig.Initial(LogLevel.Log, LogLevel.Error);
        XTableMgr.Initial();
        XResources.Init();

        int isShow = PlayerPrefs.GetInt("ShowWelcomeScreen", 1);

        if (isShow == 1)
        {
            EditorApplication.update += Update;
        }
    }
예제 #14
0
 public void Load(uint uid, uint presentid)
 {
     _uid       = uid;
     _present   = XTableMgr.GetTable <XEntityPresentation>().GetItemID(presentid);
     _path      = "Prefabs/" + present.Prefab;
     _go        = XResources.LoadInPool(_path);
     _go.name   = present.Name;
     components = new Dictionary <uint, NativeComponent>();
     anim       = AttachComponent <NativeAnimComponent>();
     base.Initilize();
     OnInitial();
     InitAnim();
 }
예제 #15
0
    public static GameObject GetDummy(uint presentid)
    {
        XEntityPresentation.RowData raw_data = XTableMgr.GetTable <XEntityPresentation>().GetItemID(presentid);
        if (raw_data == null)
        {
            return(null);
        }
        string prefab = raw_data.Prefab;
        int    n      = prefab.LastIndexOf("_SkinnedMesh");
        int    m      = prefab.LastIndexOf("Loading");

        return(n < 0 || m > 0 ?
               AssetDatabase.LoadAssetAtPath("Assets/Resources/Prefabs/" + prefab + ".prefab", typeof(GameObject)) as GameObject :
               AssetDatabase.LoadAssetAtPath("Assets/Editor/EditorResources/Prefabs/" + prefab.Substring(0, n) + ".prefab", typeof(GameObject)) as GameObject);
    }
예제 #16
0
    private XAttributes InitAttrByPresent(uint presentID)
    {
        XAttributes attr = new XAttributes();
        var         prow = XTableMgr.GetTable <XEntityPresentation>().GetItemID(presentID);

        if (prow == null)
        {
            throw new Exception("present is nil with id: " + presentID);
        }
        attr.Prefab    = prow.Prefab;
        attr.id        = (uint)XCommon.singleton.New_id;
        attr.PresentID = presentID;
        attr.Name      = prow.Name;
        return(attr);
    }
예제 #17
0
        public XEntity CreateNPC(uint id, float yRotate, Vector3 pos, int _waveid)
        {
            Quaternion rotation = Quaternion.Euler(0, yRotate, 0);

            XNpcList.RowData row    = XTableMgr.GetTable <XNpcList>().GetByUID((int)id);
            XEntity          entity = XEntityMgr.singleton.CreateNPC(row, pos, rotation);

            if (entity != null)
            {
                entity.Wave       = _waveid;
                entity.CreateTime = Time.realtimeSinceStartup;
                return(entity);
            }
            return(null);
        }
예제 #18
0
    public override void OnInitial()
    {
        _eEntity_Type |= EntityType.Role;
        base.OnInitial();
        _layer             = LayerMask.NameToLayer("Role");
        profession         = 1;
        defEquip           = XTableMgr.GetTable <DefaultEquip>().GetByUID(profession + 1);
        controller         = EntityObject.GetComponent <CharacterController>();
        controller.enabled = false;

        AttachComponent <XAIComponent>();
        AttachComponent <XEquipComponent>();
        nav = AttachComponent <XNavComponent>();
        AttachComponent <XSkillComponent>();
        AttachComponent <XBeHitComponent>();
    }
예제 #19
0
    public static void Init(MonoBehaviour en)
    {
        _entrance = en;
        Application.targetFrameRate = 60;
#if Native
        NativeInterface.Init();
#endif
        XTimerMgr.singleton.Init();
        XConfig.Initial(LogLevel.Log, LogLevel.Error);
        XGlobalConfig.Initial();
        XTableMgr.Initial();
        ShaderMgr.Init();
        XResources.Init();
        UIManager.singleton.Initial();
        Documents.singleton.Initial();
        RegistCallbackLog();
    }
예제 #20
0
    public override void OnTrigger(object param)
    {
        XMobUnitData mob = param as XMobUnitData;

        uint id = XTableMgr.GetTable <XEntityStatistics>().GetByID(mob.TemplateID).PresentID;

        XEntityPresentation.RowData data = XTableMgr.GetTable <XEntityPresentation>().GetItemID(id);
        GameObject mob_unit = GameObject.Instantiate(Resources.Load("Prefabs/" + data.Prefab)) as GameObject;
        Vector3    offset   = host.Transform.rotation * new Vector3(mob.Offset_At_X, mob.Offset_At_Y, mob.Offset_At_Z);
        Vector3    pos      = host.Transform.position + offset;

        mob_unit.transform.position = pos;
        mob_unit.transform.forward  = host.Transform.forward;
        if (mob.LifewithinSkill)
        {
            mob_unit.tag = "Finish";
        }
        _mob_unit.Add(mob_unit);
    }
예제 #21
0
 public void OnEnable()
 {
     hideFlags = HideFlags.HideAndDontSave;
     AssetPreview.SetPreviewTextureCacheSize(64);
     if (_waves == null)
     {
         _waves = new List <EditorWave>();
     }
     if (_layout == null)
     {
         _layout = new LevelLayout(this);
     }
     if (_data_info == null)
     {
         _data_info = XTableMgr.GetTable <XEntityStatistics>();
     }
     _currentEdit  = -1;
     _markGOHeight = 2.0f;
 }
예제 #22
0
    IEnumerator Start()
    {
        yield return(new WaitForSeconds(0.4f));

        var present = XTableMgr.GetTable <XEntityPresentation>().GetItemID((uint)PresentID);

        var contr = new AnimatorOverrideController();
        var ator  = GetComponent <Animator>();

        contr.runtimeAnimatorController = ator.runtimeAnimatorController;
        ator.runtimeAnimatorController  = contr;

        AnimationClip clip = XResources.Load <AnimationClip>("Animation/" + present.AnimLocation + present.AttackIdle, AssetType.Anim);

        contr[Clip.Idle]       = clip;
        contr[Clip.HitLanding] = present.HitFly != null && present.HitFly.Length == 0 ? null : XResources.Load <AnimationClip>("Animation/" + present.AnimLocation + present.HitFly[1], AssetType.Anim);

        _attr = new XHitAttribute(transform, contr, ator, present);
    }
예제 #23
0
    private XAttributes InitAttrFromClient(int statisticid)
    {
        var srow = XTableMgr.GetTable <XEntityStatistics>().GetByID(statisticid);

        if (srow == null)
        {
            throw new Exception("entity is nil with id: " + statisticid);
        }
        XAttributes attr = new XAttributes();
        var         prow = XTableMgr.GetTable <XEntityPresentation>().GetItemID(srow.PresentID);

        if (prow == null)
        {
            throw new Exception("present is nil with id: " + srow.PresentID);
        }
        attr.Prefab    = prow.Prefab;
        attr.id        = (uint)XCommon.singleton.New_id;
        attr.PresentID = srow.PresentID;
        attr.Name      = prow.Name;
        attr.InitAttribute(srow);
        return(attr);
    }
예제 #24
0
        public void ColdBuild(GameObject prefab, XConfigData conf)
        {
            if (hoster != null)
            {
                GameObject.DestroyImmediate(hoster);
            }
            hoster = UnityEngine.Object.Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;
            hoster.transform.localScale = Vector3.one * XTableMgr.GetTable <XEntityPresentation>().GetItemID((uint)conf.Player).Scale;
            hoster.AddComponent <XSkillHoster>();
            hoster.GetComponent <CharacterController>().enabled = false;
            UnityEngine.AI.NavMeshAgent agent = hoster.GetComponent <UnityEngine.AI.NavMeshAgent>();
            if (agent != null)
            {
                agent.enabled = false;
            }

            XSkillHoster component = hoster.GetComponent <XSkillHoster>();
            string       directory = conf.Directory[conf.Directory.Length - 1] == '/' ? conf.Directory.Substring(0, conf.Directory.Length - 1) : conf.Directory;
            string       path      = XEditorLibrary.GetPath("Skill" + "/" + directory);

            component.ConfigData = conf;
            component.SkillData  = XDataIO <XSkillData> .singleton.DeserializeData(path + conf.SkillName + ".txt");

            component.SkillDataExtra.ScriptPath = path;
            component.SkillDataExtra.ScriptFile = conf.SkillName;
            component.SkillDataExtra.SkillClip  = RestoreClip(conf.SkillClip, conf.SkillClipName);
            if (component.SkillData.TypeToken != 2)
            {
                if (component.SkillData.Time == 0)
                {
                    component.SkillData.Time = component.SkillDataExtra.SkillClip.length;
                }
            }
            HotBuildEx(component, conf);

            EditorGUIUtility.PingObject(hoster);
            Selection.activeObject = hoster;
        }
예제 #25
0
    public void RebuildSkillAniamtion()
    {
        AnimationClip clip = XResources.Load <AnimationClip>(SkillData.ClipName, AssetType.Anim);

        if (oVerrideController == null)
        {
            BuildOverride();
        }
        if (SkillData.TypeToken == 0)
        {
            string motion = XSkillData.JaOverrideMap[SkillData.SkillPosition];
            oVerrideController[motion] = clip;
        }
        else if (SkillData.TypeToken == 1)
        {
            oVerrideController[Clip.Art] = clip;
        }

        _present_data = XTableMgr.GetTable <XEntityPresentation>().GetItemID((uint)_xConfigData.Player);
        oVerrideController[Clip.Idle] = Resources.Load("Animation/" + _present_data.AnimLocation + _present_data.AttackIdle) as AnimationClip;
        oVerrideController[Clip.Run]  = Resources.Load("Animation/" + _present_data.AnimLocation + _present_data.AttackRun) as AnimationClip;
        oVerrideController[Clip.Walk] = Resources.Load("Animation/" + _present_data.AnimLocation + _present_data.AttackWalk) as AnimationClip;
    }
예제 #26
0
 protected override void FilterBone()
 {
     if (model != null)
     {
         TextAsset ta = AssetDatabase.LoadAssetAtPath <TextAsset>(@"Assets/Resources/Table/DefaultEquip" + AssetType.Byte);
         if (ta != null)
         {
             using (MemoryStream ms = new MemoryStream(ta.bytes))
             {
                 XTableMgr.GetTable <DefaultEquip>().ReadFile(ms);
                 for (int i = 0; i < combineConfig.BandposeName.Length; ++i)
                 {
                     if (model.name.ToLower() == combineConfig.BandposeName[i])
                     {
                         prefabName        = combineConfig.PrefabName[i];
                         creatorFolderName = combineConfig.SkillFolderName[i];
                     }
                 }
             }
         }
     }
     //isReadable = false;
     base.FilterBone();
 }
예제 #27
0
        protected override void ParseInfo(string data)
        {
            base.ParseInfo(data);
            string rawData = data.Substring(3);

            switch (infotype)
            {
            case InfoType.SpawnType:
                SpawnType = spawnType;
                break;

            case InfoType.BaseInfo:
                UID = uid;
                break;

            case InfoType.ExString:
                string[] strInfos = rawData.Split('|');
                if (strInfos.Length > 0)
                {
                    exString = strInfos[0];
                }
                break;

            case InfoType.EditorInfo:
                if (rawData.Length > 0)
                {
                    string[] strEditorCoords = rawData.Split(',');
                    rectX = int.Parse(strEditorCoords[0]);
                    rectY = int.Parse(strEditorCoords[1]);
                }
                break;

            case InfoType.TransformInfo:
                string[] strFloats = rawData.Split(',');
                int      index     = int.Parse(strFloats[0]);
                _prefabSlot.Add(index);
                if (_prefab != null)
                {
                    if (go == null)
                    {
                        go = GameObject.Instantiate(_prefab);
                    }
                    go.name = GetMonsterName(_id);
                    go.transform.position = pos;
                    go.transform.Rotate(0, rotateY, 0);

                    XEntityStatistics.RowData sData = XTableMgr.GetTable <XEntityStatistics>().GetByID((int)_uni_id);
                    if (sData == null)
                    {
                        XDebug.Log("enemy id not exist:", _uni_id);
                        break;
                    }
                    if (sData.PresentID > 0)
                    {
                        XEntityPresentation.RowData pData = XTableMgr.GetTable <XEntityPresentation>().GetItemID((uint)sData.PresentID);
                        go.transform.localScale = Vector3.one * pData.Scale;
                    }
                }
                break;
            }
        }
예제 #28
0
        public override void DoWindow(int id)
        {
            base.DoWindow(id);
            if (_wave.go != null)
            {
                Selection.activeGameObject = _wave.go;                   //EditorGUIUtility.PingObject(_wave.go);
            }
            if (_icon == null)
            {
                GenerateIcon();
            }
            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.Width(70), GUILayout.Height(100) });
            GUILayout.Box(_icon);

            GUILayout.BeginHorizontal();
            GUIStyle gs = new GUIStyle();

            gs.alignment        = TextAnchor.LowerRight;
            gs.normal.textColor = Color.white;
            XEntityStatistics.RowData eData = XTableMgr.GetTable <XEntityStatistics>().GetByID((int)_wave.UID);
            if (eData != null && _wave.SpawnType == LevelSpawnType.Spawn_Monster)
            {
                if (eData.Type == 1)
                {
                    gs.normal.textColor = Color.red;
                }
                else if (eData.Type == 6)
                {
                    gs.normal.textColor = Color.yellow;
                }
            }
            if (_wave.levelscript != null && _wave.levelscript.Length > 0)
            {
                int fileNamePos = _wave.levelscript.LastIndexOf("/");
                GUILayout.Label(_wave.levelscript.Substring(fileNamePos + 1), gs);
            }
            else
            {
                GUILayout.Label(_wave.UID + "x" + _wave.Count, gs);
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUILayout.Box("", new GUILayoutOption[] { GUILayout.Width(1), GUILayout.Height(80) });

            GUILayout.BeginVertical();
            // spawn info
            string   strSpawn = "";
            GUIStyle gsSpawn  = new GUIStyle();

            gsSpawn.alignment = TextAnchor.LowerRight;

            if (_wave.preWaves != null && _wave.preWaves.Length > 0)
            {
                strSpawn = "Pre Wave:" + _wave.preWaves;
                gsSpawn.normal.textColor = Color.green;
            }
            if (_wave.exString != null && _wave.exString.Length > 0)
            {
                strSpawn = "\nES:" + _wave.exString;
                gsSpawn.normal.textColor = Color.green;
            }
            strSpawn += "\nTime: " + _wave.time;
            gsSpawn.normal.textColor = Color.white;

            GUILayout.Label(strSpawn, gs, new GUILayoutOption[] { GUILayout.Width(100) });

            GUILayout.BeginHorizontal(new GUILayoutOption[] { GUILayout.Height(30) });
            if (_wave.HasBuff)
            {
                Texture item = AssetDatabase.LoadAssetAtPath("Assets/Editor/LevelEditor/res/bx2.png", typeof(Texture)) as Texture;
                GUILayout.Box(item);
            }
            GUILayout.EndHorizontal();

            GUILayout.Box("", new GUILayoutOption[] { GUILayout.Width(100), GUILayout.Height(1) });

            // operation
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(RemoveWaveButtonContent, LevelLayout.miniButtonWidth))
            {
                _wave.LevelMgr.RemoveWave(_wave.ID);
                _wave.RemoveSceneViewInstance();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();


            GUI.DragWindow();
        }
예제 #29
0
        private void Preview(EquipPart part)
        {
            //1.mesh collection
            List <CombineInstance> ciList = new List <CombineInstance>();

            Texture[]            m_tex = new Texture[8];
            DefaultEquip.RowData data  = XTableMgr.GetTable <DefaultEquip>().GetByUID(m_profession + 1);
            string name = "";

            for (int i = 0; i < part.partPath.Length; ++i)
            {
                string          path = part.partPath[i];
                CombineInstance ci   = new CombineInstance();
                if (string.IsNullOrEmpty(path))
                {
                    path = XEquipUtil.GetDefaultPath((EPartType)i, data);
                }
                else if (name == "")
                {
                    int index = path.LastIndexOf("_");
                    if (index >= 0)
                    {
                        name = path.Substring(0, index);
                    }
                }
                if (!string.IsNullOrEmpty(path))
                {
                    path = "Assets/Resources/Equipments/" + path;
                    Mesh    mesh = AssetDatabase.LoadAssetAtPath <Mesh>(path + AssetType.Asset);
                    Texture tex  = AssetDatabase.LoadAssetAtPath <Texture>(path + AssetType.TGA);
                    if (mesh != null)
                    {
                        ci.mesh  = mesh;
                        m_tex[i] = tex;
                    }
                    if (ci.mesh != null)
                    {
                        ciList.Add(ci);
                    }
                }
            }

            if (ciList.Count > 0)
            {
                if (newGo != null)
                {
                    GameObject.DestroyImmediate(newGo);
                }
                string skinPrfab = "Assets/Resources/Prefabs/" + combineConfig.PrefabName[m_profession] + AssetType.Prefab;
                newGo = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <Object>(skinPrfab)) as GameObject;
                if (name != "")
                {
                    newGo.name = name;
                }
                newGo.transform.localRotation = Quaternion.Euler(new Vector3(0, 180, 0));

                //2.combine
                Transform           t      = newGo.transform;
                SkinnedMeshRenderer newSmr = t.GetComponent <SkinnedMeshRenderer>();
                newSmr.sharedMesh = new Mesh();
                newSmr.sharedMesh.CombineMeshes(ciList.ToArray(), true, false);

                //3.set material
                Material mat = new Material(Shader.Find("Custom/Skin/RimlightBlend8"));
                for (int i = 0; i < m_tex.Length; ++i)
                {
                    mat.SetTexture("_Tex" + i.ToString(), m_tex[i]);
                }
                newSmr.sharedMaterial = mat;

                if (data.WeaponPoint != null && data.WeaponPoint.Length > 0)
                {
                    string    weapon = data.WeaponPoint[0].ToString();
                    Transform trans  = newGo.transform.Find(weapon);
                    if (trans != null)
                    {
                        string path = part.mainWeapon;
                        if (string.IsNullOrEmpty(path))
                        {
                            path = data.Weapon;
                        }

                        GameObject mainWeapon = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Resources/Equipments/" + path + AssetType.Prefab);
                        if (mainWeapon != null)
                        {
                            GameObject instance = GameObject.Instantiate(mainWeapon) as GameObject;
                            instance.transform.parent        = trans;
                            instance.transform.localPosition = Vector3.zero;
                            instance.transform.localRotation = Quaternion.identity;
                            instance.transform.localScale    = Vector3.one;
                        }
                    }
                }
            }
        }
예제 #30
0
    public static void MakeEquip(string name, int[] fashionIDs, List <EquipPart> equipList, TempEquipSuit tmpFashionData, int suitID)
    {
        FashionList fashionList = XTableMgr.GetTable <FashionList>();

        if (fashionIDs != null)
        {
            tmpFashionData.hash = 0;
            tmpFashionData.data.Clear();
            bool threePart = false;
            for (int i = 0; i < fashionIDs.Length; ++i)
            {
                int fashionID           = fashionIDs[i];
                FashionList.RowData row = fashionList.GetByUID(fashionID);
                if (row != null)
                {
                    List <ThreePart> tpLst = new List <ThreePart>();
                    if (row.EquipPos == 7 || row.EquipPos == 8 || row.EquipPos == 9)
                    {
                        ThreePart tp = FindThreePart(suitID, tpLst);
                        if (row.EquipPos == 9)
                        {
                            tp.part[2] = row.ModelPrefabArcher;
                        }
                        threePart = true;
                    }
                    else
                    {
                        if (row.ReplaceID != null && row.ReplaceID.Length > 1)
                        {
                            FashionList.RowData replace = fashionList.GetByUID(row.ReplaceID[1]);
                            if (replace != null)
                            {
                                if (replace.EquipPos == row.EquipPos)
                                {
                                    row = replace;
                                }
                            }
                        }
                        string path = row.ModelPrefabArcher;
                        if (!string.IsNullOrEmpty(path))
                        {
                            Hash(ref tmpFashionData.hash, path);
                            TempEquipData data = new TempEquipData();
                            data.row  = row;
                            data.path = path;
                            tmpFashionData.data.Add(data);
                        }
                    }
                }
            }
            if (threePart)
            {
                return;
            }

            bool          findSame = false;
            TempEquipSuit suit     = tmpFashionData;
            if (suit.hash == 0)
            {
                return;
            }
            for (int j = 0; j < equipList.Count; ++j)
            {
                EquipPart part = equipList[j];
                if (part != null && part.hash == suit.hash)
                {
                    part.suitName.Add(name);
                    findSame = true;
                    break;
                }
            }
            if (!findSame)
            {
                EquipPart part = new EquipPart();
                part.hash = suit.hash;
                part.suitName.Add(name);
                for (int j = 0; j < suit.data.Count; ++j)
                {
                    TempEquipData data    = suit.data[j];
                    int           partPos = ConvertPart(data.row.EquipPos);
                    if (partPos < part.partPath.Length)
                    {
                        part.partPath[partPos] = data.path;
                    }
                    else if (partPos == part.partPath.Length)
                    {
                        part.mainWeapon = data.path;
                    }
                }
                equipList.Add(part);
            }
        }
    }