protected virtual void LateUpdate()
 {
     if (CheckIfNeedToFlipSprite(WalkingPlayer.GetSpeedX()))
     {
         FlipSprite();
     }
 }
 public void XAxisAnimations(float speedX)
 {
     if (speedX < 0)       //Moving left
     {
         speedX = -speedX; // Adjusting the horizontal speed to a positive value if moving to left
     }
     Anim.SetBool("Moving", speedX != 0);
     Anim.SetBool("Sprinting", speedX > WalkingPlayer.GetRunSpeed());
 }
    public void XAxisAnimations(float speedX)
    {
        if (speedX < 0)       //Moving left
        {
            speedX = -speedX; // Adjusting the horizontal speed to a positive value if moving to left
        }
        bool moving = speedX != 0;

        Anim.SetBool("Moving", moving);

        bool sprinting = speedX > WalkingPlayer.GetRunSpeed();

        Anim.SetBool("Sprinting", sprinting);

        HandleFootstepParticles(moving, sprinting);
    }
    public virtual void YAxisAnimations()
    {
        bool grounded = WalkingPlayer.GetGrounded();

        Anim.SetBool("Grounded", grounded);

        if (grounded == LastGrounded)
        {
            return;
        }

        LastGrounded = grounded;
        if (LastGrounded)
        {
            ImpactOnFlootParticles.Play();
        }
    }
    private void HandleFootstepParticles(bool moving, bool sprinting)
    {
        MovingState newMovingState;
        bool        grounded = WalkingPlayer.GetGrounded();

        if (sprinting && grounded)
        {
            newMovingState = MovingState.sprinting;
        }
        else if (moving && grounded)
        {
            newMovingState = MovingState.moving;
        }
        else
        {
            newMovingState = MovingState.notMoving;
        }

        if (newMovingState == CurrentMovingState)
        {
            return;
        }

        CurrentMovingState = newMovingState;
        switch (CurrentMovingState)
        {
        case MovingState.notMoving:
            FootstepEmission.rateOverTime = EmissionEmpty;
            break;

        case MovingState.moving:
            FootstepEmission.rateOverTime = EmissionNormal;
            break;

        case MovingState.sprinting:
            FootstepEmission.rateOverTime = EmissionSprint;
            break;
        }
    }
Пример #6
0
 public MoveUpCommand(WalkingPlayer player)
 {
     this.Name        = "Move Up";
     this.Description = "Move the player up";
     this.player      = player;
 }
 protected virtual void FixedUpdate()
 {
     SpeedXNonLocal = WalkingPlayer.GetSpeedX();
     XAxisAnimations(SpeedXNonLocal);
     YAxisAnimations();
 }
Пример #8
0
        public WalkingScene(SpellswordGame game, World thisWorld, WalkingPlayer player)
        {
            inputHandler = game.Services.GetService <InputHandler>();
            if (inputHandler == null)
            {
                inputHandler = new InputHandler(game);
                game.Components.Add(inputHandler);
            }

            this.game      = game;
            this.thisWorld = thisWorld;
            this.player    = player;

            string[] mapFile =
            {
                "11111110001111111",
                "11111110001111111",
                "11111110001111111",
                "11110000000001111",
                "11110000000001111",
                "11110000000001111",
                "00010000000001000",
                "00000000000000000",
                "00010000000001000",
                "11110000000001111",
                "11110000000001111",
                "11110000000001111",
                "00010000000001000",
                "00000000000000000",
                "00010000000001000",
                "11110000000001111",
                "11110000000001111",
                "11110000000001111",
                "11110000000001111",
                "11111111011111111",
                "11111110001111111",
                "11111110001111111",
                "11111110001111111"
            };

            emptyTiles = new List <EmptyTile>();
            CreateEmptyTiles(game, mapFile);

            //Temp test
            Enemy welp   = new Welp("WelpSmall", "Welp");
            Enemy zombie = new Zombie("ZombieSmall", "Zombie");
            Enemy wraith = new Wraith("WraithSmall", "Wraith");
            Enemy ghost  = new Ghost("BackwardsStill", "Ghost");
            Enemy flower = new Flower("FlowerWorld", "FlowerBattle");
            Enemy dragon = new Dragon("Dragon", "Dragon", "DragonSpecial");

            enemies = new List <WorldEnemy>();
            this.enemies.Add(new WorldEnemy(game, thisWorld, new Point(3, 7), welp));    // Welp
            this.enemies.Add(new WorldEnemy(game, thisWorld, new Point(3, 13), zombie)); // Zombie
            this.enemies.Add(new WorldEnemy(game, thisWorld, new Point(13, 7), wraith)); // Wraith
            this.enemies.Add(new WorldEnemy(game, thisWorld, new Point(13, 13), ghost)); // Ghost
            this.enemies.Add(new WorldEnemy(game, thisWorld, new Point(8, 19), flower)); // Flower
            this.enemies.Add(new WorldEnemy(game, thisWorld, new Point(8, 1), dragon));  // Dragon Boss

            // More Temp Test
            swords = new List <WorldSword>();
            Weapon iceShield      = new IceShield("IceShield", 8, 15);
            Weapon iceSword       = new IceSword("IceSword", 20, 5);
            Weapon lightningSword = new LightningSword("LightningSword", 30, 5);
            Weapon focus          = new BasicFocus("SpellFocus");

            this.swords.Add(new WorldSword(game, thisWorld, new Point(1, 7), iceShield));       // Ice Shield
            this.swords.Add(new WorldSword(game, thisWorld, new Point(1, 13), iceSword));       // Ice Blade
            this.swords.Add(new WorldSword(game, thisWorld, new Point(15, 7), lightningSword)); // Lightning Blade
            this.swords.Add(new WorldSword(game, thisWorld, new Point(15, 13), focus));         // Spell/Power Focus

            InitializePlayerToMiddle();
        }
 public virtual void YAxisAnimations()
 {
     Anim.SetBool("Grounded", WalkingPlayer.GetGrounded());
 }