Exemple #1
0
        public static bool HasExistResourceActorId(uint actorId)
        {
            string prefab = RoleHelp.GetPrefabName(actorId);

            if (prefab == null || prefab == "")
            {
                return(false);
            }
            if (prefab != "" && SGameEngine.ResourceLoader.Instance.is_exist_asset("Assets/Res/" + prefab + ".prefab"))
            {
                return(true);
            }

            //资源不存在,尝试默认资源
            DBActor db = DBManager.GetInstance().GetDB <DBActor>();

            if (!db.ContainsKey(actorId))
            {
                return(false);
            }

            DBActor.ActorData data = db.GetData(actorId);
            if (data.default_actor_id == 0 || actorId == data.default_actor_id)
            {
                return(false);
            }
            return(HasExistResourceActorId(data.default_actor_id));
        }
Exemple #2
0
        public static uint CheckResourceActorId(uint actorId)
        {
            string prefab = RoleHelp.GetPrefabName(actorId);

            if (prefab != "" && SGameEngine.ResourceLoader.Instance.is_exist_asset("Assets/Res/" + prefab + ".prefab") == false)
            {//资源不存在,尝试默认资源
                DBActor db = DBManager.GetInstance().GetDB <DBActor>();

                if (!db.ContainsKey(actorId))
                {
                    return(actorId);
                }

                DBActor.ActorData data = db.GetData(actorId);
                if (data.default_actor_id != 0)
                {
                    return(data.default_actor_id);
                }
                return(actorId);
            }
            else
            {
                return(actorId);
            }
        }
