Exemplo n.º 1
0
    public static EntityCreateData BuildRobotEntityData(uint dwTempID, uint baseID, uint job, uint level, string name = "", uint moveSpeed = 1)
    {
        EntityCreateData entityData = new EntityCreateData();

        entityData.ID = dwTempID;
        table.NpcDataBase npcdb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>(baseID);
        if (npcdb != null)
        {
            if (string.IsNullOrEmpty(name))
            {
                entityData.strName = npcdb.strName;
            }
            else
            {
                entityData.strName = name;
            }
        }
        entityData.PropList = new EntityAttr[(int)RobotProp.End - (int)EntityProp.Begin];
        entityData.ViewList = new EntityViewProp[(int)Client.EquipPos.EquipPos_Max];
        table.RobotDataBase robotdata = GameTableManager.Instance.GetTableItem <table.RobotDataBase>(job, (int)level);
        if (robotdata != null)
        {
            BuildRobotPropList(robotdata, npcdb, moveSpeed, ref entityData.PropList);
            BuildRobotViewProp(robotdata, ref entityData.ViewList);
        }
        return(entityData);
    }
Exemplo n.º 2
0
    void ShowModel()
    {
        int npcID = GameTableManager.Instance.GetGlobalConfig <int>("FinalTargetModelID");

        table.NpcDataBase npcData = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)npcID);
        if (npcData != null)
        {
            uint modelID = npcData.dwViewModelSet; // 使用观察模型
            if (m_RTObj != null)
            {
                m_RTObj.Release();
            }

            m_RTObj = DataManager.Manager <RenderTextureManager>().CreateRenderTextureObj((int)modelID, 800);
            if (m_RTObj == null)
            {
                return;
            }

            m_RTObj.SetCamera(new Vector3(0, 1, 0), Vector3.zero, -4.85f);
            m_RTObj.SetModelRotateY(rotateY);
            //人物
            if (m__Model != null)
            {
                m__Model.mainTexture = m_RTObj.GetTexture();
                m__Model.MakePixelPerfect();
            }
        }
    }
Exemplo n.º 3
0
    public int SetDisplayData(uint uID)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        table.NpcDataBase npctable = GameTableManager.Instance.GetTableItem <table.NpcDataBase>(uID);
        if (npctable == null)
        {
            return(0);
        }

        GameCmd.t_MapNpcDataPos npcdata = new GameCmd.t_MapNpcDataPos();
        npcdata.mapnpcdata         = new GameCmd.t_MapNpcData();
        npcdata.mapnpcdata.npcdata = new GameCmd.t_NpcData();

        npcdata.mapnpcdata.npcdata.dwBaseID = uID;

        npcdata.mapnpcdata.npcdata.dwTempID  = this.m_dwID;
        npcdata.mapnpcdata.npcdata.movespeed = 600;

        EntityCreateData data = RoleUtil.BuildCreateEntityData(EntityType.EntityType_NPC, npcdata, 0);

        IEntity npc = es.CreateEntity(EntityType.EntityType_NPC, data, true) as INPC;

        //ISkillPart skillPart = npc.GetPart(EntityPart.Skill) as ISkillPart;
        //skillPart.ReqNpcUseSkill(208);

        m_pEntity = npc;

        return(1);
    }
Exemplo n.º 4
0
    /// <summary>
    /// 实体创建
    /// </summary>
    /// <param name="ce"></param>
    private void OnCretateEntity(Client.stCreateEntity ce)
    {
        IEntity entity = RoleStateBarManager.GetEntity(ce.uid);

        if (entity == null)
        {
            Engine.Utility.Log.Error("找不到对象------------{0}", ce.uid);
            return;
        }

        if (entity.GetEntityType() == EntityType.EntityType_Pet)
        {
            return;
        }

        if (entity.GetEntityType() == EntityType.EntityType_NPC)
        {
            table.NpcDataBase npctable = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)entity.GetProp((int)Client.EntityProp.BaseID));
            if (npctable != null)
            {
                if (npctable.dwType == (uint)GameCmd.enumNpcType.NPC_TYPE_TRAP)
                {
                    return;
                }
            }
        }
        AddRoleBar(entity);
    }
