Пример #1
0
    private void ApplyMaterial(Client.IPlayer pPlayer, uint uSuit)
    {
        table.SuitDataBase data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>(uSuit);
        if (data == null)
        {
            return;
        }

        if (data.defaultMaterial == 0)
        {
            return;
        }


        table.ResourceDataBase res = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(data.defaultMaterial);
        if (res == null)
        {
            return;
        }


        if (res.strPath == "")
        {
            return;
        }


        Engine.IRenderObj renderObj = pPlayer.renderObj;
        if (renderObj != null)
        {
            renderObj.ApplyMaterial(res.strPath);
        }
    }
Пример #2
0
    private static void BuildRobotViewProp(table.RobotDataBase robotdata, ref EntityViewProp[] propList)
    {
        if (propList == null)
        {
            return;
        }
        if (propList.Length < 0 || propList.Length > (int)Client.EquipPos.EquipPos_Max)
        {
            Engine.Utility.Log.Error("BuildRobotViewProp:外观列表长度非法");
            return;
        }
        List <uint> equipList = new List <uint>();

        equipList.Add(robotdata.Hat);
        equipList.Add(robotdata.Shoulder);
        equipList.Add(robotdata.Coat);
        equipList.Add(robotdata.Leg);
        equipList.Add(robotdata.Adornl_1);
        equipList.Add(robotdata.Adornl_2);
        equipList.Add(robotdata.Shield);
        equipList.Add(robotdata.Equip);
        equipList.Add(robotdata.Shoes);
        equipList.Add(robotdata.Cuff);
        equipList.Add(robotdata.Belf);
        equipList.Add(robotdata.Necklace);

        int index = 0;

        propList[index++] = new EntityViewProp((int)Client.EquipPos.EquipPos_Body, 0);
        propList[index++] = new EntityViewProp((int)Client.EquipPos.EquipPos_Weapon, 0);

        for (int i = 0; i < equipList.Count; i++)
        {
            if (equipList[i] != 0)
            {
                table.EquipDataBase equipdb = GameTableManager.Instance.GetTableItem <table.EquipDataBase>(equipList[i]);
                if (equipdb != null)
                {
                    if (equipdb.act_show != 0)
                    {
                        table.SuitDataBase suitDb = GameTableManager.Instance.GetTableItem <table.SuitDataBase>(equipdb.act_show, 1);
                        if (suitDb != null)
                        {
                            int pos = GetPropPos((Client.EquipPos)suitDb.base_id, propList);
                            if (pos >= 0)
                            {
                                propList[pos] = new EntityViewProp((int)suitDb.type, (int)suitDb.base_id);
                            }
                            else
                            {
                                propList[index++] = new EntityViewProp((int)suitDb.type, (int)suitDb.base_id);
                            }
                        }
                    }
                }
            }
        }
    }
Пример #3
0
 public void SetSuitData(ClientSuitData data)
 {
     m_suitData = data;
     ResetInfoGrid(m_suitData.suitBaseID != 0);
     table.SuitDataBase database = GameTableManager.Instance.GetTableItem <table.SuitDataBase>(m_suitData.suitBaseID, 1);
     if (database != null)
     {
         SetIcon(true, database.icon);
         SetBindMask(false);
         SetTimeLimitMask(false);
     }
 }
Пример #4
0
 private void OnSuitGridEvent(UIEventType eventType, object data, object param)
 {
     switch (eventType)
     {
     case UIEventType.Click:
     {
         UIEquipGrid equipGrid = data as UIEquipGrid;
         if (equipGrid.SuitData.suitBaseID != 0)
         {
             table.SuitDataBase database = GameTableManager.Instance.GetTableItem <table.SuitDataBase>(equipGrid.SuitData.suitBaseID, 1);
             if (database != null)
             {
                 DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.FashionTips, data: database);
             }
         }
         else
         {
             Engine.Utility.Log.Info("Equip pos is null");
         }
     }
     break;
     }
 }
