示例#1
0
    private void HitActionRule(EntityParent theOwner, int act, int hitActionID)
    {
        int    action  = act;
        string actName = theOwner.CurrActStateName();

        if (actName.EndsWith(PlayerActionNames.names[ActionConstants.KNOCK_DOWN]))
        {//击飞状态,受非浮空打击,一直倒地
            action = ActionConstants.KNOCK_DOWN;
            return;
        }
        if (actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT_AIR]))
        {//浮空受击
            action = ActionConstants.HIT_AIR;
        }
        else if (actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT_GROUND]) || actName.EndsWith("knockout"))
        {
            action = ActionConstants.HIT_GROUND;
        }
        else if ((theOwner is EntityMyself) && (action == ActionConstants.HIT_AIR || action == ActionConstants.KNOCK_DOWN))
        {
            int random = Mogo.Util.RandomHelper.GetRandomInt(0, 100);
            if (random <= 70)
            {//主角受到倒地状态影响时,只有30%机会成功,否则变成普通受击 By.铭
                action = ActionConstants.HIT;
            }
        }

        theOwner.SetAction(action);

        // 回调函数, 切换到 idle
        if (changeIdleTime > 0)
        {
            TimerHeap.DelTimer(changeIdleTime);
        }
        changeIdleTime = TimerHeap.AddTimer <EntityParent, int>(100, 0,
                                                                (_theOwner, _hitAct) =>
        {
            if (_theOwner == null)
            {
                return;
            }
            if (_theOwner.Motor != null)
            {
                _theOwner.Motor.CancleLookAtTarget();
            }
            //_theOwner.TriggerUniqEvent<int>(Events.FSMMotionEvent.OnHitAnimEnd, _hitAct);
            if (_theOwner is EntityMyself)
            {
                _theOwner.SetSpeed(0);
                _theOwner.Motor.SetSpeed(0);
            }
            if (_theOwner is EntityMonster)
            {
                _theOwner.ChangeState(FSMStateType.Attacking);
            }
        },
                                                                theOwner, hitActionID
                                                                );
    }
示例#2
0
        // 状态处理
        public void Process(EntityParent theOwner, params Object[] args)
        {
            int action = ActionConstants.DIE;

            theOwner.ApplyRootMotion(true);
            string actName = theOwner.CurrActStateName();

            if (actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT_AIR]) || actName.EndsWith("getup"))
            {
                action = ActionConstants.DIE_KNOCK_DOWN;
                theOwner.SetAction(action);
            }
            else if (actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT_GROUND]) || actName.EndsWith("knockout"))
            {
                action = ActionConstants.DIE;
                theOwner.SetAction(action);
            }
            else
            {
                int        hitActionID = (int)(args[0]);
                List <int> deadAction  = null;
                if (SkillAction.dataMap.ContainsKey(hitActionID))
                {
                    deadAction = SkillAction.dataMap[hitActionID].deadAction;
                }
                action = ActionConstants.DIE;
                if (deadAction == null || deadAction.Count == 0)
                {
                    action = ActionConstants.DIE;
                }
                else
                {
                    action = Utils.Choice <int>(deadAction);
                }
                theOwner.SetAction(action);
            }

            theOwner.SetSpeed(0);
            EventDispatcher.TriggerEvent(Events.LogicSoundEvent.OnHitYelling, theOwner as EntityParent, action);

            if (theOwner is EntityMyself && theOwner.motor)
            {
                theOwner.motor.enableStick = false;
            }
            //theOwner.AddCallbackInFrames<int>(theOwner.SetAction, 0);
        }
