private static int[] RotatePrint(int[] print, MapRotation rotation) { switch (rotation) { case MapRotation.Default: return(new int[] { print[0], print[1] }); case MapRotation.Clockwise: return(new int[] { print[1], -print[0] }); case MapRotation.Backwards: return(new int[] { -print[0], -print[1] }); case MapRotation.CounterClockwise: return(new int[] { -print[1], print[0] }); } throw new ArgumentOutOfRangeException(nameof(rotation)); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/>. /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.PageState != null) { if (e.PageState.ContainsKey("MapRotation") && e.PageState["MapRotation"]!=null) { mapRotation = (MapRotation) e.PageState["MapRotation"]; } else { mapRotation = await SplatoonInk.GetMapRotation(); } } else { mapRotation = await SplatoonInk.GetMapRotation(); } if(mapRotation!=null) listView.ItemsSource= mapRotation.schedule; }
public FruitTree(BuildingDef def, string layerName, MapSpot anchor, IMapController controller, MapRotation rotation) : base(def, layerName, anchor, controller, rotation) { _stageLengths = new List <Dictionary <string, int> >(); _stageLengths.Add(new Dictionary <string, int> { { "HOUR", 1 } }); _stageLengths.Add(new Dictionary <string, int> { { "HOUR", 1 } }); _stageLengths.Add(new Dictionary <string, int> { { "HOUR", 1 } }); var outputConfif = new InventoryConfig() { CanProvideItems = true, CanReceiveItems = false, HasMassLimit = false, MaxMass = -1, RespectsStackLimit = false }; var timeKeeper = GameMaster.Instance.GetController <ITimeKeeper>(); _timeKeeper = timeKeeper; _finishDate = timeKeeper.ProjectTime(_stageLengths[0]); _outputInventory = new DefaultInventory(GameMaster.Instance.GetController <IItemController>(), this, outputConfif); }
private void Start() { world = GetComponentInParent <MapRotation>(); audioPlayer = GetComponent <AudioCue>(); }
internal static IEnumerable <MapStructSide> RotateOccupiedSides(IEnumerable <MapStructSide> sides, MapRotation rotation) { foreach (var side in sides) { if (rotation == MapRotation.Default) { yield return(side); continue; } switch (side) { case MapStructSide.Center: yield return(MapStructSide.Center); continue; case MapStructSide.Top: yield return(MapStructSide.Top); continue; case MapStructSide.Bottom: yield return(MapStructSide.Bottom); continue; case MapStructSide.Forward: if (rotation == MapRotation.Clockwise) { yield return(MapStructSide.Right); } else if (rotation == MapRotation.Backwards) { yield return(MapStructSide.Back); } else if (rotation == MapRotation.CounterClockwise) { yield return(MapStructSide.Left); } continue; case MapStructSide.Right: if (rotation == MapRotation.Clockwise) { yield return(MapStructSide.Back); } else if (rotation == MapRotation.Backwards) { yield return(MapStructSide.Left); } else if (rotation == MapRotation.CounterClockwise) { yield return(MapStructSide.Forward); } continue; case MapStructSide.Back: if (rotation == MapRotation.Clockwise) { yield return(MapStructSide.Left); } else if (rotation == MapRotation.Backwards) { yield return(MapStructSide.Forward); } else if (rotation == MapRotation.CounterClockwise) { yield return(MapStructSide.Right); } continue; case MapStructSide.Left: if (rotation == MapRotation.Clockwise) { yield return(MapStructSide.Forward); } else if (rotation == MapRotation.Backwards) { yield return(MapStructSide.Right); } else if (rotation == MapRotation.CounterClockwise) { yield return(MapStructSide.Back); } continue; } } }
public static Dictionary <Tuple <int, int>, MapSpot> FootprintToMapSpotsDictionary(IEnumerable <int[]> footprint, MapRotation rotation, MapSpot anchor) { if (footprint.Any(print => print.Length != 2)) { throw new Exception($"Malformed footprint at least one print is not int[2]"); } var rotated = RotateFootprint(footprint, rotation); var dic = new Dictionary <Tuple <int, int>, MapSpot>(); foreach (var print in rotated) { dic.Add(new Tuple <int, int>(print[0], print[1]), new MapSpot(anchor.X + print[0], anchor.Y + print[1])); } return(dic); }
public static IEnumerable <int[]> RotateFootprint(IEnumerable <int[]> footprint, MapRotation rotation) { foreach (var print in footprint) { yield return(RotatePrint(print, rotation)); } }
public BaseBuilding(BuildingDef def, string layerName, MapSpot anchor, IMapController controller, MapRotation rotation) : base(def, layerName, anchor, controller, rotation) { BuildingDef = def ?? throw new ArgumentNullException(nameof(def)); AnchorPoint = anchor ?? throw new ArgumentNullException(nameof(anchor)); }
internal BaseManufacturerBuilding(ManufacturingBuildingDef def, string layerName, MapSpot anchor, IMapController controller, MapRotation rotation) : base(def, layerName, anchor, controller, rotation) { _manufacturingBuildingDef = def ?? throw new ArgumentNullException(nameof(def)); _outputInventory = new DefaultInventory(GameMaster.Instance.GetController <IItemController>(), this, _manufacturingBuildingDef.OutputConfig); _inputInventory = new DefaultInventory(GameMaster.Instance.GetController <IItemController>(), this, _manufacturingBuildingDef.InputConfig); _currentCraftingState = null; }
/// <summary> /// Initializes a new instance of the <see cref="PlainTextExporterForm" /> class. /// </summary> /// <param name="rotation">The rotation.</param> public PlainTextExporterForm(MapRotation rotation) { InitializeComponent(); textBox.Text = rotation.ToString(); }
private async void RefreshAppBarButton_Click(object sender, RoutedEventArgs e) { mapRotation = await SplatoonInk.GetMapRotation(); }
public BaseStorageContainer(StorageContainerDef def, string layerName, MapSpot anchor, IMapController controller, MapRotation rotation) : base(def, layerName, anchor, controller, rotation) { StorageContainerDef = def ?? throw new ArgumentNullException(nameof(def)); ItemController = GameMaster.Instance.GetController <IItemController>(); Inventory = new DefaultInventory(ItemController, this, def.InventoryConfig); }
public BaseMapStructure(MapStructDef def, string layerName, MapSpot anchor, IMapController controller, MapRotation rotation) : base(def) { MapController = controller ?? throw new ArgumentNullException(nameof(controller)); Anchor = anchor ?? throw new ArgumentNullException(nameof(anchor)); MapLayerName = layerName; _def = def ?? throw new ArgumentNullException(nameof(def)); MapStructValidator.ValidateDef(def); _rotationMapping = MapStructHelper.FootprintToMapSpotsDictionary(def.Footprint, rotation, anchor); }
public bool CanAddMapStructure(string layerName, MapStructDef mapStructDef, MapSpot anchor, MapRotation rotation) { if (mapStructDef == null) { throw new ArgumentNullException(nameof(mapStructDef)); } if (anchor == null) { throw new ArgumentNullException(nameof(anchor)); } var printDic = MapStructHelper.FootprintToMapSpotsDictionary(mapStructDef.Footprint, rotation, anchor); var layer = GetLayer(layerName); if (layer == null) { throw new Exception($"No layer found with name '{layerName}'."); } foreach (var print in printDic) { var spot = print.Value; if (mapStructDef.FillMapSpots) { if (GetMapStructsAt(layer.LayerName, spot).Any()) { return(false); } } else { var sides = MapStructHelper.RotateOccupiedSides(mapStructDef.OccupiesSides[print.Key], rotation); var curt = GetMapStructsAt(layer.LayerName, spot).SelectMany(x => x.GetOccupiedSides(spot)); if (sides != null && curt != null && curt.Intersect(sides).Any()) { return(false); } } } return(true); }
public DefaultManufacturingBuilding(ManufacturingBuildingDef def, string layerName, MapSpot anchor, IMapController controller, MapRotation rotation) : base(def, layerName, anchor, controller, rotation) { }