public virtual void MoveBy_Left(double d, ThingList targetThings) { position.X += d; foreach (Thing target in targetThings) { if (!target.Shootable) { continue; } if (Left < target.Right && target.Left < Right && Top < target.Bottom && target.Top < Bottom) { if (position.X > target.Center.X) { Left = target.Right; } target.Damage(damage); Hit(); return; } } int topRow = TopRow; int bottomRow = BottomRow; int leftCol = LeftCol; Map map = game.Map; if (map.IsObstacle(topRow, leftCol) || map.IsObstacle(bottomRow, leftCol)) { Left = (leftCol + 1) * Settings.BLOCK_WDITH; Hit(); } }
public virtual void MoveBy_Down(double d, ThingList targetThings) { position.Y += d; foreach (Thing target in targetThings) { if (!target.Shootable) { continue; } if (Left < target.Right && target.Left < Right && Top < target.Bottom && target.Top < Bottom) { if (position.Y < target.Center.Y) { Bottom = target.Top; } target.Damage(damage); Hit(); return; } } int leftCol = LeftCol; int rightCol = RightCol; int bottomRow = BottomRow; Map map = game.Map; if (map.IsObstacle(bottomRow, leftCol) || map.IsObstacle(bottomRow, rightCol)) { Bottom = bottomRow * Settings.BLOCK_WDITH; Hit(); } }
public override void MoveBy_Right(double d, ThingList targetThings) { position.X += d; int topRow = TopRow; int bottomRow = BottomRow; int rightCol = RightCol; Map map = game.Map; if (map.IsObstacle(topRow, rightCol) || map.IsObstacle(bottomRow, rightCol)) { Right = rightCol * Settings.BLOCK_WDITH; velocity.X = -velocity.X; } }
public override void MoveBy_Up(double d, ThingList targetThings) { position.Y += d; int leftCol = LeftCol; int rightCol = RightCol; int topRow = TopRow; Map map = game.Map; if (map.IsObstacle(topRow, leftCol) || map.IsObstacle(topRow, rightCol)) { Top = (topRow + 1) * Settings.BLOCK_WDITH; velocity.Y = -velocity.Y; } }
public override void MoveBy_Left(double d, ThingList targetThings) { position.X += d; int topRow = TopRow; int bottomRow = BottomRow; int leftCol = LeftCol; Map map = game.Map; if (map.IsObstacle(topRow, leftCol) || map.IsObstacle(bottomRow, leftCol)) { Left = (leftCol + 1) * Settings.BLOCK_WDITH; velocity.X = -velocity.X; } }
public override void MoveBy_Right(GameInput input, double d) { position.X += d; int topRow = TopRow; int bottomRow = BottomRow; int rightCol = RightCol; Map map = game.Map; for (int row = topRow; row <= bottomRow; row++) { if (map.IsObstacle(row, rightCol)) { Right = rightCol * Settings.BLOCK_WDITH; Blocked_Right(input); break; } } foreach (Thing enemy in game.Enemies) { if (Overlappes(enemy, this) && enemy.Shootable) { velocity.X = -8; EnemyDamage(enemy); } } }
public override void MoveBy_Down(double d, ThingList targetThings) { position.Y += d; int leftCol = LeftCol; int rightCol = RightCol; int bottomRow = BottomRow; Map map = game.Map; if (map.IsObstacle(bottomRow, leftCol) || map.IsObstacle(bottomRow, rightCol)) { Bottom = bottomRow * Settings.BLOCK_WDITH; if (game.Enemies.Count < 64) { game.AddEnemy(new Mushroom(game, new Vector(position.X - 16, Bottom - 32))); } Hit(); } }
public override void MoveBy_Down(double d, ThingList targetThings) { position.Y += d; int leftCol = LeftCol; int rightCol = RightCol; int bottomRow = BottomRow; Map map = game.Map; if (map.IsObstacle(bottomRow, leftCol) || map.IsObstacle(bottomRow, rightCol)) { Bottom = bottomRow * Settings.BLOCK_WDITH; if (isWormEgg) { if (game.Enemies.Count < 6) { if (!(position.X < game.Map.Width - 256 && position.X > 256) && position.Y > game.Map.Height - 128) { game.AddEnemy(new Worm(game, new Vector(position.X - 16, Bottom - 32))); } } } Hit(); } else { foreach (Thing target in targetThings) { if (!target.Shootable) { continue; } if (Left < target.Right && target.Left < Right && Top < target.Bottom && target.Top < Bottom) { if (position.Y < target.Center.Y) { Bottom = target.Top; } target.Damage(damage); Hit(); break; } } } }
public virtual void MoveBy_Down(GameInput input, double d) { position.Y += d; int leftCol = LeftCol; int rightCol = RightCol; int bottomRow = BottomRow; Map map = game.Map; for (int col = leftCol; col <= rightCol; col++) { if (map.IsObstacle(bottomRow, col)) { Bottom = bottomRow * Settings.BLOCK_WDITH; Blocked_Bottom(input); break; } } }
public virtual void MoveBy_Right(GameInput input, double d) { position.X += d; int topRow = TopRow; int bottomRow = BottomRow; int rightCol = RightCol; Map map = game.Map; for (int row = topRow; row <= bottomRow; row++) { if (map.IsObstacle(row, rightCol)) { Right = rightCol * Settings.BLOCK_WDITH; Blocked_Right(input); break; } } }
public virtual void MoveBy_Up(GameInput input, double d) { position.Y += d; int leftCol = LeftCol; int rightCol = RightCol; int topRow = TopRow; Map map = game.Map; for (int col = leftCol; col <= rightCol; col++) { if (map.IsObstacle(topRow, col)) { Top = (topRow + 1) * Settings.BLOCK_WDITH; Blocked_Top(input); break; } } }
public virtual void MoveBy_Left(GameInput input, double d) { position.X += d; int topRow = TopRow; int bottomRow = BottomRow; int leftCol = LeftCol; Map map = game.Map; for (int row = topRow; row <= bottomRow; row++) { if (map.IsObstacle(row, leftCol)) { Left = (leftCol + 1) * Settings.BLOCK_WDITH; Blodked_Left(input); break; } } }
public override void MoveBy_Down(GameInput input, double d) { position.Y += d; int leftCol = LeftCol; int rightCol = RightCol; int bottomRow = BottomRow; Map map = game.Map; for (int col = leftCol; col <= rightCol; col++) { if (map.IsObstacle(bottomRow, col)) { Bottom = bottomRow * Settings.BLOCK_WDITH; Blocked_Bottom(input); break; } } foreach (Thing enemy in game.Enemies) { if (Overlappes(enemy, this) && enemy.Shootable) { if (enemy.Center.X < Center.X) { velocity.X = 8; } else if (Center.X < enemy.Center.X) { velocity.X = -8; } else { velocity.X = game.Random.Next(0, 2) == 0 ? 8 : -8; } EnemyDamage(enemy); } } }