public override void Process(Entity entity) { FSMComponent fsm = entity.GetComponent <FSMComponent>(); InputIntentComponent inputIntent = entity.GetComponent <InputIntentComponent>(); BinaryDirectionComponent binaryDirection = entity.GetComponent <BinaryDirectionComponent>(); if (inputIntent.Up) { LinkOnGroundStateComponent onGround = entity.GetComponent <LinkOnGroundStateComponent>(); SpeedComponent speed = entity.GetComponent <SpeedComponent>(); speed.SpeedY = -onGround.JumpForce; fsm.SetState(entity, "onAir"); return; } if (inputIntent.Left ^ inputIntent.Right) { if (inputIntent.Left) { binaryDirection.Direction = BinaryDirection.Left; } if (inputIntent.Right) { binaryDirection.Direction = BinaryDirection.Right; } if (inputIntent.Run) { fsm.SetState(entity, "run"); return; } fsm.SetState(entity, "walk"); return; } fsm.SetState(entity, "idle"); }
public override void Process(Entity entity) { LinkOnGroundStateComponent onGround = entity.GetComponent <LinkOnGroundStateComponent>(); LinkWalkSpeedStateComponent walkSpeed = entity.GetComponent <LinkWalkSpeedStateComponent>(); GoalSpeedComponent goalSpeed = entity.GetComponent <GoalSpeedComponent>(); BinaryDirectionComponent binaryDirection = entity.GetComponent <BinaryDirectionComponent>(); goalSpeed.AccelX = onGround.Accel * (int)binaryDirection.Direction; goalSpeed.GoalSpeedX = walkSpeed.MaxWalkSpeed * (int)binaryDirection.Direction; }
public override void Process(Entity entity) { LinkOnGroundStateComponent onGround = entity.GetComponent <LinkOnGroundStateComponent>(); GoalSpeedComponent goalSpeed = entity.GetComponent <GoalSpeedComponent>(); BinaryDirectionComponent binaryDirection = entity.GetComponent <BinaryDirectionComponent>(); SpriteComponent sprite = entity.GetComponent <SpriteComponent>(); sprite.Name = "spr/Link/Stand"; goalSpeed.AccelX = onGround.Accel * (int)binaryDirection.Direction * -1; goalSpeed.GoalSpeedX = 0; }
public override void Process(Entity entity) { BinaryDirectionComponent binaryDirection = entity.GetComponent <BinaryDirectionComponent>(); SpriteComponent sprite = entity.GetComponent <SpriteComponent>(); sprite.Effects = SpriteEffects.None; if (binaryDirection.Direction == BinaryDirection.Left) { sprite.Effects = SpriteEffects.FlipHorizontally; } }
public override void Process(Entity entity) { LinkOnGroundStateComponent onGround = entity.GetComponent <LinkOnGroundStateComponent>(); LinkRunStateComponent run = entity.GetComponent <LinkRunStateComponent>(); SpeedComponent speed = entity.GetComponent <SpeedComponent>(); GoalSpeedComponent goalSpeed = entity.GetComponent <GoalSpeedComponent>(); BinaryDirectionComponent binaryDirection = entity.GetComponent <BinaryDirectionComponent>(); SpriteComponent sprite = entity.GetComponent <SpriteComponent>(); goalSpeed.AccelX = onGround.Accel * (int)binaryDirection.Direction; goalSpeed.GoalSpeedX = run.MaxRunSpeed * (int)binaryDirection.Direction; sprite.Name = "spr/Link/Run"; if (Math.Sign(-speed.SpeedX) == (int)binaryDirection.Direction) { sprite.Name = "spr/Link/Skid"; } }
public override void Process(Entity entity) { SpeedComponent speed = entity.GetComponent <SpeedComponent>(); SpriteComponent sprite = entity.GetComponent <SpriteComponent>(); if (speed.Speed.Y < 0) { LinkWalkSpeedStateComponent walkSpeed = entity.GetComponent <LinkWalkSpeedStateComponent>(); BinaryDirectionComponent binaryDirection = entity.GetComponent <BinaryDirectionComponent>(); if (Math.Sign(speed.SpeedX) == (int)binaryDirection.Direction && Math.Abs(speed.SpeedX) > walkSpeed.MaxWalkSpeed) { sprite.Name = "spr/Link/JumpFwd"; } else { sprite.Name = "spr/Link/Jump"; } } else { sprite.Name = "spr/Link/Fall"; } }