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;
        }
示例#3
0
        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;
        }
示例#4
0
        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";
            }
        }