//Vector2 newPosition; //float newDistance; public Gameplay(Texture2D idleSpriteSheet, Texture2D walkSpriteSheet, Texture2D tauntSpriteSheet, Texture2D jumpSpriteSheet, Texture2D backgroundtexture, Map map, Texture2D healthtexture, Texture2D enemyIdleSpritesheet, Texture2D enemyWalkSpritesheet) { //Charactertexture = charactertexture; charakter = new Charakter(idleSpriteSheet, walkSpriteSheet, tauntSpriteSheet, jumpSpriteSheet); gamebackground = new GameBackground(backgroundtexture); this.map = map; healthbar = new Healthbar(healthtexture); enemy1 = new Enemy1(enemyIdleSpritesheet, enemyWalkSpritesheet /* newPosition, newDistance*//*new Vector2(80,440)*/); enemy2 = new Enemy2(enemyIdleSpritesheet, enemyWalkSpritesheet); //camera = new Camera(GraphicsDevice.Viewport); }
public void Update(GameTime gameTime, Charakter charakter) { Console.WriteLine(state); velocity.Y += 0.15f; distance = charakter.Position.X - this.position.X; EnemyisWalkingRight = false; EnemyisWalkingLeft = false; position += velocity; rectangle = new Rectangle((int)position.X, (int)position.Y, 45, 54); switch (state) { case EnemyState.idle: //velocity.X = 0; UpdateIdle(); if (Math.Abs(distance) < 150) { state = EnemyState.hunting; } break; case EnemyState.patrolling: break; case EnemyState.hunting: UpdateHunting(); if (Math.Abs(distance) > 150) { state = EnemyState.idle; } break; } Enemyidle.Update(gameTime); Enemywalk.Update(gameTime); }