public override void RightClick(Player player) { int roll = Main.rand.Next(4); ModItem item = null; if (roll == 1) { item = mod.GetItem("SunstoneAccessory"); } else if (roll == 2) { item = mod.GetItem("SunstoneMelee"); } else if (roll == 3) { item = mod.GetItem("SunstoneRanged"); } else { item = mod.GetItem("SunstoneArcane"); } int prefix = item.ChoosePrefix(Main.rand); Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, item.item.type, 1, false, prefix, false, false); }
public static void SetStaticDefaults(ModItem modItem, string name) { modItem.DisplayName.SetDefault(name); modItem.Tooltip.SetDefault( "Increases stats for your team whilst held\n" + "Team is not affected by banner color"); }
// TODO Load MyEffects then RealEffects so load order doesn't mess things up internal void Load() { string origLoadStage = LoadingHelper.GetLoadStage(); LoadingHelper.SetLoadStage("Registering ItemEffects..."); string lastModName = ""; //ItemsToLoad.Add(ModContent.GetModItem(ModContent.ItemType<Terraria.ModLoader.Default.AprilFools>())); for (int i = 0; i < ItemsToLoad.Count; i++) { ModItem item = ItemsToLoad[i]; if (item.mod.Name != lastModName) { lastModName = item.mod.Name; LoadingHelper.SetSubText(lastModName); } //Thread.Sleep(5000); if (item is ModularEffectItem mItem) { mItem.RegisterItemEffects(); } LoadingHelper.SetProgress((float)i / ItemsToLoad.Count); } LoadingHelper.SetLoadStage(origLoadStage); LoadingHelper.SetSubText(""); LoadingHelper.SetProgress(0f); ItemsToLoad.Clear(); }
public static bool HasAndCanDraw(Player player, int type, ref bool social, ref int slot) { if (player.wereWolf || player.merman) { return(false); } ModItem mitem = ItemLoader.GetItem(type); if (mitem != null) { Item item = mitem.item; if (item.headSlot > 0) { return(BasePlayer.HasHelmet(player, type) && BaseDrawing.ShouldDrawHelmet(player, type)); } else if (item.bodySlot > 0) { return(BasePlayer.HasChestplate(player, type) && BaseDrawing.ShouldDrawChestplate(player, type)); } else if (item.legSlot > 0) { return(BasePlayer.HasLeggings(player, type) && BaseDrawing.ShouldDrawLeggings(player, type)); } else if (item.accessory) { return(BasePlayer.HasAccessory(player, type, true, true, ref social, ref slot) && BaseDrawing.ShouldDrawAccessory(player, type)); } } return(false); }
private static void OnModItemCtor(ModItem __instance) { if (!Localizer.Config.RebuildTooltips) { return; } if (Localizer.Config.RebuildTooltipsOnce && !_instance._firstRun) { return; } if (!_instance._rebuilding && !_instance._cleaning) { _instance.items.Add(new WeakReference(__instance)); _instance._cleanUpCounter++; if (_instance._cleanUpCounter > 20000 && !_instance._firstRun) { Task.Run(() => _instance.CleanUpItems()); _instance._cleanUpCounter = 0; } } }
protected override void DrawSelf(SpriteBatch spriteBatch) { base.DrawSelf(spriteBatch); CalculatedStyle innerDim = GetInnerDimensions(); Vector2 position = new Vector2(innerDim.X - 5, innerDim.Y - 15); ModItem modItem = item?.modItem; if (modItem != null) { if (modItem is EnergyItem) { EnergyItem energyItem = modItem as EnergyItem; if (energyItem.isFull()) { spriteBatch.DrawString(Main.fontMouseText, "Full!", position, Color.White); } else { spriteBatch.DrawString(Main.fontMouseText, "Charging", position, Color.White); } } else { spriteBatch.DrawString(Main.fontMouseText, "Can't charge", position, Color.White); } } }
public override void ProcessTriggers(TriggersSet triggersSet) { if (IMPCN.instance.ShowTextKey.JustPressed) { Item item = Main.HoverItem; int id; if (item == null) { Tile tile = Main.tile[Main.mouseX, Main.mouseY]; if (tile == null || tile.type == 0) { return; } id = tile.blockType(); } else { id = item.type; } ItemWithName info = IMPCNExtension.GetItem(id); if (info == null) { ModItem modItem = ItemLoader.GetItem(id); item = modItem.item; info = new ItemWithName( id: id, clazz: item.GetType().Name, english: modItem.DisplayName.GetDefault(), original: modItem.DisplayName.GetTranslation(GameCulture.Chinese) ); } QueryItemNameCommand.WriteItem(info); } }
public override void ModifyTooltips(List <TooltipLine> tooltips) { TooltipLine line2 = new TooltipLine(mod, mod.Name, "新手专用!买不了吃亏买不了上当!") { overrideColor = Color.Red }; tooltips.Add(line2); TooltipLine line = new TooltipLine(mod, mod.Name, "内含:") { overrideColor = Color.LightSlateGray }; tooltips.Add(line); foreach (int card in GetCard) { Item i = new Item(); i.SetDefaults(card); ModItem modItem = i.modItem; line = new TooltipLine(mod, mod.Name, i.Name + "×" + GetCardStack[GetCard.IndexOf(card)]) { overrideColor = Color.SlateGray }; tooltips.Add(line); } }
private void Start() { newItem = ScriptableObject.CreateInstance <ModItem>().Create("WindTurbine", ItemType.Inventory); newItem.setInventorySettings("Wind Turbine", "A wind turbine which can be repurposed in several ways.", null, "Item/" + newItem.name, 5); RAPI.addItem(newItem); RConsole.Log("firstmod loaded!"); }
public string GetHoverString() { if (stringUpToDate) { return(hoverString); } stringUpToDate = true; StringBuilder sb = new StringBuilder(); sb.Append($"Total: {bannerItems.Count}/{itemToBanner.Count}"); sb.Append($"\nVanilla: {bannerItems.Count(x=>x.type < ItemID.Count)}/249"); Dictionary <Mod, int> BannersPerMod = new Dictionary <Mod, int>(); for (int i = NPCID.Count; i < NPCLoader.NPCCount; i++) { int bannernum = Item.NPCtoBanner(i); int itemnum = Item.BannerToItem(bannernum); if (bannernum > 0 && itemnum > ItemID.Count) { ModItem item = ItemLoader.GetItem(itemnum); int currentCount; BannersPerMod.TryGetValue(item.mod, out currentCount); BannersPerMod[item.mod] = currentCount + 1; } } foreach (var item in BannersPerMod) { int num = bannerItems.Count(x => x.modItem != null && x.modItem.mod == item.Key); sb.Append($"\n{item.Key.DisplayName}: {num}/{item.Value}"); } if (unloadedBannerItems.Count > 0) { sb.Append($"\nUnloaded: {unloadedBannerItems.Count}"); } //TODO missing? // TODO event? sb.Append($"\nMissing: "); int count = 0; foreach (var item in itemToBanner) { if (!bannerItems.Any(x => x.type == item.Key)) { sb.Append($"[i:{item.Key}]"); count++; if (count > 4) { sb.Append($"..."); break; } } } hoverString = sb.ToString(); return(hoverString); }
private static void ValidateModList() { List <ModMetaData> running = ModsConfig.ActiveModsInLoadOrder.ToList(); var list = new List <ModItem>(); var builder = new StringBuilder(); foreach (ModMetaData metaData in running.Where(m => m.Active) .Where(mod => !mod.Official) .Where(mod => !File.Exists(Path.Combine(mod.RootDir.ToString(), "About/IgnoreMe.txt")))) { ModItem item; try { item = ModItem.FromMetadata(metaData); } catch (Exception) { builder.AppendLine($" - {metaData?.Name ?? metaData?.FolderName}"); continue; } list.Add(item); } if (builder.Length > 0) { builder.Insert(0, "The following mods could not be processed:\n"); TkUtils.Logger.Warn(builder.ToString()); } Mods = list.ToArray(); }
public static void LoadItems() { AmmoItems.Clear(); List <int> AmmoIds = new List <int>(); foreach (EndlessAmmoType EndlessAmmoType in EndlessAmmoTypes) { AmmoIds.Add(EndlessAmmoType.Type); } int i = 1; Item item = new Item(); for (; i < ItemID.Count; i++) { item.SetDefaults(i); if (item.consumable && AmmoIds.Contains(item.ammo)) { AmmoItems.Add(item.Clone()); } } for (; i < ItemLoader.ItemCount; i++) { ModItem modItem = ItemLoader.GetItem(i); if (modItem.item.consumable && AmmoIds.Contains(modItem.item.ammo)) { AmmoItems.Add(modItem.item.Clone()); } } }
public void UpdateModeStats() { ModItem ammo = mod.GetItem(compatibleAmmo[mode]); item.useAmmo = ammo.item.type; item.UseSound = ammo.item.UseSound; }
public ModViewModel(ModItem modItem) : this() { Name = modItem.Name; Version = modItem.Version; Author = modItem.Author; AuthorURL = modItem.AuthorURL; Description = modItem.Description; PluginURL = modItem.PluginURL; InstanceId = modItem.InstanceId; AssemblyPath = modItem.AssemblyPath; if (string.IsNullOrWhiteSpace(PluginURL) == false) { PluginURLVisibility = Visibility.Visible; ModNameOnlyVisibility = Visibility.Collapsed; } else { PluginURLVisibility = Visibility.Collapsed; ModNameOnlyVisibility = Visibility.Visible; } if (string.IsNullOrWhiteSpace(AuthorURL) == false) { AuthorURLVisibility = Visibility.Visible; AuthorOnlyVisibility = Visibility.Collapsed; } else { AuthorURLVisibility = Visibility.Collapsed; AuthorOnlyVisibility = Visibility.Visible; } }
private void LoadBlacklist() { TransferInletTileEntity.PickupBlacklist.Add(ItemID.Heart); TransferInletTileEntity.PickupBlacklist.Add(ItemID.CandyApple); TransferInletTileEntity.PickupBlacklist.Add(ItemID.CandyCane); TransferInletTileEntity.PickupBlacklist.Add(ItemID.Star); TransferInletTileEntity.PickupBlacklist.Add(ItemID.SugarPlum); TransferInletTileEntity.PickupBlacklist.Add(ItemID.SoulCake); TransferInletTileEntity.PickupBlacklist.Add(ItemID.NebulaPickup1); TransferInletTileEntity.PickupBlacklist.Add(ItemID.NebulaPickup2); TransferInletTileEntity.PickupBlacklist.Add(ItemID.NebulaPickup3); TransferInletTileEntity.PickupBlacklist.Add(ItemID.DD2EnergyCrystal); for (int i = 0; i < ItemLoader.ItemCount; i++) { ModItem item = ItemLoader.GetItem(i); if (item != null && (item.GetType().GetMethod("ItemSpace").DeclaringType != typeof(ModItem) || item.GetType().GetMethod("OnPickup").DeclaringType != typeof(ModItem))) { TransferInletTileEntity.PickupBlacklist.Add(item.item.type); } } }
public override void SetDefaults() { item = GetItem(); ModItem i = ItemLoader.GetItem(item); if (i == null) { Item I = new Item(); I.type = item; I.SetDefaults1(I.type); I.SetDefaults2(I.type); I.SetDefaults3(I.type); I.SetDefaults4(I.type); projectile.width = I.width; projectile.height = I.height; } else { projectile.width = i.item.width; projectile.height = i.item.height; } //projectile.maxPenetrate=-1; projectile.aiStyle = 5; projectile.friendly = true; projectile.penetrate = -1; projectile.alpha = 50; projectile.light = 1f; }
public override ModItem NewInstance(Item itemClone) { ModItem newModItem = base.NewInstance(itemClone); CopyItemFields(itemClone, item); return(newModItem); }
/// <summary> /// Call this in <see cref="ModItem.SetStaticDefaults"/> to register this weapon into the "clicker class" category as a "clicker". /// You can change the default tooltip BEFORE it. /// Do not call <see cref="RegisterClickerItem"/> with it as this method does this already by itself /// </summary> /// <param name="modItem">The <see cref="ModItem"/> that is to be registered</param> /// <param name="borderTexture">The path to the border texture (optional)</param> /// <exception cref="InvalidOperationException"/> public static void RegisterClickerWeapon(ModItem modItem, string borderTexture = null) { if (ClickerClass.finalizedRegisterCompat) { throw new InvalidOperationException("Tried to register a clicker weapon at the wrong time, do so in ModItem.SetStaticDefaults"); } RegisterClickerItem(modItem); int type = modItem.Item.type; if (!ClickerWeapons.Contains(type)) { ClickerWeapons.Add(type); if (borderTexture != null) { if (ModContent.HasAsset(borderTexture)) { if (!ClickerWeaponBorderTexture.ContainsKey(type)) { ClickerWeaponBorderTexture.Add(type, borderTexture); } } else { ClickerClass.mod.Logger.Info($"Border texture for {modItem.Name} not found: {borderTexture}"); } } } if (modItem.Tooltip.GetDefault() == null) { modItem.Tooltip.SetDefault("{$Mods.ClickerClass.Common.Tooltips.Clicker}"); } }
//Function to fetch the mod info from modfile(.aoemod) void ReadMeta(string line) { string command = line.Substring(0, line.IndexOf("=")); string value = line.Substring(line.IndexOf("=") + 1); if (command == "Icon") { if (value != "null") { Image buttonIcon = Image.FromFile(currentModPath + "\\" + value); button1.BackgroundImage = buttonIcon; } } if (command == "Name") { ModItem modItem = new ModItem(); modItem.Name = value; modItem.DirectoryName = currentModPath; modItem.FileName = currentModFile; if (!modItemList.Contains(modItem)) { modItemList.Add(modItem); comboBox1.Items.Add(value); comboBox1.SelectedIndex = comboBox1.Items.IndexOf(value); } comboBox1.SelectedIndex = comboBox1.Items.IndexOf(value); } if (command == "Discription") { richTextBox1.Text = File.ReadAllText(currentModPath + "\\" + value); } }
/// <summary> /// Call this in <see cref="ModItem.SetStaticDefaults"/> to register this weapon into the "clicker class" category as a "clicker". /// You can change the default tooltip BEFORE it. /// Do not call <see cref="RegisterClickerItem"/> with it as this method does this already by itself /// </summary> /// <param name="modItem">The <see cref="ModItem"/> that is to be registered</param> /// <param name="borderTexture">The path to the border texture (optional)</param> /// <exception cref="InvalidOperationException"/> public static void RegisterClickerWeapon(ModItem modItem, string borderTexture = null) { if (ClickerClass.finalizedRegisterCompat) { throw new InvalidOperationException("Tried to register a clicker weapon at the wrong time, do so in ModItem.SetStaticDefaults"); } RegisterClickerItem(modItem); int type = modItem.item.type; if (!ClickerWeapons.Contains(type)) { ClickerWeapons.Add(type); if (!string.IsNullOrEmpty(borderTexture)) { try { var probe = ModContent.GetTexture(borderTexture); if (!ClickerWeaponBorderTexture.ContainsKey(type)) { ClickerWeaponBorderTexture.Add(type, borderTexture); } } catch { } } } if (modItem.Tooltip.GetDefault() == null) { modItem.Tooltip.SetDefault("{$Mods.ClickerClass.Common.Tooltips.Clicker}"); } }
/// <summary> /// Creates and finalizes a recipe. Ingredients must be formatted new int[,] { {id1, num1}, {id2, num2}, ... }. Can build on an existing recipe. /// </summary> /// <param name="mod"></param> /// <param name="ingredients"></param> /// <param name="result"></param> /// <param name="numResult"></param> /// <param name="where"></param> public static void QuckRecipe(Mod mod, int[,] ingredients, ModItem result, int numResult = 1, ModRecipe buildOn = null, ushort where = TileID.WorkBenches) { //recipe ModRecipe recipe; if (buildOn == null) { recipe = new ModRecipe(mod); } else { recipe = buildOn; } //where to craft (use MaxValue to skip) if (where != ushort.MaxValue) { recipe.AddTile(where); } //add ingredients if (ingredients.GetLength(1) == 2) { for (int i = 0; i < ingredients.GetLength(0); i++) { recipe.AddIngredient(ingredients[i, 0], ingredients[i, 1]); } } //result recipe.SetResult(result, numResult); //complete recipe.AddRecipe(); }
// c:\quake\mymod private void UpdateDemosList() { demos.Items.Clear(); ModItem curmod = GetCurrentMod((ModItem)mods.SelectedItem); #if DEBUG if (!Directory.Exists(curmod.ModPath)) { throw new InvalidOperationException("Expected existing absolute path!"); } #endif var demoitems = GameHandler.Current.GetDemos(curmod.ModPath); if (demoitems.Count == 0) { return; } demos.Items.Add(DemoItem.None); foreach (var di in demoitems) { demos.Items.Add(di); if (di.Value == Configuration.Demo) { demos.SelectedItem = di; } } // Select the first item... if (demos.SelectedIndex == -1) { demos.SelectedIndex = 0; } }
public bool TheCardEffectThatICantDoInACSharpFile(Player player, EntrogicPlayer ePlayer, ModCard card) { if (ePlayer.IsDestroyNextCard_InnerRage) { ePlayer.IsDestroyNextCard_InnerRage = false; List <int> elementCardNumber = new List <int>(); for (int i = 0; i < ePlayer.CardReadyType.Length; i++) { if (ePlayer.CardReadyType[i] == 0) { continue; } Item item = new Item(); item.SetDefaults(ePlayer.CardReadyType[i]); ModItem modItem = item.modItem; ModCard modCard = (ModCard)modItem; if (modCard.series == CardSeriesID.Element) { elementCardNumber.Add(i); } } if (elementCardNumber.Count > 0) { int chooseCard = Main.rand.Next(0, elementCardNumber.Count); ePlayer.CardSetToGrave(ePlayer.CardHandType[number], number, true, 1, true); ePlayer.CardHandType[number] = ePlayer.CardReadyType[elementCardNumber[chooseCard]]; ePlayer.CardHandCost[number] = ePlayer.CardReadyCost[elementCardNumber[chooseCard]]; ePlayer.CardReadyType[elementCardNumber[chooseCard]] = 0; ePlayer.CardReadyCost[elementCardNumber[chooseCard]] = 0; return(false); } return(true); } return(true); }
private void Raise_ItemAdded(ModItem theitem) { if (this.ItemAdded != null) { this.ItemAdded(this, new ModItemEventArgs(theitem)); } }
public void UnloadMod(ModItem modItem) { api.Console_Write($"ModHotLoader is unloading mod: {modItem.title} from {modItem.path}"); modItem.mod.Game_Exit(); modDict.Remove(modItem.path); api.Console_Write($"ModHotLoader hasfinished unloading mod: {modItem.title}"); }
public static ModRecipe CreateRecipe(this Mod mod, ModItem modItem, int itemAmount) { ModRecipe recipe = new ModRecipe(mod); recipe.SetResult(modItem, itemAmount); return(recipe); }
public ModItem StartMod(ModItem modItem) { api.Console_Write($"ModHotLoader is starting mod: {modItem.title} from {modItem.path}"); modItem.mod.Game_Start(api); modItem.isActive = true; api.Console_Write($"ModHotLoader has finished starting mod: {modItem.title}"); return(modItem); }
public override string Texture => "ExtraExplosives/Items/Explosives/BulletBoomItem"; // texture /*public TestItem(int itemID) * { * this.SetDefaults(); * int projectileId; * if (itemID == -1) * { * projectileId = ProjectileID.Bullet; * * } * else if(ItemLoader.GetItem(itemID) != null) * { * projectileId = ItemLoader.GetItem(itemID).item.shoot; * } * else * { * Item tmp = new Item(); * tmp.CloneDefaults(itemID); * projectileId = tmp.shoot; * } * projectile = new TestProjectile().Clone(); * projectile.projectile.localAI[0] = projectileId; * _projectileID = projectileId; * }*/ public override ModItem Clone(Item item) { ModItem tmp = base.Clone(item); tmp.DisplayName.SetDefault("Base Item"); tmp.item.shoot = item.shoot; return(tmp); }
public ItemTranslation(ModItem item) { NameTranslation = string.Empty; TooltipTranslation = string.Empty; Name = item.DisplayName.GetDefault(); Tooltip = item.Tooltip.GetDefault(); }
public ModItem StopMod(ModItem mod) { api.Console_Write($"ModHotLoader is stopping mod: {mod.title} from {mod.path}"); mod.mod.Game_Exit(); mod.isActive = false; api.Console_Write($"ModHotLoader has finished stopping mod: {mod.title}"); return(mod); }
public ModificationScreen(ContentManager content, GraphicsDevice device, AudioManager audio, GameData data, World w, Camera cam) : base(content, device, audio, data) { //Mouse.SetPosition(512, 384); world = w; camera = cam; lastMouseState = ButtonState.Released; modFont = content.Load<SpriteFont>("Fonts/ModFont"); loadRectangle = new Rectangle(294, 200, 224, 45); exitRectangle = new Rectangle(891, 78, 63, 55); spriteBatch = new SpriteBatch(device); cursor = content.Load<Texture2D>("cursor"); userInterface = content.Load<Texture2D>("mod_interface"); frame = content.Load<Texture2D>("briefing_frame"); //stat mod icons i_mod_nil = content.Load<Texture2D>("Icons/mod_nil"); i_mod_str = content.Load<Texture2D>("Icons/mod_str"); i_mod_spd = content.Load<Texture2D>("Icons/mod_spd"); i_mod_rcg = content.Load<Texture2D>("Icons/mod_rcg"); i_mod_acp = content.Load<Texture2D>("Icons/mod_acp"); //type mod icons i_mod_bla = content.Load<Texture2D>("Icons/mod_bla"); i_mod_wav = content.Load<Texture2D>("Icons/mod_wav"); i_mod_tri = content.Load<Texture2D>("Icons/mod_tri"); //element mod icons i_mod_pla = content.Load<Texture2D>("Icons/mod_pla"); i_mod_hea = content.Load<Texture2D>("Icons/mod_hea"); i_mod_ice = content.Load<Texture2D>("Icons/mod_ice"); interfaceRectangle = new Rectangle(0, 0, 1024, 768); frameRectangle = new Rectangle(174, 334, 105, 105); startRectangle = new Rectangle(196, 583, 190, 67); slot1Rectangle = new Rectangle(174, 334, 105, 105); slot2Rectangle = new Rectangle(307, 334, 105, 105); slot3Rectangle = new Rectangle(174, 466, 105, 105); slot4Rectangle = new Rectangle(307, 466, 105, 105); activeModRectangle=new Rectangle(264,186,60,60); activeModTextRectangle = new Rectangle(234, 258, 117, 49); dragDropRectangle = new Rectangle(174, 334, 40, 40); helpRectangle = new Rectangle(837, 81, 56, 47); #region Inventory Rectangles inventoryRectangle[0] = new Rectangle[5]; inventoryRectangle[1] = new Rectangle[5]; inventoryRectangle[2] = new Rectangle[5]; inventoryRectangle[3] = new Rectangle[5]; for(int i = 0; i<4; i++) for (int j = 0; j < 5; j++) { inventoryRectangle[i][j]=new Rectangle(559+i*87, 217+j*86, 68, 68); } #endregion #region build modlist inventoryItems[0] = new ModItem[5]; inventoryItems[1] = new ModItem[5]; inventoryItems[2] = new ModItem[5]; inventoryItems[3] = new ModItem[5]; for (int i = 0; i < 4; i++) for (int j = 0; j < 5; j++) { inventoryItems[i][j] = new ModItem(data.mods[i+j*4]); switch (data.mods[i + j * 4].type) { case Constants.MOD_NIL: inventoryItems[i][j].icon = i_mod_nil; break; case Constants.MOD_ELM: switch (data.mods[i + j * 4].value) { case Constants.ELM_PLA: inventoryItems[i][j].icon = i_mod_pla; break; case Constants.ELM_HEA: inventoryItems[i][j].icon = i_mod_hea; break; case Constants.ELM_ICE: inventoryItems[i][j].icon = i_mod_ice; break; default: inventoryItems[i][j].icon = i_mod_nil; break; } break; case Constants.MOD_TYP: switch (data.mods[i + j * 4].value) { case Constants.TYP_BLA: inventoryItems[i][j].icon = i_mod_bla; break; case Constants.TYP_WAV: inventoryItems[i][j].icon = i_mod_wav; break; case Constants.TYP_TRI: inventoryItems[i][j].icon = i_mod_tri; break; default: inventoryItems[i][j].icon = i_mod_nil; break; } break; case Constants.MOD_STR: inventoryItems[i][j].icon = i_mod_str; break; case Constants.MOD_SPD: inventoryItems[i][j].icon = i_mod_spd; break; case Constants.MOD_RCG: inventoryItems[i][j].icon = i_mod_rcg; break; case Constants.MOD_ACP: inventoryItems[i][j].icon = i_mod_acp; break; default: inventoryItems[i][j].icon = i_mod_nil; break; } } slotItems = new ModItem[4]; if (data.player.myWeapon.mods != null) { for (int i = 0; i < 4; i++) { slotItems[i] = new ModItem(data.player.myWeapon.mods[i]); switch (slotItems[i].modification.type) { case Constants.MOD_NIL: slotItems[i].icon = i_mod_nil; break; case Constants.MOD_ELM: switch (slotItems[i].modification.value) { case Constants.ELM_PLA: slotItems[i].icon = i_mod_pla; break; case Constants.ELM_HEA: slotItems[i].icon = i_mod_hea; break; case Constants.ELM_ICE: slotItems[i].icon = i_mod_ice; break; default: slotItems[i].icon = i_mod_nil; break; } break; case Constants.MOD_TYP: switch (slotItems[i].modification.value) { case Constants.TYP_BLA: slotItems[i].icon = i_mod_bla; break; case Constants.TYP_WAV: slotItems[i].icon = i_mod_wav; break; case Constants.TYP_TRI: slotItems[i].icon = i_mod_tri; break; default: slotItems[i].icon = i_mod_nil; break; } break; case Constants.MOD_STR: slotItems[i].icon = i_mod_str; break; case Constants.MOD_SPD: slotItems[i].icon = i_mod_spd; break; case Constants.MOD_RCG: slotItems[i].icon = i_mod_rcg; break; case Constants.MOD_ACP: slotItems[i].icon = i_mod_acp; break; default: slotItems[i].icon = i_mod_nil; break; } } #region //slot1Item = new ModItem(data.player.myWeapon.mods[0]); //switch (slot1Item.modification.type) //{ // case Constants.MOD_NIL: slot1Item.icon = i_mod_nil; break; // case Constants.MOD_ELM: // switch(slot1Item.modification.value) { // case Constants.ELM_PLA: slot1Item.icon = i_mod_pla; break; // case Constants.ELM_HEA: slot1Item.icon = i_mod_hea; break; // case Constants.ELM_ICE: slot1Item.icon = i_mod_ice; break; // default: slot1Item.icon = i_mod_nil; break; // } break; // case Constants.MOD_TYP: // switch(slot1Item.modification.value) { // case Constants.TYP_BLA: slot1Item.icon = i_mod_bla; break; // case Constants.TYP_WAV: slot1Item.icon = i_mod_wav; break; // case Constants.TYP_TRI: slot1Item.icon = i_mod_tri; break; // default: slot1Item.icon = i_mod_nil; break; // } break; // case Constants.MOD_STR: slot1Item.icon = i_mod_str; break; // case Constants.MOD_SPD: slot1Item.icon = i_mod_spd; break; // case Constants.MOD_RCG: slot1Item.icon = i_mod_rcg; break; // case Constants.MOD_ACP: slot1Item.icon = i_mod_acp; break; // default: slot1Item.icon = i_mod_nil; break; //} //slot2Item = new ModItem(data.player.myWeapon.mods[1]); //switch (slot2Item.modification.type) //{ // case Constants.MOD_NIL: slot2Item.icon = i_mod_nil; break; // case Constants.MOD_ELM: // switch (slot2Item.modification.value) // { // case Constants.ELM_PLA: slot2Item.icon = i_mod_pla; break; // case Constants.ELM_HEA: slot2Item.icon = i_mod_hea; break; // case Constants.ELM_ICE: slot2Item.icon = i_mod_ice; break; // default: slot2Item.icon = i_mod_nil; break; // } break; // case Constants.MOD_TYP: // switch (slot2Item.modification.value) // { // case Constants.TYP_BLA: slot2Item.icon = i_mod_bla; break; // case Constants.TYP_WAV: slot2Item.icon = i_mod_wav; break; // case Constants.TYP_TRI: slot2Item.icon = i_mod_tri; break; // default: slot2Item.icon = i_mod_nil; break; // } break; // case Constants.MOD_STR: slot2Item.icon = i_mod_str; break; // case Constants.MOD_SPD: slot2Item.icon = i_mod_spd; break; // case Constants.MOD_RCG: slot2Item.icon = i_mod_rcg; break; // case Constants.MOD_ACP: slot2Item.icon = i_mod_acp; break; // default: slot2Item.icon = i_mod_nil; break; //} //slot3Item = new ModItem(data.player.myWeapon.mods[2]); //switch (slot3Item.modification.type) //{ // case Constants.MOD_NIL: slot3Item.icon = i_mod_nil; break; // case Constants.MOD_ELM: // switch (slot3Item.modification.value) // { // case Constants.ELM_PLA: slot3Item.icon = i_mod_pla; break; // case Constants.ELM_HEA: slot3Item.icon = i_mod_hea; break; // case Constants.ELM_ICE: slot3Item.icon = i_mod_ice; break; // default: slot3Item.icon = i_mod_nil; break; // } break; // case Constants.MOD_TYP: // switch (slot3Item.modification.value) // { // case Constants.TYP_BLA: slot3Item.icon = i_mod_bla; break; // case Constants.TYP_WAV: slot3Item.icon = i_mod_wav; break; // case Constants.TYP_TRI: slot3Item.icon = i_mod_tri; break; // default: slot3Item.icon = i_mod_nil; break; // } break; // case Constants.MOD_STR: slot3Item.icon = i_mod_str; break; // case Constants.MOD_SPD: slot3Item.icon = i_mod_spd; break; // case Constants.MOD_RCG: slot3Item.icon = i_mod_rcg; break; // case Constants.MOD_ACP: slot3Item.icon = i_mod_acp; break; // default: slot3Item.icon = i_mod_nil; break; //} //slot4Item = new ModItem(data.player.myWeapon.mods[3]); //switch (slot4Item.modification.type) //{ // case Constants.MOD_NIL: slot4Item.icon = i_mod_nil; break; // case Constants.MOD_ELM: // switch (slot4Item.modification.value) // { // case Constants.ELM_PLA: slot4Item.icon = i_mod_pla; break; // case Constants.ELM_HEA: slot4Item.icon = i_mod_hea; break; // case Constants.ELM_ICE: slot4Item.icon = i_mod_ice; break; // default: slot4Item.icon = i_mod_nil; break; // } break; // case Constants.MOD_TYP: // switch (slot4Item.modification.value) // { // case Constants.TYP_BLA: slot4Item.icon = i_mod_bla; break; // case Constants.TYP_WAV: slot4Item.icon = i_mod_wav; break; // case Constants.TYP_TRI: slot4Item.icon = i_mod_tri; break; // default: slot4Item.icon = i_mod_nil; break; // } break; // case Constants.MOD_STR: slot4Item.icon = i_mod_str; break; // case Constants.MOD_SPD: slot4Item.icon = i_mod_spd; break; // case Constants.MOD_RCG: slot4Item.icon = i_mod_rcg; break; // case Constants.MOD_ACP: slot4Item.icon = i_mod_acp; break; // default: slot4Item.icon = i_mod_nil; break; //} #endregion } slot1Item = slotItems[0]; slot2Item = slotItems[1]; slot3Item = slotItems[2]; slot4Item = slotItems[3]; #endregion dragDropActive = false; }
private void onInventoryClick() { for(int i = 0; i<4; i++) for (int j = 0; j < 5; j++) { if (inventoryRectangle[i][j].Contains(Mouse.GetState().X, Mouse.GetState().Y) && Mouse.GetState().LeftButton == ButtonState.Pressed &&lastMouseState==ButtonState.Released) { frameRectangle = new Rectangle(559 + i * 87, 217 + j * 86, 68, 68); activeMod = (i + 1)+j*4; dragDropActive = true; } if (inventoryRectangle[i][j].Contains(Mouse.GetState().X, Mouse.GetState().Y) && Mouse.GetState().LeftButton == ButtonState.Released && lastMouseState == ButtonState.Pressed) { dragDropActive = false; if (activeMod > 20) { ModItem token=slot1Item; switch (activeMod) { case 21: token = slot1Item; slot1Item = inventoryItems[i][j]; break; case 22: token = slot2Item; slot2Item = inventoryItems[i][j]; break; case 23: token = slot3Item; slot3Item = inventoryItems[i][j]; break; case 24: token = slot4Item; slot4Item = inventoryItems[i][j]; break; default: break; } inventoryItems[i][j] = token; activeMod = (i+1)+j*4; frameRectangle = new Rectangle(559 + i * 87, 217 + j * 86, 68, 68); } } } }
private void onSlot4Click() { if (slot4Rectangle.Contains(Mouse.GetState().X, Mouse.GetState().Y) && Mouse.GetState().LeftButton == ButtonState.Pressed && lastMouseState == ButtonState.Released) { dragDropActive = true; frameRectangle = new Rectangle(307, 466, 105, 105); activeMod = 24; } if (slot4Rectangle.Contains(Mouse.GetState().X, Mouse.GetState().Y) && Mouse.GetState().LeftButton == ButtonState.Released && lastMouseState == ButtonState.Pressed) { dragDropActive = false; if (activeMod < 21) { ModItem token = inventoryItems[(activeMod - 1) % 4][(activeMod - 1) / 4]; inventoryItems[(activeMod - 1) % 4][(activeMod - 1) / 4] = slot4Item; slot4Item = token; activeMod = 24; frameRectangle = new Rectangle(307, 466, 105, 105); } } }