示例#1
0
            /// <summary>
            /// 方向和速度是否都相同
            /// </summary>
            public bool Equal(PkgNwarMove moveData)
            {
                if (moveData == null)
                {
                    return(false);
                }

                float vx = moveData.speed * Mathf.Cos(moveData.dir);
                float vy = moveData.speed * Mathf.Sin(moveData.dir);

                //pos_x == moveData.px && pos_y == moveData.py &&
                return(Mathf.Approximately(dir_x, vx) && Mathf.Approximately(dir_y, vy) &&
                       speed == moveData.speed);
            }
示例#2
0
            /// <summary>
            /// 给滑动数据赋值
            /// </summary>
            public void Assign(PkgNwarMove moveData)
            {
                if (moveData == null)
                {
                    return;
                }

                float vx = moveData.speed * Mathf.Cos(moveData.dir);
                float vy = moveData.speed * Mathf.Sin(moveData.dir);

                //pos_x = moveData.px;
                //pos_y = moveData.py;
                dir_x = vx;
                dir_y = vy;
                speed = (int)moveData.speed;
            }
示例#3
0
        public void HandleAppear(PkgNwarMove appear, List <PkgKv> buffs)
        {
            AppearInfo = appear;
            BuffList   = buffs;

            if (Actor != null)
            {
                // 进入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);
                    }
                }

                // Actor已经创建了,直接更新下就好
                Actor.MoveCtrl.ReceiveWalkBegin(appear);
                return;
            }

            // 怪物是不需要发送look的
            if (Info == null)
            {
                return;
            }

            if (IsInfoOutOfDate)
            {
                // 获取玩家信息
                SendUpdateInfo();
                return;
            }

            if (!mIsWaittingCreateActor)
            {
                CreateActor();
            }
        }
示例#4
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);
            }
        }