Exemple #3
0
        /// <summary>
        /// 设置变身技能
        /// </summary>
        /// <param name="actor_id"></param>
        void SetShapeShiftSkill(uint actor_id)
        {
            DBActor db = DBManager.Instance.GetDB <DBActor>();

            if (db == null)
            {
                return;
            }

            Dictionary <DBCommandList.OPFlag, SkillInfo> config = null;

            if (!mFitSkillIdPos.TryGetValue(m_ShiftFitIdx, out config))
            {
                config = new Dictionary <DBCommandList.OPFlag, SkillInfo>();
                mFitSkillIdPos[m_ShiftFitIdx] = config;
            }

            // 拿到玩家职业的默认按键信息数据
            DBActor.ActorData act_data = db.GetData(actor_id);
            if (act_data != null)
            {
                for (uint i = 0; i < act_data.skill_count; ++i)
                {
                    SkillInfo info = new SkillInfo();
                    info.Id = act_data.skill_idx[i];
                    config[DBCommandList.BtnToOPFlag(i + 1)] = info;
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 通过角色表id来进行属性字段的初始化(用于LocalActorAttribure的初始化)
        /// </summary>
        /// <param name="type_id"></param>
        public void InitAttributeData(uint type_id)
        {
            //查表根据类型填充属性字段
            DBActor db = DBManager.GetInstance().GetDB <DBActor>();

            if (null == db)
            {
                GameDebug.Log("[ActorAttributeData]DBActor is null");
                return;
            }

            if (!db.ContainsKey(type_id))
            {
                GameDebug.Log("[ActorAttributeData]DBActor not exist type_id: " + type_id);
                return;
            }

            DBActor.ActorData data = db.GetData(type_id);
            Vocation            = data.vocation;
            BehaviourTree       = data.behaviour_tree + ".json";
            SummonBehaviourTree = data.summon_behaviour_tree + ".json";
            DefaultMotionRadius = data.motion_radius;
            WarTag        = data.war_tag;
            AttackRotaion = data.attack_rotaion;
            Quality       = (uint)data.color;
            Gravity       = data.gravity;

            // 设置默认属性,保证初始的攻速为1
            Attribute[GameConst.AR_ATK_SPEED_BASE].Value  = 100;
            Attribute[GameConst.AR_ATK_SPEED_ADD].Value   = 0;
            Attribute[GameConst.AR_MOVE_REAL_SPEED].Value = (uint)(data.runspeed);
        }
Exemple #5
0
        public UnitID CreateNPC(Neptune.NPC npcInfo, Actor parent = null)
        {
            if (npcInfo == null)
            {
                GameDebug.LogError("Error in create npc, npc info is null!!!");
                return(null);
            }

            Vector3 bornPos = npcInfo.Position;

            NpcDefine npcDefine = NpcHelper.MakeNpcDefine((uint)npcInfo.ExcelId);

            if (npcDefine == null)
            {
                GameDebug.LogError("Error in create npc, npc define is null!!!");
                return(null);
            }

            // 护送任务NPC可以创建多个
            if (GetNpcByNpcId((uint)npcInfo.Id) != null && npcDefine.Function != NpcDefine.EFunction.ESCORT)
            {
                return(null);
            }

            uint uuid = GetAvailableUUId(npcInfo, npcDefine);

            DBActor dbActor = DBManager.GetInstance().GetDB <DBActor>();

            DBActor.ActorData actorData = dbActor.GetData((uint)npcDefine.ActorId);

            bornPos = RoleHelp.GetPositionInScene((uint)npcDefine.ActorId, npcInfo.Position.x, npcInfo.Position.z);
            if (npcInfo.Id >= 300)
            {
                GameDebug.LogError("npcInfo.Id is too large! " + npcInfo.Id);
            }
            xc.UnitCacheInfo initData = new xc.UnitCacheInfo(EUnitType.UNITTYPE_NPC, uuid);
            initData.ClientNpc       = npcInfo;
            initData.ClientNpcDefine = NpcHelper.MakeNpcDefine((uint)(npcInfo.ExcelId));
            initData.CacheType       = xc.UnitCacheInfo.EType.ET_Create;
            initData.PosBorn         = bornPos;
            initData.ParentActor     = parent;

            // 如果有父角色,则出生在父角色附近的一个随机位置
            if (parent != null)
            {
                Vector3 pos    = AIHelper.GetActorRangeRandomPosition(parent, 1f, 2f);
                bool    result = false;
                initData.PosBorn = InstanceHelper.ClampInWalkableRange(pos, pos, out result);
            }

            mCreatings.Add(initData.UnitID.obj_idx);

            ActorManager.Instance.PushUnitCacheData(initData);

            return(initData.UnitID);
        }
Exemple #6
0
        /// <summary>
        /// 通过角色id来获取角色对应的在对话框里面的摄像机旋转
        /// </summary>
        /// <param name="type_id"></param>
        /// <returns></returns>
        public static Vector3 GetPrefabCamRotateInDialogWnd(uint type_id)
        {
            DBActor db = DBManager.GetInstance().GetDB <DBActor>();

            if (!db.ContainsKey(type_id))
            {
                GameDebug.LogError(string.Format("GetPrefabCamRotateInDialogWnd Id:[{0}] don't exist", type_id));
                return(Vector3.zero);
            }

            DBActor.ActorData data = db.GetData(type_id);
            return(ModelHelper.GetModelCamRotateInDialogWnd(data.model_id));
        }
Exemple #7
0
        public static float GetPrefabFloatScale(uint type_id)
        {
            DBActor db = DBManager.GetInstance().GetDB <DBActor>();

            if (!db.ContainsKey(type_id))
            {
                GameDebug.LogError(string.Format("GetPrefabScale Id:[{0}] don't exist", type_id));
                return(1f);
            }

            DBActor.ActorData data = db.GetData(type_id);
            return(ModelHelper.GetModelScale(data.model_id));
        }
Exemple #8
0
        /// <summary>
        /// 通过角色id来获取角色对应的角色头像
        /// </summary>
        /// <param name="type_id"></param>
        /// <returns></returns>
        public static string GetRoleIcon(uint type_id)
        {
            DBActor db = DBManager.GetInstance().GetDB <DBActor>();

            if (!db.ContainsKey(type_id))
            {
                GameDebug.LogError(string.Format("GetRoleIcon Id:[{0}] don't exist", type_id));
                return("");
            }

            DBActor.ActorData data = db.GetData(type_id);
            string            icon = ModelHelper.GetModelIcon(data.model_id);

            if (icon.Length == 0)
            {
                return(string.Empty);
            }

            return(icon);
        }
Exemple #9
0
        /// <summary>
        /// 根据角色表id来获取角色的名字
        /// </summary>
        public static string GetActorName(uint type_id)
        {
            DBActor db = DBManager.GetInstance().GetDB <DBActor>();

            if (!db.ContainsKey(type_id))
            {
                GameDebug.LogError(string.Format("GetActorName Id:[{0}] don't exist", type_id));
                return("");
            }

            DBActor.ActorData data = db.GetData(type_id);
            string            name = data.name;

            if (name.Length == 0)
            {
                return("");
            }

            return(name);
        }
Exemple #10
0
        /// <summary>
        /// 通过角色id来获取角色对应的资源名字
        /// </summary>
        public static string GetPrefabName(uint type_id, bool is_local_player = false)
        {
            DBActor db = DBManager.GetInstance().GetDB <DBActor>();

            if (!db.ContainsKey(type_id))
            {
                GameDebug.LogError(string.Format("GetPreFabName Id:[{0}] don't exist", type_id));
                return("");
            }

            DBActor.ActorData data = db.GetData(type_id);
            string            name = ModelHelper.GetModelPrefab(data.model_id, is_local_player);

            if (name.Length == 0)
            {
                return(string.Empty);
            }

            return(name);
        }