Exemplo n.º 5
0
    private static void BuildRobotPropList(table.RobotDataBase data, table.NpcDataBase npcdb, uint moveSpeed, ref EntityAttr[] propList)
    {
        if (propList.Length < 0 || propList.Length > (int)RobotProp.End - (int)EntityProp.Begin)
        {
            Engine.Utility.Log.Error("BuildRobotPropList:属性列表长度非法");
            return;
        }
        int index = 0;

        propList[index++] = new EntityAttr((int)RobotProp.Sex, (int)npcdb.sex);
        propList[index++] = new EntityAttr((int)RobotProp.Job, (int)data.dwJob);
        propList[index++] = new EntityAttr((int)CreatureProp.Level, (int)data.dwLevel);
        propList[index++] = new EntityAttr((int)EntityProp.BaseID, (int)npcdb.dwID); //模型ID 0
        propList[index++] = new EntityAttr((int)CreatureProp.Mp, (int)data.mp);      // 法力值
        propList[index++] = new EntityAttr((int)CreatureProp.MaxMp, (int)data.mp);   // 法力值
        propList[index++] = new EntityAttr((int)CreatureProp.Hp, (int)data.hp);
        propList[index++] = new EntityAttr((int)CreatureProp.MaxHp, (int)data.hp);
        propList[index++] = new EntityAttr((int)FightCreatureProp.Power, (int)data.power);                    // 战斗力
        propList[index++] = new EntityAttr((int)FightCreatureProp.Strength, (int)data.liliang);               // 力量
        propList[index++] = new EntityAttr((int)FightCreatureProp.Corporeity, (int)data.tizhi);               // 体质
        propList[index++] = new EntityAttr((int)FightCreatureProp.Intelligence, (int)data.zhili);             // 智力
        propList[index++] = new EntityAttr((int)FightCreatureProp.Spirit, (int)data.jingshen);                // 精神
        propList[index++] = new EntityAttr((int)FightCreatureProp.Agility, (int)data.minjie);                 // 敏捷
        propList[index++] = new EntityAttr((int)FightCreatureProp.PhysicsAttack, (int)(data.pdam * 0.8));     // 最小物理攻击力
        propList[index++] = new EntityAttr((int)FightCreatureProp.PhysicsDefend, (int)(data.pdef * 0.8));     // 最小物理防御力
        propList[index++] = new EntityAttr((int)FightCreatureProp.MagicAttack, (int)(data.mdam * 0.8));       // 最小法术攻击力
        propList[index++] = new EntityAttr((int)FightCreatureProp.MagicDefend, (int)(data.mdef * 0.8));       // 最小法术防御力
        propList[index++] = new EntityAttr((int)FightCreatureProp.MaxPhysicsAttack, (int)(data.pdam * 1.15)); // 最大物理攻击力
        propList[index++] = new EntityAttr((int)FightCreatureProp.MaxPhysicsDefend, (int)(data.pdef * 1.15)); // 最大物理防御力
        propList[index++] = new EntityAttr((int)FightCreatureProp.MaxMagicAttack, (int)(data.mdam * 1.15));   // 最大法术攻击力
        propList[index++] = new EntityAttr((int)FightCreatureProp.MaxMagicDefend, (int)(data.mdef * 1.15));   // 最大法术防御力
        propList[index++] = new EntityAttr((int)FightCreatureProp.PhysicsCrit, (int)data.lucky);              // 物理致命一击
        propList[index++] = new EntityAttr((int)FightCreatureProp.MagicCrit, (int)data.mlucky);               // 法术致命一击
        propList[index++] = new EntityAttr((int)FightCreatureProp.Hit, (int)data.phit);                       // 命中
        propList[index++] = new EntityAttr((int)FightCreatureProp.Dodge, (int)data.hide_per);                 // 闪避

        propList[index++] = new EntityAttr((int)FightCreatureProp.IceAttack, (int)data.ssdam);                // 冰攻
        propList[index++] = new EntityAttr((int)FightCreatureProp.FireAttack, (int)data.esdam);               // 火攻
        propList[index++] = new EntityAttr((int)FightCreatureProp.EleAttack, (int)data.lsdam);                // 电攻
        propList[index++] = new EntityAttr((int)FightCreatureProp.WitchAttack, (int)data.vsdam);              // 暗攻

        propList[index++] = new EntityAttr((int)FightCreatureProp.IceDefend, (int)data.ssdef);                // 冰防
        propList[index++] = new EntityAttr((int)FightCreatureProp.FireDefend, (int)data.esdef);               // 火防
        propList[index++] = new EntityAttr((int)FightCreatureProp.EleDefend, (int)data.lsdef);                // 电防
        propList[index++] = new EntityAttr((int)FightCreatureProp.WitchDefend, (int)data.vsdef);              // 暗防


        propList[index++] = new EntityAttr((int)FightCreatureProp.PhysicsAbsorb, (int)data.pabs);      // 物伤吸收
        propList[index++] = new EntityAttr((int)FightCreatureProp.MagicAbsorb, (int)data.mabs);        // 法伤吸收
        propList[index++] = new EntityAttr((int)FightCreatureProp.HarmDeepen, (int)data.harm_add_per); // 伤害加深
        propList[index++] = new EntityAttr((int)FightCreatureProp.HarmAbsorb, (int)data.harm_sub_per); // 伤害吸收
        propList[index++] = new EntityAttr((int)FightCreatureProp.CritiRatio, (int)data.criti_ratio);  // 暴击伤害百分比



        propList[index++] = new EntityAttr((int)FightCreatureProp.Cure, (int)data.cure);    // 治疗
        propList[index++] = new EntityAttr((int)WorldObjProp.MoveSpeed, (int)moveSpeed);
        //  propList[index++] = new EntityAttr((int)PlayerProp.LoginOutTime, (int)data.lastofftime); // 最近一次下线时间
    }
