public async Task <DirectionDto> GetDirectionByIdAsync(Guid id) { DirectionDto direction = DirectionConverter.Convert(await _directionRepo.GetByIdAsync(id)); direction.Administration = AdministrationConverter.Convert(await _adminRepo.GetByDirectionIdAsync(id)); direction.Courses = CourseConverter.Convert(await _courseRepo.GetByDirectionIdAsync(id)); return(direction); }
public BattleshipMainView(IEventAggregator aggregator, IGamePackageResolver resolver ) { _aggregator = aggregator; _resolver = resolver; _aggregator.Subscribe(this); _boardUI = new GameBoardWPF(); Grid mainGrid = new Grid(); AddAutoColumns(mainGrid, 1); AddLeftOverColumn(mainGrid !, 1); // try as leftovers mainGrid !.Margin = new Thickness(5, 5, 5, 5); AddControlToGrid(mainGrid, _boardUI, 0, 0); StackPanel otherStack = new StackPanel(); otherStack.Margin = new Thickness(5, 5, 5, 5); AddControlToGrid(mainGrid, otherStack, 0, 1); _shipUI = new ShipControlWPF(); otherStack.Children.Add(_shipUI); StackPanel tempStack = new StackPanel(); tempStack.Margin = new Thickness(0, 5, 0, 0); var thisBind = GetVisibleBinding(nameof(BattleshipMainViewModel.ShipDirectionsVisible)); tempStack.SetBinding(StackPanel.VisibilityProperty, thisBind); var firstBut = GetGamingButton("Horizontal", nameof(BattleshipMainViewModel.ShipDirection)); firstBut.CommandParameter = true; thisBind = new Binding(nameof(BattleshipMainViewModel.ShipsHorizontal)); IValueConverter thisConv; thisConv = new DirectionConverter(); thisBind.Converter = thisConv; thisBind.ConverterParameter = true; // this one is true for comparison //WindowHelper.SetKeyBindings(Key.F1, nameof(BattleshipMainViewModel.ShipDirectionCommand), true); firstBut.SetBinding(BackgroundProperty, thisBind); tempStack.Children.Add(firstBut); firstBut = GetGamingButton("Vertical", nameof(BattleshipMainViewModel.ShipDirection)); //WindowHelper.SetKeyBindings(Key.F2, nameof(BattleshipMainViewModel.ShipDirectionCommand), false); firstBut.CommandParameter = false; thisBind = new Binding(nameof(BattleshipMainViewModel.ShipsHorizontal)); thisBind.Converter = thisConv; thisBind.ConverterParameter = false; firstBut.SetBinding(BackgroundProperty, thisBind); tempStack.Children.Add(firstBut); otherStack.Children.Add(tempStack); // i think SimpleLabelGrid firstInfo = new SimpleLabelGrid(); firstInfo.AddRow("Turn", nameof(BattleshipMainViewModel.NormalTurn)); firstInfo.AddRow("Status", nameof(BattleshipMainViewModel.Status)); otherStack.Children.Add(firstInfo.GetContent); //for now, no hotkeys. otherwise, requires lots of rethinking on this one. Content = mainGrid; }
public async Task <List <DirectionDto> > GetAllDirectionAsync() { List <DirectionDto> directions = DirectionConverter.Convert(await _directionRepo.GetAllAsync()); List <CourseDto> courses = await GetAllCourseAsync(); foreach (DirectionDto i in directions) { i.Courses = courses.Where(x => x.DirectionId == i.Id).ToList(); } return(directions); }
private Direction FoodInDirection(VoxelInfo[, ,] neighbourhood) { for (int t = 0; t < 3; ++t) { for (int h = 0; h < 3; ++h) { for (int b = 0; b < 3; ++b) { if (!(t == 1 && h == 1 && b == 1)) // if not the voxel itself { if (TypeInformation.IsBiomass(neighbourhood[t, h, b].Type)) { return(DirectionConverter.ToDirection(t, h, b)); } } } } } return(Direction.SELF); }
private Direction GetBranchDirection(VoxelInfo[, ,] neighbourhood) { if (neighbourhood[2, 1, 1].Type == VoxelType.PINE_WOOD && neighbourhood[0, 1, 1].Type == VoxelType.EMPTY) { return(DirectionConverter.ToDirection(0, 1, 1)); } if (neighbourhood[0, 1, 1].Type == VoxelType.PINE_WOOD && neighbourhood[2, 1, 1].Type == VoxelType.EMPTY) { return(DirectionConverter.ToDirection(2, 1, 1)); } if (neighbourhood[1, 1, 2].Type == VoxelType.PINE_WOOD && neighbourhood[1, 1, 0].Type == VoxelType.EMPTY) { return(DirectionConverter.ToDirection(1, 1, 0)); } if (neighbourhood[1, 1, 0].Type == VoxelType.PINE_WOOD && neighbourhood[1, 1, 2].Type == VoxelType.EMPTY) { return(DirectionConverter.ToDirection(1, 1, 2)); } return(Direction.SELF); }
public override bool MoveOnThis(Truck truck, Direction direction) { if (_Movable == null) { _Movable = truck; _PlacedCounter++; return(true); } else { if (DirectionConverter.Convert(this, direction).MoveOnThis(_Movable, direction)) { _Movable = truck; truck._Field = this; _PlacedCounter++; return(true); } else { return(false); } } }
public void TestGetStringValue() { DirectionType dirn = DirectionType.Rtl; DirectionConverter.GetStringValue(dirn).Should().Be("rtl"); }
public void TestGetEnumValueRtl() { DirectionConverter.GetEnumValue("rtl").Should().Be(DirectionType.Rtl); }
public void TestGetEnumValueDuffValue() { DirectionConverter.GetEnumValue("rubbish").Should().Be(null); }
public void TestGetStringValueNullableNull() { DirectionType?dirn = null; DirectionConverter.GetStringValue(dirn).Should().Be(""); }
public void TestGetStringValueInvalidEnumValue() { DirectionType dirn = (DirectionType)1; DirectionConverter.GetStringValue(dirn).Should().Be(""); }
public async Task <DirectionDto> CreateDirectionAsync(DirectionDto item) { return(DirectionConverter.Convert(await _directionRepo.CreateAsync(DirectionConverter.Convert(item)))); }
public VoxelInfo[, ,] ApplyRule(VoxelInfo[, ,] neighbourhood) { // Apply each 18-th turn if (neighbourhood[1, 1, 1].Ticks < TypeInformation.GetGrowingSteps(VoxelType.SPRUCE_WOOD)) { return(null); } VoxelInfo[, ,] output = new VoxelInfo[3, 3, 3]; int gen = neighbourhood[1, 1, 1].Generation; if (gen == 0) { // Grow 3x3 and ovveride current generation output[1, 1, 1] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 1, 0, TypeInformation.GetGrowingSteps(VoxelType.SPRUCE_WOOD) / 2); output[2, 1, 1] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2, 0, TypeInformation.GetGrowingSteps(VoxelType.SPRUCE_WOOD) / 4); output[0, 1, 1] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2, 0, TypeInformation.GetGrowingSteps(VoxelType.SPRUCE_WOOD) / 4); output[1, 1, 2] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2, 0, TypeInformation.GetGrowingSteps(VoxelType.SPRUCE_WOOD) / 4); output[1, 1, 0] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2, 0, TypeInformation.GetGrowingSteps(VoxelType.SPRUCE_WOOD) / 4); output[2, 1, 2] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2); output[2, 1, 0] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2); output[0, 1, 2] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2); output[0, 1, 0] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2); if (TypeInformation.IsNotWoodButBiomass(neighbourhood[2, 0, 1].Type) || neighbourhood[2, 0, 1].Type == VoxelType.EMPTY) { output[2, 0, 1] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2, 0, TypeInformation.GetGrowingSteps(VoxelType.SPRUCE_WOOD) / 4, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[0, 0, 1].Type) || neighbourhood[0, 0, 1].Type == VoxelType.EMPTY) { output[0, 0, 1] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2, 0, TypeInformation.GetGrowingSteps(VoxelType.SPRUCE_WOOD) / 4, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[1, 0, 2].Type) || neighbourhood[1, 0, 2].Type == VoxelType.EMPTY) { output[1, 0, 2] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2, 0, TypeInformation.GetGrowingSteps(VoxelType.SPRUCE_WOOD) / 4, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[1, 0, 0].Type) || neighbourhood[1, 0, 0].Type == VoxelType.EMPTY) { output[1, 0, 0] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2, 0, TypeInformation.GetGrowingSteps(VoxelType.SPRUCE_WOOD) / 4, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[2, 0, 2].Type) || neighbourhood[2, 0, 2].Type == VoxelType.EMPTY) { output[2, 0, 2] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2, 0, 0, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[2, 0, 0].Type) || neighbourhood[2, 0, 0].Type == VoxelType.EMPTY) { output[2, 0, 0] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2, 0, 0, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[0, 0, 2].Type) || neighbourhood[0, 0, 2].Type == VoxelType.EMPTY) { output[0, 0, 2] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2, 0, 0, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[0, 0, 0].Type) || neighbourhood[0, 0, 0].Type == VoxelType.EMPTY) { output[0, 0, 0] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, 2, 0, 0, Direction.UP); } } else if (gen < TypeInformation.GetGrowHeight(VoxelType.SPRUCE_WOOD)) { // Grow upwards // Grow in given direction Int3 coord = DirectionConverter.FromDirection(DirectionConverter.ToOppositeDirection(neighbourhood[1, 1, 1].From)); if (TypeInformation.IsNotWoodButBiomass(neighbourhood[coord.X, coord.Y, coord.Z].Type) || neighbourhood[coord.X, coord.Y, coord.Z].Type == VoxelType.EMPTY) { output[coord.X, coord.Y, coord.Z] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, gen + 1, 0, 0, neighbourhood[1, 1, 1].From); } //output[1, 2, 1] = new VoxelInfo(VoxelType.SPRUCE_WOOD, true, gen + 1); output[1, 1, 1] = new VoxelInfo(VoxelType.SPRUCE_WOOD); } else { // Grow upwards one last time //output[1, 2, 1] = new VoxelInfo(VoxelType.SPRUCE_WOOD); if (neighbourhood[1, 1, 1].From != Direction.UP) { output[1, 2, 1] = new VoxelInfo(VoxelType.SPRUCE_NEEDLE, true); } output[1, 1, 1] = new VoxelInfo(VoxelType.SPRUCE_WOOD); } return(output); }
public async Task <bool> UpdateDirectionAsync(DirectionDto item) { return(await _directionRepo.UpdateAsync(DirectionConverter.Convert(item))); }
public VoxelInfo[, ,] ApplyRule(VoxelInfo[, ,] neighbourhood) { if (neighbourhood[1, 1, 1].Ticks < TypeInformation.GetGrowingSteps(VoxelType.HESPEROPHANES_CINNEREUS)) { return(null); } VoxelInfo[, ,] output = new VoxelInfo[3, 3, 3]; int gen = neighbourhood[1, 1, 1].Generation; int res = neighbourhood[1, 1, 1].Resources; int t = random.Next(0, 3); int h = random.Next(0, 3); int b = random.Next(0, 3); if (gen == 0) { if (IsWalkable(neighbourhood[t, h, b])) { output[1, 1, 1] = new VoxelInfo(VoxelType.EMPTY); output[t, h, b] = new VoxelInfo(VoxelType.HESPEROPHANES_CINNEREUS, true, 1); } else { output[1, 1, 1] = new VoxelInfo(VoxelType.HESPEROPHANES_CINNEREUS, true, 1); } } else if (gen < TypeInformation.GetGrowHeight(VoxelType.HESPEROPHANES_CINNEREUS) && res == 10) { Int3 moveTo = DirectionConverter.FromDirection(neighbourhood[1, 1, 1].From); t = moveTo.X; h = moveTo.Y; b = moveTo.Z; output[t, h, b] = new VoxelInfo(VoxelType.HESPEROPHANES_CINNEREUS, true, 0); if (random.Next(0, 11) > 7) { output[1, 1, 1] = new VoxelInfo(VoxelType.HESPEROPHANES_CINNEREUS, true, gen + random.Next(1, 5), 0, TypeInformation.GetGrowingSteps(VoxelType.HESPEROPHANES_CINNEREUS), Direction.SELF); } else { output[1, 1, 1] = new VoxelInfo(VoxelType.EMPTY); } } else// if (gen < TypeInformation.GetGrowHeight(VoxelType.HESPEROPHANES_CINNEREUS)) { Direction food = FoodInDirection(neighbourhood); if (food != Direction.SELF) { Int3 foodPos = DirectionConverter.FromDirection(food); int eattime = -10; if (neighbourhood[foodPos.X, foodPos.Y, foodPos.Z].Type == VoxelType.PINE_WOOD || neighbourhood[foodPos.X, foodPos.Y, foodPos.Z].Type == VoxelType.SPRUCE_WOOD) { eattime = -20; } if (neighbourhood[foodPos.X, foodPos.Y, foodPos.Z].Type == VoxelType.TEAK_WOOD || neighbourhood[foodPos.X, foodPos.Y, foodPos.Z].Type == VoxelType.OAK_WOOD) { eattime = -5; } output[1, 1, 1] = new VoxelInfo(VoxelType.HESPEROPHANES_CINNEREUS, true, gen + random.Next(0, 3), 10, eattime, food); } else if (IsWalkable(neighbourhood[t, h, b])) { output[1, 1, 1] = new VoxelInfo(VoxelType.EMPTY); output[t, h, b] = new VoxelInfo(VoxelType.HESPEROPHANES_CINNEREUS, true, gen + random.Next(1, 5)); } else { output[1, 1, 1] = new VoxelInfo(VoxelType.HESPEROPHANES_CINNEREUS, true, gen + random.Next(1, 5)); } } /* else * { * output[1, 1, 1] = new VoxelInfo(VoxelType.EMPTY); * }*/ return(output); }
public VoxelInfo[, ,] ApplyRule(VoxelInfo[, ,] neighbourhood) { // Apply each 18-th turn if (neighbourhood[1, 1, 1].Ticks < TypeInformation.GetGrowingSteps(VoxelType.PINE_WOOD)) { return(null); } int height = random.Next((int)(TypeInformation.GetGrowHeight(VoxelType.PINE_WOOD) * 0.75), (int)(TypeInformation.GetGrowHeight(VoxelType.PINE_WOOD) * 1.25)); VoxelInfo[, ,] output = new VoxelInfo[3, 3, 3]; int gen = neighbourhood[1, 1, 1].Generation; int res = neighbourhood[1, 1, 1].Resources; if (gen == 0) { // Grow Cross and ovveride current generation output[1, 1, 1] = new VoxelInfo(VoxelType.PINE_WOOD, true, 1, 0, TypeInformation.GetGrowingSteps(VoxelType.PINE_WOOD) / 2); output[2, 1, 1] = new VoxelInfo(VoxelType.PINE_WOOD, true, 2, 30); output[0, 1, 1] = new VoxelInfo(VoxelType.PINE_WOOD, true, 2, 30); output[1, 1, 2] = new VoxelInfo(VoxelType.PINE_WOOD, true, 2, 30); output[1, 1, 0] = new VoxelInfo(VoxelType.PINE_WOOD, true, 2, 30); if (TypeInformation.IsNotWoodButBiomass(neighbourhood[1, 0, 1].Type) || neighbourhood[1, 0, 1].Type == VoxelType.EMPTY) { output[1, 0, 1] = new VoxelInfo(VoxelType.PINE_WOOD, true, random.Next(1, height), 0, 0, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[2, 0, 1].Type) || neighbourhood[2, 0, 1].Type == VoxelType.EMPTY) { output[2, 0, 1] = new VoxelInfo(VoxelType.PINE_WOOD, true, random.Next(1, height), 0, 0, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[0, 0, 1].Type) || neighbourhood[0, 0, 1].Type == VoxelType.EMPTY) { output[0, 0, 1] = new VoxelInfo(VoxelType.PINE_WOOD, true, random.Next(1, height), 0, 0, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[1, 0, 2].Type) || neighbourhood[1, 0, 2].Type == VoxelType.EMPTY) { output[1, 0, 2] = new VoxelInfo(VoxelType.PINE_WOOD, true, random.Next(1, height), 0, 0, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[1, 0, 0].Type) || neighbourhood[1, 0, 0].Type == VoxelType.EMPTY) { output[1, 0, 0] = new VoxelInfo(VoxelType.PINE_WOOD, true, random.Next(1, height), 0, 0, Direction.UP); } } else if (gen == -1) { output[1, 2, 1] = new VoxelInfo(VoxelType.PINE_NEEDLE, true); output[1, 1, 1] = new VoxelInfo(VoxelType.PINE_WOOD); } else if (gen < height) { if (res > 0 && gen > TypeInformation.GetGrowHeight(VoxelType.PINE_WOOD) / 2) { if (random.Next(0, 11) > 7) { res -= 15; Direction grow = GetBranchDirection(neighbourhood); Int3 temp = DirectionConverter.FromDirection(grow); if (neighbourhood[temp.X, 0, temp.Z].Type == VoxelType.EMPTY || TypeInformation.IsNotWoodButBiomass(neighbourhood[temp.X, 0, temp.Z].Type)) { output[temp.X, temp.Y, temp.Z] = new VoxelInfo(VoxelType.PINE_WOOD, true, random.Next((int)(height * 0.75), height), 0, 0, DirectionConverter.ToOppositeDirection(grow)); } } } Int3 coord = DirectionConverter.FromDirection(DirectionConverter.ToOppositeDirection(neighbourhood[1, 1, 1].From)); // Grow in given direction if (TypeInformation.IsNotWoodButBiomass(neighbourhood[coord.X, coord.Y, coord.Z].Type) || neighbourhood[coord.X, coord.Y, coord.Z].Type == VoxelType.EMPTY) { output[coord.X, coord.Y, coord.Z] = new VoxelInfo(VoxelType.PINE_WOOD, true, gen + 1, res, 0, neighbourhood[1, 1, 1].From); } output[1, 1, 1] = new VoxelInfo(VoxelType.PINE_WOOD); } else { // Grow upwards one last time if (neighbourhood[1, 1, 1].From != Direction.UP) { output[1, 2, 1] = new VoxelInfo(VoxelType.PINE_WOOD, true, -1, 0, TypeInformation.GetGrowingSteps(VoxelType.PINE_WOOD)); } output[1, 1, 1] = new VoxelInfo(VoxelType.PINE_WOOD); } return(output); }
public VoxelInfo[, ,] ApplyRule(VoxelInfo[, ,] neighbourhood) { // Apply each 18-th turn if (neighbourhood[1, 1, 1].Ticks < TypeInformation.GetGrowingSteps(VoxelType.TEAK_WOOD)) { return(null); } int height = random.Next((int)(TypeInformation.GetGrowHeight(VoxelType.TEAK_WOOD) * 0.75), (int)(TypeInformation.GetGrowHeight(VoxelType.TEAK_WOOD) * 1.25)); VoxelInfo[, ,] output = new VoxelInfo[3, 3, 3]; int gen = neighbourhood[1, 1, 1].Generation; if (gen == 0) { // Grow a 2x2 quad (override current generation) output[1, 1, 1] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1); output[2, 1, 1] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1); output[1, 1, 2] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1); output[2, 1, 2] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1); if (TypeInformation.IsNotWoodButBiomass(neighbourhood[1, 0, 1].Type) || neighbourhood[1, 0, 1].Type == VoxelType.EMPTY) { output[1, 0, 1] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1, 0, 0, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[2, 0, 1].Type) || neighbourhood[2, 0, 1].Type == VoxelType.EMPTY) { output[2, 0, 1] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1, 0, 0, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[1, 0, 2].Type) || neighbourhood[1, 0, 2].Type == VoxelType.EMPTY) { output[1, 0, 2] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1, 0, 0, Direction.UP); } if (TypeInformation.IsNotWoodButBiomass(neighbourhood[2, 0, 2].Type) || neighbourhood[2, 0, 2].Type == VoxelType.EMPTY) { output[2, 0, 2] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1, 0, 0, Direction.UP); } } else if (gen < height) { Int3 coord = DirectionConverter.FromDirection(DirectionConverter.ToOppositeDirection(neighbourhood[1, 1, 1].From)); // Grow in given direction if (TypeInformation.IsNotWoodButBiomass(neighbourhood[coord.X, coord.Y, coord.Z].Type) || neighbourhood[coord.X, coord.Y, coord.Z].Type == VoxelType.EMPTY) { output[coord.X, coord.Y, coord.Z] = new VoxelInfo(VoxelType.TEAK_WOOD, true, gen + 1, 0, 0, neighbourhood[1, 1, 1].From); } output[1, 1, 1] = new VoxelInfo(VoxelType.TEAK_WOOD); } else { if (neighbourhood[1, 1, 1].From == Direction.DOWN) { if (TypeInformation.IsNotWoodButBiomass(neighbourhood[1, 2, 1].Type) || neighbourhood[1, 2, 1].Type == VoxelType.EMPTY) { output[1, 2, 1] = new VoxelInfo(VoxelType.TEAK_LEAF, true, 1); } } output[1, 1, 1] = new VoxelInfo(VoxelType.TEAK_WOOD); } return(output); }