Exemplo n.º 1
0
    public PlayerState(IEventManager playerEvent)
    {
        #region Player State Initialization
        _StateIdle              = new IdleState(this);
        _StateWalk              = new WalkState(this);
        _StateSprint            = new SprintState(this);
        _StateFall              = new FallState(this);
        _StateCrouch            = new CrouchState(this);
        _StateJump              = new JumpState(this);
        _StateCrouchWalk        = new CrouchWalkState(this);
        _StateSlide             = new SlideState(this);
        _StateCrouchJump        = new CrouchJumpState(this);
        _StateCrouchFall        = new CrouchFallState(this);
        _StateAirMoveCrouchFall = new AirMoveCrouchFallState(this);
        _StateAirMoveCrouchJump = new AirMoveCrouchJumpState(this);
        _StateAirMoveFall       = new AirMoveFallState(this);
        _StateAirMoveJump       = new AirMoveJumpState(this);
        #endregion

        _ActiveProxies      = new HashSet <IDynamicProxy>();
        _EventPlayer        = playerEvent;
        _CurrentPlayerState = _StateIdle;

        #region State Proxy Initialization
        _MediatorToggleProxy             = new ToggleProxyMediator();
        _ProxySprint                     = new SprintProxy(this, _MediatorToggleProxy);
        _ProxyCrouch                     = new CrouchProxy(this, _MediatorToggleProxy);
        _MediatorToggleProxy.ProxyCrouch = _ProxyCrouch;
        _MediatorToggleProxy.ProxySprint = _ProxySprint;

        _ProxyWalk = new WalkProxy(this, _MediatorToggleProxy);
        _ProxyFall = new FallProxy(this);
        _ProxyJump = new JumpProxy(this, _MediatorToggleProxy);
        #endregion
    }
        public void Handle(object command)
        {
            switch (command)
            {
            case Start_sprint cmd:
            {
                Action <object> publish = (e) => { _publish(new Event_message(cmd.SprintId.Value, e)); };
                new Sprint(publish, new SprintState(_events(cmd.SprintId.Value).Select(_ => _.Payload)))
                .Start();
            }
            break;

            case Remove_task_from_sprint cmd:
            {
                var             state   = new SprintState(_events(cmd.SprintId.Value).Select(_ => _.Payload));
                Action <object> publish = (e) =>
                {
                    state.Project(e);
                    _publish(new Event_message(cmd.SprintId.Value, e));
                };
                new Sprint(publish, state)
                .Remove_task(cmd.TaskId);
            }
            break;
            }
        }
Exemplo n.º 3
0
 private SprintState()
 {
     if (_instance != null)
     {
         return;
     }
     _instance = this;
 }
Exemplo n.º 4
0
 public QueryHandler(Func <List <EventMessage> > history)
 {
     _history         = history;
     _SprintReadModel =
         new SprintState(
             _history()
             .Where(_ => _._source == s._sprint)
             .Select(_ => _._e));
 }
 public SprintDescriptionResultsDtoBuilder Add(int id, SprintState state = SprintState.CLOSED)
 {
     Add(new SprintDescriptionDto
     {
         Id    = id,
         State = state
     });
     return(this);
 }
 public Sprint(string name, DateTime startTime, DateTime endTime, ScrumMaster scrumMaster)
 {
     backlog          = new Backlog();
     this.scrumMaster = scrumMaster;
     this.name        = name;
     this.startTime   = startTime;
     this.endTime     = endTime;
     this.sprintState = new InitializedSprintState();
     sprintState.setSprint(this);
     team = new Dictionary <User, int>();
 }
        public SprintDtoCollectionBuilder Add(int id, TimeSpan sprintRange, SprintState sprintState = SprintState.CLOSED)
        {
            DateTime endDate = DateTime.UtcNow;

            if (Models.Any())
            {
                endDate = Models.Last().StartDate;
            }

            return(Add(id, endDate.Subtract(sprintRange), endDate, sprintState));
        }