Пример #5
0
        //-------------------------------------------------------------------------------------------------------
        public override bool CreateEntityView(EntityCreateData data)
        {
            m_Data = data;

            base.CreateEntityView(data);
            if (GetEntityType() != EntityType.EntityType_NPC)
            {
                Engine.Utility.Log.Error("NPC:CreateEntityView failed:{0}", GetName());
                return(false);
            }

            int     nID      = GetProp((int)EntityProp.BaseID);
            int     suitID   = GetProp((int)NPCProp.SuitID);
            int     masterID = GetProp((int)NPCProp.Masterid);
            int     type     = GetProp((int)NPCProp.MasterType);
            IEntity en       = EntityHelper.GetEntity((GameCmd.SceneEntryType)type, (uint)masterID);

            if (en != null)
            {
                if (EntityHelper.IsMainPlayer(en))
                {
                    m_isMySlave = true;
                }
            }
            string strResName = "";

            if (nID == 0)
            {
                // 则使用默认数据
                // strResName = data.strName;
            }
            else
            {
                var table_data = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)nID);
                if (table_data == null)
                {
                    Engine.Utility.Log.Error("不存在这个NPC: " + nID);
                    return(false);
                }
                m_bCanSelect = table_data.dwCanBeSelect == 1;
                if (m_Data.ViewList == null)
                {
                    uint modelID = table_data.dwModelSet;
                    if (suitID != 0)
                    {
                        table.SuitDataBase sdb = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)suitID, 1);
                        if (sdb != null)
                        {
                            if (sdb.resid != 0)
                            {
                                modelID = sdb.resid;
                            }
                        }
                    }
                    table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(modelID);
                    if (resDB == null)
                    {
                        Engine.Utility.Log.Error("NPC:找不到NPC模型资源路径配置{0}", modelID);
                        return(false);
                    }
                    strResName = resDB.strPath;
                }
                else
                {
                    for (int i = 0; i < data.ViewList.Length; ++i)
                    {
                        if (data.ViewList[i] == null)
                        {
                            continue;
                        }

                        if (data.ViewList[i].nPos == (int)EquipPos.EquipPos_Body)
                        {
                            //if(data.ViewList[i].)
                            var suit_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)data.ViewList[i].value);
                            if (suit_data != null)
                            {
                                table.ResourceDataBase db = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(suit_data.resid);
                                if (db == null)
                                {
                                    Debug.LogError("ResourceDataBase is null bodypahtid is " + suit_data.resid + "  请检查resource 表格");
                                    return(false);
                                }
                                //string bodyPath = db.strPath;
                                //if (data.ViewList[i] != null)
                                //{
                                //    strResName = data.ViewList[i].value == 0 ? bodyPath : EntityHelper.GetModelPath((uint)data.ViewList[i].value, (Cmd.enmCharSex)GetProp((int)PlayerProp.Sex));
                                //}
                                strResName = db.strPath;
                            }
                            else
                            {
                                strResName = "";
                            }
                        }
                    }
                }

                // 技能形态
                m_Data.eSkillState = (SkillSettingState)GetProp((int)NPCProp.SkillStatus);

                if ((int)GameCmd.ArenaNpcType.ArenaNpcType_Player == GetProp((int)NPCProp.ArenaNpcType))
                {
                    SetName(m_Data.strName);
                }
                else
                {
                    if (string.IsNullOrEmpty(data.strName))
                    {
                        SetName(table_data.strName);
                    }
                    else
                    {
                        SetName(data.strName);
                    }
                }
                if (IsSummon())
                {
                    IEntitySystem es = EntitySystem.m_ClientGlobal.GetEntitySystem();
                    if (es != null)
                    {
                        IPlayer player = es.FindEntity <IPlayer>((uint)masterID);
                        if (player != null)
                        {
                            string playerName = player.GetName();
                            string summonName = GetName();
                            string tempName   = playerName + "的" + summonName;
                            SetName(tempName);
                        }
                    }
                }
            }

            // TODO: 根据配置表读取数据
            //if ( !m_EntityView.Create( ref strResName , OnCreateRenderObj ) )
            //{
            //    Engine.Utility.Log.Error( "CreateEntityView failed:{0}" , strResName );
            //}

            string strPath, strFileName, strExt, strFileNameNoExt;

            Engine.Utility.StringUtility.ParseFileName(ref strResName, out strPath, out strFileName, out strFileNameNoExt, out strExt);
            m_strObjName = strFileNameNoExt;

            // 功能NPC立即创建
            if (!IsMonster() && !IsPet() && !IsSummon())
            {
                m_Data.bImmediate = true;
            }

            if (m_Data.bImmediate)
            {
                // 立即创建
                if (!m_EntityView.Create(ref strResName, OnCreateRenderObj, false))
                {
                    Engine.Utility.Log.Error("CreateEntityView failed:{0}", strResName);
                }
            }
            else
            {
                EntityViewCreator.Instance.AddView(GetUID(), m_EntityView, ref strResName, OnCreateRenderObj);
            }


            return(false);
        }
