public Enemy(Vector2 position, string enemyState) { Position = position; MaxVelocity = new Vector2(GameValues.EnemyMaxXVelocity, GameValues.PhysicsMaxYVelocity); Acceleration = Vector2.Zero; EnemyStateTransitionMachine = new EnemyStateTransitionMachine(); IsFlipped = false; IsSlidingShell = false; IsTongueCaptured = false; rand = new Random(); randBuffer = 0; Fireball = new Fireball(Vector2.Zero, false, true); koopaShellTimeout = GameValues.EnemyKoopaShellTimeout; deadGoombaTimeout = GameValues.EnemyDeadEnemyTimeout; if (enemyState == "WalkingGoomba") { EnemyState = new WalkingGoomba(position, this); Velocity = new Vector2(-MaxVelocity.X, 0); } else if (enemyState == "RightWalkingKoopa") { EnemyState = new RightWalkingKoopa(position, this); Velocity = new Vector2(MaxVelocity.X, 0); } else if (enemyState == "LeftWalkingKoopa") { EnemyState = new LeftWalkingKoopa(position, this); Velocity = new Vector2(-MaxVelocity.X, 0); } else if (enemyState == "PiranhaPlant") { EnemyState = new PiranhaPlant(position, this); } else if (enemyState == "HidingInsideShellKoopa") { EnemyState = new HidingInsideShellKoopa(position, this); } else if (enemyState == "ComingOutOfShellKoopa") { EnemyState = new ComingOutOfShellKoopa(position, this); } else if (enemyState == "CrawfisLeft") { EnemyState = new CrawfisLeft(position, this); Velocity = new Vector2(-MaxVelocity.X, 0); } else if (enemyState == "BowserLeft") { EnemyState = new BowserLeft(position, this); Velocity = new Vector2(-MaxVelocity.X, 0); } else if (enemyState == "NoEnemy") { EnemyState = new NoEnemy(this); } CollisionRectangle = EnemyState.CollisionRectangle; }
public void ChangeState(string state) { if (state == "SuperMario.EnemyStates.LeftWalkingKoopa") { EnemyState = new RightWalkingKoopa(Position, this); } else if (state == "SuperMario.EnemyStates.RightWalkingKoopa") { EnemyState = new LeftWalkingKoopa(Position, this); } else if (state == "SuperMario.EnemyStates.CrawfisLeft") { EnemyState = new CrawfisRight(Position, this); } else if (state == "SuperMario.EnemyStates.CrawfisRight") { EnemyState = new CrawfisLeft(Position, this); } else if (state == "SuperMario.EnemyStates.BowserLeft") { EnemyState = new BowserRight(Position, this); } else if (state == "SuperMario.EnemyStates.BowserRight") { EnemyState = new BowserLeft(Position, this); } }