コード例 #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));
        }
コード例 #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);
            }
        }
コード例 #3
0
        public void LocalPlayerWalkToDestination(Vector3 targetPos, Task relateTask = null)
        {
            Actor player = Game.GetInstance().GetLocalPlayer();

            if (player == null)
            {
                return;
            }

            targetPos.y = RoleHelp.GetHeightInScene(player.ActorId, targetPos.x, targetPos.z);
            targetPos   = InstanceHelper.ClampInWalkableRange(targetPos, 10);

            // 判断是否可到达
            XNavMeshPath walkMeshPath = new XNavMeshPath();

            XNavMesh.CalculatePath(player.transform.position, targetPos, xc.Dungeon.LevelManager.GetInstance().AreaExclude, walkMeshPath);
            if (walkMeshPath.status != XNavMeshPathStatus.PathComplete)
            {
                // 如果通过任务导航寻路,且在新手副本的不可到达区域,则直接飞过去,以免因为配置错误而导致卡死
                if (relateTask != null && SceneHelp.Instance.CurSceneID == GameConstHelper.GetUint("GAME_BORN_DUNGEON"))
                {
                    GameDebug.LogWarning(DBConstText.GetText("MAP_POS_CAN_NOT_REACH") + ",该场景是新手场景,直接瞬移过去");
                    player.MoveCtrl.SendFly(targetPos);
                    player.SetPosition(targetPos);
                }
                else
                {
                    UINotice.Instance.ShowMessage(DBConstText.GetText("MAP_POS_CAN_NOT_REACH"));
                }
                return;
            }

            InstanceManager.Instance.IsAutoFighting = false;

            mPathWalker.WalkTo(targetPos);
            //player.MoveCtrl.TryWalkTo(targetPos);

            /*
             * uint instanceType = InstanceManager.Instance.InstanceType;
             *
             * if (instanceType == GameConst.WAR_TYPE_WILD || instanceType == GameConst.WAR_TYPE_HOLE || instanceType == GameConst.WAR_SUBTYPE_WILD_PUB || instanceType == GameConst.WAR_TYPE_MULTI)
             * {
             *  if(mPathWalker == null)
             *  {
             *      return;
             *  }
             *
             *  mPathWalker.WalkTo(targetPos);
             * }
             * else
             * {
             *  player.MoveCtrl.TryWalkTo(targetPos);
             * }*/

            TaskNavigationActive(true);
            IsNavigating = true;
        }
コード例 #4
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);
        }
コード例 #5
0
        public override void SetSenderIcon(uint senderID, uint transferLv)
        {
            string icon_name = RoleHelp.GetPlayerIconName(senderID, transferLv, false);
            Sprite iconSpr   = mSpriteList.LoadSprite(icon_name);

            if (null != iconSpr)
            {
                mSenderIconImg.sprite = iconSpr;
            }
        }
コード例 #6
0
ファイル: WildMonsterInfo.cs プロジェクト: wuhuolong/MaxBooks
        public override void HandleActorCreate(Actor actor)
        {
            base.HandleActorCreate(actor);

            mActorUID = actor.UID;

            if (Actor == null)
            {
                return;
            }

            var monster = actor as Monster;

            monster.Color = (Monster.QualityColor)Info.color;
            monster.SetNameText();
            monster.CurLife         = Info.hp; // 同步当前血量
            monster.AlwaysShowHpBar = true;
            //monster.SpartanMonsterGroupId = (int)Info.group_id;

            // 设置玩家坐标
            Actor.Stop();

            var unit_scale = GlobalConst.UnitScale;
            var x          = AppearInfo.pos.px * unit_scale;
            var z          = AppearInfo.pos.py * unit_scale;
            var pos        = new Vector3(x, RoleHelp.GetHeightInScene(Actor.ActorId, x, z), z);

            //pos = InstanceHelper.ClampInWalkableRange(pos);

            Actor.transform.position = pos;

            // 进入AOI视野增加buff
            if (BuffList != null)
            {
                uint server_time = Game.Instance.ServerTime;
                for (int i = 0; i < BuffList.Count; ++i)
                {
                    uint end_time = (uint)(BuffList[i].v / 1000);
                    uint second   = 1;
                    if (end_time > server_time)
                    {
                        second = end_time - server_time;
                    }
                    //GameDebug.LogError(string.Format("servertime = {0} BuffList[i].v = {1} second = {2}", server_time, end_time, second));
                    Actor.BuffCtrl.AddBuff(BuffList[i].k, second);
                }
            }

            if (AppearInfo.speed > 0)
            {
                Actor.MoveCtrl.ReceiveWalkBegin(AppearInfo);
            }
        }