Exemplo n.º 6
0
    public ColorType GetNpcNameColor(IEntity entity)
    {
        ColorType nameColor = ColorType.JSXT_NpcCheFu;
        INPC      npc       = entity as INPC;

        if (npc.IsCanAttackNPC())
        {
            if (npc.IsMercenary())
            {
                nameColor = ColorType.JSXT_Enemy_White;
            }
            else
            {
                if (npc.IsPet())
                {
                    nameColor = ColorType.JSXT_ZhanHun;
                }
                else if (npc.IsSummon())
                {
                    nameColor = ColorType.JSXT_ZhaoHuanWu;
                }
                else
                {
                    int level     = MainPlayerHelper.GetPlayerLevel();
                    int monsterLv = entity.GetProp((int)CreatureProp.Level);
                    int levelGap  = GameTableManager.Instance.GetGlobalConfig <int>("MonsterWarningLevelGap");
                    if (level + levelGap < monsterLv)
                    {
                        nameColor = ColorType.JSXT_Enemy_Red;
                    }
                    else
                    {
                        nameColor = ColorType.JSXT_Enemy_White;
                    }
                }
            }
        }
        else
        {
            table.NpcDataBase npcdb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)entity.GetProp((int)Client.EntityProp.BaseID));
            if (npcdb != null)
            {
                if (npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_COLLECT_PLANT)
                {
                    nameColor = ColorType.JSXT_CaiJiWu;
                }
                else if (npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_TRANSFER || npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_FUNCTION)
                {
                    nameColor = ColorType.JSXT_ChuanSongZhen;
                }
                else
                {
                    nameColor = ColorType.White;
                }
            }
        }

        return(nameColor);
    }
Exemplo n.º 7
0
    /// <summary>
    /// 全局UI事件处理器
    /// </summary>
    /// <param name="eventType"></param>
    /// <param name="data"></param>
    public void GlobalEventHandler(int eventType, object data)
    {
        switch (eventType)
        {
        case (int)Client.GameEventID.SYSTEM_LOADSCENECOMPELETE:
        {
            Client.stLoadSceneComplete loadScene = (Client.stLoadSceneComplete)data;
            if (loadScene.nMapID == 159)
            {
                DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.CampFightingPanel);
            }
        }
        break;

        case (int)Client.GameEventID.ENTITYSYSTEM_LEVELUP:
        {
            CaculateCampSectionIndex();
        }
        break;

        case (int)Client.GameEventID.ENTITYSYSTEM_CREATEENTITY:
        {
            //             if (isEnterScene == false)
            //             {
            //                 return;
            //             }

            Client.stCreateEntity npcEntity = (Client.stCreateEntity)data;

            Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();
            if (es == null)
            {
                return;
            }

            Client.IEntity npc = es.FindEntity(npcEntity.uid);
            if (npc == null)
            {
                return;
            }

            int npcBaseId = npc.GetProp((int)Client.EntityProp.BaseID);
            //采集物
            table.NpcDataBase npctable = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)npcBaseId);
            if (npctable != null && npctable.dwType == (uint)GameCmd.enumNpcType.NPC_TYPE_COLLECT_PLANT)        //采集物
            {
                GameCmd.eCamp camp = (GameCmd.eCamp)npc.GetProp((int)Client.CreatureProp.Camp);
                if (m_CampCombatResultInfo != null && m_CampCombatResultInfo.m_MyCampCombatInfo.camp != camp)
                {
                    CampNpcOnTrigger callback = new CampNpcOnTrigger();
                    npc.SetCallback(callback);
                }
            }
        }
        break;
        }
    }
Exemplo n.º 8
0
 string GetNpcName(uint nNpcId)
 {
     table.NpcDataBase npcdb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>(nNpcId);
     if (npcdb != null)
     {
         return(npcdb.strName);
     }
     return("");
 }
