Exemple #1
0
    /// <summary>
    /// 激活行为.
    /// </summary>
    public override void Active()
    {
        base.Active();

        curPosition = beginPosition = KingSoftCommonFunction.NearPosition(hero.Position);
        endPosition = KingSoftCommonFunction.NearPosition(endPosition);
        NavMesh.CalculatePath(beginPosition, endPosition, -1, path);

        steps    = path.corners;
        stepsLen = steps.Length;
        if (stepsLen <= 1)
        {
            endPosition = curPosition;
            isFinish    = true;
            return;
        }
        curStepIndex = 1;
        if (stepsLen > 1)
        {
            SendNextDistance();
        }
        isFinish = false;


        if (Vector3.Distance(hero.Position, endPosition) < deltaSpace)
        {
            hero.Position = KingSoftCommonFunction.GetGoundHeight(hero.Position);
            Vector3 forward = endPosition - hero.Position;
            forward      = new Vector3(forward.x, 0, forward.z);
            hero.Forward = forward;
            OnDistanceChange(hero.Position);
            isFinish = true;
        }
    }
Exemple #2
0
    /// <summary>
    /// Update this instance.
    /// </summary>
    public override void Update()
    {
        if (Vector3.Distance(hero.Position, endPosition) < deltaSpace)
        {
            Vector3 forward = endPosition - hero.Position;
            forward      = new Vector3(forward.x, 0, forward.z);
            hero.Forward = forward;
            isFinish     = true;
            return;
        }

        if (curStepIndex < stepsLen)
        {
            curPosition = new Vector3(hero.Position.x, curPosition.y, hero.Position.z);
            bool    b       = KingSoftMath.MoveTowards(ref curPosition, steps[curStepIndex], speed * Time.deltaTime);
            Vector3 forward = curPosition - hero.Position;
            forward = new Vector3(forward.x, 0, forward.z);
            if (forward.x != 0 || forward.z != 0)
            {
                hero.Rotation = Quaternion.RotateTowards(hero.Rotation, Quaternion.LookRotation(forward), 600f * Time.deltaTime);
            }
            hero.Position = KingSoftCommonFunction.GetGoundHeight(curPosition);
            if (b)
            {
                curStepIndex++;
                if (curStepIndex == stepsLen)
                {
                    hero.Position = endPosition;
                    isFinish      = true;
                }
                else
                {
                    SendNextDistance();
                }
            }
            else if (curStepIndex == stepsLen - 1 && deltaSpace > 0)
            {
                if (Vector3.Distance(curPosition, steps[curStepIndex]) < deltaSpace)
                {
                    hero.Position = KingSoftCommonFunction.GetGoundHeight(curPosition);
                    hero.Forward  = forward;
                    OnDistanceChange(hero.Position);
                    isFinish = true;
                }
            }
        }
        else
        {
            isFinish = true;
        }
    }
    /// <summary>
    /// Update this instance.
    /// </summary>
    public override void Update()
    {
        bool b = KingSoftMath.MoveTowards(ref curPosition, endPosition, speed * Time.deltaTime);

        if (b)
        {
            isFinish      = true;
            hero.Position = KingSoftCommonFunction.GetGoundHeight(curPosition);
        }
        else
        {
            hero.Position = curPosition;
        }
    }
Exemple #4
0
        public object OnMoveToDestination(params object[] objs)
        {
            if (objs.Length < 1)
            {
                return(null);
            }

            Vector3 _destination;

            _destination = (Vector3)objs[0];

            bool sendMessage = false;

            if (objs.Length >= 2)
            {
                sendMessage = Convert.ToBoolean(objs[1]);
            }

            if (Owner.property.isMainHero)
            {
                Owner.property.finalDestination = KingSoftCommonFunction.GetGoundHeight(_destination);
                AnimationComponent.OperaWalking = true;
            }

            EventRet ret  = Owner.DispatchEvent(ControllerCommand.TryFinishAction);
            bool     bRet = (bool)ret.GetReturn <AnimationComponent>();

            if (bRet)
            {
                ActionWalk walk = new ActionWalk(Owner);
                if (objs.Length >= 3)
                {
                    walk.deltaSpace = (float)(objs[3]);
                }
                walk.speed       = Owner.Speed;
                walk.IsPushStack = sendMessage;
                walk.endPosition = _destination;
                Owner.DispatchEvent(ControllerCommand.SetActiveAction, walk);
            }
            else
            {
                Owner.DispatchEvent(ControllerCommand.ActionMoveToDistance, _destination, Owner.Speed, sendMessage);
            }

            return(null);
        }
Exemple #5
0
    /// <summary>
    /// 激活行为.
    /// </summary>
    public override void Active()
    {
        base.Active();
        curPosition = beginPosition = hero.Position;
        endPosition = KingSoftCommonFunction.GetGoundHeight(endPosition);
        forward     = (endPosition - beginPosition).normalized;
        distance    = Vector3.Distance(beginPosition, endPosition);
        float deltaY = Mathf.Abs(curPosition.y - beginPosition.y);


        if (type == ThrowUpType.DISTANCE)
        {
            deltaHeight = beginPosition.y - endPosition.y;                                              //因为服务器的速度是水平的速度.
            curPosition = beginPosition = new Vector3(beginPosition.x, endPosition.y, beginPosition.z); //起点和终点放在一个水平面上.
            float v = (speed + endSpeed) / 2;
            totalTime = distance / v;
            a         = (endSpeed - speed) / totalTime;
        }
    }
