示例#1
0
        public override void UpdateLogic(LandWorld world, IEntity owner, Time deltaTime)
        {
            if (world.EntityManager.IsBookingStillValid(owner) == false)
            {
                WalkKinematicAbility walkKinematicAbility = owner.GetAbilityById("kinematic.walk") as WalkKinematicAbility;

                if (Keyboard.IsKeyPressed(Keyboard.Key.Z))
                {
                    walkKinematicAbility.SetSteering(world, owner, MovingDirection.ABOVE);
                }
                else if (Keyboard.IsKeyPressed(Keyboard.Key.S))
                {
                    walkKinematicAbility.SetSteering(world, owner, MovingDirection.UNDER);
                }

                if (Keyboard.IsKeyPressed(Keyboard.Key.D))
                {
                    walkKinematicAbility.SetSteering(world, owner, MovingDirection.RIGHT);
                }
                else if (Keyboard.IsKeyPressed(Keyboard.Key.Q))
                {
                    walkKinematicAbility.SetSteering(world, owner, MovingDirection.LEFT);
                }
            }
        }
示例#2
0
        public PlayerEntity(int positionX, int positionY, int positionZ) : base(positionX, positionY, positionZ)
        {
            WalkKinematicAbility walkKinematicAbility = new WalkKinematicAbility(1f);

            this.idToAbilities.Add("kinematic.walk", walkKinematicAbility);

            PlayerBehavior playerBehavior = new PlayerBehavior();

            this.idToBehaviors.Add("player", playerBehavior);
        }
示例#3
0
        public PlayerEntity2D(IObject2DFactory factory, PlayerEntity playerEntity) :
            base(factory, playerEntity)
        {
            Texture texture = factory.GetTextureByIndex(0);

            IntRect[] walkTop = new IntRect[]
            {
                new IntRect(2 * 32, 0 * 32, 32, 32),
                new IntRect(11 * 32, 5 * 32, 32, 32)
            };

            Animation animationWalkTop = new Animation(walkTop, Time.FromMilliseconds(250), AnimationType.LOOP);

            IntRect[] walkBot = new IntRect[]
            {
                new IntRect(2 * 32, 2 * 32, 32, 32),
                new IntRect(2 * 32, 3 * 32, 32, 32)
            };

            Animation animationWalkBot = new Animation(walkBot, Time.FromMilliseconds(250), AnimationType.LOOP);

            IntRect[] walkRight = new IntRect[]
            {
                new IntRect(1 * 32, 2 * 32, 32, 32),
                new IntRect(1 * 32, 3 * 32, 32, 32)
            };

            Animation animationWalkRight = new Animation(walkRight, Time.FromMilliseconds(250), AnimationType.LOOP);

            IntRect[] walkLeft = new IntRect[]
            {
                new IntRect(0 * 32, 3 * 32, 32, 32),
                new IntRect(1 * 32, 0 * 32, 32, 32)
            };

            Animation animationWalkLeft = new Animation(walkLeft, Time.FromMilliseconds(250), AnimationType.LOOP);


            IntRect[] idleTop = new IntRect[]
            {
                new IntRect(9 * 32, 4 * 32, 32, 32)
            };

            Animation animationIdleTop = new Animation(idleTop, Time.FromMilliseconds(250), AnimationType.LOOP);

            IntRect[] idleBot = new IntRect[]
            {
                new IntRect(2 * 32, 1 * 32, 32, 32)
            };

            Animation animationIdleBot = new Animation(idleBot, Time.FromMilliseconds(250), AnimationType.LOOP);

            IntRect[] idleRight = new IntRect[]
            {
                new IntRect(10 * 32, 4 * 32, 32, 32)
            };

            Animation animationIdleRight = new Animation(idleRight, Time.FromMilliseconds(250), AnimationType.LOOP);

            IntRect[] idleLeft = new IntRect[]
            {
                new IntRect(9 * 32, 6 * 32, 32, 32)
            };

            Animation animationIdleLeft = new Animation(idleLeft, Time.FromMilliseconds(250), AnimationType.LOOP);

            this.animationsList.Add(animationIdleTop);
            this.animationsList.Add(animationIdleBot);
            this.animationsList.Add(animationIdleRight);
            this.animationsList.Add(animationIdleLeft);

            this.animationsList.Add(animationWalkTop);
            this.animationsList.Add(animationWalkBot);
            this.animationsList.Add(animationWalkRight);
            this.animationsList.Add(animationWalkLeft);

            this.ObjectSprite = new Sprite(texture, new IntRect(2 * 32, 1 * 32, 32, 32));

            //this.ObjectSprite.Scale = new Vector2f(0.5f, 0.5f);

            this.Position = new Vector2f(playerEntity.Position.X, playerEntity.Position.Y);

            WalkKinematicAbility walkKinematicAbility = this.characterEntity.GetAbilityById("kinematic.walk") as WalkKinematicAbility;

            walkKinematicAbility.MovingStateUpdated += OnMovingStateUpdated;
        }
示例#4
0
        public override void Dispose()
        {
            WalkKinematicAbility walkKinematicAbility = this.characterEntity.GetAbilityById("kinematic.walk") as WalkKinematicAbility;

            walkKinematicAbility.MovingStateUpdated -= OnMovingStateUpdated;
        }