Exemplo n.º 9
0
        public void AddNPC(t_MapNpcDataPos data, uint master_id)
        {
            Profiler.BeginSample("AddNpc");
            if (data == null)
            {
                return;
            }

            Engine.Utility.Log.Trace("添加NPC:{0}", data.mapnpcdata.npcdata.dwBaseID);

            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

            if (es == null)
            {
                Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
                return;
            }

            table.NpcDataBase npctable = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)data.mapnpcdata.npcdata.dwBaseID);
            if (npctable == null)
            {
                Engine.Utility.Log.Error("严重错误:not fount npc baseid {0}", data.mapnpcdata.npcdata.dwBaseID);
                return;
            }

            if (npctable.dwType == (uint)GameCmd.enumNpcType.NPC_TYPE_ROBOT)
            {
                if (es.FindRobot(data.mapnpcdata.npcdata.dwTempID) != null)
                {
                    CreateRobot(data, npctable.job); // 更新数据
                    return;
                }

                if (m_dicNPCData.ContainsKey(data.mapnpcdata.npcdata.dwTempID))
                {
                    return;
                }

                CreateRobot(data, npctable.job);
            }
            else
            {
                if (es.FindNPC(data.mapnpcdata.npcdata.dwTempID) != null)
                {
                    CreateNPC(data, master_id); // 更新数据
                    return;
                }

                if (m_dicNPCData.ContainsKey(data.mapnpcdata.npcdata.dwTempID))
                {
                    return;
                }

                CreateNPC(data, master_id);
            }
            Profiler.EndSample();
        }
Exemplo n.º 10
0
    void DoGameEvent(int eventID, object param)
    {
        if (eventID == (int)GameEventID.ENTITYSYSTEM_CREATEENTITY)
        {
            if (m_bEnterCityWar == false)
            {
                return;
            }

            Client.stCreateEntity npcEntity = (Client.stCreateEntity)param;

            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();
            if (es == null)
            {
                return;
            }

            IEntity npc = es.FindEntity(npcEntity.uid);
            if (npc == null)
            {
                return;
            }

            int npcBaseId = npc.GetProp((int)EntityProp.BaseID);

            // 1、设置城战图腾氏族ID
            CityWarTotem cityWarTotem = m_lstCityWarTotem.Find((d) => { return(d.npcBaseId == npcBaseId); });
            if (cityWarTotem != null)
            {
                //npc.SetProp((int)Client.CreatureProp.ClanId, (int)cityWarTotem.clanId);

                uint clanId     = cityWarTotem.clanId;
                int  clanIdLow  = (int)(clanId & 0x0000ffff);
                int  clanIdHigh = (int)(clanId >> 16);
                npc.SetProp((int)Client.CreatureProp.ClanIdLow, clanIdLow);
                npc.SetProp((int)Client.CreatureProp.ClanIdHigh, clanIdHigh);
            }

            // 2、采集物
            table.NpcDataBase npctable = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)npcBaseId);
            if (npctable != null && npctable.dwType == (uint)GameCmd.enumNpcType.NPC_TYPE_COLLECT_PLANT)//采集物
            {
                CampNpcOnTrigger callback = new CampNpcOnTrigger();
                npc.SetCallback(callback);
            }

            // 城战打印
            //UnityEngine.Debug.LogError("------npctable.dwID = " + npcBaseId);
            //List<CityWarTotem> list = DataManager.Manager<CityWarManager>().CityWarTotemList;
            //for (int i = 0; i < list.Count; i++)
            //{
            //    UnityEngine.Debug.LogError(">>>>>>totemNpcId = " + list[i].totemNpcId + " clanId = " + list[i].clanId);
            //}
        }
    }
Exemplo n.º 11
0
        /// <summary>
        /// 通过[编号]二分快速查表
        /// </summary>
        /// <param name="dwID">编号</param>
        /// <returns></returns>
        public static NpcDataBase Query(this List <NpcDataBase> sorted, uint dwID)
        {
            var key = new NpcDataBase()
            {
                dwID = dwID
            };
            var comparer = new Comparer1();
            var index    = sorted.BinarySearch(key, comparer);

            return(index >= 0 ? sorted[index] : default(NpcDataBase));
        }
Exemplo n.º 12
0
    public void OnUpdate(IEntity entity, object param = null)
    {
        Client.IEntity mainPlayer = Client.ClientGlobal.Instance().MainPlayer;
        if (mainPlayer == null || mainPlayer.IsDead() || entity == null)
        {
            return;
        }

        UnityEngine.Vector3 dis = mainPlayer.GetPos() - entity.GetPos();

        uint npcid = (uint)entity.GetProp((int)Client.EntityProp.BaseID);

        if (npcid != m_nNpcID || SQRMagnitude <= 0f)
        {
            m_nNpcID = npcid;
            table.NpcDataBase npcdb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>(m_nNpcID);
            if (npcdb != null)
            {
                SQRMagnitude = npcdb.dwCallDis * npcdb.dwCallDis * 0.01f * 0.01f;
            }
        }

        if (dis.sqrMagnitude < SQRMagnitude)
        {
            if (IsTrigger)
            {
                return;
            }
            IsTrigger = true;
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.CAMP_ADDCOLLECTNPC,
                                                                new stCampCollectNpc()
            {
                npcid = entity.GetUID(), enter = true
            });
        }
        else
        {
            if (IsTrigger)
            {
                Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.CAMP_ADDCOLLECTNPC,
                                                                    new stCampCollectNpc()
                {
                    npcid = entity.GetUID(), enter = false
                });
            }
            IsTrigger = false;
        }
    }
