Esempio n. 1
0
 public void InitAsLeanState(IFsmTransitionHelper infoProvider, ICharacterInfoProvider characterInfo)
 {
     AddState(PostureState.CreateNoPeekState(), infoProvider, characterInfo);
     AddState(PostureState.CreatePeekLeftState(), infoProvider, characterInfo);
     AddState(PostureState.CreatePeekRightState(), infoProvider, characterInfo);
     _resetParam = ResetLeanStateParam;
 }
Esempio n. 2
0
        public void InitCommon(IFsmTransitionHelper infoProvider, ICharacterInfoProvider characterInfo)
        {
            AddState(ActionState.CreateCommonNullState(), infoProvider, characterInfo);

            AddState(ActionState.CreateFireState(), infoProvider, characterInfo);
            AddState(ActionState.CreateSpecialFireState(), infoProvider, characterInfo);
            AddState(ActionState.CreateSpecialFireHold(), infoProvider, characterInfo);
            AddState(ActionState.CreateSpecialFireEnd(), infoProvider, characterInfo);
            AddState(ActionState.CreateInjuryState(), infoProvider, characterInfo);
            AddState(ActionState.CreateReloadState(), infoProvider, characterInfo);
            AddState(ActionState.CreateSpecialReloadState(), infoProvider, characterInfo);

            AddState(ActionState.CreateUnarmState(), infoProvider, characterInfo);
            AddState(ActionState.CreateDrawState(), infoProvider, characterInfo);
            AddState(ActionState.CreateSwitchWeaponState(), infoProvider, characterInfo);
            AddState(ActionState.CreatePickUpState(), infoProvider, characterInfo);
            AddState(ActionState.CreateMeleeAttackOneState(), infoProvider, characterInfo);
            AddState(ActionState.CreateMeleeAttackTwoState(), infoProvider, characterInfo);
            AddState(ActionState.CreateMeleeAttackSpecialState(), infoProvider, characterInfo);
            AddState(ActionState.CreateGrenadeState(), infoProvider, characterInfo);
            AddState(ActionState.CreateOpenDoorState(), infoProvider, characterInfo);
            AddState(ActionState.CreatePropsState(), infoProvider, characterInfo);

            AddState(ActionState.CreateGlidingState(), infoProvider, characterInfo);
            AddState(ActionState.CreateParachutingState(), infoProvider, characterInfo);

            AddState(ActionState.CreateBuriedBombState(), infoProvider, characterInfo);
            AddState(ActionState.CreateDismantleBombState(), infoProvider, characterInfo);

            _resetParam = ResetCommon;
        }
Esempio n. 3
0
        public void InitTransfigurationState(IFsmTransitionHelper infoProvider, ICharacterInfoProvider characterInfo)
        {
            AddState(ActionState.CreateTransfigurationNullState(), infoProvider, characterInfo);
            AddState(ActionState.CreateTransfigurationStartState(), infoProvider, characterInfo);
            AddState(ActionState.CreateTransfigurationFinishState(), infoProvider, characterInfo);

            _resetParam = ResetTransfiguration;
        }
Esempio n. 4
0
 public void SetCharacterInfo(ICharacterInfoProvider characterInfo)
 {
     _characterInfo = characterInfo;
     foreach (var v in _transitions)
     {
         v.SetCharacterInfo(characterInfo);
     }
 }
Esempio n. 5
0
        public PostureManager(IFsmTransitionHelper infoProvider, ICharacterInfoProvider characterInfo)
        {
            _commonFsm = new PostureFsm("StandCrouchProne");
            _commonFsm.InitAsCommonState(infoProvider, characterInfo);
            AddFsm(_commonFsm);

            _leanFsm = new PostureFsm("Lean");
            _leanFsm.InitAsLeanState(infoProvider, characterInfo);
            AddFsm(_leanFsm);
        }
Esempio n. 6
0
        public ActionManager(IFsmTransitionHelper infoProvider, ICharacterInfoProvider characterInfo)
        {
            _commonFsm = new ActionFsm("CommonAction");
            _commonFsm.InitCommon(infoProvider, characterInfo);
            AddFsm(_commonFsm);

            _keepFsm = new ActionFsm("KeepAction");
            _keepFsm.InitKeep(infoProvider, characterInfo);
            AddFsm(_keepFsm);
        }
Esempio n. 7
0
 public void Init(IFsmTransitionHelper infoProvider, ICharacterInfoProvider characterInfo)
 {
     AddState(MovementState.CreateIdleState(), infoProvider, characterInfo);
     AddState(MovementState.CreateWalkState(), infoProvider, characterInfo);
     AddState(MovementState.CreateRunState(), infoProvider, characterInfo);
     AddState(MovementState.CreateSprintState(), infoProvider, characterInfo);
     AddState(MovementState.CreateDiveMoveState(), infoProvider, characterInfo);
     AddState(MovementState.CreateEnterLadderState(), infoProvider, characterInfo);
     AddState(MovementState.CreateLadderMoveState(), infoProvider, characterInfo);
     AddState(MovementState.CreateExitLadderState(), infoProvider, characterInfo);
     _resetParam = ResetMovement;
 }
