void FixedUpdate() { #if UNITY_EDITOR if (isDummy) { return; } if (actorController == null) { return; // prevents error spam after editing a script } #endif actorPhysics.UpdateInternalStateFromPhysicsResult(); actorController.FixedUpdateCommands(); MovementStateType nextState = movementState.FixedUpdateState(); if (nextState != MovementStateType.NONE) { if (!movementStateLookup.TryGetValue(nextState, out IMovementState newMovement)) { Debug.Log(this.name + " could not find movementState for " + nextState.ToString()); } else { MovementStateType previousState = movementState.ExitState(nextState); movementState = newMovement; movementState.EnterState(previousState); currentMovementState = nextState; } } actorPhysics.ApplyToPhysics(); }
public ISprite build(IMovementState mState) { if (mState is LeftIdleState) { Texture2D texture = content.Load <Texture2D>("mario_idle"); // not sure about how to best deal with position of the sprite. pass a mario all the way // to this point and might as well assign his sprite directly rather than return a sprite // going to default to 0,0 then let the state change the sprite location to match the objects product = new SpriteAnimated(texture, 1, 1, 24, false); } else if (mState is LeftJumpingIdleState) { Texture2D texture = content.Load <Texture2D>("mario_jump"); product = new SpriteAnimated(texture, 1, 1, 24, false); } else if (mState is LeftJumpingState) { //this repates with above, possible to optimize down the number of elseif branches at a later date Texture2D texture = content.Load <Texture2D>("mario_jump"); product = new SpriteAnimated(texture, 1, 1, 24, false); } else if (mState is LeftWalkingState) { Texture2D texture = content.Load <Texture2D>("mario_walk"); product = new SpriteAnimated(texture, 1, 3, 12, false); } else if (mState is RightIdleState || mState is null) { Texture2D texture = content.Load <Texture2D>("mario_idle"); product = product = new SpriteStatic(texture, true); } else if (mState is RightJumpingIdleState) { Texture2D texture = content.Load <Texture2D>("mario_jump"); product = product = new SpriteStatic(texture, true); } else if (mState is RightJumpingState) { Texture2D texture = content.Load <Texture2D>("mario_jump"); product = product = new SpriteStatic(texture, true); } else if (mState is RightWalkingState) { Texture2D texture = content.Load <Texture2D>("mario_walk"); product = new SpriteAnimated(texture, 1, 3, 12, true); } else if (mState is RightCrouchingState) { Texture2D texture = content.Load <Texture2D>("mario_crouch"); product = product = new SpriteStatic(texture, true); } else if (mState is LeftCrouchingState) { Texture2D texture = content.Load <Texture2D>("mario_crouch"); product = new SpriteAnimated(texture, 1, 1, 24, false); } return(product); }
public MovementContext(global::Vanguard obs) { vanguard = obs; movementStates = new Dictionary <MovementStates, IMovementState>(); movementStates.Add(MovementStates.LateralMovement, new LateralMovement(this, vanguard)); movementStates.Add(MovementStates.VerticalMovement, new VerticalMovement(this, vanguard)); currentState = movementStates[MovementStates.LateralMovement]; }
public Mario(Vector2 location, int lives) : base(location) { sprite = SpriteMachine.Instance.CreateSprite(SpriteMachine.SpriteTag.SmallMarioIdleRight); HealthState = new SmallMarioState(this); MovementState = new RightFacingMarioState(this); Physics = new Physics(location, true); this.lives = lives; }
public Mario(Vector2 location) : base(location) { sprite = SpriteMachine.Instance.CreateSprite(SpriteMachine.SpriteTag.SmallMarioIdleRight); HealthState = new SmallMarioState(this); MovementState = new RightFacingMarioState(this); Physics = new Physics(location, true); speedMultiplier = 1.0f; }
private static void AssertAllLinesConfirmed(IMovementState mov, IDictionary <string, Tuple <decimal, decimal, decimal> > quantitiesDict) { var movLineNotConfirmed = mov.MovementLines.Where(line => !quantitiesDict.ContainsKey(line.LineNumber)).FirstOrDefault(); if (null != movLineNotConfirmed) { throw new NullReferenceException(String.Format("Movement line NOT found confirmation. Line No.: {0}", movLineNotConfirmed.LineNumber)); } }
public ISprite build(IMovementState mState) { product = localFactory.build(mState); if (product == null) { Console.WriteLine("help"); } return(product); }
public IMovementState Get(string id) { IMovementState state = CurrentSession.Get <MovementState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IMovementState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames)); } return(state); }
public static TDeleteMovement ToDeleteMovement <TDeleteMovement>(this IMovementState state) where TDeleteMovement : IDeleteMovement, new() { var cmd = new TDeleteMovement(); cmd.DocumentNumber = state.DocumentNumber; cmd.Version = ((IMovementStateProperties)state).Version; return(cmd); }
public void ChangeState(MovementState targetState) { switch (targetState) { case MovementState.STOPPED: { NextState = new StoppedState(MovementModel, this); break; } case MovementState.ACCELERATING: { NextState = new AccelState(MovementModel, this); break; } case MovementState.MOVING: { NextState = new MovingState(MovementModel, this); break; } case MovementState.JUMPING: { NextState = new JumpingState(MovementModel, this); break; } case MovementState.FALL_FORGIVENESS: { NextState = new FallForgivenessState(MovementModel, this); break; } case MovementState.FALLING: { NextState = new FallingState(MovementModel, this); break; } case MovementState.HUGGING_WALL: { NextState = new HuggingWallState(MovementModel, this); break; } case MovementState.WALL_LAUNCH: { NextState = new WallLaunchState(MovementModel, this); break; } } changedState = true; }
protected void NewMovementDocumentActionCommandAndExecute(ICreateMovement c, IMovementState s, IMovementStateCreated e) { var pCommandHandler = this.MovementDocumentActionCommandHandler; var pCmdContent = default(string); var pCmd = new PropertyCommand <string, string> { Content = pCmdContent, GetState = () => s.DocumentStatusId, SetState = p => e.DocumentStatusId = p, OuterCommandType = CommandType.Create }; pCmd.Context = this.State; pCommandHandler.Execute(pCmd); }
public DtoMovementLineStates(IMovementState outerState, IEnumerable <IMovementLineState> innerStates) { this._outerState = outerState; if (innerStates == null) { this._innerStates = new IMovementLineState[] { }; } else { this._innerStates = innerStates; } }
protected virtual ICreateMovement CreateReversalMovement(IMovementState movement) { var reversalMov = DoCreateReversalMovement(movement); foreach (var d in movement.MovementLines) { var r = DoCreateReversalMovementLine(d); reversalMov.MovementLines.Add(r); } return(reversalMov); }
public Controller() { stIdle = new IdleState(this); stRun = new RunState(this); stClimb = new ClimbState(this); stFall = new FallState(this); stJump = new JumpState(this); stWallJump = new WallJumpState(this); stClimbJump = new ClimbJumpState(this); stWallSlide = new WallSlideState(this); stDash = new DashState(this); stBoostJump = new BoostJumpState(this); stBoostWallJump = new BoostWallJumpState(this); }
// //////////////////////////////////// #region MovementConfirmation /// <summary> /// 创建 Movement 的确认单。 /// </summary> private ICreateMovementConfirmation CreateMovementConfirmation(IMovementState movement) { var movConfirm = new CreateMovementConfirmation(); movConfirm.MovementDocumentNumber = movement.DocumentNumber; movConfirm.DocumentNumber = "MC" + movement.DocumentNumber;//SeqIdGenerator.GetNextId(); movConfirm.DocumentTypeId = DocumentTypeIds.MovementConfirmation; //movConfirm.CreatedBy = movConfirm.UpdatedBy = Context.User; //movConfirm.CreationTime = movConfirm.UpdateTime = now; AddMovementConfirmationLines(movement, movConfirm); return(movConfirm); }
public IMovementState Get(string id, bool nullAllowed) { IMovementState state = CurrentSession.Get <MovementState> (id); if (!nullAllowed && state == null) { state = new MovementState(); (state as MovementState).DocumentNumber = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IMovementState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames)); } return(state); }
private void AddMovementConfirmationLines(IMovementState movement, ICreateMovementConfirmation movConfirm) { foreach (var movLine in movement.MovementLines) { var confirmLine = new CreateMovementConfirmationLine(); //confirmLine.MovementConfirmationDocumentNumber = movConfirm; //confirmLine.CreatedBy = confirmLine.UpdatedBy = Context.User; //confirmLine.CreationTime = confirmLine.UpdateTime = now; confirmLine.LineNumber = movLine.LineNumber;//SeqIdGenerator.GetNextId().ToString(); confirmLine.MovementLineNumber = movLine.LineNumber; confirmLine.TargetQuantity = movLine.MovementQuantity; confirmLine.ConfirmedQuantity = 0L; //?? movConfirm.MovementConfirmationLines.Add(confirmLine); } }
public async Task <IMovementState> GetAsync(string documentNumber) { IMovementState state = null; var idObj = documentNumber; var uriParameters = new MovementUriParameters(); uriParameters.Id = idObj; var req = new MovementGetRequest(uriParameters); var resp = await _ramlClient.Movement.Get(req); MovementProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToMovementState(); return(state); }
private void Start() { switch (StartingState) { case MovementState.STOPPED: { CurrentState = new StoppedState(MovementModel, this); break; } } PreviousState = CurrentState; CurrentState.OnEnterState(); StartingPosition = transform.position; }
public void UpdateState(PlayerInputs input) { if (changedState) { CurrentState.OnExitState(); PreviousState = CurrentState; CurrentState = NextState; MovementModel.State = CurrentState.State; CurrentState.OnEnterState(); changedState = false; } CurrentState.OnUpdateState(input); }
public void Save(IMovementState state) { IMovementState s = state; if (ReadOnlyProxyGenerator != null) { s = ReadOnlyProxyGenerator.GetTarget <IMovementState>(state); } CurrentSession.SaveOrUpdate(s); var saveable = s as ISaveable; if (saveable != null) { saveable.Save(); } CurrentSession.Flush(); }
internal static ICreateInventoryItemEntry CreateInventoryItemEntry(IMovementState movement, IMovementLineState movementLine, string locatorId, decimal quantity, int lineSubSeqId, Func <long> nextEntrySeqId, bool usingInTransitQty = false) { var entry = new CreateInventoryItemEntry(); var invItemId = new InventoryItemId(movementLine.ProductId, locatorId, movementLine.AttributeSetInstanceId); entry.InventoryItemId = invItemId; entry.EntrySeqId = nextEntrySeqId(); if (!usingInTransitQty) { entry.OnHandQuantity = quantity; } else { entry.InTransitQuantity = quantity; } entry.Source = new InventoryItemSourceInfo(DocumentTypeIds.Movement, movement.DocumentNumber, movementLine.LineNumber, lineSubSeqId); return(entry); }
/// <summary> /// 生成反转的单据(但不包括行)。 /// </summary> protected virtual ICreateMovement DoCreateReversalMovement(IMovementState movement) { var reversalMov = new CreateMovement(); //reversalInOut.Organization = inOut.Organization; //reversalInOut.Client = inOut.Client; //生成新的单号: reversalMov.DocumentNumber = "RM" + SeqIdGenerator.GetNextId();//DocumentNumberGenerator.GetNewDocumentNumber(); //设置反转关系: reversalMov.ReversalDocumentNumber = movement.DocumentNumber; //movement.Reversal = reversalMov; //源单据前向关联到反转单据: //movement.Description = "(" + reversalMov.DocumentNumber + "<-)";//(1000016<-) //反转单据后向关联到源单据: reversalMov.Description = "{->" + movement.DocumentNumber + ")";//{->1000015) //reversalMov.Posted = movement.Posted;//?? //reversalMov.Processing = movement.Processing; //reversalMov.Processed = movement.Processed; reversalMov.DocumentTypeId = movement.DocumentTypeId; reversalMov.MovementDate = movement.MovementDate;//??? reversalMov.ApprovalAmount = movement.ApprovalAmount; reversalMov.ChargeAmount = movement.ChargeAmount; reversalMov.DateReceived = movement.DateReceived; reversalMov.FreightAmount = movement.FreightAmount; reversalMov.Active = movement.Active; reversalMov.IsInTransit = false;//?? reversalMov.SalesRepresentativeId = movement.SalesRepresentativeId; reversalMov.ShipperId = movement.ShipperId; reversalMov.BusinessPartnerId = movement.BusinessPartnerId; //reversalMov.User = movement.User; reversalMov.WarehouseIdFrom = movement.WarehouseIdFrom; reversalMov.WarehouseIdTo = movement.WarehouseIdTo; return(reversalMov); }
public void SetState(IMovementState state) { if (mState == state) { return; } Debug.LogFormat("{0} -> {1}", mState, state); stateText.text = state.ToString(); if (mState != null) { mState.Exit(); } mState = state; mState.Enter(); anim.SetInteger("StateID", mState.ID); }
public ISprite CreateSprite(IMovementState movement, IConditionState condition) { ISprite sprite = new DeadMarioSprite(marioSpriteSheet); Type spriteType; string code = ""; if (movement != null && condition != null) { code = movement.GetType().ToString() + condition.GetType().ToString(); } if (Mario.Instance != null && Mario.Instance.RowId != -1) { marioCostumeDictionary.TryGetValue(code, out spriteType); if (spriteType != null) { ConstructorInfo[] constr = new ConstructorInfo[1]; constr = spriteType.GetConstructors(); sprite = (ISprite)constr[0].Invoke(new object[] { marioCostumeSpriteSheet }); CostumeSprite costSprite = (CostumeSprite)sprite; costSprite.RowId = Mario.Instance.RowId; sprite = costSprite; } } else { marioDictionary.TryGetValue(code, out spriteType); if (spriteType != null) { ConstructorInfo[] constr = new ConstructorInfo[1]; constr = spriteType.GetConstructors(); sprite = (ISprite)constr[0].Invoke(new object[] { marioSpriteSheet }); } } return(sprite); }
protected bool IsRepeatedCommand(IMovementCommand command, IEventStoreAggregateId eventStoreAggregateId, IMovementState state) { bool repeated = false; if (((IMovementStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.GetEvent(typeof(IMovementEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
public void ChangeStateImmediate(MovementState targetState) { switch (targetState) { case MovementState.STOPPED: { NextState = new StoppedState(MovementModel, this); break; } case MovementState.ACCELERATING: { NextState = new AccelState(MovementModel, this); break; } case MovementState.MOVING: { NextState = new MovingState(MovementModel, this); break; } case MovementState.JUMPING: { NextState = new JumpingState(MovementModel, this); break; } case MovementState.FALL_FORGIVENESS: { NextState = new FallForgivenessState(MovementModel, this); break; } case MovementState.FALLING: { NextState = new FallingState(MovementModel, this); break; } case MovementState.HUGGING_WALL: { NextState = new HuggingWallState(MovementModel, this); break; } case MovementState.WALL_LAUNCH: { NextState = new WallLaunchState(MovementModel, this); break; } } CurrentState.OnExitState(); PreviousState = CurrentState; CurrentState = NextState; MovementModel.State = CurrentState.State; CurrentState.OnEnterState(); }
public void SetMovementState(IMovementState movementState) { MovementState = movementState; UpdateSprite(); }
private void Persist(IEventStoreAggregateId eventStoreAggregateId, IMovementAggregate aggregate, IMovementState state) { EventStore.AppendEvents(eventStoreAggregateId, ((IMovementStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); }); if (AggregateEventListener != null) { AggregateEventListener.EventAppended(new AggregateEvent <IMovementAggregate, IMovementState>(aggregate, state, aggregate.Changes)); } }
public MovementLineStates(IMovementState outerState) { this._movementState = outerState; this._forReapplying = outerState.ForReapplying; }