Exemplo n.º 13
0
    /// <summary>
    /// 获取NPC头顶标识数据
    /// </summary>
    /// <param name="npcBaseId"></param>
    /// <returns></returns>
    public static table.NpcHeadMaskDataBase GetNPCHeadMaskDB(uint npcBaseId)
    {
        table.NpcHeadMaskDataBase db = null;
        if (npcBaseId != 0
            //&& entity.GetEntityType() == EntityType.EntityType_NPC
            )
        {
            table.NpcDataBase npcdb
                = GameTableManager.Instance.GetTableItem <table.NpcDataBase>(npcBaseId);
            if (null != npcdb && npcdb.npcHeadMaskID != 0)
            {
                db = GameTableManager.Instance.GetTableItem <table.NpcHeadMaskDataBase>(npcdb.npcHeadMaskID);
            }
        }

        return(db);
    }
Exemplo n.º 14
0
        void AddEffectOnEntity(IEntity en, bool bBorn)
        {
            if (en == null)
            {
                return;
            }
            if (en.GetEntityType() == EntityType.EntityType_Player)
            {
                int job = en.GetProp((int)PlayerProp.Job);
                int sex = en.GetProp((int)PlayerProp.Sex);
                SelectRoleDataBase sdb = table.SelectRoleDataBase.Where((GameCmd.enumProfession)job, (GameCmd.enmCharSex)sex);
                if (sdb != null)
                {
                    if (bBorn)
                    {
                        AddEffect(en, sdb.borneffect);
                    }
                    else
                    {
                        AddEffect(en, sdb.deadeffect);
                    }
                }
            }
            else if (en.GetEntityType() == EntityType.EntityType_NPC ||
                     en.GetEntityType() == EntityType.EntityType_Monster)
            {
                int modelID           = en.GetProp((int)EntityProp.BaseID);
                table.NpcDataBase ndb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)modelID);
                if (ndb != null)
                {
                    uint effectID = ndb.strBirthMagic;

                    if (bBorn)
                    {
                        AddEffect(en, ndb.strBirthMagic);
                    }
                    else
                    {
                        AddEffect(en, ndb.strDeathMagic);
                    }
                }
            }
        }
Exemplo n.º 15
0
    void ShowModel(HuntingDataBase data)
    {
        string[] monID     = data.monsterID.Split('_');
        uint     monsterid = uint.Parse(monID[0]);

        table.NpcDataBase npcData = GameTableManager.Instance.GetTableItem <NpcDataBase>(monsterid);
        if (npcData != null)
        {
            uint modelID = npcData.dwViewModelSet;  // 使用观察模型
            if (m_RTObj != null)
            {
                m_RTObj.Release();
                m_RTObj = null;
            }

            m_RTObj = DataManager.Manager <RenderTextureManager>().CreateRenderTextureObj((int)modelID, 800);
            if (m_RTObj == null)
            {
                return;
            }
            ModeDiplayDataBase modelDisp = GameTableManager.Instance.GetTableItem <ModeDiplayDataBase>(modelID);
            if (modelDisp == null)
            {
                Engine.Utility.Log.Error("BOSS模型ID为{0}的模型展示数据为空", modelID);
                return;
            }
            m_RTObj.SetDisplayCamera(modelDisp.pos800, modelDisp.rotate800, modelDisp.Modelrotation);
            m_RTObj.PlayModelAni(Client.EntityAction.Stand);
            UIRenderTexture rt = m__Model.GetComponent <UIRenderTexture>();
            if (null == rt)
            {
                rt = m__Model.gameObject.AddComponent <UIRenderTexture>();
            }
            if (null != rt)
            {
                rt.SetDepth(3);
                rt.Initialize(m_RTObj, m_RTObj.YAngle, new UnityEngine.Vector2(800, 800));
            }
        }
    }
Exemplo n.º 16
0
    protected override void OnShow(object data)
    {
        base.OnShow(data);

        if (data is LangTalkData)
        {
            m_LangTalkData = data as LangTalkData;

            m_trans_BtnRoot.transform.DestroyChildren();

            m_trans_BtnRoot.transform.parent.GetComponent <UIScrollView>().ResetPosition();

            table.NpcDataBase npcdb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>(m_LangTalkData.nNpcId);
            if (npcdb != null)
            {
                m_label_Npc_Name.text = npcdb.strName;
            }

            m_UIXmlRichText.Clear();
            if (m_LangTalkData.lstTalks.Count > 0)
            {
                m_UIXmlRichText.AddXml(RichXmlHelper.RichXmlAdapt(m_LangTalkData.lstTalks[0].strText));
            }

            for (int i = 0; i < m_LangTalkData.buttons.Count; i++)
            {
                GameObject go = NGUITools.AddChild(m_trans_BtnRoot.gameObject, m_btn_btn.gameObject);
                if (go != null)
                {
                    go.GetComponentInChildren <UILabel>().text = m_LangTalkData.buttons[i].strBtnName;
                    go.name = string.Format("btn_{0}", i);
                    UIEventListener.Get(go).onClick = onClick_Btn_Btn;
                    go.transform.localPosition      = new UnityEngine.Vector3(0, -i * 58, 0);
                    go.SetActive(true);
                }
            }
        }
    }