Esempio n. 8
0
        public void SetCurrentType(int type)
        {
            if (type == _type)
            {
                return;
            }
            if (!_dict.ContainsKey(type))
            {
                var info = new CharacterInfoProvider();
                var item = SingletonManager.Get <CharacterInfoManager>().GetCharacterInfoByType(type);
                if (item == null)
                {
                    Logger.ErrorFormat("type:{0} is not exist in item use default config!!!", type);
                    _currentInfo = _defaultInfo;
                    _type        = int.MinValue;
                    return;
                }
                else
                {
                    info.JumpSpeed    = item.JumpSpeed;
                    info.StandCapsule = new CharacterControllerCapsule()
                    {
                        Height  = item.StandHeight,
                        Radius  = item.StandRadius,
                        Posture = PostureInConfig.Stand
                    };
                    info.CrouchCapsule = new CharacterControllerCapsule()
                    {
                        Height  = item.CrouchHeight,
                        Radius  = item.CrouchRadius,
                        Posture = PostureInConfig.Crouch
                    };
                    info.ProneCapsule = new CharacterControllerCapsule()
                    {
                        Height  = item.ProneHeight,
                        Radius  = item.ProneRadius,
                        Posture = PostureInConfig.Prone
                    };
                    info.BigJumpHeight = item.BigJumpHeight;
                    info.StepOffset    = item.StepOffset;
                    info.SlopeLimit    = item.SlopeLimit;
                    _dict.Add(type, info);
                }
            }

            _currentInfo = _dict[type];
            Logger.InfoFormat("set type from:{0} to:{1}!!!", _type, type);
            _type = type;
        }
Esempio n. 9
0
        public void InitKeep(IFsmTransitionHelper infoProvider, ICharacterInfoProvider characterInfo)
        {
            AddState(ActionState.CreateKeepNullState(), infoProvider, characterInfo);

            AddState(ActionState.CreateVehiclesAnimState(), infoProvider, characterInfo);
            AddState(ActionState.CreateSightP3State(), infoProvider, characterInfo);
            AddState(ActionState.CreateRescueState(), infoProvider, characterInfo);
            
            AddState(ActionState.CreateRageStartState(), infoProvider, characterInfo);
            AddState(ActionState.CreateRageLoopState(), infoProvider, characterInfo);
            AddState(ActionState.CreateRageEndState(), infoProvider, characterInfo);
            
            AddState(ActionState.CreateSuccessPoseState(), infoProvider, characterInfo);

            _resetParam = ResetKeep;
        }
Esempio n. 10
0
        public CharacterStateManager(ICharacterInfoProvider characterInfo)
        {
            AssertUtility.Assert(characterInfo != null);
            int snapshotCount = 0;

            _posture       = new PostureManager(this, characterInfo);
            snapshotCount += _posture.SnapshotCount();

            _movement      = new MovementManager(this, characterInfo);
            snapshotCount += _movement.SnapshotCount();

            _action        = new ActionManager(this, characterInfo);
            snapshotCount += _action.SnapshotCount();

            _snapshotsCache = new List <FsmSnapshot>(snapshotCount);
            for (int i = 0; i < snapshotCount; i++)
            {
                _snapshotsCache.Add(new FsmSnapshot());
            }
        }
Esempio n. 11
0
        public void AddState(FsmState state, IFsmTransitionHelper infoProvider, ICharacterInfoProvider characterInfo)
        {
            if (!_states.ContainsKey(state.StateId))
            {
                if (_states.Count == 0)
                {
                    _defaultStateId = state.StateId;
                    _currentState   = state;
                }

                // set callback to change current state
                state.SetTransitionCallback(SetCurrentState);
                state.SetTransitionHelper(infoProvider);
                state.SetCharacterInfo(characterInfo);
                // add state to FSM
                _states.Add(state.StateId, state);
            }
            else
            {
                Logger.ErrorFormat("duplicate fsmState: {0} in {1}", state.StateId, _name);
            }
        }
