public ToolBarOption(int x, int y, ToolBarButton tool, Material m) : base(x, y, 48, 48, PVResources.DEAD_IMAGE) { _Parent = tool; _Type = m; _Parent.GetOptions().Add(this); _Image = WorldHelper.TileImageFromType(_Type); }
private void _Harvest() { _BeingHarvested = false; _Harvested = true; _OnHarvestTimer = 1 * 20; Game.P.SetIsWorking(false); SetImage((Image) new Bitmap(WorldHelper.TileImageFromType(_BaseType), Width, Height)); Game.P.AddItem(_Drop); }
public Tile(int x, int y, Material type, World world) : base(x, y, C.TILE_WIDTH, C.TILE_HEIGHT, PVResources.MaterialImageMap[type]) { X = x; Y = y; _Material = type; // Remove underlying tile (before we add this tile) WorldHelper.RemoveTileAtPoint(X, Y); world.Tiles.Add(this); _Image = PVResources.MaterialImageMap[_Material]; }
public FunctionTile(int x, int y, Material type, World world) : base(x, y, type, world) { _Type = type; _BaseType = FunctionTile.FunctionTileBases[_Type]; _HarvestTime = WorldHelper.HarvestTimeFromType(_Type); _HarvestTimer = _HarvestTime; _RegenerateTime = WorldHelper.RegenerateTimeFromType(_Type); _RegenerateTimer = _RegenerateTime; _Image = WorldHelper.TileImageFromType(_Type); TextX = X; TextY = Y; // +1 because array is 0-index, and rdm max = parm -1 _Drop = new ItemStack(TileDrops[_Type][C.RDM.Next(TileDrops.Count + 1)], 1); world.FunctionTiles.Add(this); }
private void _TriggerSelectedWorldTool(Rectangle click) { if (SELECTED_WORLDTOOL == WorldTool.TILE) { new Tile(C.round(C.MX, 64), C.round(C.MY, 64), ToolBarButton.SELECTED_TOOL.GetSelectedOption().GetMaterial(), Game.World); } else if (SELECTED_WORLDTOOL == WorldTool.FUNCTION_TILE) { new FunctionTile(C.round(C.MX, 64), C.round(C.MY, 64), ToolBarButton.SELECTED_TOOL.GetSelectedOption().GetMaterial(), Game.World); } else if (SELECTED_WORLDTOOL == WorldTool.STRUCTURE_TILE) { new StructureTile(C.round(C.MX, 64), C.round(C.MY, 64), ToolBarButton.SELECTED_TOOL.GetSelectedOption().GetMaterial(), Game.World); } else if (SELECTED_WORLDTOOL == WorldTool.ERASER) { WorldHelper.RemoveTileAtPoint(click); } }
// Must have this init sepearte as instance is added to world tiles array in differnent place public FunctionTile(BinFuncTile bint) : base(bint) { _Type = (Material)Enum.Parse(typeof(Material), bint.mat); _HarvestTime = WorldHelper.HarvestTimeFromType(_Type); _HarvestTimer = _HarvestTime; _RegenerateTime = WorldHelper.RegenerateTimeFromType(_Type); _RegenerateTimer = bint.RegenerateTimer; _Harvested = bint.Harvested; if (_Harvested) { _Image = WorldHelper.TileImageFromType(_BaseType); } else { _Image = WorldHelper.TileImageFromType(_Type); } TextX = X; TextY = Y; // +1 because array is 0-index, and rdm max = parm -1 _Drop = new ItemStack(TileDrops[_Type][C.RDM.Next(TileDrops.Count + 1)], 1); }
public override void ClickedDown(Rectangle click) { if (!Enabled) { return; } if (click.IntersectsWith(_GetSaveButtonBounds())) { WorldHelper.SaveWorld(Game.World); return; } else if (click.IntersectsWith(_GetLoadButtonBounds())) { WorldHelper.LoadWorld("temp_world"); return; } //if (click.IntersectsWith(GetBounds())) foreach (var tb in ToolBarButtons) { if (click.IntersectsWith(tb.GetCamRelBounds()) || (click.IntersectsWith(tb.GetDropDownBounds()) && tb.isFocused())) { tb.Select(click); return; } } // If no tool or option selected if (ToolBarButton.SELECTED_TOOL == null || !ToolBarButton.SELECTED_TOOL.HasSelectedOption()) { return; } _TriggerSelectedWorldTool(click); }
//is not added to world tile list with this init, must add seperatly public Tile(BinTile bint) : base(bint.X, bint.Y, C.TILE_WIDTH, C.TILE_HEIGHT, PVResources.MaterialImageMap[(Material)Enum.Parse(typeof(Material), bint.mat)]) { _Material = (Material)Enum.Parse(typeof(Material), bint.mat); _Image = WorldHelper.TileImageFromType(_Material); }
private void _ResetTile() { _Image = (Image) new Bitmap(WorldHelper.TileImageFromType(_Type), Width, Height); _RegenerateTimer = _RegenerateTime; _ResetHarvest(); }