Exemplo n.º 17
0
        //------------------------------------------------------------------------------------------------

        private void CreateNPC(GameCmd.t_MapNpcDataPos npcdata, uint master_id)
        {
            Profiler.BeginSample("CreateNPC");
            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

            if (es == null)
            {
                Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
                return;
            }

            //MapVector2 mapPos = MapVector2.FromCoordinate(npcdata.cur_pos.x * 0.01f, npcdata.cur_pos*0.01f);
            Vector3 pos = new Vector3(npcdata.cur_pos.x * 0.01f, 0, -npcdata.cur_pos.y * 0.01f); // 服务器到客户端坐标转换


            EntityCreateData data = RoleUtil.BuildCreateEntityData(EntityType.EntityType_NPC, npcdata, master_id);
            INPC             npc  = es.FindNPC(npcdata.mapnpcdata.npcdata.dwTempID);

            if (npc != null)
            {
                npc.UpdateProp(data);
                NpcAscription.Instance.UpdateBelong(npc, npcdata.mapnpcdata.npcdata.owernuserid, npcdata.mapnpcdata.npcdata.owernteamid, npcdata.mapnpcdata.npcdata.owernclanid, npcdata.mapnpcdata.npcdata.ownername);
            }
            else
            {
                npc = es.CreateEntity(EntityType.EntityType_NPC, data, !m_bDelayLoad) as INPC;
                // 发送事件 CreateEntity
                if (npc != null)
                {
                    NpcAscription.Instance.UpdateBelong(npc, npcdata.mapnpcdata.npcdata.owernuserid, npcdata.mapnpcdata.npcdata.owernteamid, npcdata.mapnpcdata.npcdata.owernclanid, npcdata.mapnpcdata.npcdata.ownername);
                    table.NpcDataBase npctable = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)npcdata.mapnpcdata.npcdata.dwBaseID);
                    if (npctable != null)
                    {
                        //Debug.LogError("********** npctable.dwID = " + npctable.dwID);
                        if (npcdata.mapnpcdata.npcdata.arenanpctype == ArenaNpcType.ArenaNpcType_Player)//离线的真实玩家名字,用服务器的
                        {
                            npc.SendMessage(EntityMessage.EntityCommond_SetName, npcdata.mapnpcdata.npcdata.name);
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(npcdata.mapnpcdata.npcdata.name))
                            {
                                npc.SendMessage(EntityMessage.EntityCommond_SetName, npctable.strName);
                            }
                        }
                        if (npctable.dwType == (uint)GameCmd.enumNpcType.NPC_TYPE_TRANSFER)//传送阵
                        {
                            EntityOnTrigger callback = new EntityOnTrigger();
                            npc.SetCallback(callback);
                        }
                    }
                    if (npc != null)
                    {
                        PlayAni anim_param = new PlayAni();
                        anim_param.strAcionName = EntityAction.Stand;
                        anim_param.fSpeed       = 1;
                        anim_param.nStartFrame  = 0;
                        anim_param.nLoop        = -1;
                        anim_param.fBlendTime   = 0.2f;
                        npc.SendMessage(EntityMessage.EntityCommand_PlayAni, anim_param);
                    }
                }
            }
            if (npc != null)
            {
                npc.SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos);
                Vector3 rot = GameUtil.S2CDirection(npcdata.mapnpcdata.npcdata.byDirect);
                npc.SendMessage(EntityMessage.EntityCommand_SetRotate, (object)rot);
                IBuffPart buffpart = npc.GetPart(EntityPart.Buff) as IBuffPart;
                if (buffpart != null)
                {
                    buffpart.ReceiveBuffList(npcdata.mapnpcdata.statelist.data);
                }
            }

            Profiler.EndSample();
        }