コード例 #7
0
        Utils.Timer mEndTimer;// 移动结束的Timer
        public void ReceiveWalkBegin(PkgNwarMove moves)
        {
            if (false == mIsRecvMsg)
            {
                return;
            }

            // 移动时的位置和方向
            Vector3 pos = Vector3.zero;
            Vector3 dir = Vector3.zero;

            pos.x = moves.pos.px * GlobalConst.UnitScale;
            pos.z = moves.pos.py * GlobalConst.UnitScale;

            // 如果速度为0,直接设置到目标点(移动时间太短的话也当作停止处理)
            if (moves.speed == 0 || (moves.time != 0 && moves.time <= 66))
            {
                pos = RoleHelp.GetPositionInScene(mOwner.ActorId, pos.x, pos.z);
                mOwner.SetPosition(pos);
                mOwner.MoveSpeed = 0;
                return;
            }

            dir.x = moves.speed * Mathf.Cos(moves.dir);
            dir.z = moves.speed * Mathf.Sin(moves.dir);

            MoveStep step = new MoveStep();

            step.type  = EActorStepType.AT_WALK_BEGIN;
            step.pos   = pos;
            step.dir   = dir;
            step.speed = moves.speed * GlobalConst.UnitScale;

            mCurStep = step;
            mbDirty  = true;

            // 如果移动时间不为0,则在规定的时间内自动停止
            if (moves.time != 0)
            {
                if (mEndTimer != null)
                {
                    mEndTimer.Destroy();
                }

                mEndTimer = new Utils.Timer((int)moves.time, false, moves.time, OnTimerFinish);
            }
        }
コード例 #8
0
        public void ReceiveSetPos(S2CNwarSetPos pack)
        {
            if (mOwner.MoveImplement != null)
            {
                Vector3 pos    = RoleHelp.GetPositionInScene(mOwner.ActorId, pack.move.pos.px * GlobalConst.UnitScale, pack.move.pos.py * GlobalConst.UnitScale);
                bool    result = false;
                pos = InstanceHelper.ClampInWalkableRange(pos, pos, out result);
                mOwner.MoveImplement.SetPosition(pos);
            }

            bool isWalking = mOwner.ActorMachine.IsWalking();

            mOwner.Stop();
            TryWalkAlongStop();

            // 如果当前正在寻路,则重新寻路,因为需要重新计算路径
            if (isWalking == true && mOwner.ActorMachine.DestList.size > 0)
            {
                int newWalkId = 0;
                if (mReachCallbacks != null && mReachCallbacks.ContainsKey(m_WalkId) == true)
                {
                    newWalkId = TryWalkToAlong(mOwner.ActorMachine.DestList[mOwner.ActorMachine.DestList.size - 1], mReachCallbacks[m_WalkId]);
                }
                else
                {
                    newWalkId = TryWalkToAlong(mOwner.ActorMachine.DestList[mOwner.ActorMachine.DestList.size - 1]);
                }

                // 如果当前正在任务寻路,则赋值给最新的walk id
                if (TargetPathManager.Instance.IsNavigating == true && TargetPathManager.Instance.PathWalker != null)
                {
                    TargetPathManager.Instance.PathWalker.WalkId = newWalkId;
                }
            }

            // 本地是否要激活自动战斗
            if (pack.move.id == LocalPlayerManager.Instance.LocalActorAttribute.UnitId.obj_idx)
            {
                if (SceneHelp.Instance.IsAutoFightingAfterSwitchInstance == true)
                {
                    SceneHelp.Instance.IsAutoFightingAfterSwitchInstance = false;
                    InstanceManager.Instance.IsAutoFighting = true;
                }
                mIsMoving = false;
            }
        }
コード例 #9
0
ファイル: NpcHelper.cs プロジェクト: wuhuolong/MaxBooks
        public static string GetNpcName(uint instanceId, uint npcJsonId)
        {
            if (instanceId == 0)
            {
                instanceId = SceneHelp.Instance.CurSceneID;
            }
            Neptune.Data levelData = xc.Dungeon.LevelManager.Instance.LoadLevelFileTemporary(SceneHelp.GetFirstStageId(instanceId));
            if (levelData != null)
            {
                Neptune.NPC npcInfo = levelData.GetNode <Neptune.NPC>((int)npcJsonId);
                if (npcInfo != null)
                {
                    return(RoleHelp.GetActorName(NpcHelper.MakeNpcDefine(npcInfo.ExcelId).ActorId));
                }
            }

            return(string.Empty);
        }
コード例 #10
0
ファイル: WildMonsterInfo.cs プロジェクト: wuhuolong/MaxBooks
        /// <summary>
        /// 实际创建Actor
        /// </summary>
        protected override void CreateActor()
        {
            base.CreateActor();

            Vector3 pos_born = Vector3.zero;

            if (AppearInfo != null)
            {
                var unit_scale = GlobalConst.UnitScale;
                var x          = AppearInfo.pos.px * unit_scale;
                var z          = AppearInfo.pos.py * unit_scale;
                pos_born = new Vector3(x, RoleHelp.GetHeightInScene(Info.actor_id, x, z), z);
            }

            var cache_info = ActorHelper.CreateUnitCacheInfo(Info, pos_born);

            ActorManager.Instance.PushUnitCacheData(cache_info);
        }