Exemplo n.º 8
0
 public SprintRecord(string id, bool archived, BoardRecord board, string name, SprintState state, DateTime from, DateTime to, bool @default, string?description = null)
 {
     Id          = id;
     IsArchived  = archived;
     Board       = board;
     Name        = name;
     State       = state;
     From        = from;
     To          = to;
     IsDefault   = @default;
     Description = description;
 }
 public SprintDtoCollectionBuilder Add(int id,
                                       DateTime startDate,
                                       DateTime endDate,
                                       SprintState state = SprintState.CLOSED)
 {
     Add(new SprintDto
     {
         Id        = id,
         StartDate = startDate,
         EndDate   = endDate,
         State     = state
     });
     return(this);
 }
Exemplo n.º 10
0
        public void Execute(object command)
        {
            switch (command)
            {
            case Start_sprint s:
            {
                var state =
                    new SprintState(
                        _all_events()
                        .Where(_ => _._source == s.Sprint)
                        .Select(_ => _._e));
                var sprint =
                    new Sprint(state,
                               (e) =>
                    {
                        state.Apply(e);
                        _publish(new EventMessage(s.Sprint, e));
                    });
                sprint.Start();
            }
            break;

            case Finish_task s:
            {
                var state =
                    new SprintState(
                        _all_events()
                        .Where(_ => _._source == s.Sprint)
                        .Select(_ => _._e));
                var sprint =
                    new Sprint(state,
                               (e) =>
                    {
                        state.Apply(e);
                        _publish(new EventMessage(s.Sprint, e));
                    });
                sprint.Finish_task(s.Task);
            }
            break;
            }
        }
Exemplo n.º 11
0
    void Start()
    {
        playerStats.AdjustInventory();
        SpriteEquip();
        throwablePrefab = Resources.Load("Prefabs/ThrownWeapon") as GameObject;

        idle          = new IdleState(this); states.Add(idle.stateName, idle);
        move          = new MoveState(this); states.Add(move.stateName, move);
        dodge         = new DodgeState(this); states.Add(dodge.stateName, dodge);
        sprint        = new SprintState(this); states.Add(sprint.stateName, sprint);
        slide         = new SlideState(this); states.Add(slide.stateName, slide);
        combo         = new ComboState(this); states.Add(combo.stateName, combo);
        strong_attack = new StrongRedirectState(this); states.Add(strong_attack.stateName, strong_attack);
        dash_attack   = new DashRedirectState(this); states.Add(dash_attack.stateName, dash_attack);
        defense       = new DefensiveRedirectState(this); states.Add(defense.stateName, defense);
        guard         = new GuardState(this); states.Add(guard.stateName, guard);
        stun          = new StunState(this); states.Add(stun.stateName, stun);
        strike        = new StrikeState(this); states.Add(strike.stateName, strike);
        death         = new DeathState(this); states.Add(death.stateName, death);

        currentState = idle;
        currentState.StartState();
    }
Exemplo n.º 12
0
 public override void Sprint()
 {
     base.Sprint();
     currentState = new SprintState(details);
     currentState.Sprint();
 }
 public void setState(SprintState sprintState)
 {
     sprintState.setSprint(this);
     this.sprintState = sprintState;
 }
 public SprintDescriptionResultsDtoBuilder AddMany(int fromId, int toId, SprintState state)
 => For(toId - fromId, (i) => Add(fromId + i, state));
