public override void Tick(Living l) { if (this.HitTimer.Allow()) { Tile tile = World.Data.World.GetTile(l.Dimension, this.Target.X, this.Target.Y); List <World.Base.Item> drop = null; if (tile is Grass) { drop = this.Tillable.TillableBehavior.TillSomePercent(.02F, this.Target); } else if (tile is Dirt) { drop = this.Tillable.TillableBehavior.TillSomePercent(.07F, this.Target); } if (drop != null && drop.Count > 0) { ItemAdder.AddItem(drop[0], l.MapLocation, l.Dimension); } if (this.Tillable.TillableBehavior.PercentTilled > 1) { Tile tillableTile = new TilledDirt(new Point2D(this.Target.X, this.Target.Y)); World.Data.World.Dimensions[this.Dimension][this.Target.X, this.Target.Y] = tillableTile; this.CompleteTask(); } } }
private void Awake() { if (instance != null) { Debug.LogWarning("More than one instance of ItemAdder!"); } instance = this; }
public override void Tick(Living l) { List <Item> toDrop = l.Inventory.RemoveSomeOfItem(this.ItemID, this.ItemAmount); if (toDrop != null) { //Drop all of the items that should be dropped. foreach (Item item in toDrop) { ItemAdder.AddItem(item, this.Location, this.Dimension); } } this.CompleteTask(); }
public override void Tick(Living l) { if (this.HitTimer.Allow()) { List <World.Base.Item> drop = this.Minable.MiningBehavior.MineSomePercent(.1F, this.Target); if (drop != null && drop.Count > 0) { ItemAdder.AddItem(drop[0], l.MapLocation, l.Dimension); } if (this.Minable.MiningBehavior.PercentMined > 1) { this.RemoveResource(l.Dimension); this.CompleteTask(); } } }
/// <summary> /// Drops the result of the harvesting down. /// </summary> /// <param name="l"></param> /// <param name="drop"></param> private void DropItem(Living l, Item drop) { //The tile the entity is standing on Tile entityOn = World.Data.World.GetTile(l.Dimension, l.MapLocation.X, l.MapLocation.Y); if (entityOn.Item == null || entityOn.Item.GetType() == drop.GetType()) { ItemAdder.AddItem(drop, l.MapLocation, l.Dimension); } else { l.Inventory.AddItem(drop); Point2D emtpyTile = ItemFinder.FindNearestNoItemResource(entityOn.MapLocation, l.Dimension); DropItemTask task = new DropItemTask(emtpyTile, l.Dimension, drop, l.ID, Guid.NewGuid()); task.ReservedFor = l.ID; TaskManager.Manager.AddTask(task); } }
protected override void JobTick(Living living) { if (this.HitTimer.Allow()) { List <World.Base.Item> drop = this.Minable.MiningBehavior.MineSomePercent(.1F); if (drop != null && drop.Count > 0) { ItemAdder.AddItem(drop[0], living.MapLocation, living.Dimension); } if (this.Minable.MiningBehavior.PercentMined > 1) { this.RemoveResource(living.Dimension); this.CompleteJob(living); } } }
private void Listener_KeyPressed(object sender, KeyboardEventArgs e) { if (e.Key == Microsoft.Xna.Framework.Input.Keys.Escape) { this.HandleEscapeKey(); } if (e.Key == Microsoft.Xna.Framework.Input.Keys.R) { Point2D result = ItemFinder.FindNearestLocation(0, new MagicalLifeAPI.DataTypes.Point2D(0, 0), 0); if (result != null) { ItemAdder.AddItem(new StoneChunk(0), result, 0); ItemAdder.AddItem(new StoneChunk(0), result, 0); ItemRemover.RemoveSome(result, 0, 1); ItemRemover.RemoveAllItems(result, 0); } } }
/// <summary> /// Drops the result of the harvesting down. /// </summary> /// <param name="l"></param> /// <param name="drop"></param> private void DropItem(Living l, Item drop) { //The tile the entity is standing on ComponentSelectable entityS = l.GetExactComponent <ComponentSelectable>(); Tile entityOn = World.Data.World.GetTile(l.Dimension, entityS.MapLocation.X, entityS.MapLocation.Y); if (entityOn.MainObject == null || entityOn.MainObject.GetType() == drop.GetType()) { ItemAdder.AddItem(drop, entityS.MapLocation, l.Dimension); } else { l.Inventory.AddItem(drop); Point2D emtpyTile = ItemFinder.FindMainObjectEmptyTile(entityOn.GetExactComponent <ComponentSelectable>().MapLocation, l.Dimension); DropItemTask task = new DropItemTask(emtpyTile, l.Dimension, drop, l.ID, Guid.NewGuid()); task.ReservedFor = l.ID; TaskManager.Manager.AddTask(task); } }
public override void Tick(Living l) { if (this.HitTimer.Allow()) { Tile tile = World.Data.World.GetTile(l.Dimension, this.Target.X, this.Target.Y); List <Item> drop = this.Tillable.TillSomePercent(this.Tillable.PercentTillTick, this.Target); if (drop?.Count > 0) { ItemAdder.AddItem(drop[0], l.GetExactComponent <ComponentSelectable>().MapLocation, l.Dimension); } if (this.Tillable.PercentTilled > 1) { Tile tillableTile = this.Tillable.ResultingTile(new Point2D(this.Target.X, this.Target.Y), this.Dimension); World.Data.World.Dimensions[this.Dimension][this.Target.X, this.Target.Y] = tillableTile; this.CompleteTask(); } } }
public ObservableCodeCollectionViewGallery(ItemsLayoutOrientation orientation = ItemsLayoutOrientation.Vertical, bool grid = true, int initialItems = 1000, bool addItemsWithTimer = false, ItemsUpdatingScrollMode scrollMode = ItemsUpdatingScrollMode.KeepItemsInView) { var layout = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Star } } }; IItemsLayout itemsLayout = grid ? new GridItemsLayout(3, orientation) : new LinearItemsLayout(orientation) as IItemsLayout; var itemTemplate = ExampleTemplates.PhotoTemplate(); var collectionView = new CollectionView { ItemsLayout = itemsLayout, ItemTemplate = itemTemplate, AutomationId = "collectionview", Header = "This is the header", ItemsUpdatingScrollMode = scrollMode }; var generator = new ItemsSourceGenerator(collectionView, initialItems, ItemsSourceType.ObservableCollection); var remover = new ItemRemover(collectionView); var adder = new ItemAdder(collectionView); var replacer = new ItemReplacer(collectionView); var mover = new ItemMover(collectionView); var inserter = new ItemInserter(collectionView); layout.Children.Add(generator); layout.Children.Add(remover); Grid.SetRow(remover, 1); layout.Children.Add(adder); Grid.SetRow(adder, 2); layout.Children.Add(replacer); Grid.SetRow(replacer, 3); layout.Children.Add(mover); Grid.SetRow(mover, 4); layout.Children.Add(inserter); Grid.SetRow(inserter, 5); layout.Children.Add(collectionView); Grid.SetRow(collectionView, 6); Content = layout; if (addItemsWithTimer) { generator.GenerateEmptyObservableCollectionAndAddItemsEverySecond(); } else { generator.GenerateItems(); } }
public override void ModifyWorld() { ItemAdder.AddItem(this.Item, this.Location, this.Dimension); }
public ObservableCodeCollectionViewGallery(ItemsLayoutOrientation orientation = ItemsLayoutOrientation.Vertical, bool grid = true) { var layout = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Star } } }; IItemsLayout itemsLayout = grid ? new GridItemsLayout(3, orientation) : new ListItemsLayout(orientation) as IItemsLayout; var itemTemplate = ExampleTemplates.PhotoTemplate(); var collectionView = new CollectionView { ItemsLayout = itemsLayout, ItemTemplate = itemTemplate }; var generator = new ItemsSourceGenerator(collectionView); var remover = new ItemRemover(collectionView); var adder = new ItemAdder(collectionView); var replacer = new ItemReplacer(collectionView); var mover = new ItemMover(collectionView); layout.Children.Add(generator); layout.Children.Add(remover); Grid.SetRow(remover, 1); layout.Children.Add(adder); Grid.SetRow(adder, 2); layout.Children.Add(replacer); Grid.SetRow(replacer, 3); layout.Children.Add(mover); Grid.SetRow(mover, 4); layout.Children.Add(collectionView); Grid.SetRow(collectionView, 5); Content = layout; generator.GenerateObservableCollection(); }