コード例 #11
0
ファイル: WorshipModel.cs プロジェクト: wuhuolong/MaxBooks
        public static UnitID CreateWorshipModelForLua(uint type_id, uint uid, uint rank, string name, string guildName, uint honor, uint title, XLua.LuaTable modIdLst, XLua.LuaTable fashions, XLua.LuaTable suit_effects, Action <Actor> cbResLoad = null)
        {
            Vector3            pos      = Vector3.zero;
            Quaternion         rotation = Quaternion.identity;
            List <Neptune.Tag> tags     = Neptune.DataHelper.GetTagListByType(Neptune.DataManager.Instance.Data, "special_pos");

            if (rank <= tags.Count)
            {
                pos      = tags[(int)(rank - 1)].Position;
                pos      = RoleHelp.GetPositionInScene(type_id, pos.x, pos.z);
                rotation = tags[(int)(rank - 1)].Rotation;
            }

            xc.UnitCacheInfo info = new xc.UnitCacheInfo(EUnitType.UNITTYPE_PLAYER, GetAvailableUUId());
            info.AOIPlayer.model_id_list = XLua.XUtils.CreateListByLuaTable <uint, uint>(modIdLst);
            info.AOIPlayer.fashions      = XLua.XUtils.CreateListByLuaTable <uint, uint>(fashions);
            info.AOIPlayer.suit_effects  = XLua.XUtils.CreateListByLuaTable <uint, uint>(suit_effects);
            info.AOIPlayer.type_idx      = type_id;
            info.PosBorn  = pos;
            info.Rotation = rotation;

            info.AOIPlayer.model_id_list.AddRange(info.AOIPlayer.fashions);

            ActorHelper.GetModelFashionList(info.AOIPlayer.model_id_list, info.AOIPlayer.model_id_list, info.AOIPlayer.fashions);

            var model = ActorManager.Instance.CreateActor <WorshipModel>(info, info.Rotation, null, true, cbResLoad);

            model.RawUID           = uid;
            model.Rank             = rank;
            model.UserName         = name;
            model.GuildName        = guildName;
            model.mActorAttr.Honor = honor;
            model.mActorAttr.Title = title;

            WorshipModelHeadBehavior worshipModelHeadBehavior = model.GetBehavior <WorshipModelHeadBehavior>();

            worshipModelHeadBehavior.ResetHeadInfo();
            worshipModelHeadBehavior.Honor = honor;
            worshipModelHeadBehavior.Title = title;

            return(info.UnitID);
        }
コード例 #12
0
ファイル: ActorManager.cs プロジェクト: wuhuolong/MaxBooks
        public T CreateActor <T>(xc.UnitCacheInfo info, Quaternion rot, Monster.CreateParam createParam, bool showFashion = false, Action <Actor> cbResloaded = null) where T : Actor, new ()
        {
            if (mActorSet.ContainsKey(info.UnitID))
            {
                GameDebug.LogError("Actor's key conflict. Type: " + info.UnitID.type + ", UID: " + info.UnitID.obj_idx);
                return(null);
            }

            Vector3 scale = RoleHelp.GetPrefabScale(info);

            T actor = new T(); // Activator.CreateInstance<T>();

            actor.OnCreate(info, createParam);
            mActorSet.Add(info.UnitID, actor);

            if (info.UnitType == EUnitType.UNITTYPE_PLAYER)
            {
                var voaction = (Actor.EVocationType)ActorHelper.TypeIdToRoleId(info.AOIPlayer.type_idx);
                StartCoroutine(actor.mAvatarCtrl.CreateModelFromModleList(info.PosBorn, rot, scale, info.AOIPlayer.model_id_list, info.AOIPlayer.fashions, info.AOIPlayer.suit_effects, voaction, cbResloaded));
            }
            else
            {
                string prefab = RoleHelp.GetPrefabName(info);
//                 if(info.UnitType == EUnitType.UNITTYPE_MONSTER && info.AOIMonster != null)
//                 {
//                     if(info.AOIMonster.type_idx >= 201 && info.AOIMonster.type_idx < 208)
//                     {//守护
//                         prefab = prefab + "_pet_test";
//                     }
//                     else if (info.AOIMonster.type_idx >= 301 && info.AOIMonster.type_idx < 308)
//                     {//坐骑
//                         prefab = prefab + "_mount_test";
//                     }
//                 }
                StartCoroutine(actor.mAvatarCtrl.CreateModelFromPrefab(prefab, info.PosBorn, rot, scale, cbResloaded));
            }

            //actor.transform.position = info.PosBorn;
            actor.AfterCreate();

            return(actor);
        }
コード例 #13
0
        protected virtual UnitCacheInfo CreateUnitCacheData(S2CNwarInitInfo player_info)
        {
            var born_pos  = RoleHelp.GetPositionInScene(ActorHelper.RoleIdToTypeId(player_info.brief.rid), player_info.init_pos.px * GlobalConst.UnitScale, player_info.init_pos.py * GlobalConst.UnitScale);
            var init_data = ActorHelper.CreateUnitCacheInfo(player_info.brief, born_pos);

            // 读取出生点朝向
            List <Neptune.Tag> tags = Neptune.DataHelper.GetTagListByType(Neptune.DataManager.Instance.Data, "born_pos");

            if (tags.Count > 0)
            {
                init_data.Rotation = tags[0].Rotation;
            }
            if (LocalPlayerManager.Instance.BornRotation.Equals(Quaternion.identity) == false)
            {
                init_data.Rotation = LocalPlayerManager.Instance.BornRotation;
                LocalPlayerManager.Instance.BornRotation = Quaternion.identity;
            }

            return(init_data);
        }
コード例 #14
0
        public void SetPosition(Vector3 pos)
        {
            Vector3 newPos = pos;

            newPos.y = RoleHelp.GetHeightInScene(mOwner.ActorId, newPos.x, newPos.z);

            /*if (m_NavMeshAgent != null)
             * {
             *  m_NavMeshAgent.enabled = false;
             * }*/

            mOwnerTrans.position = newPos;

            /*if (m_NavMeshAgent != null)
             * {
             *  m_NavMeshAgent.enabled = true;
             * }*/

            m_IsGround = true;
            OnMove();
        }
