public void EndAndInitialPointAreDifferent(int width, int height) { var labyrinth = new LabyrinthGenerator(height, width); labyrinth.GenerateLabyrinth(); Assert.IsFalse(labyrinth.InitialPoint.Equals(labyrinth.EndPoint)); }
public MapController(int width, int height) { labyrinthGenerator = new LabyrinthGenerator(width, height); labyrinthGenerator.GenerateLabyrinth(); PlayerPosition = new Cell(InitialPoint.X, InitialPoint.Y, CellTypes.Player); Maze = labyrinthGenerator.ToArray(); IsEndReached = false; ExploreCells(); UpdateVisibleCells(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); labyrinth = LabyrinthGenerator.GenerateLabyrinth(labyrinthName, this); SetContentView(Resource.Layout.Main); GridLayout layout = FindViewById <GridLayout>(Resource.Id.gridLayout1); LabyrinthViewGenerator.Generate(labyrinth, layout, this); heroImage = FindViewById <ImageView>(Resource.Id.imageView1); if (bundle != null) { time = bundle.GetInt("time"); iterator = bundle.GetInt("iterator"); heroImage.TranslationX = bundle.GetFloat("HeroPositionX"); var surfaceOrientation = WindowManager.DefaultDisplay.Rotation; if (surfaceOrientation == SurfaceOrientation.Rotation0 || surfaceOrientation == SurfaceOrientation.Rotation180) { heroImage.TranslationX += 350; } else { heroImage.TranslationX -= 350; } heroImage.TranslationY = bundle.GetFloat("HeroPositionY"); } else { var surfaceOrientation = WindowManager.DefaultDisplay.Rotation; if (surfaceOrientation == SurfaceOrientation.Rotation0 || surfaceOrientation == SurfaceOrientation.Rotation180) { heroImage.TranslationX = -460 + labyrinth.Start.XCoord * 150; } else { heroImage.TranslationX = -810 + labyrinth.Start.XCoord * 150; } heroImage.TranslationY = labyrinth.Start.YCoord * 150 + 40; } Hero hero = new Hero(labyrinth.Finish); hero.MoveToNextRoom(labyrinth.Start); List <Coordinates> journey = hero.journey; ValueAnimator animator = ValueAnimator.OfInt(0, 10); animator.SetDuration(1000 * journey.Count); animator.Update += (object sender, ValueAnimator.AnimatorUpdateEventArgs e) => { float shift = 15; if (iterator == journey.Count - 1) { return; } if (journey[iterator].X < journey[iterator + 1].X) { heroImage.TranslationX += shift; } if (journey[iterator].X > journey[iterator + 1].X) { heroImage.TranslationX -= shift; } if (journey[iterator].Y < journey[iterator + 1].Y) { heroImage.TranslationY += shift; } if (journey[iterator].Y > journey[iterator + 1].Y) { heroImage.TranslationY -= shift; } if (time++ > 8) { iterator++; time = 0; } }; animator.Start(); }