Example #1
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);
        }
Example #2
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
     );
 }
Example #3
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);
            EventDispatcher.TriggerEvent(Events.LogicSoundEvent.OnHitYelling, theOwner as EntityParent, action);

            // 回调函数, 切换到 idle
            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);
                    }
                },
                theOwner, hitActionID
            );
        }
Example #4
0
        // 为去除警告暂时屏蔽以下代码
        //private uint stiffTotal = 0;
        virtual public void OnHit(int _actionID, uint _attackerID, uint woundId, List <int> harm)
        {
            if (theOwner.CurrentMotionState == MotionState.DEAD)
            {
                return;
            }
            if (theOwner.currSpellID != -1)
            {//专为旋风斩之类有duration的技能临时做
                SkillData s = SkillData.dataMap[theOwner.currSpellID];
                if (SkillAction.dataMap[s.skillAction[0]].duration > 0)
                {
                    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 ((theOwner is EntityMyself) && (MapData.dataMap.Get(MogoWorld.thePlayer.sceneId).type == MapType.ARENA))
            {//如果主角在竞技场内受到HIT,无视之,不进受击状态
                List <int> hitAction2 = SkillAction.dataMap[_actionID].hitAction;
                if (hitAction2 == null || hitAction.Count == 0)
                {
                    return;
                }
                int action2 = Utils.Choice <int>(hitAction2);
                if (action2 == ActionConstants.HIT)
                {
                    return;
                }
            }


            if (MogoWorld.showHitAction && _act > 0 && theOwner.curHp > 0 &&
                !actName.EndsWith("getup") &&
                !actName.EndsWith("knockout") &&
                !actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT_GROUND]) &&
                //!theOwner.IsInTransition() &&
                cfgShow)
            {//如果没填就不做受击表现
                theOwner.ChangeMotionState(MotionState.HIT, _actionID, _attackerID);
            }
            if (MogoWorld.showHitEM && !(theOwner is EntityMonster) && action.hitExtraSpeed != 0)
            {
                theOwner.motor.SetExrtaSpeed(-action.hitExtraSpeed);
                theOwner.motor.SetMoveDirection(theOwner.Transform.forward);
                TimerHeap.AddTimer <EntityParent>((uint)(action.hitExtraSl * 1000), 0, (e) => {
                    if (e == null || e.motor == null)
                    {
                        return;
                    }
                    e.motor.SetExrtaSpeed(0);
                }, theOwner);
            }
        }