コード例 #15
0
        /// <summary>
        /// 移动固定的位置
        /// </summary>
        /// <param name="offset">移动的偏移数值</param>
        /// <param name="on_ground">移动时是否贴近地面</param>
        /// <param name="slider">移动时是否沿着边界滑动</param>
        public void Move(Vector3 offset, bool on_ground, bool slider = true)
        {
//             MoveAgent(offset, on_ground, slider);
//             return;

            if (offset == Vector3.zero || mOwner.DisableMoveState)
            {
                return;
            }

            move_data.pos = new PkgNwarPos();

            // 减少Trans.position 这样的调用,会显著影响性能
            Vector3 ownerPos = mOwnerTrans.position;

            // 当移动不贴近地面(浮空等)时,需要先计算贴近地面的高度,不然NavMesh的碰撞检测可能检测不到
            if (on_ground == false)
            {
                float height = RoleHelp.GetHeightInScene(mOwner.ActorId, ownerPos.x, ownerPos.z);
                ownerPos.y = height;
            }

            Vector3 origin = ownerPos;        // 碰撞检测的起点
            Vector3 newPos = origin + offset; // 移动后的新位置

            Vector3 move     = offset;        // 偏移量
            float   offset_y = move.y;        // 记录原有的高度偏移

            move.y = 0;                       // 碰撞检测时将高度偏移设置为0

            bool touchEdge = false;           // 已经触碰到边界

            bool is_localplayer = mOwner.IsLocalPlayer;

            bool collide_check = true;
            bool is_monster    = mOwner.IsMonster();//怪物不进行碰撞检测

            if (is_monster)
            {
                collide_check = false;
            }
            else
            {
                collide_check = true;
            }

            if (collide_check)
            {
                Vector3     final_move = move;
                XNavMeshHit hit;
                if (XNavMesh.Raycast(origin, origin + move * (1.0f + Radius / move.magnitude), out hit, LevelManager.GetInstance().AreaExclude))
                {
                    touchEdge = true;

                    if (slider)// 需要沿着边界滑动时
                    {
                        float sameDir = Vector3.Dot(hit.normal, final_move);
                        if (sameDir > 0)// 法线与移动方向相同,说明角色在边界外
                        {
                            final_move.y = offset_y;
                            newPos       = origin + final_move;
                        }
                        else
                        {
                            if (hit.normal == Vector3.zero)// NavMesh获得的法线数值可能为0
                            {
                                Debug.DrawLine(origin, origin + final_move, Color.yellow, 5.0f);

                                final_move.y = offset_y;
                                newPos       = origin + final_move;
                                //final_move = Vector3.zero;
                                //newPos = origin;
                            }
                            else
                            {
                                // 碰到边界进行滑动
                                Vector3 tanget = Vector3.Cross(Vector3.up, hit.normal);
                                final_move = tanget * Vector3.Dot(tanget, final_move);
                                float sMoveLen = final_move.magnitude;
                                if (sMoveLen < DBActor.MinDisToGround)// 移动方向垂直于法线
                                {
                                    final_move = Vector3.zero;
                                    newPos     = origin;
                                }
                                else
                                {
                                    // 沿着切线方向再次做检测,以免滑动的时候移动到另一个边界外
                                    if (XNavMesh.Raycast(origin, origin + final_move * (1.0f + Radius / sMoveLen), out hit, LevelManager.GetInstance().AreaExclude))
                                    {
                                        final_move = Vector3.zero;
                                        newPos     = origin;
                                    }
                                    else
                                    {
                                        final_move.y = offset_y;
                                        newPos       = origin + final_move;
                                    }
                                }
                            }
                        }
                    }
                    else// 不滑动,则直接移动到碰撞点
                    {
                        Vector3 radius_pos = PhysicsHelp.BoundaryHitPos(origin, hit.position);
                        newPos.x = radius_pos.x;
                        newPos.z = radius_pos.z;
                    }
                }
            }

            float terrain_height = RoleHelp.GetHeightInScene(mOwner.ActorId, newPos.x, newPos.z);

            if (newPos.y < terrain_height + DBActor.MinDisToGround)// 如果当前位置已经贴近地面,则设置m_IsGround为true
            {
                m_IsGround = true;
                newPos.y   = terrain_height;
            }
            else
            {
                if (on_ground || touchEdge) // 如果角色已经触碰到边界,则让其掉到地上
                {
                    newPos.y   = terrain_height;
                    m_IsGround = true;
                }
                else
                {
                    m_IsGround = false;
                }
            }

            // 在多人副本、野外地图中,本地玩家碰到障碍物的时候需要通知服务端
            if (is_localplayer && slider)
            {
                if (touchEdge)
                {
                    m_IsTouchEdge = true;

                    Vector3 totalMove = newPos - origin;
                    totalMove.y = 0;
                    Vector3 moveDir = totalMove.normalized;

                    move_data.id     = mOwner.UID.obj_idx;
                    move_data.pos.px = (int)(origin.x * 100.0f);
                    move_data.pos.py = (int)(origin.z * 100.0f);
                    move_data.dir    = Maths.Util.VectorToAngle(moveDir);

                    float   totalMoveLen = totalMove.magnitude;
                    Vector3 xz_offset    = offset;
                    xz_offset.y = 0;
                    float ortMoveLen = xz_offset.magnitude;
                    if (totalMoveLen > 0 && ortMoveLen > 0)
                    {
                        move_data.speed = (uint)(mOwner.MoveSpeed * (totalMoveLen / ortMoveLen) * 100);
                    }
                    else
                    {
                        move_data.speed = 0;
                    }

                    // 数据发生变化时才发送滑动协议
                    if (!mSliderData.Equal(move_data))
                    {
                        mSliderData.Assign(move_data);

                        slider_data.slide = move_data;
                        NetClient.GetCrossClient().SendData <C2SNwarSlide>(NetMsg.MSG_NWAR_SLIDE, slider_data);
                    }
                }
                // 当滑动结束时,需要同步一次方向和位置
                else if (m_IsTouchEdge)
                {
                    m_IsTouchEdge = false;

                    Vector3 totalMove = newPos - origin;
                    totalMove.y = 0;
                    Vector3 moveDir = totalMove.normalized;

                    move_data.id     = mOwner.UID.obj_idx;
                    move_data.pos.px = (int)(origin.x * 100.0f);
                    move_data.pos.py = (int)(origin.z * 100.0f);
                    move_data.dir    = Maths.Util.VectorToAngle(moveDir);

                    float   totalMoveLen = totalMove.magnitude;
                    Vector3 xz_offset    = offset;
                    xz_offset.y = 0;
                    float ortMoveLen = xz_offset.magnitude;
                    if (totalMoveLen > 0 && ortMoveLen > 0)
                    {
                        move_data.speed = (uint)(mOwner.MoveSpeed * (totalMoveLen / ortMoveLen) * 100);
                    }
                    else
                    {
                        move_data.speed = 0;
                    }

                    mSliderData.Assign(move_data);
                    slider_data.slide = move_data;
                    NetClient.GetCrossClient().SendData <C2SNwarSlide>(NetMsg.MSG_NWAR_SLIDE, slider_data);
                }
            }

            mOwnerTrans.position = newPos;
            OnMove();
        }