Exemplo n.º 18
0
 public static bool IsNeedHpSlider(Client.IEntity entity)
 {
     if (entity.GetEntityType() == EntityType.EntityType_NPC)
     {
         INPC npc = entity as INPC;
         //是可以攻击的NPC
         if (npc.IsCanAttackNPC())
         {
             Client.ISkillPart skillPart = MainPlayerHelper.GetMainPlayer().GetPart(EntityPart.Skill) as Client.ISkillPart;
             bool canAttack = true;
             if (skillPart != null)
             {
                 int skillerror = 0;
                 canAttack = skillPart.CheckCanAttackTarget(entity, out skillerror);
             }
             if (npc.IsPet())
             {
                 if (npc.IsMainPlayerSlave())
                 {
                     return(true);
                 }
                 else
                 {
                     if (canAttack)
                     {
                         return(true);
                     }
                 }
                 return(false);
             }
             else if (npc.IsSummon())
             {
                 if (npc.IsMainPlayerSlave())
                 {
                     return(true);
                 }
                 else
                 {
                     if (canAttack)
                     {
                         return(true);
                     }
                 }
                 return(false);
             }
             else if (npc.IsMonster())
             {
                 int hp    = entity.GetProp((int)CreatureProp.Hp);
                 int maxhp = entity.GetProp((int)CreatureProp.MaxHp);
                 return(hp < maxhp);
             }
         }
         else
         {
             table.NpcDataBase npcdb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)entity.GetProp((int)Client.EntityProp.BaseID));
             if (npcdb != null)
             {
                 if (npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_TRANSFER || npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_COLLECT_PLANT ||
                     npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_FUNCTION)
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Exemplo n.º 19
0
    bool ShowTalkStr(int nindex)
    {
        bool success = false;

        if (m_dialogInfo != null)
        {
            if (m_dialogInfo.buttons != null)
            {
                if (m_dialogInfo.buttons.Count < 2)
                {
                    StopAllCoroutines();
                    //倒计时
                    tempTime  = 0;
                    CLOSETIME = CONST_TASK_CD;
                    m_label_LabelNext.gameObject.SetActive(true);
                    m_label_LabelNext.text = ((int)CLOSETIME).ToString() + "秒后自动跳过";
                    StartCoroutine(WaitToClose());
                }
                else
                {
                    m_label_LabelNext.gameObject.SetActive(false);
                }
            }
        }


        ResetDes();
        if (m_dialogInfo != null)
        {
            if (m_dialogInfo.lstTalks != null)
            {
                if (nindex < m_dialogInfo.lstTalks.Count)
                {
                    LangTalkData.Talk talkInfo = m_dialogInfo.lstTalks[nindex];

                    if (talkInfo.bUser)
                    {
                        string name = "";
                        if (Client.ClientGlobal.Instance().MainPlayer != null)
                        {
                            name = Client.ClientGlobal.Instance().MainPlayer.GetName();
                        }
                        m_label_nameLabel.text = name;
                        ShowRoleTexture(true);
                    }
                    else
                    {
                        table.NpcDataBase npcdata = GameTableManager.Instance.GetTableItem <table.NpcDataBase>(m_dialogInfo.nNpcId);
                        if (npcdata != null)
                        {
                            ShowRoleTexture(false, npcdata);

                            m_label_nameLabel.text = npcdata.strName;
                        }
                    }

                    bool useRichText = false;//富文本有泄漏bug 暂时不用
                    if (useRichText)
                    {
                        string desc = string.Format("<size value=\"24\"><color value=\"#1c2850\">{0} </color></size>", talkInfo.strText);
                        if (uiXmlRichText != null)
                        {
                            this.uiXmlRichText.fontSize = 24;
                            this.uiXmlRichText.AddXml(RichXmlHelper.RichXmlAdapt(desc));
                        }
                    }
                    else
                    {
                        string desc = string.Format("[1c2850]{0}[-]", talkInfo.strText);
                        m_label_normalText.text = desc;
                    }

                    success = true;
                }
            }

            if (m_dialogInfo.talkVoice != null && nindex < m_dialogInfo.talkVoice.Length)
            {
                Engine.IAudio audio = Engine.RareEngine.Instance().GetAudio();
                if (audio != null && m_nPlayingAudioId != 0)
                {
                    audio.StopEffect(m_nPlayingAudioId);
                }
                table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(m_dialogInfo.talkVoice[nindex]);
                if (resDB == null)
                {
                    Engine.Utility.Log.Error("找不到选择角色的Mp3资源");
                }

                if (audio != null && resDB != null)
                {
                    //m_nPlayingAudioId = audio.PlayUIEffect(resDB.strPath);
                    Client.IPlayer mainPlayer = Client.ClientGlobal.Instance().MainPlayer;
                    if (mainPlayer != null)
                    {
                        Transform tf = mainPlayer.GetTransForm();
                        if (tf != null)
                        {
                            m_nPlayingAudioId = audio.PlayEffect(tf.gameObject, resDB.strPath, false, true);
                        }
                    }
                }
            }
        }

        //是否显示下一个
        //bool nextVisible = (null != m_dialogInfo
        //    && null != m_dialogInfo.lstTalks
        //    && (m_dialogInfo.lstTalks.Count > nindex + 1));
        //if (null != m_label_LabelNext && m_label_LabelNext.gameObject.activeSelf != nextVisible)
        //{
        //    m_label_LabelNext.gameObject.SetActive(nextVisible);
        //}

        return(success);
    }
Exemplo n.º 20
0
    void ShowRoleTexture(bool bPlayer, table.NpcDataBase npcDb = null)
    {
        if (m_RTObj != null)
        {
            m_RTObj.Release();
        }
        if (bPlayer)
        {
            m_RTObj = DataManager.Manager <RenderTextureManager>().CreateRenderTextureObj(MainPlayerHelper.GetMainPlayer(), 700);
        }
        else if (npcDb != null)
        {
            m_RTObj = DataManager.Manager <RenderTextureManager>().CreateRenderTextureObj((int)npcDb.dwViewModelSet, 700);
        }
        if (m_RTObj == null)
        {
            return;
        }
        if (bPlayer)
        {
            Client.IPlayer player = MainPlayerHelper.GetMainPlayer();
            if (player == null)
            {
                return;
            }
            uint job = (uint)player.GetProp((int)Client.PlayerProp.Job);
            int  sex = (int)player.GetProp((int)Client.PlayerProp.Sex);
            table.SelectRoleDataBase roleSelectData = GameTableManager.Instance.GetTableItem <table.SelectRoleDataBase>(job, sex);
            float offsety  = 1.5f;
            float distance = 1.7f;
            float rotateX  = 0f;
            if (roleSelectData != null)
            {
                offsety  = roleSelectData.offsetY * 0.01f;
                distance = roleSelectData.distance * 0.01f;
                rotateX  = roleSelectData.diaRotateX * 0.01f;
            }

            m_RTObj.SetCamera(new Vector3(0f, offsety, 0), new Vector3(rotateX, 0, 0), distance);
            //m_RTObj.SetCamera(new Vector3(0f, offsety, 0), Vector3.zero, distance);
        }
        else
        {
            float offsety  = 1.0f;
            float distance = 1.7f;
            float rotateX  = 0f;
            if (npcDb != null)
            {
                offsety  = npcDb.diaOffsetY * 0.01f;
                distance = npcDb.diaDistance * 0.01f;
                rotateX  = npcDb.diaRotateX * 0.01f;
            }

            m_RTObj.SetCamera(new Vector3(0f, offsety, 0), new Vector3(rotateX, 0, 0), distance);
            //m_RTObj.SetCamera(new Vector3(0f, offsety, 0), Vector3.zero, distance);
        }
        rotateY = 170f;
        //设置人物旋转
        m_RTObj.SetModelRotateY(rotateY);
        m_RTObj.PlayModelAni(Client.EntityAction.Stand);

        //人物
        if (m__NpcTexture != null)
        {
            m__NpcTexture.mainTexture = m_RTObj.GetTexture();
            //m__NpcTexture.MakePixelPerfect();
        }
    }
Exemplo n.º 21
0
    public void InitInfo(Client.NPCInfo info)
    {
        if (null == m_spMaskIcon)
        {
            m_spMaskIcon = transform.Find("MaskIcon").GetComponent <UISprite>();
        }
        m_type  = (MapScrollItemType)info.type;
        npcInfo = info;
        if (info != null)
        {
            Transform labelTrans = transform.Find("Label");
            bool      visible    = RoleStateBarManager.IsEntityHaveHeadIconMask((uint)info.npcID);
            if (null != m_spMaskIcon)
            {
                if (m_spMaskIcon.gameObject.activeSelf != visible)
                {
                    m_spMaskIcon.gameObject.SetActive(visible);
                }

                if (visible)
                {
                    table.NpcHeadMaskDataBase maskDb = RoleStateBarManager.GetNPCHeadMaskDB((uint)info.npcID);
                    if (null != maskDb)
                    {
                        UIManager.GetAtlasAsyn(maskDb.miniMapMaskIcon, ref m_curIconAsynSeed, () =>
                        {
                            if (null != m_spMaskIcon)
                            {
                                m_spMaskIcon.atlas = null;
                            }
                        }, m_spMaskIcon, false);
                    }
                }
            }
            if (labelTrans != null)
            {
                UILabel label = labelTrans.GetComponent <UILabel>();
                if (label != null)
                {
                    string showText = npcInfo.name;
                    if (npcInfo.pos.x != 0 || npcInfo.pos.y != 0)
                    {
                        string levelStr = string.Empty;

                        table.NpcDataBase ndb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)npcInfo.npcID);
                        if (ndb != null)
                        {
                            if (ndb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_NONE)
                            {
                                if (ndb.dwMonsterType != 0)
                                {
                                    levelStr = ndb.dwLevel + "级 ";
                                }
                            }
                        }

                        showText = levelStr + npcInfo.name + "(" + npcInfo.pos.x.ToString() + "," + npcInfo.pos.y.ToString() + ")";
                    }
                    label.text = showText;
                }
            }
        }
    }