Exemple #6
0
    public virtual void InitParam(AnimActionParam param, KSkillDisplay skillDisplay)
    {
        displayInfor    = skillDisplay;
        WeaponPosition  = displayInfor.WeaponPosition;
        skillId         = param.skillId;
        targetId        = param.targetId;
        level           = param.level;
        target          = param.target;
        endPosition     = KingSoftCommonFunction.GetGoundHeight(KingSoftCommonFunction.NearPosition(param.position));
        activeSkill     = KConfigFileManager.GetInstance().GetActiveSkill(skillId, level);
        FirstAttackTime = 0;
        animArys        = displayInfor.Anim.Split('|');
        int [] ids = KingSoftCommonFunction.RandomAry(animArys.Length);
        beginFxs = displayInfor.BeginEffect.Split('|');
        beginFxs = KingSoftCommonFunction.GrowArrays(beginFxs, animArys.Length);
        if (isRandomAnim)
        {
            animArys = KingSoftCommonFunction.RandomAryByList(animArys, ids);
            beginFxs = KingSoftCommonFunction.RandomAryByList(beginFxs, ids);
        }
        if (beginFxs[0].Length > 0)
        {
            AssetLoader.GetInstance().PreLoad(URLUtil.GetResourceLibPath() + beginFxs[0]);
        }
        if (displayInfor.EndEffect.Length > 0)
        {
            AssetLoader.GetInstance().PreLoad(URLUtil.GetResourceLibPath() + displayInfor.EndEffect);
        }
        if (displayInfor.BulletEffect.Length > 0)
        {
            AssetLoader.GetInstance().PreLoad(URLUtil.GetResourceLibPath() + displayInfor.BulletEffect);
        }

        try
        {
            string [] AttackTimes = activeSkill.AttackTimeList.Split(';');
            if (displayInfor.CameraEffect.CompareTo("SHAKE_ALL") == 0)
            {
                foreach (string _t in AttackTimes)
                {
                    try
                    {
                        shakeTimes.Add((float)System.Convert.ToDouble(_t));
                    }
                    catch (System.Exception e)
                    {
                    }
                }
                if (shakeTimes.Count > 0)
                {
                    FirstAttackTime = (float)shakeTimes[0];
                }
            }
            else
            {
                if (AttackTimes.Length > 0)
                {
                    try
                    {
                        FirstAttackTime = (float)System.Convert.ToDouble(AttackTimes[0]);
                    }
                    catch (System.Exception e)
                    {
                    }
                }
            }
            if (activeSkill.ClientCache)
            {
                KAminEvent _event = KConfigFileManager.GetInstance().GetAnimEvent(hero.property.tabID, animArys[0]);
                if (null == _event)
                {
                    FirstAttackTime = hero.AnimCmp.GetAnimLong(animArys[0]) - 0.3f;
                }
                else
                {
                    FirstAttackTime = _event.time;
                }
            }
        }
        catch (System.Exception e) {
        }
        hitTicker.SetCD(FirstAttackTime);
        finishTicker.SetCD(FirstAttackTime + displayInfor.hitDelay);
    }
Exemple #7
0
        public object OnDestinationChange(params object[] objs)
        {
            Vector3 destination = (Vector3)objs[0];

            destination = KingSoftCommonFunction.GetGoundHeight(KingSoftCommonFunction.NearPosition(destination));
            int moveType = (int)objs[1];

            Owner.property.destination = destination;
            if (!Owner.property.isMainHero)
            {
                Owner.property.finalDestination = KingSoftCommonFunction.GetGoundHeight(KingSoftCommonFunction.NearPosition(destination));
            }
            if (Owner.Position == Owner.property.destination)
            {
                return(null);
            }
            if (moveType == (int)KForceMoveType.fmtJump)
            {
                Owner.DispatchEvent(ControllerCommand.Jump, destination);
                return(null);
            }
            else if (moveType == (int)KForceMoveType.fmtRush)
            {
                Owner.DispatchEvent(ControllerCommand.Drag, destination);
                return(null);
            }
            else if (moveType == (byte)KForceMoveType.fmtPull)
            {
                Owner.DispatchEvent(ControllerCommand.Drag, destination);
                return(null);
            }
            else if (moveType == (byte)KForceMoveType.fmtBack)
            {
                Owner.DispatchEvent(ControllerCommand.Back, destination);
                return(null);
            }
            else if (moveType == (byte)KForceMoveType.fmtPlayerFuKong)
            {
                Owner.DispatchEvent(ControllerCommand.FuKong, destination);
                return(null);
            }
            else //if (moveType == (byte)KForceMoveType.fmtInvalid)
            {
                bool bRet = Owner.ActiveAction.TryFinish();
                if (!bRet)
                {
                    bool bRet2 = Owner.ActiveAction.MoveToDistance(destination, Owner.Speed);
                    if (bRet2)
                    {
                        if (Owner.property.isMainHero)
                        {
                            Owner.property.finalDestination = KingSoftCommonFunction.GetGoundHeight(KingSoftCommonFunction.NearPosition(destination));
                        }
                        return(null);
                    }
                }
                if (Owner.Position.x == destination.x && Owner.Position.z == destination.z)
                {
                    Owner.Position = destination;
                    return(null);
                }
                ActionWalk walk = new ActionWalk(Owner);
                walk.speed       = Owner.Speed;
                walk.IsPushStack = false;
                walk.endPosition = destination;
                Owner.DispatchEvent(ControllerCommand.SetActiveAction, walk);
            }
            return(null);
        }