public Walker(Rectangle rectangle, Texture2D texture) : base(rectangle, texture) { this.rectangle = rectangle; int d = rnd.Next(0, 2); int e = rnd.Next(0, 2); this.texture = 0 == e?ContentManager.Textures["walker1"]: ContentManager.Textures["walker2"]; velocityX = d == 0 ? 140 : -140; state = walkerState.alive; timer = 0; }
void IDamaged.GetDamaged() { velocityY = -150; collidable = false; state = walkerState.damaged; }
public override void Move(float TimeElapsed) { if (state == walkerState.dying) { timer += TimeElapsed; if (timer >= 2) { enemydead = true; } if (collisionYbot) { velocityY = 0; } rectangle.Y += velocityY * TimeElapsed; } else if (state == walkerState.damaged) { timer += TimeElapsed; if (timer >= 2) { enemydead = true; } rectangle.Y += velocityY * TimeElapsed; } else { if (GetHitTopLeft || GetHitTopRight) { GetHitTopLeft = false; GetHitTopRight = false; state = walkerState.dying; collidable = false; velocityX = 0; } if (GetHitSide) { scene.player.GetHit(this); } if (!collisionX) { rectangle.X += velocityX * TimeElapsed; } else { velocityX = -velocityX; } if (!collisionYbot && !collisionYtop) { rectangle.Y += velocityY * TimeElapsed; } else { velocityY = 0; if (collisionYtop) { velocityY += 15; rectangle.Y += velocityY * TimeElapsed; } } } }