Exemplo n.º 15
0
    private void MakeFSM()
    {
        NormalIdleState normalIdle = new NormalIdleState(this.transform);

        normalIdle.AddTransition(Transition.NormalIdleTSTurnR, StateID.TurnR);           //
        normalIdle.AddTransition(Transition.NormalIdleTSTurnL, StateID.TurnL);           //
        normalIdle.AddTransition(Transition.NormalIdleTSNormalMove, StateID.NormalMove); //
        normalIdle.AddTransition(Transition.NormalIdleTSFightIdle, StateID.FightIdle);   //
        normalIdle.AddTransition(Transition.NormalIdleTSSprint, StateID.Sprint);         //
        normalIdle.AddTransition(Transition.NormalIdleTSCoverR, StateID.CoverR);         //
        normalIdle.AddTransition(Transition.NormalIdleTSCoverL, StateID.CoverL);         //
        normalIdle.AddTransition(Transition.NormalIdleTSCoverHiR, StateID.CoverHiR);
        normalIdle.AddTransition(Transition.NormalIdleTSCoverHiL, StateID.CoverHiL);
        normalIdle.AddTransition(Transition.NormalIdleTSPickUp, StateID.PickUp);     //
        normalIdle.AddTransition(Transition.NormalIdleTSOpenDoor, StateID.OpenDoor); //
        normalIdle.AddTransition(Transition.NormalIdleTSUsePad, StateID.UsePad);     //

        TurnRState turnR = new TurnRState(this.transform);

        turnR.AddTransition(Transition.TurnRTSTurnL, StateID.TurnL);
        turnR.AddTransition(Transition.TurnRTSNormalIdle, StateID.NormalIdle);
        turnR.AddTransition(Transition.TurnRTSNormalMove, StateID.NormalMove);

        TurnLState turnL = new TurnLState(this.transform);

        turnL.AddTransition(Transition.TurnLTSNormalIdle, StateID.NormalIdle);
        turnL.AddTransition(Transition.TurnLTSNormalMove, StateID.NormalMove);

        FightIdleState fightIdle = new FightIdleState(this.transform);

        fightIdle.AddTransition(Transition.FightIdleTSFightMove, StateID.FightMove);   //
        fightIdle.AddTransition(Transition.FightIdleTSNormalMove, StateID.NormalMove); //
        fightIdle.AddTransition(Transition.FightIdleTSNormalIdle, StateID.NormalIdle); //

        NormalMoveState normalMove = new NormalMoveState(this.transform);

        normalMove.AddTransition(Transition.NormalMoveTSFightMove, StateID.FightMove);   //
        normalMove.AddTransition(Transition.NormalMoveTSNormalIdle, StateID.NormalIdle); //
        normalMove.AddTransition(Transition.NormalMoveTSSprint, StateID.Sprint);         //
        normalMove.AddTransition(Transition.NormalMoveTSRoll, StateID.Roll);             //
        normalMove.AddTransition(Transition.NormalMoveTSCoverR, StateID.CoverR);         //
        normalMove.AddTransition(Transition.NormalMoveTSCoverL, StateID.CoverL);         //
        normalMove.AddTransition(Transition.NormalMoveTSCoverHiR, StateID.CoverHiR);
        normalMove.AddTransition(Transition.NormalMoveTSCoverHiL, StateID.CoverHiL);
        normalMove.AddTransition(Transition.NormalMoveTSOpenDoor, StateID.OpenDoor); //
        normalMove.AddTransition(Transition.NormalMoveTSUsePad, StateID.UsePad);     //

        FightMoveState fightMove = new FightMoveState(this.transform);

        fightMove.AddTransition(Transition.FightMoveTSFightIdle, StateID.FightIdle);   //
        fightMove.AddTransition(Transition.FightMoveTSNormalMove, StateID.NormalMove); //

        RollState roll = new RollState(this.transform);

        roll.AddTransition(Transition.RollTSNormalIdle, StateID.NormalIdle); //
        roll.AddTransition(Transition.RollTSNormalMove, StateID.NormalMove); //

        SprintState sprint = new SprintState(this.transform);

        sprint.AddTransition(Transition.SprintTSNormalIdle, StateID.NormalIdle); //
        sprint.AddTransition(Transition.SprintTSNormalMove, StateID.NormalMove); //
        sprint.AddTransition(Transition.SprintTSCoverR, StateID.CoverR);         //
        sprint.AddTransition(Transition.SprintTSCoverL, StateID.CoverL);         //
        sprint.AddTransition(Transition.SprintTSRoll, StateID.Roll);             //
        sprint.AddTransition(Transition.SprintTSCoverHiR, StateID.CoverHiR);
        sprint.AddTransition(Transition.SprintTSCoverHiL, StateID.CoverHiL);
        sprint.AddTransition(Transition.SprintTSOpenDoor, StateID.OpenDoor); //
        sprint.AddTransition(Transition.SprintTSUsePad, StateID.UsePad);     //

        CoverJumpState coverJump = new CoverJumpState(this.transform);

        coverJump.AddTransition(Transition.CoverJumpTSNormalIdle, StateID.NormalIdle);//

        CoverRState coverR = new CoverRState(this.transform);

        coverR.AddTransition(Transition.CoverRTSCoverL, StateID.CoverL);                       //
        coverR.AddTransition(Transition.CoverRTSRoll, StateID.Roll);                           //
        coverR.AddTransition(Transition.CoverRTSNormalMove, StateID.NormalMove);               //
        coverR.AddTransition(Transition.CoverRTSCoverJump, StateID.CoverJump);                 //
        coverR.AddTransition(Transition.CoverRTSCoverLoRShootIdle, StateID.CoverLoRShootIdle); //
        coverR.AddTransition(Transition.CoverRTSCoverRReload, StateID.CoverRReload);           //
        coverR.AddTransition(Transition.CoverRTSNormalIdle, StateID.NormalIdle);               //

        CoverLoRShootIdleState coverLoRShootIdle = new CoverLoRShootIdleState(this.transform);

        coverLoRShootIdle.AddTransition(Transition.CoverLoRShootIdleTSCoverLoRShootBeforeDown, StateID.CoverLoRShootBeforeDown); //
        coverLoRShootIdle.AddTransition(Transition.CoverLoRShootIdleTSFightIdle, StateID.FightIdle);                             //
        coverLoRShootIdle.AddTransition(Transition.CoverLoRShootIdleTSCoverR, StateID.CoverR);                                   //

        CoverLoRShootBeforeDownState coverLoRShootBeforeDown = new CoverLoRShootBeforeDownState(this.transform);

        coverLoRShootBeforeDown.AddTransition(Transition.CoverLoRShootBeforeDownTSCoverR, StateID.CoverR);                       //
        coverLoRShootBeforeDown.AddTransition(Transition.CoverLoRShootBeforeDownTSCoverLoRShootIdle, StateID.CoverLoRShootIdle); //
        coverLoRShootBeforeDown.AddTransition(Transition.CoverLoRShootBeforeDownTSNormalIdle, StateID.NormalIdle);               //

        CoverLState coverL = new CoverLState(this.transform);

        coverL.AddTransition(Transition.CoverLTSCoverR, StateID.CoverR);                       //
        coverL.AddTransition(Transition.CoverLTSRoll, StateID.Roll);                           //
        coverL.AddTransition(Transition.CoverLTSNormalMove, StateID.NormalMove);               //
        coverL.AddTransition(Transition.CoverLTSCoverJump, StateID.CoverJump);                 //
        coverL.AddTransition(Transition.CoverLTSCoverLoLShootIdle, StateID.CoverLoLShootIdle); //
        coverL.AddTransition(Transition.CoverLTSCoverLReload, StateID.CoverLReload);           //
        coverL.AddTransition(Transition.CoverLTSNormalIdle, StateID.NormalIdle);               //

        CoverLoLShootIdleState coverLoLShootIdle = new CoverLoLShootIdleState(this.transform);

        coverLoLShootIdle.AddTransition(Transition.CoverLoLShootIdleTSCoverLoLShootBeforeDown, StateID.CoverLoLShootBeforeDown); //
        coverLoLShootIdle.AddTransition(Transition.CoverLoLShootIdleTSFightIdle, StateID.FightIdle);                             //
        coverLoLShootIdle.AddTransition(Transition.CoverLoLShootIdleTSCoverL, StateID.CoverL);                                   //

        CoverLoLShootBeforeDownState coverLoLShootBeforeDown = new CoverLoLShootBeforeDownState(this.transform);

        coverLoLShootBeforeDown.AddTransition(Transition.CoverLoLShootBeforeDownTSCoverL, StateID.CoverL);                       //
        coverLoLShootBeforeDown.AddTransition(Transition.CoverLoLShootBeforeDownTSCoverLoLShootIdle, StateID.CoverLoLShootIdle); //
        coverLoLShootBeforeDown.AddTransition(Transition.CoverLoLShootBeforeDownTSNormalIdle, StateID.NormalIdle);               //

        CoverHiRState coverHiR = new CoverHiRState(this.transform);

        coverHiR.AddTransition(Transition.CoverHiRTSCoverHiL, StateID.CoverHiL);
        coverHiR.AddTransition(Transition.CoverHiRTSNormalMove, StateID.NormalMove);
        coverHiR.AddTransition(Transition.CoverHiRTSCoverHiRightIdle, StateID.CoverHiRightIdle);
        coverHiR.AddTransition(Transition.CoverHiRTSNormalIdle, StateID.NormalIdle);

        CoverHiRightIdleState coverHiRightIdle = new CoverHiRightIdleState(this.transform);

        coverHiRightIdle.AddTransition(Transition.CoverHiRightIdleTSCoverHiR, StateID.CoverHiR);
        coverHiRightIdle.AddTransition(Transition.CoverHiRightIdleTSRoll, StateID.Roll);
        coverHiRightIdle.AddTransition(Transition.CoverHiRightIdleTSCoverHiRShootIdle, StateID.CoverHiRShootIdle);
        coverHiRightIdle.AddTransition(Transition.CoverHiRightIdleTSNormalIdle, StateID.NormalIdle);

        CoverHiRShootIdleState coverHiRShootIdle = new CoverHiRShootIdleState(this.transform);

        coverHiRShootIdle.AddTransition(Transition.CoverHiRShootIdleTSCoverHiRShootBeforeDown, StateID.CoverHiRShootBeforeDown);
        coverHiRShootIdle.AddTransition(Transition.CoverHiRShootIdleTSCoverHiRightIdle, StateID.CoverHiRightIdle);
        coverHiRShootIdle.AddTransition(Transition.CoverHiRShootIdleTSFightIdle, StateID.FightIdle);

        CoverHiRShootBeforeDownState coverHiRShootBeforeDown = new CoverHiRShootBeforeDownState(this.transform);

        coverHiRShootBeforeDown.AddTransition(Transition.CoverHiRShootBeforeDownTSCoverHiRightIdle, StateID.CoverHiRightIdle);
        coverHiRShootBeforeDown.AddTransition(Transition.CoverHiRShootBeforeDownTSCoverHiRShootIdle, StateID.CoverHiRShootIdle);
        coverHiRShootBeforeDown.AddTransition(Transition.CoverHiRShootBeforeDownTSNormalIdle, StateID.NormalIdle);

        CoverHiLState coverHiL = new CoverHiLState(this.transform);

        coverHiL.AddTransition(Transition.CoverHiLTSCoverHiR, StateID.CoverHiR);
        coverHiL.AddTransition(Transition.CoverHiLTSNormalMove, StateID.NormalMove);
        coverHiL.AddTransition(Transition.CoverHiLTSCoverHiLeftIdle, StateID.CoverHiLeftIdle);
        coverHiL.AddTransition(Transition.CoverHiLTSNormalIdle, StateID.NormalIdle);

        CoverHiLeftIdleState coverHiLeftIdle = new CoverHiLeftIdleState(this.transform);

        coverHiLeftIdle.AddTransition(Transition.CoverHiLeftIdleTSCoverHiL, StateID.CoverHiL);
        coverHiLeftIdle.AddTransition(Transition.CoverHiLeftIdleTSRoll, StateID.Roll);
        coverHiLeftIdle.AddTransition(Transition.CoverHiLeftIdleTSCoverHiLShootIdle, StateID.CoverHiLShootIdle);
        coverHiLeftIdle.AddTransition(Transition.CoverHiLeftIdleTSNormalIdle, StateID.NormalIdle);

        CoverHiLShootIdleState coverHiLShootIdle = new CoverHiLShootIdleState(this.transform);

        coverHiLShootIdle.AddTransition(Transition.CoverHiLShootIdleTSCoverHiLShootBeforeDown, StateID.CoverHiLShootBeforeDown);
        coverHiLShootIdle.AddTransition(Transition.CoverHiLShootIdleTSCoverHiLeftIdle, StateID.CoverHiLeftIdle);
        coverHiLShootIdle.AddTransition(Transition.CoverHiRShootIdleTSFightIdle, StateID.FightIdle);


        CoverHiLShootBeforeDownState coverHiLShootBeforeDown = new CoverHiLShootBeforeDownState(this.transform);

        coverHiLShootBeforeDown.AddTransition(Transition.CoverHiLShootBeforeDownTSCoverHiLeftIdle, StateID.CoverHiLeftIdle);
        coverHiLShootBeforeDown.AddTransition(Transition.CoverHiLShootBeforeDownTSCoverHiLShootIdle, StateID.CoverHiLShootIdle);
        coverHiLShootBeforeDown.AddTransition(Transition.CoverHiLShootBeforeDownTSNormalIdle, StateID.NormalIdle);

        CoverRReloadState coverRReloadState = new CoverRReloadState(this.transform);

        coverRReloadState.AddTransition(Transition.CoverRReloadTSCoverR, StateID.CoverR);//

        CoverLReloadState coverLReloadState = new CoverLReloadState(this.transform);

        coverLReloadState.AddTransition(Transition.CoverLReloadTSCoverL, StateID.CoverL);//

        PickUpState pickUpState = new PickUpState(this.transform);

        pickUpState.AddTransition(Transition.PickUpTSNormalIdle, StateID.NormalIdle);//

        OpenDoorState openDoorState = new OpenDoorState(this.transform);

        openDoorState.AddTransition(Transition.OpenDoorTSNormalIdle, StateID.NormalIdle);//

        UsePadState usePadState = new UsePadState(this.transform);

        usePadState.AddTransition(Transition.UsePadTSNormalIdle, StateID.NormalIdle);//


        fsm = new FSMSystem();

        fsm.AddState(normalIdle);
        fsm.AddState(normalMove);
        fsm.AddState(roll);
        fsm.AddState(sprint);
        fsm.AddState(fightIdle);
        fsm.AddState(fightMove);
        fsm.AddState(coverR);
        fsm.AddState(coverL);
        fsm.AddState(coverJump);
        fsm.AddState(turnR);
        fsm.AddState(turnL);
        fsm.AddState(coverHiR);
        fsm.AddState(coverHiL);
        fsm.AddState(coverHiRightIdle);
        fsm.AddState(coverHiLeftIdle);
        fsm.AddState(coverHiRShootIdle);
        fsm.AddState(coverHiRShootBeforeDown);
        fsm.AddState(coverHiLShootIdle);
        fsm.AddState(coverHiLShootBeforeDown);
        fsm.AddState(coverLoRShootIdle);
        fsm.AddState(coverLoRShootBeforeDown);
        fsm.AddState(coverLoLShootIdle);
        fsm.AddState(coverLoLShootBeforeDown);
        fsm.AddState(coverRReloadState);
        fsm.AddState(coverLReloadState);
        fsm.AddState(pickUpState);
        fsm.AddState(openDoorState);
        fsm.AddState(usePadState);
    }
 public SprintDtoCollectionBuilder AddMany(int fromId, int toId, TimeSpan sprintRange, SprintState state = SprintState.CLOSED)
 => For(toId - fromId, (i, b) => Add(fromId + i, sprintRange, state));