ItemSlot makeslot(int id, GameObject.MapEntities.Actors.Player Player) { ItemSlot s = new ItemSlot(Player.Equipment[id]); s.X = 0; s.Y = 0; s.CanGrab = true; s.CanPut = true; s.BeforeItemChanged += new ItemSlot.ItemEventHandler((sender, e) => { GameObject.Item item = (GameObject.Item)(e as ItemSlot.ItemEventArgs).Item; if ((item as GameObject.Items.ItemEquip) == null) { e.Cancel = true; if (item == null) { Console.Write("^FF0000 No item."); } else { List <string> ToolTip = item.GetTooltip(); Console.WriteEx("^BEGINLINK " + GUI.Renderer.ColourToCode(item.NameColour) + "[" + item.GetName() + "] ^ENDLINK ^FF0000 is not a suitable item.", new List <Action> { new Action(() => { GUI.ToolTipWindow tip = new GUI.ToolTipWindow(this.WM, ToolTip, WM.MouseX, WM.MouseY, false); WM.Add(tip); }) }); } } }); s.ItemOut += new ItemSlot.ItemEventHandler((sender, e) => { int thisslot = id; GameObject.Items.ItemEquip item = (GameObject.Items.ItemEquip)(e as ItemSlot.ItemEventArgs).Item; List <string> ToolTip = item.GetTooltip(); Console.WriteEx("^BEGINLINK " + GUI.Renderer.ColourToCode(item.NameColour) + "[" + item.GetName() + "] ^ENDLINK ^FFFFFF is removed.", new List <Action> { new Action(() => { GUI.ToolTipWindow tip = new GUI.ToolTipWindow(this.WM, ToolTip, WM.MouseX, WM.MouseY, false); WM.Add(tip); }) }); Player.UnequipItem(item, thisslot); }); s.ItemIn += new ItemSlot.ItemEventHandler((sender, e) => { int thisslot = id; GameObject.Items.ItemEquip item = (GameObject.Items.ItemEquip)(e as ItemSlot.ItemEventArgs).Item; List <string> ToolTip = item.GetTooltip(); Console.WriteEx("^BEGINLINK " + GUI.Renderer.ColourToCode(item.NameColour) + "[" + item.GetName() + "] ^ENDLINK ^FFFFFF is equipped.", new List <Action> { new Action(() => { GUI.ToolTipWindow tip = new GUI.ToolTipWindow(this.WM, ToolTip, WM.MouseX, WM.MouseY, false); WM.Add(tip); }) }); Player.EquipItem(item, thisslot); }); return(s); }
public void Init(GraphicsDevice device) { Assets.Textures["tiles1"] = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\tiles2.png", System.IO.FileMode.Open)); Assets.Textures["walls"] = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\walls2.png", System.IO.FileMode.Open)); Assets.Textures["items"] = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\itemsprites.png", System.IO.FileMode.Open)); Assets.Textures["creatures"] = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\creatures.png", System.IO.FileMode.Open)); Assets.Textures["winskin"] = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\winskin.png", System.IO.FileMode.Open)); // Assets.Textures["creatures"] = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\creatures.png", System.IO.FileMode.Open)); this.Map = new Components.Map(40, 40); //* player = new Components.MapCreature(); player.ParentMap = this.Map; player.Name = "Colonist 1"; player.WorkProfile[Components.WorkTypes.Hauling] = true; this.Map.Objects.Add(player); player = new Components.MapCreature(); player.ParentMap = this.Map; player.Name = "Colonist 2"; player.WorkProfile[Components.WorkTypes.Construction] = true; this.Map.Objects.Add(player); player = new Components.MapCreature(); player.ParentMap = this.Map; player.Name = "Colonist 3"; player.WorkProfile[Components.WorkTypes.Hauling] = true; this.Map.Objects.Add(player); //*/ player = new Components.MapCreature(); player.ParentMap = this.Map; player.Name = "Colonist 4"; player.WorkProfile[Components.WorkTypes.Construction] = true; this.Map.Objects.Add(player); /*/ * player = new Components.MapCreature(); * player.ParentMap = this.Map; * player.Name = "Colonist 5"; * this.Map.Objects.Add(player); * player = new Components.MapCreature(); * player.ParentMap = this.Map; * player.Name = "Colonist 6"; * this.Map.Objects.Add(player); * player = new Components.MapCreature(); * player.ParentMap = this.Map; * player.Name = "Colonist 7"; * this.Map.Objects.Add(player); * player = new Components.MapCreature(); * player.ParentMap = this.Map; * player.Name = "Colonist 8"; * this.Map.Objects.Add(player); * //*/ WM = new GUI.WindowManager(); WM.Renderer = new GUI.Renderer(device); WM.Renderer.GUIEffect = Assets.Effects["GUI"]; WM.Renderer.UIFont = Assets.SpriteFonts["UIFontO"]; WM.Renderer.WindowSkin = Assets.Textures["winskin"]; GUI.ToolTipWindow t = new GUI.ToolTipWindow(WM, "GUI successfully installed!", 0, 0, false); Console.WriteCallback = new Action <string>(ConsoleWrite); Console.WriteCallbackEx = new Action <string, List <Action> >(ConsoleWriteEx); t.AnchorBottom = true; t.AnchorRight = true; WM.Add(t); WM.Add(new Windows.ConsoleWindow(WM)); WM.Screen.X = 0; WM.Screen.Y = 0; ScreenResized(device); }