コード例 #16
0
        //only directly called for local player, initiative ride
        private IEnumerator RideAync()
        {
            mOriginalScale = Vector3.one;

            if (this == null || this.IsDestroy || mOwner == null || mOwner.IsDestroy)
            {
                yield break;
            }

            if (mOwner.mVisibleCtrl != null && mOwner.mVisibleCtrl.VisibleMode != EVisibleMode.Visible)
            {
                yield break;
            }
            if (mOwner.mAvatarCtrl == null)
            {
                yield break;
            }
            if (mCurrentRideId == mDirtyRideId)
            {
                mDirtyRideId = -1;
                yield break;
            }

            //test some situation
            if (!TestRide())
            {
                yield break;
            }

            mCurrentRideId = (uint)mDirtyRideId;
            mDirtyRideId   = -1;

            DBGrowSkin db_skin = DBManager.Instance.GetDB <DBGrowSkin>();

            DBGrowSkin.DBGrowSkinItem skin_item = null;
            if (db_skin != null)
            {
                skin_item = db_skin.GetOneItem(GameConst.GROW_TYPE_RIDE, mCurrentRideId);
            }
            if (skin_item != null)
            {
                if (ClientModel.HasExistResourceActorId(skin_item.ActorId) == false)
                {
                    yield break;//不存在资源
                }
            }

            mIsprocessingRide = true;

            //clone rider
            if (mRiderActor != null)
            {
                if (mRiderActor.transform != null)
                {
                    mRiderActor.transform.parent = null;
                }
            }
            else
            {
                mRiderActor = ClientModel.CreateClientModelByClone(mOwner, null);
                if (this == null || this.IsDestroy || mOwner == null || mOwner.IsDestroy || mRiderActor == null || mRiderActor.IsDestroy)
                {
                    mIsprocessingRide = false;
                    yield break;
                }

                // 设置坐骑的阴影状态
                var rider_shadow_behavior = mRiderActor.GetBehavior <ShadowBehavior>();
                var owner_shadow_behavior = mOwner.GetBehavior <ShadowBehavior>();
                if (rider_shadow_behavior != null && owner_shadow_behavior != null)
                {
                    if (owner_shadow_behavior.ShadowType == ShadowType.REAL_SHADOW)
                    {
                        rider_shadow_behavior.ShadowType = ShadowType.REAL_SHADOW;
                    }
                    else
                    {
                        rider_shadow_behavior.ShadowType = ShadowType.NONE;
                    }

                    rider_shadow_behavior.RealShadow = owner_shadow_behavior.RealShadow;
                }

                while (this != null && this.IsDestroy == false && mRiderActor != null && mRiderActor.IsDestroy == false &&
                       (mRiderActor.mAvatarCtrl == null || mRiderActor.mAvatarCtrl.IsLoading(true)))
                {
                    if (mOwner == null || mOwner.IsDestroy)
                    {
                        mIsprocessingRide = false;
                        yield break;
                    }
                    yield return(null);
                }
            }
            if (this == null || this.IsDestroy)
            {
                yield break;
            }
            if (mOwner == null || mOwner.IsDestroy || mOwner.mAvatarCtrl == null)
            {
                mIsprocessingRide = false;
                yield break;
            }
            // DBGrowSkin db_skin = DBManager.Instance.GetDB<DBGrowSkin>();
            // DBGrowSkin.DBGrowSkinItem skin_item = null;
            //if(db_skin != null)
            //skin_item = db_skin.GetOneItem(GameConst.GROW_TYPE_RIDE, mCurrentRideId);
            mGrowSkinItem = skin_item;
            if (skin_item != null && mOwner != null && mOwner.IsDestroy == false && mOwner.mAvatarCtrl != null)
            {
                string prefab_name = RoleHelp.GetPrefabName(skin_item.ActorId, mOwner.mAvatarCtrl.IsLocalPlayerModel());
                if (string.IsNullOrEmpty(prefab_name))
                {
                    mOwner.mAvatarCtrl.ModelPrefab = null;
                    mIsprocessingRide = false;
                    yield break;
                }
                else
                {
                    mOwner.mAvatarCtrl.ModelPrefab = prefab_name;
                }
            }
            else
            {
                mIsprocessingRide = false;
                yield break;
            }
            if (ActorManager.Instance == null)
            {
                mIsprocessingRide = false;
                yield break;
            }
            yield return(ActorManager.Instance.StartCoroutine(mOwner.mAvatarCtrl.LoadAsync_public()));

            while (this != null && this.IsDestroy == false && mOwner != null && mOwner.IsDestroy == false && mOwner.mAvatarCtrl != null && mOwner.mAvatarCtrl.IsLoading(true))
            {
                yield return(null);
            }
            if (this == null || this.IsDestroy)
            {
                yield break;
            }
            if (mOwner == null || mOwner.IsDestroy || mOwner.transform == null)
            {
                mIsprocessingRide = false;
                yield break;
            }

            if (skin_item != null && mOwner != null && mOwner.IsDestroy == false && mOwner.mAvatarCtrl != null)
            {
                mOriginalScale = mOwner.mAvatarCtrl.ModelScale;
                mOwner.mAvatarCtrl.ModelScale = RoleHelp.GetPrefabScale(skin_item.ActorId);
            }

            //mount
            Transform mountPoint = xc.ui.ugui.UIHelper.FindChildInHierarchy(mOwner.transform, AvatarCtrl.MOUNT_POINT_NAME);

            if (mountPoint == null)
            {
                Debug.LogError(string.Format("mount point not found for {0}", AvatarCtrl.MOUNT_POINT_NAME, mCurrentRideId));
                //mount rider
                mIsprocessingRide = false;
                yield break;
            }
            float height = mountPoint.position.y - mOwner.transform.position.y;

            if (mRiderActor != null && mRiderActor.transform != null)
            {
                mRiderActor.transform.parent           = mountPoint;
                mRiderActor.transform.position         = mountPoint.position;
                mRiderActor.transform.localEulerAngles = new Vector3(0, 0, 0);
                mRiderActor.mAvatarCtrl.ResetElfinObject();
                mRiderActor.mAvatarCtrl.ResetSuitPos();
            }

            //animate
            mRideAnim = ANIMATION_RIDE;
            if (mOwner.IsWalking())
            {
                mOwner.Play(Actor.EAnimation.walk);
            }
            else
            {
                mOwner.Play(Actor.EAnimation.idle);
            }

            //mOwner.PlayLastAnimation_real();
            //mOwner.Play("idle");
            for (int index = 1; index < 3; ++index)
            {
                yield return(null);
            }
            if (this == null || this.IsDestroy)
            {
                yield break;
            }

            //mount rider
            mIsprocessingRide = false;

            if (mOwner == null || mOwner.IsDestroy || mOwner.transform == null || mRiderActor == null || mRiderActor.transform == null)
            {
                yield break;
            }
            mountPoint = xc.ui.ugui.UIHelper.FindChildInHierarchy(mOwner.transform, AvatarCtrl.MOUNT_POINT_NAME);
            Transform bip_transform = xc.ui.ugui.UIHelper.FindChildInHierarchy(mRiderActor.transform, "Bip001");

            if (mountPoint != null && bip_transform != null)
            {
                mRiderActor.transform.localPosition = mountPoint.InverseTransformVector(mountPoint.position - bip_transform.position);
            }

            //VocationInfo info = DBVocationInfo.Instance.GetVocationInfo((byte)mOwner.VocationID);
            string  idle_action_name = GetIdleActionWhenRidingName();
            Vector3 mount_offset     = DBVocationMountInfo.Instance.GetMountOffset((byte)mOwner.VocationID, idle_action_name);

            if (mount_offset.magnitude > 0.001f)
            {
                mRiderActor.transform.localPosition = mount_offset;
            }

            mOwner.ResetEffect();
            if (mOwner.MoveImplement != null)
            {
                mOwner.MoveImplement.OnResLoaded();
            }

            mOwner.OnModelChanged();

            if (mRiderActor.mAvatarCtrl != null)
            {
                mRiderActor.mAvatarCtrl.SetLayer(mOwner.GetLayer());
            }
            if (mRideFinishCallback != null)
            {
                mRideFinishCallback();
                mRideFinishCallback = null;
            }
        }