示例#5
0
        /// <summary>
        /// 开始朝方向移动时,发送消息
        /// </summary>
        protected void SendWalkBegin(Vector3 dir, bool force_sendmsg)
        {
            if (!mIsSendMsg)
            {
                return;
            }

            dir.Normalize();

            // 通过限制夹角来控制方向同步的频率
            float curAngle = Maths.Util.VectorToAngle(dir);

            if (mLastSendAngle != -100 && force_sendmsg == false)
            {
                if (Mathf.Abs(curAngle - mLastSendAngle) < minAngle)
                {
                    return;
                }
            }

            mLastSendAngle = curAngle;

            Vector3 pos = mOwner.Trans.position;

            C2SNwarMove c2sMove   = new C2SNwarMove();
            PkgNwarMove move_data = new PkgNwarMove();

            move_data.id = mOwner.UID.obj_idx;
            //move_data.type = (uint)walk_type;
            PkgNwarPos nwarPos = new PkgNwarPos();

            nwarPos.px    = (int)(pos.x * 100);
            nwarPos.py    = (int)(pos.z * 100);
            move_data.pos = nwarPos;
            //move_data.dir = Mathf.Atan(dir.z / dir.x);
            move_data.dir   = Maths.Util.VectorToAngle(dir);
            move_data.speed = (uint)(mOwner.MoveSpeed * 100);
            c2sMove.move    = move_data;

            Net.NetClient.GetCrossClient().SendData <C2SNwarMove>(NetMsg.MSG_NWAR_MOVE, c2sMove);
            mIsMoving = true;
            mLastSendMovePackageTime = Time.realtimeSinceStartup;
            mLastSendMoveDir         = dir;
            //GameDebug.Log("<<<MSG_NWAR_MOVE, dirx: " + dir.x + " diry: " + dir.z);
        }
        /// <summary>
        /// 开始
        /// </summary>
        public override bool Begin(SkillAction action)
        {
            base.Begin(action);

            m_DynamicStageTime = mSkillAction.ActionData.CastingStageTime;
            m_RealTargetPos    = Vector3.zero;

            // 判定是否要进入持续施法阶段
            if (mSkillAction.ActionData.SkillInfo.CastingTime <= 0.0f)
            {
                return(false);
            }

            Actor src_actor = mSkillAction.SkillParent.SrcActor;

            // 技能的隐身
            if (mSkillAction.ActionData.SkillInfo.Invisible)
            {
                if (src_actor.mVisibleCtrl.VisibleMode == EVisibleMode.Visible)
                {
                    mSkillAction.HideActor = true;
                    src_actor.mVisibleCtrl.SetActorVisible(false, true, false, VisiblePriority.SKILL);
                }
            }

            // 播放动画
            string casting_ani = mSkillAction.ActionData.CastingAnimation;

            if (casting_ani != string.Empty && casting_ani != mSkillAction.ActionData.SkillAnimation)
            {
                src_actor.Play(mSkillAction.ActionData.CastingAnimation);
            }
            src_actor.SetAnimationSpeed(mSkillAction.SkillParent.SpeedScale);

            // 施法阶段的位移
            MoveCtrl move_ctrl = src_actor.MoveCtrl;

            mSkillAction.SkillParent.MovingSpeed = mSkillAction.ActionData.SkillInfo.CastingSpeed;
            src_actor.MoveSpeed = mSkillAction.ActionData.SkillInfo.CastingSpeed;
            mSkillAction.BeginMove();

            uint target_id = mSkillAction.SkillParent.TargetID;     // 目标玩家的id

            if (target_id == 0)                                     // 无目标玩家
            {
                move_ctrl.MoveDirInAttacking(src_actor.ForwardDir); // 沿当前方向移动
                Vector3 src_pos = src_actor.Trans.position;
                m_RealTargetPos = src_pos + mSkillAction.SkillParent.AttackDir * mSkillAction.ActionData.SkillInfo.CastingSpeed * mSkillAction.ActionData.CastingStageTime;
                XNavMeshHit hit;
                if (XNavMesh.Raycast(src_pos, m_RealTargetPos, out hit, xc.Dungeon.LevelManager.GetInstance().AreaExclude))
                {
                    m_RealTargetPos = PhysicsHelp.BoundaryHitPos(src_pos, hit.position);
                }
            }
            else// 有目标玩家
            {
                Vector3 src_pos      = src_actor.Trans.position;
                Actor   target_actor = ActorManager.Instance.GetPlayer(target_id);// 获取目标玩家

                Vector3 target_pos = Vector3.zero;
                if (target_actor != null)
                {
                    target_pos = target_actor.Trans.position;
                    Vector3 vec = target_pos - src_pos;
                    float   len = vec.magnitude;

                    if (len > mSkillAction.RushTargetRange)
                    {
                        float real_len = len - mSkillAction.RushTargetRange;
                        target_pos = src_pos + vec * real_len / len;
                        XNavMeshHit hit;
                        if (XNavMesh.Raycast(src_pos, target_pos, out hit, xc.Dungeon.LevelManager.GetInstance().AreaExclude))
                        {
                            target_pos = PhysicsHelp.BoundaryHitPos(src_pos, hit.position);
                        }

                        if (mSkillAction.ActionData.SkillInfo.CastingSpeed != 0)
                        {
                            m_RealTargetPos = target_pos;
                            float calc_castingTime = real_len / mSkillAction.ActionData.SkillInfo.CastingSpeed;// 根据距离和速度计算施法阶段的时间
                            float fix_castingTime  = mSkillAction.ActionData.CastingStageTime;
                            if (calc_castingTime < fix_castingTime)
                            {
                                m_DynamicStageTime = calc_castingTime;
                            }
                        }
                    }
                    else
                    {
                        target_pos         = src_pos;
                        m_DynamicStageTime = 0;
                    }

                    move_ctrl.MoveDirInAttacking(vec);// 冲到目标点的方向
                }
                else
                {
                    target_pos = src_pos + mSkillAction.SkillParent.AttackDir * mSkillAction.ActionData.SkillInfo.CastingSpeed * mSkillAction.ActionData.CastingStageTime;
                    XNavMeshHit hit;
                    if (XNavMesh.Raycast(src_pos, target_pos, out hit, xc.Dungeon.LevelManager.GetInstance().AreaExclude))
                    {
                        target_pos      = PhysicsHelp.BoundaryHitPos(src_pos, hit.position);
                        m_RealTargetPos = target_pos;
                    }
                }

                if (src_actor.AttackCtrl.mIsSendMsg)
                {
                    C2SNwarChargeStop charge_stop = new C2SNwarChargeStop();
                    charge_stop.skill_id = mSkillAction.ActionData.SkillInfo.Id;
                    PkgNwarMove move = new PkgNwarMove();
                    move.id = src_actor.UID.obj_idx;
                    PkgNwarPos pos = new PkgNwarPos();
                    pos.px           = (int)(target_pos.x * 100);
                    pos.py           = (int)(target_pos.z * 100);
                    move.pos         = pos;
                    move.speed       = 0;
                    move.time        = 0;
                    charge_stop.move = move;

                    NetClient.GetCrossClient().SendData <C2SNwarChargeStop>(NetMsg.MSG_NWAR_CHARGE_STOP, charge_stop);
                }
            }


            return(true);
        }
示例#7
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();
            }
        }