Пример #6
0
        public override bool CreateEntityView(EntityCreateData data)
        {
            //Profiler.BeginSample("CreateEntityView");
            m_Data = data;
            base.CreateEntityView(data);
            if (GetEntityType() != EntityType.EntityType_Player)
            {
                m_bChangeRestore = false;
                Engine.Utility.Log.Error("CreateEntityView failed:{0}", GetName());
                return(false);
            }

            string strResName = "";
            //if (data.PropList != null)
            //{
            //    for (int i = 0; i < data.PropList.Length; ++i )
            //    {
            //        if (data.PropList[i].nPropIndex == (int)PlayerProp.TransModelResId)
            //        {
            int ntransModelID = GetProp((int)PlayerProp.TransModelResId);//.PropList[i].value;

            if (ntransModelID != 0)
            {
                table.ResourceDataBase resData = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>((uint)ntransModelID);
                if (resData != null)
                {
                    strResName = resData.strPath;
                }
            }
            //            break;
            //        }
            //    }
            //}

            table.SuitDataBase table_data = null;
            if (string.IsNullOrEmpty(strResName) && data.ViewList != null)
            {
                //Profiler.BeginSample("CreateEntityView:Table:Query");
                for (int i = 0; i < data.ViewList.Length; ++i)
                {
                    if (data.ViewList[i] == null)
                    {
                        continue;
                    }

                    if (data.ViewList[i].nPos == (int)EquipPos.EquipPos_Body)
                    {
                        table_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)data.ViewList[i].value);
                        if (table_data == null)
                        {
                            GameCmd.enumProfession profession = (GameCmd.enumProfession)GetProp((int)PlayerProp.Job);
                            GameCmd.enmCharSex     sex        = (GameCmd.enmCharSex)GetProp((int)PlayerProp.Sex);
                            var role_data = table.SelectRoleDataBase.Where(profession, sex);
                            if (role_data == null)
                            {
                                Engine.Utility.Log.Error("CreateEntityView:job{0}或者sex{1}数据非法!", profession, sex);
                                return(false);
                            }

                            table_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)role_data.bodyPathID);
                        }
                        if (table_data != null)
                        {
                            table.ResourceDataBase db = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(table_data.resid);
                            if (db == null)
                            {
                                Debug.LogError("ResourceDataBase is null bodypahtid is " + table_data.resid + "  请检查resource 表格");
                                return(false);
                            }
                            strResName = db.strPath;
                        }
                        //else
                        //{
                        //    strResName = "";
                        //}

                        //if(m_EntityView!=null)
                        //{
                        //    m_EntityView.AddSuitData(EquipPos.EquipPos_Body, data.ViewList[i].value, (int)table_data.resid);
                        //}
                    }
                }
                //Profiler.EndSample();
            }

            // 修改技能形态值
            m_Data.eSkillState = (SkillSettingState)GetProp((int)PlayerProp.SkillStatus);

            // 设置名称
            SetName(data.strName);
            string strPath, strFileName, strExt, strFileNameNoExt;

            Engine.Utility.StringUtility.ParseFileName(ref strResName, out strPath, out strFileName, out strFileNameNoExt, out strExt);
            m_strObjName = strFileNameNoExt;

            if (m_Data.bImmediate)
            {
                // 立即创建
                if (!m_EntityView.Create(ref strResName, OnCreateRenderObj, m_Data.bImmediate))
                {
                    Engine.Utility.Log.Error("CreateEntityView failed:{0}", strResName);
                    return(false);
                }
            }
            else
            {
                EntityViewCreator.Instance.AddView(GetUID(), m_EntityView, ref strResName, OnCreateRenderObj);
            }

            //Profiler.EndSample();
            //Profiler.EndSample();
            return(true);
        }