コード例 #17
0
        /// <summary>
        /// 处理actor创建成功
        /// </summary>
        /// <param name="actor"></param>
        public override void HandleActorCreate(Actor actor)
        {
            base.HandleActorCreate(actor);

            mActorUID = actor.UID;

            if (Actor == null)
            {
                return;
            }

            // 设置玩家坐标
            Actor.Stop();

            if (AppearInfo == null)
            {
                GameDebug.LogError("HandleActorCreate AppearInfo == null, uuid = " + UUID);
                return;
            }

            var unit_scale = GlobalConst.UnitScale;
            var x          = AppearInfo.pos.px * unit_scale;
            var z          = AppearInfo.pos.py * unit_scale;
            var pos        = new Vector3(x, RoleHelp.GetHeightInScene(Actor.ActorId, x, z), z);

            //pos = InstanceHelper.ClampInWalkableRange(pos);

            Actor.transform.position = pos;

            // 进入AOI视野增加buff
            if (BuffList != null)
            {
                uint server_time = Game.Instance.ServerTime;
                for (int i = 0; i < BuffList.Count; ++i)
                {
                    uint end_time = (uint)(BuffList[i].v / 1000);
                    uint second   = 1;
                    if (end_time > server_time)
                    {
                        second = end_time - server_time;
                    }
                    //GameDebug.LogError(string.Format("servertime = {0} BuffList[i].v = {1} second = {2}", server_time, end_time, second));
                    Actor.BuffCtrl.AddBuff(BuffList[i].k, second);
                }
            }

            if (FlagOperate.HasFlag(AppearBit, GameConst.APPEAR_BIT_IS_DEAD))// 初始就是死亡状态
            {
                if (!Actor.IsDead())
                {
                    Actor.BeattackedCtrl.KillSelf();
                }
            }
            else
            {
                if (Actor.IsDead())
                {
                    Actor.Relive();
                }
            }

            if (AppearInfo.speed > 0)
            {
                Actor.MoveCtrl.ReceiveWalkBegin(AppearInfo);
            }

            if (Info == null)
            {
                GameDebug.LogError("HandleActorCreate Info == null, uuid = " + UUID);
                return;
            }

            if (Info.war != null)
            {
                foreach (PkgAttrElm attrElm in Info.war.attr_elm)
                {
                    if (attrElm.attr == GameConst.AR_MAX_HP)
                    {
                        Actor.FullLife = attrElm.value;
                    }
                    else if (attrElm.attr == GameConst.AR_MAX_MP)
                    {
                        Actor.FullMp = attrElm.value;
                        Actor.CurMp  = Actor.FullMp; // 初始化时将蓝量加满
                    }
                }

                Actor.CurLife = Info.war.hp;
                // 进入AOI视野增加buff

                /*for(int i = 0; i < Info.war.buffs.Count; ++i)
                 * {
                 *  Actor.AuraCtrl.AddAura(Info.war.buffs[i].k);
                 * }*/
            }

            Actor.SubscribeActorEvent(Actor.ActorEvent.DEAD, OnActorDead);
            Actor.UpdateNameColor(Info.name_color);
            if (Info.war != null)
            {
                //Actor.PKLvProtect = Info.war.pk_lv_protect;
                Actor.UpdateByBitState(Info.bit_states);
            }

            WaittingLookExtList.Add(UUID);
        }