Esempio n. 12
0
        public void InitAsCommonState(IFsmTransitionHelper infoProvider, ICharacterInfoProvider characterInfo)
        {
            AddState(PostureState.CreateStandState(), infoProvider, characterInfo);
            AddState(PostureState.CreateCrouchState(), infoProvider, characterInfo);
            AddState(PostureState.CreateProneState(), infoProvider, characterInfo);
            AddState(PostureState.CreateJumpStartState(), infoProvider, characterInfo);
            AddState(PostureState.CreateProneTransitState(), infoProvider, characterInfo);
            AddState(PostureState.CreateProneToStandState(), infoProvider, characterInfo);
            AddState(PostureState.CreateProneToCrouchState(), infoProvider, characterInfo);
            AddState(PostureState.CreateJumpEndState(), infoProvider, characterInfo);
            AddState(PostureState.CreateFreefallState(), infoProvider, characterInfo);
            AddState(PostureState.CreateSwimState(), infoProvider, characterInfo);
            AddState(PostureState.CreateDiveState(), infoProvider, characterInfo);
            AddState(PostureState.CreateDyingTransition(), infoProvider, characterInfo);
            AddState(PostureState.CreateDyingState(), infoProvider, characterInfo);

            AddState(PostureState.CreateClimbState(), infoProvider, characterInfo);
            AddState(PostureState.CreatePostureLadderState(), infoProvider, characterInfo);

            AddState(PostureState.CreateSlideState(), infoProvider, characterInfo);

            _resetParam = ResetCommonStateParam;
        }
Esempio n. 13
0
 public void SetCharacterInfo(ICharacterInfoProvider characterInfo)
 {
     _characterInfo = characterInfo;
 }
Esempio n. 14
0
 public SpeedManager(PlayerEntity player,
                     Contexts contexts,
                     ICharacterPosture posture,
                     ICharacterMovement movement,
                     ICharacterPostureInConfig postureInConfig,
                     ICharacterMovementInConfig movementInConfig,
                     ICharacterInfoProvider characterInfoProvider)
 {
     _contexts                 = contexts;
     _player                   = player;
     _posture                  = posture;
     _movement                 = movement;
     _postureInConfig          = postureInConfig;
     _movementInConfig         = movementInConfig;
     _characterInfoProvider    = characterInfoProvider;
     _speedConditionDictionary = new Dictionary <int, Action>()
     {
         // 落地
         {
             CharacterStateConfigHelper.GenerateId(PostureInConfig.Land, MovementInConfig.Null),
             () => { SetCurrentState(PostureInConfig.Null, MovementInConfig.Null); }
         },
         // 站立&静走
         {
             CharacterStateConfigHelper.GenerateId(PostureInConfig.Stand, MovementInConfig.Walk),
             () => { SetCurrentState(PostureInConfig.Stand, MovementInConfig.Walk); }
         },
         // 站立&跑步
         {
             CharacterStateConfigHelper.GenerateId(PostureInConfig.Stand, MovementInConfig.Run),
             () => { SetCurrentState(PostureInConfig.Stand, MovementInConfig.Run); }
         },
         // 站立&冲刺
         {
             CharacterStateConfigHelper.GenerateId(PostureInConfig.Stand, MovementInConfig.Sprint),
             () => { SetCurrentState(PostureInConfig.Stand, MovementInConfig.Sprint); }
         },
         // 蹲下&静走
         {
             CharacterStateConfigHelper.GenerateId(PostureInConfig.Crouch, MovementInConfig.Walk),
             () => { SetCurrentState(PostureInConfig.Crouch, MovementInConfig.Walk); }
         },
         // 蹲下&跑步
         {
             CharacterStateConfigHelper.GenerateId(PostureInConfig.Crouch, MovementInConfig.Run),
             () => { SetCurrentState(PostureInConfig.Crouch, MovementInConfig.Run); }
         },
         // 蹲下&冲刺
         {
             CharacterStateConfigHelper.GenerateId(PostureInConfig.Crouch, MovementInConfig.Sprint),
             () => { SetCurrentState(PostureInConfig.Crouch, MovementInConfig.Sprint); }
         },
         // 趴下&匍匐
         {
             CharacterStateConfigHelper.GenerateId(PostureInConfig.Prone, MovementInConfig.Null),
             () => { SetCurrentState(PostureInConfig.Prone, MovementInConfig.Walk); }
         },
         // 游泳
         {
             CharacterStateConfigHelper.GenerateId(PostureInConfig.Swim, MovementInConfig.Null),
             () => { SetCurrentState(PostureInConfig.Swim, MovementInConfig.Swim); }
         },
         // 潜水
         {
             CharacterStateConfigHelper.GenerateId(PostureInConfig.Dive, MovementInConfig.Null),
             () => { SetCurrentState(PostureInConfig.Dive, MovementInConfig.Dive); }
         },
         // 受伤
         {
             CharacterStateConfigHelper.GenerateId(PostureInConfig.Dying, MovementInConfig.Null),
             () => { SetCurrentState(PostureInConfig.Dying, MovementInConfig.Walk); }
         },
         // 受伤
         {
             CharacterStateConfigHelper.GenerateId(PostureInConfig.Null, MovementInConfig.Ladder),
             () => { SetCurrentState(PostureInConfig.Null, MovementInConfig.Ladder); }
         }
     };
 }
Esempio n. 15
0
 public MovementManager(IFsmTransitionHelper infoProvider, ICharacterInfoProvider characterInfo)
 {
     _commonFsm = new MovementFsm("Movement");
     _commonFsm.Init(infoProvider, characterInfo);
     AddFsm(_commonFsm);
 }