示例#3
0
        private void HitRule(EntityParent theOwner, int act, int hitActionID)
        {
            int      action = act;
            HitState h      = null;

            if (!HitState.dataMap.TryGetValue(theOwner.hitStateID, out h))
            {//如果没有配置,用回原来接口
                HitActionRule(theOwner, action, hitActionID);
                return;
            }
            string actName = theOwner.CurrActStateName();

            if (theOwner.currSpellID != -1)
            {
                action = h.GetSkillAct(action);
            }
            else if (actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT]))
            {
                action = h.GetHitAct(action);
            }
            else if (actName.EndsWith(PlayerActionNames.names[ActionConstants.PUSH]))
            {
                action = h.GetPushAct(action);
            }
            else if (actName.EndsWith(PlayerActionNames.names[ActionConstants.KNOCK_DOWN]))
            {
                action = h.GetKnockDownAct(action);
            }
            else if (actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT_AIR]))
            {
                action = h.GetHitAirAct(action);
            }
            else if (actName.EndsWith("knockout"))
            {
                action = h.GetKnockOutAct(action);
            }
            else if (actName.EndsWith("getup"))
            {
                action = h.GetGetUpAct(action);
            }
            else if (theOwner.animator.GetInteger("Action") == ActionConstants.REVIVE)
            {
                action = h.GetReviveAct(action);
            }
            else //(theOwner.CurrentMotionState == MotionState.IDLE)
            {
                action = h.GetIdleAct(action);
            }
            if (action != 0)
            {
                theOwner.SetAction(action);
            }
            // 回调函数, 切换到 idle
            theOwner.AddCallbackInFrames <EntityParent, int>(
                (_theOwner, _hitAct) =>
            {
                _theOwner.motor.CancleLookAtTarget();
                _theOwner.TriggerUniqEvent <int>(Events.FSMMotionEvent.OnHitAnimEnd, _hitAct);
                if (_theOwner is EntityMyself)
                {
                    _theOwner.SetSpeed(0);
                    _theOwner.motor.SetSpeed(0);
                }
            },
                theOwner, hitActionID
                );
        }
    virtual public void OnHit(int _actionID, uint _attackerID, uint woundId, List <int> harm)
    {
        if (woundId != theOwner.ID)
        {
            return;
        }
        //TODO如果死了return

        if (!theOwner.immuneShift)
        {
            theOwner.ClearSkill(true);
        }
        SkillAction action = SkillAction.dataMap[_actionID];

        if (action.hitSfx != null && action.hitSfx[0] > 0)
        {
            theOwner.PlayFX((int)action.hitSfx[0]);
        }
        //HitBuff(action);
        List <int> hitAction = action.hitAction;

        if (hitAction == null || hitAction.Count == 0 || theOwner.immuneShift)
        {
            return;
        }
        int  _act    = Utils.Choice <int>(hitAction);
        bool cfgShow = true;
        //if (((theOwner is EntityMonster) && (theOwner as EntityMonster).ShowHitAct != 0) ||
        //    ((theOwner is EntityDummy) && (theOwner as EntityDummy).ShowHitAct != 0) ||
        //    ((theOwner is EntityMercenary) && (theOwner as EntityMercenary).ShowHitAct != 0))
        //{
        //    cfgShow = false;
        //}
        string actName = theOwner.CurrActStateName();

        if (GameWorld.showHitAction && _act > 0 && theOwner.curHp > 0 &&
            !actName.EndsWith("getup") &&
            !actName.EndsWith("knockout") &&
            !actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT_GROUND]) &&
            //!theOwner.IsInTransition() &&
            cfgShow)
        {//如果没填就不做受击表现
            //TODO切换被击状态
            //theOwner.SetAction(_act);
            //theOwner.Actor.AddCallbackInFrames<int>(theOwner.SetAction, 0);
            theOwner.ChangeState(FSMStateType.Hit, _actionID, _attackerID);
        }
        if (GameWorld.showHitEM && !(theOwner is EntityMonster) && action.hitExtraSpeed != 0)
        {
            theOwner.Motor.SetExrtaSpeed(-action.hitExtraSpeed);
            theOwner.Motor.SetMoveDirection(theOwner.transform.forward);
            TimerHeap.AddTimer <EntityParent>((uint)(action.hitExtraSl), 0, (e) =>
            {
                if (e == null || e.Motor == null)
                {
                    return;
                }
                e.Motor.SetExrtaSpeed(0);
            }, theOwner);
        }
    }