コード例 #18
0
        public void HandleAppear(PkgNwarMove appear, uint version, List <PkgKv> buffs, uint appear_bit)
        {
            DeadTime = 0f;

            var redundancy_appear = false;

            if (AppearInfo != null)
            {
                redundancy_appear = true;
            }

            AppearInfo = appear;
            BuffList   = buffs;
            AppearBit  = appear_bit;

            if (Actor != null)
            {
                if (FlagOperate.HasFlag(appear_bit, GameConst.APPEAR_BIT_IS_DEAD))// 初始就是死亡状态
                {
                    if (!Actor.IsDead())
                    {
                        Actor.BeattackedCtrl.KillSelf();
                    }
                }
                else
                {
                    if (Actor.IsDead())
                    {
                        Actor.Relive();
                    }
                }

                // Actor已经创建了,直接更新下就好
                var unit_scale = GlobalConst.UnitScale;
                var x          = AppearInfo.pos.px * unit_scale;
                var z          = AppearInfo.pos.py * unit_scale;
                var pos        = new Vector3(x, RoleHelp.GetHeightInScene(Actor.ActorId, x, z), z);

                Actor.transform.position = pos;

                // 进入AOI视野增加buff
                if (BuffList != null)
                {
                    uint server_time = Game.Instance.ServerTime;
                    for (int i = 0; i < BuffList.Count; ++i)
                    {
                        uint end_time = (uint)(BuffList[i].v / 1000);
                        uint second   = 1;
                        if (end_time > server_time)
                        {
                            second = end_time - server_time;
                        }
                        //GameDebug.LogError(string.Format("servertime = {0} BuffList[i].v = {1} second = {2}", server_time, end_time, second));
                        Actor.BuffCtrl.AddBuff(BuffList[i].k, second);
                    }
                }

                if (AppearInfo.speed > 0)
                {
                    Actor.MoveCtrl.ReceiveWalkBegin(appear);
                }

                // version有变化的时候更新缓存
                if (Info != null && Info.version != version)
                {
                    SendUpdateInfo();
                }

                return;
            }

            // 如果已经appear过了,不要再处理了
            if (redundancy_appear)
            {
                return;
            }

            if (Info == null || IsInfoOutOfDate || Info.version != version)
            {
                // 获取玩家信息
                SendUpdateInfo();
                return;
            }

            if (!mIsWaittingCreateActor)
            {
                CreateActor();
            }
        }
コード例 #19
0
        public string GetStepFixedDescription(int stepIndex)
        {
            var step = GetStep(stepIndex);

            if (step == null || step.Description == null)
            {
                return(string.Empty);
            }

            string result = DBConstText.GetText(step.Description);

            // 对目标名字进行替换
            if (step.Goal == GameConst.GOAL_TALK)
            {
                result = string.Format(result, NpcHelper.GetNpcName(step.InstanceId, step.NpcId));
            }
            else if (step.Goal == GameConst.GOAL_KILL_MON)
            {
                result = string.Format(result, RoleHelp.GetActorName(step.MonsterId));
            }
            else if (step.Goal == GameConst.GOAL_INTERACT)
            {
                result = string.Format(result, RoleHelp.GetActorName(NpcHelper.MakeNpcDefine(step.NpcId).ActorId));
            }
            else if (step.Goal == GameConst.GOAL_KILL_COLLECT)
            {
                result = string.Format(result, GoodsHelper.GetGoodsOriginalNameByTypeId(step.GoodsId));
            }
            else if (step.Goal == GameConst.GOAL_COLLECT_GOODS)
            {
                if (step.MinWorldBossSpecialMonId > 0 && step.MaxWorldBossSpecialMonId > 0)
                {
                    DBSpecialMon dbSpecialMon = DBManager.Instance.GetDB <DBSpecialMon>();
                    uint         minLevel     = dbSpecialMon.GetSpecialMonLevel(step.MinWorldBossSpecialMonId);
                    uint         maxLevel     = dbSpecialMon.GetSpecialMonLevel(step.MaxWorldBossSpecialMonId);
                    result = string.Format(result, minLevel, maxLevel, GoodsHelper.GetGoodsOriginalNameByTypeId(step.GoodsId));
                }
                else
                {
                    result = string.Format(result, GoodsHelper.GetGoodsOriginalNameByTypeId(step.GoodsId));
                }
            }
            else if (step.Goal == GameConst.GOAL_WAR_WIN || step.Goal == GameConst.GOAL_WAR_ENTER || step.Goal == GameConst.GOAL_WAR_GRADE)
            {
                result = string.Format(result, InstanceHelper.GetInstanceName(step.InstanceId2));
            }
            else if (step.Goal == GameConst.GOAL_EQUIP_SUBMIT)
            {
                result = string.Format(result, GoodsHelper.GetGoodsColorName(step.EquipColor) + xc.Equip.EquipHelper.GetEquipLvStepName(step.EquipLvStep));
            }
            else if (step.Goal == GameConst.GOAL_SECRET_AREA)
            {
                result = string.Format(result, InstanceHelper.GetKungfuGodInstanceName(step.SecretAreaId));
            }
            else if (step.Goal == GameConst.GOAL_TRIGRAM)
            {
                result = string.Format(result, TaskHelper.GetTrigramName(step.TrigramId));
            }
            else if (step.Goal == GameConst.GOAL_EQUIP_WEAR)
            {
                result = string.Format(result, GoodsHelper.GetGoodsColorName(step.EquipColor) + xc.Equip.EquipHelper.GetEquipLvStepName(step.EquipLvStep));
            }
            else if (step.Goal == GameConst.GOAL_EQUIP_STRENGTH)
            {
                result = string.Format(result, step.EquipStrenghtLv);
            }
            else if (step.Goal == GameConst.GOAL_EQUIP_GEM)
            {
            }
            else if (step.Goal == GameConst.GOAL_PET_LV)
            {
                result = string.Format(result, step.PetLv);
            }
            else if (step.Goal == GameConst.GOAL_GROW_LV)
            {
            }
            else if (step.Goal == GameConst.GOAL_STIGMA_LV)
            {
                DBStigma dbStigma = DBManager.Instance.GetDB <DBStigma>();
                DBStigma.DBStigmaInfo stigmaInfo = dbStigma.GetOneDBStigmaInfo(step.StigmaId);
                if (stigmaInfo != null)
                {
                    string name = stigmaInfo.Name;
                    result = string.Format(result, name);
                }
                else
                {
                    GameDebug.LogError("GetStepFixedDescription error, can not find stigma info by id " + step.StigmaId);
                }
            }
            else if (step.Goal == GameConst.GOAL_DRAGON_SOUL)
            {
                result = string.Format(result, step.ExpectResult);
            }
            else if (step.Goal == GameConst.GOAL_EQUIP_STRENGTH_TLV)
            {
                result = string.Format(result, step.EquipStrenghtLv);
            }
            else if (step.Goal == GameConst.GOAL_KILL_BOSS)
            {
                if (step.MonsterLevel > 0)
                {
                    result = string.Format(result, step.ExpectResult, step.MonsterLevel);
                }
                else
                {
                    result = string.Format(result, step.ExpectResult);
                }
            }
            else if (step.Goal == GameConst.GOAL_LIGHT_EQUIP)
            {
                List <string> names = DBManager.Instance.QuerySqliteField <string>(GlobalConfig.DBFile, "data_light_equip", "id", step.LightEquipLv.ToString(), "desc");
                if (names != null && names.Count > 0)
                {
                    result = string.Format(result, names[0]);
                }
            }
            else
            {
                result = TaskHelper.GetStepFixedDescriptionByLua(step);
            }
            return(result);
        }