// Use this for initialization public void setValues(GameObject sel, MeleeWeapon ownerWeap) { self = sel; wepCol = GetComponent<BoxCollider>(); this.ownerWeap = ownerWeap; curTeam = sel.GetComponent<PlayerController>().team; }
private void Awake() { MeleeWeapon = Instantiate(prefab); MeleeWeapon.transform.SetParent(meleeWeaponOrigin, false); MeleeWeapon.CollidedWithCharacter += OnWeaponCollidedWithCharacter; CharacterInAttackRange = false; }
//Allows the player to pick up a new weapon public void PickUpWeapon(MeleeWeapon wep) { if (equippedWeapon == primaryWeapon) { primaryWeapon = wep; } else { secondaryWeapon = wep; } equippedWeapon = wep; }
private void Awake() { weapon = GetComponentInParent <MeleeWeapon>(); }
public LetterViewerMenu(string mail, string mailTitle, bool fromCollection = false) : base((int)Utility.getTopLeftPositionForCenteringOnScreen(1280, 720).X, (int)Utility.getTopLeftPositionForCenteringOnScreen(1280, 720).Y, 1280, 720, showUpperRightCloseButton: true) { isFromCollection = fromCollection; mail = mail.Split(new string[1] { "[#]" }, StringSplitOptions.None)[0]; mail = mail.Replace("@", Game1.player.Name); if (mail.Contains("%update")) { mail = mail.Replace("%update", Utility.getStardewHeroStandingsString()); } isMail = true; Game1.playSound("shwip"); backButton = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + 32, yPositionOnScreen + height - 32 - 64, 48, 44), Game1.mouseCursors, new Rectangle(352, 495, 12, 11), 4f) { myID = 101, rightNeighborID = 102 }; forwardButton = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + width - 32 - 48, yPositionOnScreen + height - 32 - 64, 48, 44), Game1.mouseCursors, new Rectangle(365, 495, 12, 11), 4f) { myID = 102, leftNeighborID = 101 }; acceptQuestButton = new ClickableComponent(new Rectangle(xPositionOnScreen + width / 2 - 128, yPositionOnScreen + height - 128, (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest")).X + 24, (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest")).Y + 24), "") { myID = 103, rightNeighborID = 102, leftNeighborID = 101 }; this.mailTitle = mailTitle; letterTexture = Game1.temporaryContent.Load <Texture2D>("LooseSprites\\letterBG"); if (mail.Contains("¦")) { mail = (Game1.player.IsMale ? mail.Substring(0, mail.IndexOf("¦")) : mail.Substring(mail.IndexOf("¦") + 1)); } if (mail.Contains("%item")) { string itemDescription = mail.Substring(mail.IndexOf("%item"), mail.IndexOf("%%") + 2 - mail.IndexOf("%item")); string[] split = itemDescription.Split(' '); mail = mail.Replace(itemDescription, ""); if (!isFromCollection) { if (split[1].Equals("object")) { int maxNum3 = split.Length - 1; int which3 = Game1.random.Next(2, maxNum3); which3 -= which3 % 2; Object o3 = new Object(Vector2.Zero, Convert.ToInt32(split[which3]), Convert.ToInt32(split[which3 + 1])); itemsToGrab.Add(new ClickableComponent(new Rectangle(xPositionOnScreen + width / 2 - 48, yPositionOnScreen + height - 32 - 96, 96, 96), o3) { myID = 104, leftNeighborID = 101, rightNeighborID = 102 }); backButton.rightNeighborID = 104; forwardButton.leftNeighborID = 104; } else if (split[1].Equals("tools")) { for (int i = 2; i < split.Length; i++) { Item tool = null; switch (split[i]) { case "Axe": tool = new Axe(); break; case "Hoe": tool = new Hoe(); break; case "Can": tool = new WateringCan(); break; case "Scythe": tool = new MeleeWeapon(47); break; case "Pickaxe": tool = new Pickaxe(); break; } if (tool != null) { itemsToGrab.Add(new ClickableComponent(new Rectangle(xPositionOnScreen + width / 2 - 48, yPositionOnScreen + height - 32 - 96, 96, 96), tool)); } } } else if (split[1].Equals("bigobject")) { int maxNum2 = split.Length - 1; int which2 = Game1.random.Next(2, maxNum2); Object o2 = new Object(Vector2.Zero, Convert.ToInt32(split[which2])); itemsToGrab.Add(new ClickableComponent(new Rectangle(xPositionOnScreen + width / 2 - 48, yPositionOnScreen + height - 32 - 96, 96, 96), o2) { myID = 104, leftNeighborID = 101, rightNeighborID = 102 }); backButton.rightNeighborID = 104; forwardButton.leftNeighborID = 104; } else if (split[1].Equals("furniture")) { int maxNum = split.Length - 1; int which = Game1.random.Next(2, maxNum); Item o = Furniture.GetFurnitureInstance(Convert.ToInt32(split[which])); itemsToGrab.Add(new ClickableComponent(new Rectangle(xPositionOnScreen + width / 2 - 48, yPositionOnScreen + height - 32 - 96, 96, 96), o) { myID = 104, leftNeighborID = 101, rightNeighborID = 102 }); backButton.rightNeighborID = 104; forwardButton.leftNeighborID = 104; } else if (split[1].Equals("money")) { int moneyToAdd = ((split.Length > 4) ? Game1.random.Next(Convert.ToInt32(split[2]), Convert.ToInt32(split[3])) : Convert.ToInt32(split[2])); moneyToAdd -= moneyToAdd % 10; Game1.player.Money += moneyToAdd; moneyIncluded = moneyToAdd; } else if (split[1].Equals("conversationTopic")) { string topic = split[2]; int numDays = Convert.ToInt32(split[3].Replace("%%", "")); Game1.player.activeDialogueEvents.Add(topic, numDays); if (topic.Equals("ElliottGone3")) { Utility.getHomeOfFarmer(Game1.player).fridge.Value.addItem(new Object(732, 1)); } } else if (split[1].Equals("cookingRecipe")) { Dictionary <string, string> cookingRecipes = Game1.content.Load <Dictionary <string, string> >("Data\\CookingRecipes"); int lowest_required_heart_level = 1000; string recipe_string = ""; foreach (string s in cookingRecipes.Keys) { string[] cookingSplit = cookingRecipes[s].Split('/'); string[] getConditions = cookingSplit[3].Split(' '); if (!getConditions[0].Equals("f") || !getConditions[1].Equals(mailTitle.Replace("Cooking", "")) || Game1.player.cookingRecipes.ContainsKey(s)) { continue; } int required_heart_level = Convert.ToInt32(getConditions[2]); if (required_heart_level <= lowest_required_heart_level) { lowest_required_heart_level = required_heart_level; recipe_string = s; learnedRecipe = s; if (LocalizedContentManager.CurrentLanguageCode != 0) { learnedRecipe = cookingSplit[cookingSplit.Length - 1]; } } } if (recipe_string != "") { if (!Game1.player.cookingRecipes.ContainsKey(recipe_string)) { Game1.player.cookingRecipes.Add(recipe_string, 0); } cookingOrCrafting = Game1.content.LoadString("Strings\\UI:LearnedRecipe_cooking"); } } else if (split[1].Equals("craftingRecipe")) { learnedRecipe = split[2].Replace('_', ' '); if (!Game1.player.craftingRecipes.ContainsKey(learnedRecipe)) { Game1.player.craftingRecipes.Add(learnedRecipe, 0); } cookingOrCrafting = Game1.content.LoadString("Strings\\UI:LearnedRecipe_crafting"); if (LocalizedContentManager.CurrentLanguageCode != 0) { Dictionary <string, string> craftingRecipes = Game1.content.Load <Dictionary <string, string> >("Data\\CraftingRecipes"); if (craftingRecipes.ContainsKey(learnedRecipe)) { string[] craftingSplit = craftingRecipes[learnedRecipe].Split('/'); learnedRecipe = craftingSplit[craftingSplit.Length - 1]; } } } else if (split[1].Equals("itemRecovery")) { if (Game1.player.recoveredItem != null) { Item item = Game1.player.recoveredItem; Game1.player.recoveredItem = null; itemsToGrab.Add(new ClickableComponent(new Rectangle(xPositionOnScreen + width / 2 - 48, yPositionOnScreen + height - 32 - 96, 96, 96), item) { myID = 104, leftNeighborID = 101, rightNeighborID = 102 }); backButton.rightNeighborID = 104; forwardButton.leftNeighborID = 104; } } else if (split[1].Equals("quest")) { questID = Convert.ToInt32(split[2].Replace("%%", "")); if (split.Length > 4) { if (!Game1.player.mailReceived.Contains("NOQUEST_" + questID)) { Game1.player.addQuest(questID); } questID = -1; } backButton.rightNeighborID = 103; forwardButton.leftNeighborID = 103; } } } if (mailTitle == "ccBulletinThankYou" && !Game1.player.hasOrWillReceiveMail("ccBulletinThankYouReceived")) { foreach (NPC j in Utility.getAllCharacters()) { if (!j.datable && j.isVillager()) { Game1.player.changeFriendship(500, j); } } Game1.addMailForTomorrow("ccBulletinThankYouReceived", noLetter: true); } Random r = new Random((int)(Game1.uniqueIDForThisGame / 2uL) ^ Game1.year ^ (int)Game1.player.UniqueMultiplayerID); bool hide_secret_santa = fromCollection; if (Game1.currentSeason == "winter" && Game1.dayOfMonth >= 18 && Game1.dayOfMonth <= 25) { hide_secret_santa = false; } mail = mail.Replace("%secretsanta", hide_secret_santa ? "???" : Utility.getRandomTownNPC(r).displayName); int page_height = height - 128; if (HasInteractable()) { page_height = height - 128 - 32; } mailMessage = SpriteText.getStringBrokenIntoSectionsOfHeight(mail, width - 64, page_height); if (mailTitle.Equals("winter_5_2") || mailTitle.Equals("winter_12_1") || mailTitle.ToLower().Contains("wizard")) { whichBG = 2; } else if (mailTitle.Equals("Sandy")) { whichBG = 1; } else if (mailTitle.Contains("Krobus")) { whichBG = 3; } forwardButton.visible = page < mailMessage.Count - 1; backButton.visible = page > 0; if (Game1.options.SnappyMenus) { populateClickableComponentList(); snapToDefaultClickableComponent(); if (mailMessage != null && mailMessage.Count <= 1) { backButton.myID = -100; forwardButton.myID = -100; } } }
private void Start() { MeleeWeapon meleeWeapon = gameObject.GetComponentInChildren <MeleeWeapon>(); AttackRange = meleeWeapon.GetMeleeAttackRadius() + meleeWeapon.WeaponAttackPoint.localPosition.magnitude; }
/// <summary>Converts a MeleeWeapon into a ModWeapon by copying all the fields</summary> /// <param name="original">The original (preferably vanilla) weapon</param> public ModWeapon(MeleeWeapon original) { Helpers.CopyFields <MeleeWeapon>(original, this); this.name = "Modded: " + this.name; ModEntry.INSTANCE.Monitor.Log(name + " | Damage: " + minDamage + " - " + maxDamage); }
/// <summary> /// 创建角色(base,无装备,有武器) /// </summary> /// <param name="id">ID</param> /// <param name="name">名字</param> /// <param name="faction">势力(玩家,友军,敌人)</param> /// <param name="type">(英雄,普通)</param> /// <param name="constitution">体质</param> /// <param name="strength">力量</param> /// <param name="agility">灵巧</param> /// <param name="dexterous">洞察</param> /// <param name="concentration">专注</param> /// <param name="weapon">武器</param> /// <param name="allExperience">全部经验</param> /// <param name="skills">技能</param> /// <param name="currentExperience">当前经验</param> public CharacterProperty(int id, string name, CharacterFaction faction, CharacterType type, string sprite, CharacterKind kind, int constitution, int strength, int agility, int dexterous, int concentration, Item weapon, float allExperience, float resistance = 0, int[] skills = null, float currentExperience = 0, int headID = 0, int clothID = 0, int pantsID = 0, int beltID = 0, BuffProp buffProp = null) { #region 装备处理 if (this.EquipmentProp == null) { this.EquipmentProp = new EquipProp(headID, clothID, pantsID, beltID); } if ((headID != 0) || (clothID != 0) || (pantsID != 0) || (beltID != 0)) { this.EquipmentProp = new EquipProp(headID, clothID, pantsID, beltID); resistance += EquipmentProp.Resistance; constitution += EquipmentProp.Constitution; strength += EquipmentProp.Strength; dexterous += EquipmentProp.Dexterous; agility += EquipmentProp.Agility; concentration += EquipmentProp.Concentration; } #endregion #region 加成处理 if (buffProp != null) { this.BuffItemProp = buffProp; constitution += buffProp.Constitution; strength += buffProp.Strength; dexterous += buffProp.Dexterous; agility += buffProp.Agility; concentration += buffProp.Concentration; //else ... } #endregion this.ID = id; this.Name = name; this.Faction = faction; this.Type = type; this.Sprite = sprite; this.AllExperience = allExperience; this.Resistance = resistance; this.Constitution = constitution; this.Strength = strength; this.Agility = agility; this.Dexterous = dexterous; this.Concentration = concentration; this.HealthLevel = 100; this.charKind = kind; this.Level = CountLevel(allExperience, out currentExperience); this.CurrentExperience = currentExperience; this.Power = constitution + strength + agility + dexterous + concentration; this.WeaponWith = weapon; //通常角色 if (type == CharacterType.Common) { this.MaxHealth = 100 + 3 * constitution; this.MaxStamina = 100 + 1 * constitution; this.HealthRecovery = 0.2f; this.StaminaRecovery = 5f; this.MoveSpeed = 1.3f * (1 + 0.01f * agility); this.AimingSpeed = 2 * (1 + 0.02f * concentration); this.Critical = 0.1f + 0.01f * dexterous; this.MeleeRaise = 1.5f; this.ShootRaise = 1.5f; this.ThrowRaise = 1.5f; this.MaxAngle = 10 * (1 - 0.01f * concentration); this.KickDamage = 20 + strength; this.PunchDamage = 20 + strength; if (weapon is MeleeWeapon) { MeleeWeapon melee = (MeleeWeapon)weapon; this.MeleeDamage = melee.MeleeDamage + strength; this.ThrowDamage = melee.ThrowDamage + strength; this.AttackInterval = melee.AttackInterval * (1 - 0.02f * agility); } else if (weapon is ShootWeapon) { ShootWeapon shoot = (ShootWeapon)weapon; this.MinAngle = (110 - shoot.Accuracy / 15); this.Capacity = shoot.Accuracy * MaxAngle / 10; this.PullingTime = shoot.LaShuanTime * (1 - 0.02f * agility); this.ReloadTime = shoot.ReloadTime * (1 - 0.01f * agility); this.MeleeDamage = shoot.MeleeDamage + strength; this.ShootDamage = shoot.ShootDamage; this.AttackInterval = shoot.AttackInterval * (1 - 0.01f * agility); this.DeclineRange = shoot.DamageRange; } } //英雄角色 else if (type == CharacterType.Hero) { this.SkillA = skills[0]; this.SkillB = skills[1]; this.SkillC = skills[2]; this.SkillD = skills[3]; this.SkillE = skills[4]; this.SkillF = skills[5]; this.SkillG = skills[6]; this.SkillH = skills[7]; this.SkillI = skills[8]; this.SkillJ = skills[9]; this.SkillK = skills[10]; this.SkillL = skills[11]; this.SkillM = skills[12]; this.SkillN = skills[13]; this.SkillO = skills[14]; this.SkillP = skills[15]; this.SkillQ = skills[16]; this.SkillR = skills[17]; this.SkillS = skills[18]; this.SkillT = skills[19]; this.MaxHealth = 100 + 3 * constitution + 20 * SkillA; this.MaxStamina = 100 + 1 * constitution + 20 * SkillF; this.HealthRecovery = 0.2f + 2 * SkillM + 100 * SkillN; this.StaminaRecovery = 5 + 2 * SkillL; this.MoveSpeed = 1.3f * (1 + 0.01f * agility + 0.15f * SkillR); this.AimingSpeed = 2f * (1 + 0.02f * concentration + 0.1f * SkillQ); this.Critical = 0.1f + 0.01f * dexterous + 0.04f * SkillD; this.MeleeRaise = 1.5f + 0.5f * SkillI; this.ShootRaise = 1.5f + 0.5f * SkillJ; this.ThrowRaise = 1.5f + 1 * SkillT; this.MaxAngle = 10 * (1 - 0.01f * concentration - 0.04f * SkillE); this.Resistance = this.Resistance + 0.04f * SkillG + 0.1f * SkillN; this.KickDamage = 20 + 20 * SkillH; if (weapon is MeleeWeapon) { MeleeWeapon melee = (MeleeWeapon)weapon; this.MeleeDamage = (melee.MeleeDamage + strength) * (1 + 0.04f * SkillB); this.AttackInterval = melee.AttackInterval * (1 - 0.02f * agility - 0.04f * SkillC); this.ThrowDamage = melee.ThrowDamage * (1 + SkillT) + strength; } else if (weapon is ShootWeapon) { ShootWeapon shoot = (ShootWeapon)weapon; this.MinAngle = (110 - shoot.Accuracy / 15) * (1 - 0.1f * SkillP); this.Capacity = shoot.Accuracy * MaxAngle / 10f; this.ReloadTime = shoot.ReloadTime * (1 - 0.01f * agility - 0.1f * SkillO); this.PullingTime = shoot.LaShuanTime * (1 - 0.02f * agility - 0.08f * SkillK); this.MeleeDamage = (shoot.MeleeDamage * (1 + SkillT) + strength) * (1 + 0.04f * SkillB); this.ShootDamage = shoot.ShootDamage; this.AttackInterval = shoot.AttackInterval * (1 - 0.01f * agility - 0.04f * SkillC); } } }
public void Draw(SpriteBatch spriteBatch) { if (this.weapon != null && this.weaponSwingCooldown > this.SwingThreshold && !this.defendFistUsed) { int frames = this.weapon.type.Value == 3 ? 4 : 7; int duration = this.CooldownTimeout - this.SwingThreshold; int tick = Math.Abs(this.weaponSwingCooldown - this.CooldownTimeout); int currentFrame = this.CurrentFrame(tick, duration, frames); if (Compat.IsModLoaded(ModUids.PACIFISTMOD_UID)) { currentFrame = 1; } Helper.DrawDuringUse(currentFrame, this.follower.FacingDirection, spriteBatch, this.follower.getLocalPosition(Game1.viewport), this.follower, MeleeWeapon.getSourceRect(this.weapon.InitialParentTileIndex), this.weapon.type.Value, this.weapon.isOnSpecial); } }
public void CombineWith(MeleeWeapon other) { }
// Token: 0x06000F06 RID: 3846 RVA: 0x001335E0 File Offset: 0x001317E0 public LetterViewerMenu(string mail, string mailTitle) : base((int)Utility.getTopLeftPositionForCenteringOnScreen(320 * Game1.pixelZoom, 180 * Game1.pixelZoom, 0, 0).X, (int)Utility.getTopLeftPositionForCenteringOnScreen(320 * Game1.pixelZoom, 180 * Game1.pixelZoom, 0, 0).Y, 320 * Game1.pixelZoom, 180 * Game1.pixelZoom, true) { this.isMail = true; Game1.playSound("shwip"); this.backButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize / 2, this.yPositionOnScreen + this.height - Game1.tileSize / 2 - 16 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(352, 495, 12, 11), (float)Game1.pixelZoom, false); this.forwardButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width - Game1.tileSize / 2 - 12 * Game1.pixelZoom, this.yPositionOnScreen + this.height - Game1.tileSize / 2 - 16 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(365, 495, 12, 11), (float)Game1.pixelZoom, false); this.acceptQuestButton = new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.width / 2 - Game1.tileSize * 2, this.yPositionOnScreen + this.height - Game1.tileSize * 2, Game1.tileSize * 4, Game1.tileSize), ""); this.mailTitle = mailTitle; Game1.temporaryContent = Game1.content.CreateTemporary(); this.letterTexture = Game1.temporaryContent.Load <Texture2D>("LooseSprites\\letterBG"); if (mail.Contains("%item")) { string itemDescription = mail.Substring(mail.IndexOf("%item"), mail.IndexOf("%%") + 2 - mail.IndexOf("%item")); string[] split = itemDescription.Split(new char[] { ' ' }); mail = mail.Replace(itemDescription, ""); if (split[1].Equals("object")) { int maxNum = split.Length - 1; int which = Game1.random.Next(2, maxNum); which -= which % 2; Object o = new Object(Vector2.Zero, Convert.ToInt32(split[which]), Convert.ToInt32(split[which + 1])); this.itemsToGrab.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.width / 2 - 12 * Game1.pixelZoom, this.yPositionOnScreen + this.height - Game1.tileSize / 2 - 24 * Game1.pixelZoom, 24 * Game1.pixelZoom, 24 * Game1.pixelZoom), o)); } else if (split[1].Equals("tools")) { for (int i = 2; i < split.Length; i++) { Item tool = null; string a = split[i]; if (!(a == "Axe")) { if (!(a == "Hoe")) { if (!(a == "Can")) { if (!(a == "Scythe")) { if (a == "Pickaxe") { tool = new Pickaxe(); } } else { tool = new MeleeWeapon(47); } } else { tool = new WateringCan(); } } else { tool = new Hoe(); } } else { tool = new Axe(); } if (tool != null) { this.itemsToGrab.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.width / 2 - 12 * Game1.pixelZoom, this.yPositionOnScreen + this.height - Game1.tileSize / 2 - 24 * Game1.pixelZoom, 24 * Game1.pixelZoom, 24 * Game1.pixelZoom), tool)); } } } else if (split[1].Equals("bigobject")) { int maxNum2 = split.Length - 1; int which2 = Game1.random.Next(2, maxNum2); Object o2 = new Object(Vector2.Zero, Convert.ToInt32(split[which2]), false); this.itemsToGrab.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.width / 2 - 12 * Game1.pixelZoom, this.yPositionOnScreen + this.height - Game1.tileSize / 2 - 24 * Game1.pixelZoom, 24 * Game1.pixelZoom, 24 * Game1.pixelZoom), o2)); } else if (split[1].Equals("money")) { int moneyToAdd = (split.Length > 4) ? Game1.random.Next(Convert.ToInt32(split[2]), Convert.ToInt32(split[3])) : Convert.ToInt32(split[2]); moneyToAdd -= moneyToAdd % 10; Game1.player.Money += moneyToAdd; this.moneyIncluded = moneyToAdd; } else if (split[1].Equals("quest")) { this.questID = Convert.ToInt32(split[2]); if (split.Length > 4) { if (!Game1.player.mailReceived.Contains("NOQUEST_" + this.questID)) { Game1.player.addQuest(this.questID); } this.questID = -1; } } else { if (split[1].Equals("cookingRecipe")) { Dictionary <string, string> cookingRecipes = Game1.content.Load <Dictionary <string, string> >("Data\\CookingRecipes"); using (Dictionary <string, string> .KeyCollection.Enumerator enumerator = cookingRecipes.Keys.GetEnumerator()) { while (enumerator.MoveNext()) { string s = enumerator.Current; string[] getConditions = cookingRecipes[s].Split(new char[] { '/' })[3].Split(new char[] { ' ' }); if (getConditions[0].Equals("f") && getConditions[1].Equals(mailTitle.Replace("Cooking", "")) && Game1.player.friendships[getConditions[1]][0] >= Convert.ToInt32(getConditions[2]) * 250 && !Game1.player.cookingRecipes.ContainsKey(s)) { Game1.player.cookingRecipes.Add(s, 0); this.learnedRecipe = s; this.cookingOrCrafting = Game1.content.LoadString("Strings\\UI:LearnedRecipe_cooking", new object[0]); break; } } goto IL_704; } } if (split[1].Equals("craftingRecipe")) { this.learnedRecipe = split[2].Replace('_', ' '); Game1.player.craftingRecipes.Add(this.learnedRecipe, 0); this.cookingOrCrafting = Game1.content.LoadString("Strings\\UI:LearnedRecipe_crafting", new object[0]); } } } IL_704: Random r = new Random((int)(Game1.uniqueIDForThisGame / 2uL) - Game1.year); mail = mail.Replace("%secretsanta", Utility.getRandomTownNPC(r, Utility.getFarmerNumberFromFarmer(Game1.player)).name); this.mailMessage = SpriteText.getStringBrokenIntoSectionsOfHeight(mail, this.width - Game1.tileSize, this.height - Game1.tileSize * 2); }
public Item UnpackItem(ModDataDictionary modData, string recipientName) { string[] fields = new[] { "giftsender", "giftname", "giftid", "giftparentid", "gifttype", "giftstack", "giftquality", "giftpreserve", "gifthoney", "giftcolour", "giftdata" }; if (fields.Any(field => !modData.ContainsKey(AssetPrefix + field))) { string msg = fields.Where(field => !modData.ContainsKey(field)) .Aggregate("This gift is missing data:", (str, field) => str + "\n" + field) + "\nIf this gift was placed before updating, please revert to the previous version and collect the gift!" + "\nOtherwise, leave a report on the mod page for Gift Wrapper with your log file (https://smapi.io/log)."; Monitor.Log(msg, LogLevel.Warn); return(null); } // Parse the wrapped gift's serialised modData fields to use in rebuilding its gift item long giftSender = long.Parse(modData[AssetPrefix + fields[0]]); string giftName = modData[AssetPrefix + fields[1]]; int giftId = int.Parse(modData[AssetPrefix + fields[2]]); int giftParentId = int.Parse(modData[AssetPrefix + fields[3]]); int giftType = int.Parse(modData[AssetPrefix + fields[4]]); int giftStack = int.Parse(modData[AssetPrefix + fields[5]]); int giftQuality = int.Parse(modData[AssetPrefix + fields[6]]); int giftPreserve = int.Parse(modData[AssetPrefix + fields[7]]); int giftHoney = int.Parse(modData[AssetPrefix + fields[8]]); string giftColour = modData[AssetPrefix + fields[9]]; string giftData = modData[AssetPrefix + fields[10]]; Item actualGift = null; switch (giftType) { case (int)GiftType.BedFurniture: actualGift = new BedFurniture(which: giftId, tile: Vector2.Zero); break; case (int)GiftType.Furniture: actualGift = new Furniture(which: giftId, tile: Vector2.Zero); break; case (int)GiftType.BigCraftable: actualGift = new StardewValley.Object(tileLocation: Vector2.Zero, parentSheetIndex: giftId, isRecipe: false); break; case (int)GiftType.MeleeWeapon: actualGift = new MeleeWeapon(spriteIndex: giftId); break; case (int)GiftType.Hat: actualGift = new Hat(which: giftId); break; case (int)GiftType.Boots: actualGift = new Boots(which: giftId); // todo: test boots colour ((Boots)actualGift).appliedBootSheetIndex.Set(giftQuality); ((Boots)actualGift).indexInColorSheet.Set(int.Parse(giftColour)); break; case (int)GiftType.Clothing: int[] colourSplit = giftColour.Split('/').ToList().ConvertAll(int.Parse).ToArray(); Color colour = new Color(r: colourSplit[0], g: colourSplit[1], b: colourSplit[2], a: colourSplit[3]); actualGift = new Clothing(item_index: giftId); ((Clothing)actualGift).clothesColor.Set(colour); break; case (int)GiftType.Ring: actualGift = new Ring(which: giftId); break; case (int)GiftType.Object: actualGift = new StardewValley.Object(parentSheetIndex: giftId, initialStack: giftStack) { Quality = giftQuality }; actualGift.Name = giftName; if (giftParentId != -1) { ((StardewValley.Object)actualGift).preservedParentSheetIndex.Value = giftParentId; } if (giftPreserve != -1) { ((StardewValley.Object)actualGift).preserve.Value = (StardewValley.Object.PreserveType)giftPreserve; } if (giftHoney != 0) { ((StardewValley.Object)actualGift).honeyType.Value = (StardewValley.Object.HoneyType)giftHoney; } break; } if (actualGift == null) { return(null); } Dictionary <string, string> giftDataDeserialised = ((Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(giftData)).ToObject <Dictionary <string, string> >(); if (giftDataDeserialised != null) { // Apply serialised mod data back to the gifted item actualGift.modData.Set(giftDataDeserialised); } if (recipientName != null && Game1.player.UniqueMultiplayerID != giftSender) { // Show a message to all players to celebrate this wonderful event Multiplayer multiplayer = Helper.Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue(); multiplayer.globalChatInfoMessage(AssetPrefix + (giftStack > 1 ? "message.giftopened_quantity" : "message.giftopened"), recipientName, // Recipient's name Game1.getFarmer(giftSender).Name, // Sender's name actualGift.DisplayName, // Gift name giftStack.ToString()); // Gift quantity } return(actualGift); }
private MeleeWeapon ChangeWeapon(MeleeWeapon w) { MeleeWeapon n = null; if (w is Knuckles) { n = new Dagger(); } else if (w is Dagger) { n = new Knuckles(); } else if (w is Spear) { n = new Quarterstaff(); } else if (w is Quarterstaff) { n = new Spear(); } else if (w is Sword) { n = new Mace(); } else if (w is Mace) { n = new Sword(); } else if (w is Longsword) { n = new BattleAxe(); } else if (w is BattleAxe) { n = new Longsword(); } else if (w is Glaive) { n = new WarHammer(); } else if (w is WarHammer) { n = new Glaive(); } if (n == null) { return(null); } var level = w.level; if (level > 0) { n.Upgrade(level); } else if (level < 0) { n.Degrade(-level); } if (w.IsEnchanted) { n.Enchant(Weapon.Enchantment.Random()); } n.levelKnown = w.levelKnown; n.cursedKnown = w.cursedKnown; n.cursed = w.cursed; Journal.Remove(Journal.Feature.WELL_OF_TRANSMUTATION); return(n); }
internal static float ChanceFromSpeed( MeleeWeapon weapon ) { return ( weapon.speed / 100 ).ClipMaxMin(); }
public ReadyMeleeWeaponAction(BattleSoldier soldier, MeleeWeapon weapon) { _soldier = soldier; _weapon = weapon; }
public void GameLoop_UpdateTicking(object sender, StardewModdingAPI.Events.UpdateTickingEventArgs e) { //Monitor.Log($"player sprite frame {Game1.player.Sprite.currentFrame}"); if (weaponAnimationFrame > -1 && advancedWeaponAnimating != null) { MeleeActionFrame frame = advancedWeaponAnimating.frames[weaponAnimationFrame]; Farmer user = weaponAnimating.getLastFarmerToUse(); if (weaponAnimationFrame == 0 && weaponAnimationTicks == 0) { weaponStartFacingDirection = user.facingDirection.Value; //Monitor.Log($"Starting animation, facing {weaponStartFacingDirection}"); } if (user.CurrentTool != weaponAnimating) { //Monitor.Log($"Switched tools to {Game1.player.CurrentTool?.DisplayName}"); weaponAnimating = null; weaponAnimationFrame = -1; weaponAnimationTicks = 0; advancedWeaponAnimating = null; return; } if (frame.invincible != null) { //Monitor.Log($"Setting invincible as {frame.invincible}"); user.temporarilyInvincible = (bool)frame.invincible; } if (weaponAnimationTicks == 0) { //Monitor.Log($"Starting frame {weaponAnimationFrame}"); user.faceDirection((weaponStartFacingDirection + frame.relativeFacingDirection) % 4); //Monitor.Log($"facing {user.getFacingDirection()}, relative {frame.relativeFacingDirection}"); if (frame.special != null) { try { switch (frame.special.name) { case "lightning": LightningStrike(user, weaponAnimating, frame.special.parameters); break; case "explosion": Explosion(user, weaponAnimating, frame.special.parameters); break; } } catch (Exception ex) { Monitor.Log($"Exception thrown on special effect:\n{ex}", LogLevel.Error); } } if (frame.action == WeaponAction.NORMAL) { //Monitor.Log($"Starting normal attack"); user.completelyStopAnimatingOrDoingAction(); user.CanMove = false; user.UsingTool = true; user.canReleaseTool = true; weaponAnimating.setFarmerAnimating(user); } else if (frame.action == WeaponAction.SPECIAL) { //Monitor.Log($"Starting special attack"); weaponAnimating.animateSpecialMove(user); } if (frame.trajectoryX != 0 || frame.trajectoryY != 0) { float trajectoryX = frame.trajectoryX; float trajectoryY = frame.trajectoryY; Vector2 rawTrajectory = TranslateVector(new Vector2(trajectoryX, trajectoryY), user.FacingDirection); user.setTrajectory(new Vector2(rawTrajectory.X, -rawTrajectory.Y)); // game trajectory y is backwards idek //Monitor.Log($"player trajectory {user.xVelocity},{user.yVelocity}"); } if (frame.sound != null) { //Monitor.Log($"Playing sound {frame.sound}"); user.currentLocation.playSound(frame.sound, NetAudio.SoundContext.Default); } foreach (AdvancedWeaponProjectile p in frame.projectiles) { Vector2 velocity = TranslateVector(new Vector2(p.xVelocity, p.yVelocity), user.FacingDirection); Vector2 startPos = TranslateVector(new Vector2(p.startingPositionX, p.startingPositionY), user.FacingDirection); int damage = advancedWeaponAnimating.type > 0 ? p.damage * myRand.Next(weaponAnimating.minDamage, weaponAnimating.maxDamage) : p.damage; //Monitor.Log($"player position: {user.Position}, start position: { new Vector2(startingPositionX, startingPositionY) }"); user.currentLocation.projectiles.Add(new BasicProjectile(damage, p.parentSheetIndex, p.bouncesTillDestruct, p.tailLength, p.rotationVelocity, velocity.X, velocity.Y, user.Position + new Vector2(0, -64) + startPos, p.collisionSound, p.firingSound, p.explode, p.damagesMonsters, user.currentLocation, user, p.spriteFromObjectSheet)); } } if (++weaponAnimationTicks >= frame.frameTicks) { weaponAnimationFrame++; weaponAnimationTicks = 0; //Monitor.Log($"Advancing to frame {weaponAnimationFrame}"); } if (weaponAnimationFrame >= advancedWeaponAnimating.frames.Count) { //Monitor.Log($"Ending weapon animation"); user.completelyStopAnimatingOrDoingAction(); user.CanMove = true; user.UsingTool = false; user.setTrajectory(Vector2.Zero); if (user.IsLocalPlayer) { int cd = advancedWeaponAnimating.cooldown; if (user.professions.Contains(28)) { cd /= 2; } if (weaponAnimating.hasEnchantmentOfType <ArtfulEnchantment>()) { cd /= 2; } switch (weaponAnimating.type.Value) { case 1: MeleeWeapon.daggerCooldown = cd; break; case 2: MeleeWeapon.clubCooldown = cd; break; case 3: MeleeWeapon.defenseCooldown = cd; break; } } weaponAnimationFrame = -1; weaponAnimating = null; advancedWeaponAnimating = null; weaponAnimationTicks = 0; } return; } }
public WeaponProxy(MeleeWeapon weapon) { Weapon = weapon; }
private static bool beginSpecialMove_prefix(MeleeWeapon __instance, Farmer who) { __instance.leftClick(who); return(false); }
// Awake void Awake() { parentWeapon = transform.parent.GetComponent<MeleeWeapon>(); }
public void SetShootEnermyEffect() { Aim componentInChildren = GetComponentInChildren <Aim>(); if (null != componentInChildren) { componentInChildren.SetShootEnermyEffect(); } else { MeleeWeapon componentInChildren2 = rightHand.GetComponentInChildren <MeleeWeapon>(); if (componentInChildren2 != null) { componentInChildren2.SetShootEnermyEffect(); } else { Grenade componentInChildren3 = rightHand.GetComponentInChildren <Grenade>(); if (componentInChildren3 != null) { componentInChildren3.SetShootEnermyEffect(); } else { FlashBang componentInChildren4 = rightHand.GetComponentInChildren <FlashBang>(); if (componentInChildren4 != null) { componentInChildren4.SetShootEnermyEffect(); } else { SmokeGrenade componentInChildren5 = rightHand.GetComponentInChildren <SmokeGrenade>(); if (componentInChildren5 != null) { componentInChildren5.SetShootEnermyEffect(); } else { SenseBomb componentInChildren6 = rightHand.GetComponentInChildren <SenseBomb>(); if (componentInChildren6 != null) { componentInChildren6.SetShootEnermyEffect(); } else { XmasBomb componentInChildren7 = rightHand.GetComponentInChildren <XmasBomb>(); if (componentInChildren7 != null) { componentInChildren7.SetShootEnermyEffect(); } else { PoisonBomb componentInChildren8 = rightHand.GetComponentInChildren <PoisonBomb>(); if (componentInChildren8 != null) { componentInChildren8.SetShootEnermyEffect(); } else { GetComponent <LocalController>().SetShootEnermyEffect(); } } } } } } } } }
private Tile Create(TileType type) { switch (type) { case (TileType.Hero): { int heroX = rando.Next(0, width); //get random width int heroY = rando.Next(0, height); //get random height while ((mapArray[heroX, heroY] is EmptyTile) == false) //while the tile is already taken, create a random X and Y position { heroX = rando.Next(0, width); //get random width heroY = rando.Next(0, height); //get random height } Hero tempHero = new Hero(heroX, heroY, 20, 20); return(tempHero); } case (TileType.Enemy): { int gobX = rando.Next(0, width); //get random width int gobY = rando.Next(0, height); //get random height while ((mapArray[gobX, gobY] is EmptyTile) == false) //while the tile is already taken, create a random X and Y position { gobX = rando.Next(0, width); //get random width gobY = rando.Next(0, height); //get random height } Random randEnemy = new Random(Guid.NewGuid().GetHashCode()); //use randomseed to get a new random value each time // from joppiesaus on Aug 16 at 6:54 on stack overflow //https://stackoverflow.com/questions/1785744/how-do-i-seed-a-random-class-to-avoid-getting-duplicate-random-values //Accessed 10 October 2020 for (int i = 0; i < 2; ++i) { int getRandEnemy = randEnemy.Next(0, 3); //coinflip between goblin and mage each time //added leaders for POE if (getRandEnemy == 1) { Goblin tempGob = new Goblin(gobX, gobY, 10, 1); return(tempGob); } else if (getRandEnemy == 2) { Mage tempMage = new Mage(gobX, gobY, 5, 5); return(tempMage); } else { Leader tempLeader = new Leader(gobX, gobY, Player); return(tempLeader); } } return(null); } case (TileType.Gold): { int goldX = rando.Next(0, width); //get random width int goldY = rando.Next(0, height); //get random height while ((mapArray[goldX, goldY] is EmptyTile) == false) //while the tile is already taken, create a random X and Y position { goldX = rando.Next(0, width); //get random width goldY = rando.Next(0, height); //get random height } Gold tempGold = new Gold(goldX, goldY); return(tempGold); } case (TileType.Weapon): { int weaponX = rando.Next(0, width); int weaponY = rando.Next(0, height); while ((mapArray[weaponX, weaponY] is EmptyTile) == false) { weaponX = rando.Next(0, width); weaponY = rando.Next(0, height); } Random randWeapon = new Random(Guid.NewGuid().GetHashCode()); int getrandWeapon = randWeapon.Next(0, 4); if (getrandWeapon == 0) { RangedWeapon tempweapon = new RangedWeapon(weaponX, weaponY, RangedWeapon.Types.Rifle); return(tempweapon); } else if (getrandWeapon == 1) { RangedWeapon tempweapon = new RangedWeapon(weaponX, weaponY, RangedWeapon.Types.Longbow); return(tempweapon); } else if (getrandWeapon == 2) { MeleeWeapon tempweapon = new MeleeWeapon(weaponX, weaponY, MeleeWeapon.Types.Dagger); return(tempweapon); } else { MeleeWeapon tempweapon = new MeleeWeapon(weaponX, weaponY, MeleeWeapon.Types.Longsword); return(tempweapon); } } default: break; } return(null); }
public static void drawHoverTextWithoutShadow(SpriteBatch b, string text, SpriteFont font, int xOffset = 0, int yOffset = 0, int moneyAmountToDisplayAtBottom = -1, string boldTitleText = null, int healAmountToDisplay = -1, string[] buffIconsToDisplay = null, Item hoveredItem = null, int currencySymbol = 0, int extraItemToShowIndex = -1, int extraItemToShowAmount = -1, int overrideX = -1, int overrideY = -1, float alpha = 1f, CraftingRecipe craftingIngredients = null) { if (text == null || text.Length == 0) { return; } if (boldTitleText != null && boldTitleText.Length == 0) { boldTitleText = null; } int num = 20; int num2 = Math.Max((healAmountToDisplay == -1) ? 0 : ((int)font.MeasureString(healAmountToDisplay + "+ Energy" + Game1.tileSize / 2).X), Math.Max((int)font.MeasureString(text).X, (boldTitleText == null) ? 0 : ((int)Game1.dialogueFont.MeasureString(boldTitleText).X))) + Game1.tileSize / 2; int num3 = Math.Max(num * 3, (int)font.MeasureString(text).Y + Game1.tileSize / 2 + (int)((moneyAmountToDisplayAtBottom <= -1) ? 0f : (font.MeasureString(moneyAmountToDisplayAtBottom + string.Empty).Y + 4f)) + (int)((boldTitleText == null) ? 0f : (Game1.dialogueFont.MeasureString(boldTitleText).Y + (float)(Game1.tileSize / 4))) + ((healAmountToDisplay == -1) ? 0 : 38)); if (extraItemToShowIndex != -1) { string[] array = Game1.objectInformation[extraItemToShowIndex].Split(new char[] { '/' }); string text2 = array[0]; if (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.en) { text2 = array[array.Length - 1]; } string text3 = Game1.content.LoadString("Strings\\UI:ItemHover_Requirements", new object[] { extraItemToShowAmount, text2 }); int num4 = Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, extraItemToShowIndex, 16, 16).Width * 2 * Game1.pixelZoom; num2 = Math.Max(num2, num4 + (int)font.MeasureString(text3).X); } if (buffIconsToDisplay != null) { for (int i = 0; i < buffIconsToDisplay.Length; i++) { string text4 = buffIconsToDisplay[i]; if (!text4.Equals("0")) { num3 += 34; } } num3 += 4; } string text5 = null; if (hoveredItem != null) { num3 += (Game1.tileSize + 4) * hoveredItem.attachmentSlots(); text5 = hoveredItem.getCategoryName(); if (text5.Length > 0) { num2 = Math.Max(num2, (int)font.MeasureString(text5).X + Game1.tileSize / 2); num3 += (int)font.MeasureString("T").Y; } int num5 = 9999; int num6 = 15 * Game1.pixelZoom + Game1.tileSize / 2; if (hoveredItem is MeleeWeapon) { MeleeWeapon meleeWeapon = hoveredItem as MeleeWeapon; num3 = Math.Max(num * 3, (int)((boldTitleText == null) ? 0f : (Game1.dialogueFont.MeasureString(boldTitleText).Y + (float)(Game1.tileSize / 4))) + Game1.tileSize / 2) + (int)font.MeasureString("T").Y + (int)((moneyAmountToDisplayAtBottom <= -1) ? 0f : (font.MeasureString(moneyAmountToDisplayAtBottom + string.Empty).Y + 4f)); num3 += ((!(hoveredItem.Name == "Scythe")) ? ((hoveredItem as MeleeWeapon).getNumberOfDescriptionCategories() * Game1.pixelZoom * 12) : 0); num3 += (int)font.MeasureString(Game1.parseText((hoveredItem as MeleeWeapon).description, Game1.smallFont, Game1.tileSize * 4 + Game1.tileSize / 4)).Y; num2 = (int)Math.Max((float)num2, Math.Max(font.MeasureString(Game1.content.LoadString("Strings\\UI:ItemHover_Damage", new object[] { num5, num5 })).X + (float)num6, Math.Max(font.MeasureString(Game1.content.LoadString("Strings\\UI:ItemHover_Speed", new object[] { num5 })).X + (float)num6, Math.Max(font.MeasureString(Game1.content.LoadString("Strings\\UI:ItemHover_DefenseBonus", new object[] { num5 })).X + (float)num6, Math.Max(font.MeasureString(Game1.content.LoadString("Strings\\UI:ItemHover_CritChanceBonus", new object[] { num5 })).X + (float)num6, Math.Max(font.MeasureString(Game1.content.LoadString("Strings\\UI:ItemHover_CritPowerBonus", new object[] { num5 })).X + (float)num6, font.MeasureString(Game1.content.LoadString("Strings\\UI:ItemHover_Weight", new object[] { num5 })).X + (float)num6)))))); } else if (hoveredItem is Boots) { num3 -= (int)font.MeasureString(text).Y; num3 += (int)((float)((hoveredItem as Boots).getNumberOfDescriptionCategories() * Game1.pixelZoom * 12) + font.MeasureString(Game1.parseText((hoveredItem as Boots).description, Game1.smallFont, Game1.tileSize * 4 + Game1.tileSize / 4)).Y); num2 = (int)Math.Max((float)num2, Math.Max(font.MeasureString(Game1.content.LoadString("Strings\\UI:ItemHover_DefenseBonus", new object[] { num5 })).X + (float)num6, font.MeasureString(Game1.content.LoadString("Strings\\UI:ItemHover_ImmunityBonus", new object[] { num5 })).X + (float)num6)); } else if (hoveredItem is StardewValley.Object && (hoveredItem as StardewValley.Object).edibility != -300) { if (healAmountToDisplay == -1) { num3 += (Game1.tileSize / 2 + Game1.pixelZoom * 2) * ((healAmountToDisplay <= 0) ? 1 : 2); } else { num3 += Game1.tileSize / 2 + Game1.pixelZoom * 2; } healAmountToDisplay = (int)Math.Ceiling((double)(hoveredItem as StardewValley.Object).Edibility * 2.5) + (hoveredItem as StardewValley.Object).quality * (hoveredItem as StardewValley.Object).Edibility; num2 = (int)Math.Max((float)num2, Math.Max(font.MeasureString(Game1.content.LoadString("Strings\\UI:ItemHover_Energy", new object[] { num5 })).X + (float)num6, font.MeasureString(Game1.content.LoadString("Strings\\UI:ItemHover_Health", new object[] { num5 })).X + (float)num6)); } if (buffIconsToDisplay != null) { for (int j = 0; j < buffIconsToDisplay.Length; j++) { if (!buffIconsToDisplay[j].Equals("0") && j <= 11) { num2 = (int)Math.Max((float)num2, font.MeasureString(Game1.content.LoadString("Strings\\UI:ItemHover_Buff" + j, new object[] { num5 })).X + (float)num6); } } } } if (craftingIngredients != null) { num2 = Math.Max((int)Game1.dialogueFont.MeasureString(boldTitleText).X + Game1.pixelZoom * 3, Game1.tileSize * 6); num3 += craftingIngredients.getDescriptionHeight(num2 - Game1.pixelZoom * 2) + ((healAmountToDisplay != -1) ? 0 : (-Game1.tileSize / 2)) + Game1.pixelZoom * 3; } if (hoveredItem is FishingRod && moneyAmountToDisplayAtBottom > -1) { num3 += (int)font.MeasureString("T").Y; } int num7 = Game1.getOldMouseX() + Game1.tileSize / 2 + xOffset; int num8 = Game1.getOldMouseY() + Game1.tileSize / 2 + yOffset; if (overrideX != -1) { num7 = overrideX; } if (overrideY != -1) { num8 = overrideY; } if (num7 + num2 > Utility.getSafeArea().Right) { num7 = Utility.getSafeArea().Right - num2; num8 += Game1.tileSize / 4; } if (num8 + num3 > Utility.getSafeArea().Bottom) { num7 += Game1.tileSize / 4; if (num7 + num2 > Utility.getSafeArea().Right) { num7 = Utility.getSafeArea().Right - num2; } num8 = Utility.getSafeArea().Bottom - num3; } IClickableMenu.drawTextureBox(b, Game1.menuTexture, new Rectangle(0, 256, 60, 60), num7, num8, num2 + ((craftingIngredients == null) ? 0 : (Game1.tileSize / 3)), num3, Color.White * alpha, 1f, false); if (boldTitleText != null) { IClickableMenu.drawTextureBox(b, Game1.menuTexture, new Rectangle(0, 256, 60, 60), num7, num8, num2 + ((craftingIngredients == null) ? 0 : (Game1.tileSize / 3)), (int)Game1.dialogueFont.MeasureString(boldTitleText).Y + Game1.tileSize / 2 + (int)((hoveredItem == null || text5.Length <= 0) ? 0f : font.MeasureString("asd").Y) - Game1.pixelZoom, Color.White * alpha, 1f, false); b.Draw(Game1.menuTexture, new Rectangle(num7 + Game1.pixelZoom * 3, num8 + (int)Game1.dialogueFont.MeasureString(boldTitleText).Y + Game1.tileSize / 2 + (int)((hoveredItem == null || text5.Length <= 0) ? 0f : font.MeasureString("asd").Y) - Game1.pixelZoom, num2 - Game1.pixelZoom * ((craftingIngredients != null) ? 1 : 6), Game1.pixelZoom), new Rectangle?(new Rectangle(44, 300, 4, 4)), Color.White); b.DrawString(Game1.dialogueFont, boldTitleText, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)) + new Vector2(2f, 2f), Game1.textShadowColor); b.DrawString(Game1.dialogueFont, boldTitleText, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)) + new Vector2(0f, 2f), Game1.textShadowColor); b.DrawString(Game1.dialogueFont, boldTitleText, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)), Game1.textColor); num8 += (int)Game1.dialogueFont.MeasureString(boldTitleText).Y; } if (hoveredItem != null && text5.Length > 0) { num8 -= 4; Utility.drawTextWithShadow(b, text5, font, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)), hoveredItem.getCategoryColor(), 1f, -1f, 2, 2, 1f, 3); num8 += (int)font.MeasureString("T").Y + ((boldTitleText == null) ? 0 : (Game1.tileSize / 4)) + Game1.pixelZoom; } else { num8 += ((boldTitleText == null) ? 0 : (Game1.tileSize / 4)); } if (hoveredItem != null && hoveredItem is Boots) { Boots boots = hoveredItem as Boots; Utility.drawTextWithShadow(b, Game1.parseText(boots.description, Game1.smallFont, Game1.tileSize * 4 + Game1.tileSize / 4), font, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3); num8 += (int)font.MeasureString(Game1.parseText(boots.description, Game1.smallFont, Game1.tileSize * 4 + Game1.tileSize / 4)).Y; if (boots.defenseBonus > 0) { Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4 + 4)), new Rectangle(110, 428, 10, 10), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, false, 1f, -1, -1, 0.35f); Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\UI:ItemHover_DefenseBonus", new object[] { boots.defenseBonus }), font, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom * 13), (float)(num8 + Game1.tileSize / 4 + Game1.pixelZoom * 3)), Game1.textColor * 0.9f * alpha, 1f, -1f, -1, -1, 1f, 3); num8 += (int)Math.Max(font.MeasureString("TT").Y, (float)(12 * Game1.pixelZoom)); } if (boots.immunityBonus > 0) { Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4 + 4)), new Rectangle(150, 428, 10, 10), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, false, 1f, -1, -1, 0.35f); Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\UI:ItemHover_ImmunityBonus", new object[] { boots.immunityBonus }), font, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom * 13), (float)(num8 + Game1.tileSize / 4 + Game1.pixelZoom * 3)), Game1.textColor * 0.9f * alpha, 1f, -1f, -1, -1, 1f, 3); num8 += (int)Math.Max(font.MeasureString("TT").Y, (float)(12 * Game1.pixelZoom)); } } else if (hoveredItem != null && hoveredItem is MeleeWeapon) { MeleeWeapon meleeWeapon2 = hoveredItem as MeleeWeapon; Utility.drawTextWithShadow(b, Game1.parseText(meleeWeapon2.description, Game1.smallFont, Game1.tileSize * 4 + Game1.tileSize / 4), font, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3); num8 += (int)font.MeasureString(Game1.parseText(meleeWeapon2.description, Game1.smallFont, Game1.tileSize * 4 + Game1.tileSize / 4)).Y; if (meleeWeapon2.indexOfMenuItemView != 47) { Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4 + 4)), new Rectangle(120, 428, 10, 10), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, false, 1f, -1, -1, 0.35f); Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\UI:ItemHover_Damage", new object[] { meleeWeapon2.minDamage, meleeWeapon2.maxDamage }), font, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom * 13), (float)(num8 + Game1.tileSize / 4 + Game1.pixelZoom * 3)), Game1.textColor * 0.9f * alpha, 1f, -1f, -1, -1, 1f, 3); num8 += (int)Math.Max(font.MeasureString("TT").Y, (float)(12 * Game1.pixelZoom)); if (meleeWeapon2.speed != ((meleeWeapon2.type != 2) ? 0 : -8)) { Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4 + 4)), new Rectangle(130, 428, 10, 10), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, false, 1f, -1, -1, 0.35f); bool flag = (meleeWeapon2.type == 2 && meleeWeapon2.speed < -8) || (meleeWeapon2.type != 2 && meleeWeapon2.speed < 0); Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\UI:ItemHover_Speed", new object[] { ((((meleeWeapon2.type != 2) ? meleeWeapon2.speed : (meleeWeapon2.speed - -8)) <= 0) ? string.Empty : "+") + ((meleeWeapon2.type != 2) ? meleeWeapon2.speed : (meleeWeapon2.speed - -8)) / 2 }), font, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom * 13), (float)(num8 + Game1.tileSize / 4 + Game1.pixelZoom * 3)), (!flag) ? (Game1.textColor * 0.9f * alpha) : Color.DarkRed, 1f, -1f, -1, -1, 1f, 3); num8 += (int)Math.Max(font.MeasureString("TT").Y, (float)(12 * Game1.pixelZoom)); } if (meleeWeapon2.addedDefense > 0) { Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4 + 4)), new Rectangle(110, 428, 10, 10), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, false, 1f, -1, -1, 0.35f); Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\UI:ItemHover_DefenseBonus", new object[] { meleeWeapon2.addedDefense }), font, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom * 13), (float)(num8 + Game1.tileSize / 4 + Game1.pixelZoom * 3)), Game1.textColor * 0.9f * alpha, 1f, -1f, -1, -1, 1f, 3); num8 += (int)Math.Max(font.MeasureString("TT").Y, (float)(12 * Game1.pixelZoom)); } if ((double)meleeWeapon2.critChance / 0.02 >= 2.0) { Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4 + 4)), new Rectangle(40, 428, 10, 10), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, false, 1f, -1, -1, 0.35f); Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\UI:ItemHover_CritChanceBonus", new object[] { (int)((double)meleeWeapon2.critChance / 0.02) }), font, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom * 13), (float)(num8 + Game1.tileSize / 4 + Game1.pixelZoom * 3)), Game1.textColor * 0.9f * alpha, 1f, -1f, -1, -1, 1f, 3); num8 += (int)Math.Max(font.MeasureString("TT").Y, (float)(12 * Game1.pixelZoom)); } if ((double)(meleeWeapon2.critMultiplier - 3f) / 0.02 >= 1.0) { Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)), new Rectangle(160, 428, 10, 10), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, false, 1f, -1, -1, 0.35f); Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\UI:ItemHover_CritPowerBonus", new object[] { (int)((double)(meleeWeapon2.critMultiplier - 3f) / 0.02) }), font, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom * 11), (float)(num8 + Game1.tileSize / 4 + Game1.pixelZoom * 3)), Game1.textColor * 0.9f * alpha, 1f, -1f, -1, -1, 1f, 3); num8 += (int)Math.Max(font.MeasureString("TT").Y, (float)(12 * Game1.pixelZoom)); } if (meleeWeapon2.knockback != meleeWeapon2.defaultKnockBackForThisType(meleeWeapon2.type)) { Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4 + 4)), new Rectangle(70, 428, 10, 10), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, false, 1f, -1, -1, 0.35f); Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\UI:ItemHover_Weight", new object[] { (((float)((int)Math.Ceiling((double)(Math.Abs(meleeWeapon2.knockback - meleeWeapon2.defaultKnockBackForThisType(meleeWeapon2.type)) * 10f))) <= meleeWeapon2.defaultKnockBackForThisType(meleeWeapon2.type)) ? string.Empty : "+") + (int)Math.Ceiling((double)(Math.Abs(meleeWeapon2.knockback - meleeWeapon2.defaultKnockBackForThisType(meleeWeapon2.type)) * 10f)) }), font, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom * 13), (float)(num8 + Game1.tileSize / 4 + Game1.pixelZoom * 3)), Game1.textColor * 0.9f * alpha, 1f, -1f, -1, -1, 1f, 3); num8 += (int)Math.Max(font.MeasureString("TT").Y, (float)(12 * Game1.pixelZoom)); } } } else if (!string.IsNullOrEmpty(text) && text != " ") { b.DrawString(font, text, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)) + new Vector2(2f, 2f), Game1.textShadowColor * alpha); b.DrawString(font, text, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)) + new Vector2(0f, 2f), Game1.textShadowColor * alpha); b.DrawString(font, text, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)) + new Vector2(2f, 0f), Game1.textShadowColor * alpha); b.DrawString(font, text, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)), Game1.textColor * 0.9f * alpha); num8 += (int)font.MeasureString(text).Y + 4; } if (craftingIngredients != null) { craftingIngredients.drawRecipeDescription(b, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 - Game1.pixelZoom * 2)), num2); num8 += craftingIngredients.getDescriptionHeight(num2); } if (healAmountToDisplay != -1) { if (healAmountToDisplay > 0) { Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4)), new Rectangle((healAmountToDisplay >= 0) ? 0 : 140, 428, 10, 10), Color.White, 0f, Vector2.Zero, 3f, false, 0.95f, -1, -1, 0.35f); Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\UI:ItemHover_Energy", new object[] { ((healAmountToDisplay <= 0) ? string.Empty : "+") + healAmountToDisplay }), font, new Vector2((float)(num7 + Game1.tileSize / 4 + 34 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4 + 8)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3); num8 += 34; Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4)), new Rectangle(0, 438, 10, 10), Color.White, 0f, Vector2.Zero, 3f, false, 0.95f, -1, -1, 0.35f); Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\UI:ItemHover_Health", new object[] { ((healAmountToDisplay <= 0) ? string.Empty : "+") + (int)((float)healAmountToDisplay * 0.4f) }), font, new Vector2((float)(num7 + Game1.tileSize / 4 + 34 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4 + 8)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3); num8 += 34; } else if (healAmountToDisplay != -300) { Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4)), new Rectangle(140, 428, 10, 10), Color.White, 0f, Vector2.Zero, 3f, false, 0.95f, -1, -1, 0.35f); Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\UI:ItemHover_Energy", new object[] { string.Empty + healAmountToDisplay }), font, new Vector2((float)(num7 + Game1.tileSize / 4 + 34 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4 + 8)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3); num8 += 34; } } if (buffIconsToDisplay != null) { for (int k = 0; k < buffIconsToDisplay.Length; k++) { if (!buffIconsToDisplay[k].Equals("0")) { Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 4 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4)), new Rectangle(10 + k * 10, 428, 10, 10), Color.White, 0f, Vector2.Zero, 3f, false, 0.95f, -1, -1, 0.35f); string text6 = ((Convert.ToInt32(buffIconsToDisplay[k]) <= 0) ? string.Empty : "+") + buffIconsToDisplay[k] + " "; if (k <= 11) { text6 = Game1.content.LoadString("Strings\\UI:ItemHover_Buff" + k, new object[] { text6 }); } Utility.drawTextWithShadow(b, text6, font, new Vector2((float)(num7 + Game1.tileSize / 4 + 34 + Game1.pixelZoom), (float)(num8 + Game1.tileSize / 4 + 8)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3); num8 += 34; } } } if (hoveredItem != null && hoveredItem.attachmentSlots() > 0) { num8 += 16; hoveredItem.drawAttachments(b, num7 + Game1.tileSize / 4, num8); if (moneyAmountToDisplayAtBottom > -1) { num8 += Game1.tileSize * hoveredItem.attachmentSlots(); } } if (moneyAmountToDisplayAtBottom > -1) { b.DrawString(font, moneyAmountToDisplayAtBottom + string.Empty, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)) + new Vector2(2f, 2f), Game1.textShadowColor); b.DrawString(font, moneyAmountToDisplayAtBottom + string.Empty, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)) + new Vector2(0f, 2f), Game1.textShadowColor); b.DrawString(font, moneyAmountToDisplayAtBottom + string.Empty, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)) + new Vector2(2f, 0f), Game1.textShadowColor); b.DrawString(font, moneyAmountToDisplayAtBottom + string.Empty, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.tileSize / 4 + 4)), Game1.textColor); if (currencySymbol == 0) { b.Draw(Game1.debrisSpriteSheet, new Vector2((float)(num7 + Game1.tileSize / 4) + font.MeasureString(moneyAmountToDisplayAtBottom + string.Empty).X + 20f, (float)(num8 + Game1.tileSize / 4 + 16)), new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.debrisSpriteSheet, 8, 16, 16)), Color.White, 0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, 0.95f); } else if (currencySymbol == 1) { b.Draw(Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 8) + font.MeasureString(moneyAmountToDisplayAtBottom + string.Empty).X + 20f, (float)(num8 + Game1.tileSize / 4 - 5)), new Rectangle?(new Rectangle(338, 400, 8, 8)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f); } else if (currencySymbol == 2) { b.Draw(Game1.mouseCursors, new Vector2((float)(num7 + Game1.tileSize / 8) + font.MeasureString(moneyAmountToDisplayAtBottom + string.Empty).X + 20f, (float)(num8 + Game1.tileSize / 4 - 7)), new Rectangle?(new Rectangle(211, 373, 9, 10)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f); } num8 += Game1.tileSize * 3 / 4; } if (extraItemToShowIndex != -1) { IClickableMenu.drawTextureBox(b, Game1.menuTexture, new Rectangle(0, 256, 60, 60), num7, num8 + Game1.pixelZoom, num2, Game1.tileSize * 3 / 2, Color.White, 1f, true); num8 += Game1.pixelZoom * 5; string[] array2 = Game1.objectInformation[extraItemToShowIndex].Split(new char[] { '/' }); string text7 = array2[4]; string text8 = Game1.content.LoadString("Strings\\UI:ItemHover_Requirements", new object[] { extraItemToShowAmount, text7 }); b.DrawString(font, text8, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.pixelZoom)) + new Vector2(2f, 2f), Game1.textShadowColor); b.DrawString(font, text8, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.pixelZoom)) + new Vector2(0f, 2f), Game1.textShadowColor); b.DrawString(font, text8, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.pixelZoom)) + new Vector2(2f, 0f), Game1.textShadowColor); b.DrawString(Game1.smallFont, text8, new Vector2((float)(num7 + Game1.tileSize / 4), (float)(num8 + Game1.pixelZoom)), Game1.textColor); b.Draw(Game1.objectSpriteSheet, new Vector2((float)(num7 + Game1.tileSize / 4 + (int)font.MeasureString(text8).X + Game1.tileSize / 3), (float)num8), new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, extraItemToShowIndex, 16, 16)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f); } }
public static void MeleeWeapon_Postfix(MeleeWeapon __instance) { //context.Monitor.Log($"0 created melee weapon {__instance.Name} {__instance.InitialParentTileIndex} {__instance.ParentSheetIndex} {Environment.StackTrace}"); ModEntry.AddEnchantments(__instance); }
public static bool draw_Prefix(ref Furniture __instance, NetInt ___sourceIndexOffset, NetVector2 ___drawPosition, SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { if (__instance.isTemporarilyInvisible) { return(false); } Rectangle drawn_source_rect = __instance.sourceRect.Value; drawn_source_rect.X += drawn_source_rect.Width * ___sourceIndexOffset.Value; if (Furniture.isDrawingLocationFurniture) { if (__instance.HasSittingFarmers() && __instance.sourceRect.Right <= Furniture.furnitureFrontTexture.Width && __instance.sourceRect.Bottom <= Furniture.furnitureFrontTexture.Height) { spriteBatch.Draw(Furniture.furnitureTexture, Game1.GlobalToLocal(Game1.viewport, ___drawPosition + ((__instance.shakeTimer > 0) ? new Vector2(Game1.random.Next(-1, 2), Game1.random.Next(-1, 2)) : Vector2.Zero)), drawn_source_rect, Color.White * alpha, 0f, Vector2.Zero, 4f, __instance.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (float)(__instance.boundingBox.Value.Top + 16) / 10000f); spriteBatch.Draw(Furniture.furnitureFrontTexture, Game1.GlobalToLocal(Game1.viewport, ___drawPosition + ((__instance.shakeTimer > 0) ? new Vector2(Game1.random.Next(-1, 2), Game1.random.Next(-1, 2)) : Vector2.Zero)), drawn_source_rect, Color.White * alpha, 0f, Vector2.Zero, 4f, __instance.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (float)(__instance.boundingBox.Value.Bottom - 8) / 10000f); } else { spriteBatch.Draw(Furniture.furnitureTexture, Game1.GlobalToLocal(Game1.viewport, ___drawPosition + ((__instance.shakeTimer > 0) ? new Vector2(Game1.random.Next(-1, 2), Game1.random.Next(-1, 2)) : Vector2.Zero)), drawn_source_rect, Color.White * alpha, 0f, Vector2.Zero, 4f, __instance.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, ((int)__instance.furniture_type == 12) ? (2E-09f + __instance.tileLocation.Y / 100000f) : ((float)(__instance.boundingBox.Value.Bottom - (((int)__instance.furniture_type == 6 || (int)__instance.furniture_type == 17 || (int)__instance.furniture_type == 13) ? 48 : 8)) / 10000f)); } } else { spriteBatch.Draw(Furniture.furnitureTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0), y * 64 - (__instance.sourceRect.Height * 4 - __instance.boundingBox.Height) + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0))), __instance.sourceRect, Color.White * alpha, 0f, Vector2.Zero, 4f, __instance.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, ((int)__instance.furniture_type == 12) ? (2E-09f + __instance.tileLocation.Y / 100000f) : ((float)(__instance.boundingBox.Value.Bottom - (((int)__instance.furniture_type == 6 || (int)__instance.furniture_type == 17 || (int)__instance.furniture_type == 13) ? 48 : 8)) / 10000f)); } if (__instance.heldObject.Value != null) { if (__instance.heldObject.Value is Furniture) { (__instance.heldObject.Value as Furniture).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2(__instance.boundingBox.Center.X - 32, __instance.boundingBox.Center.Y - (__instance.heldObject.Value as Furniture).sourceRect.Height * 4 - (__instance.drawHeldObjectLow ? (-16) : 16))), (float)(__instance.boundingBox.Bottom - 7) / 10000f, alpha); } else { spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2(__instance.boundingBox.Center.X - 32, __instance.boundingBox.Center.Y - (__instance.drawHeldObjectLow ? 32 : 85))) + new Vector2(32f, 53f), Game1.shadowTexture.Bounds, Color.White * alpha, 0f, new Vector2(Game1.shadowTexture.Bounds.Center.X, Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)__instance.boundingBox.Bottom / 10000f); // Add support for rendering weapons on tables. if (__instance.heldObject.Value is WeaponProxy weapon) { spriteBatch.Draw(Tool.weaponsTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2(__instance.boundingBox.Center.X - 32, __instance.boundingBox.Center.Y - (__instance.drawHeldObjectLow ? 32 : 85))), MeleeWeapon.getSourceRect(weapon.Weapon.IndexOfMenuItemView), Color.White * alpha, 0f, Vector2.Zero, 4f, SpriteEffects.None, (float)(__instance.boundingBox.Bottom + 1) / 10000f); } else if (__instance.heldObject.Value is SlingshotProxy slingshot) { spriteBatch.Draw(Tool.weaponsTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2(__instance.boundingBox.Center.X - 32, __instance.boundingBox.Center.Y - (__instance.drawHeldObjectLow ? 32 : 85))), MeleeWeapon.getSourceRect(slingshot.Weapon.IndexOfMenuItemView), Color.White * alpha, 0f, Vector2.Zero, 4f, SpriteEffects.None, (float)(__instance.boundingBox.Bottom + 1) / 10000f); } else { spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2(__instance.boundingBox.Center.X - 32, __instance.boundingBox.Center.Y - (__instance.drawHeldObjectLow ? 32 : 85))), GameLocation.getSourceRectForObject(__instance.heldObject.Value.ParentSheetIndex), Color.White * alpha, 0f, Vector2.Zero, 4f, SpriteEffects.None, (float)(__instance.boundingBox.Bottom + 1) / 10000f); } } } if ((bool)__instance.isOn && (int)__instance.furniture_type == 14) { spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(__instance.boundingBox.Center.X - 12, __instance.boundingBox.Center.Y - 64)), new Rectangle(276 + (int)((Game1.currentGameTime.TotalGameTime.TotalMilliseconds + (double)(x * 3047) + (double)(y * 88)) % 400.0 / 100.0) * 12, 1985, 12, 11), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, (float)(__instance.getBoundingBox(new Vector2(x, y)).Bottom - 2) / 10000f); spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(__instance.boundingBox.Center.X - 32 - 4, __instance.boundingBox.Center.Y - 64)), new Rectangle(276 + (int)((Game1.currentGameTime.TotalGameTime.TotalMilliseconds + (double)(x * 2047) + (double)(y * 98)) % 400.0 / 100.0) * 12, 1985, 12, 11), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, (float)(__instance.getBoundingBox(new Vector2(x, y)).Bottom - 1) / 10000f); } else if ((bool)__instance.isOn && (int)__instance.furniture_type == 16) { spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(__instance.boundingBox.Center.X - 20, (float)__instance.boundingBox.Center.Y - 105.6f)), new Rectangle(276 + (int)((Game1.currentGameTime.TotalGameTime.TotalMilliseconds + (double)(x * 3047) + (double)(y * 88)) % 400.0 / 100.0) * 12, 1985, 12, 11), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, (float)(__instance.getBoundingBox(new Vector2(x, y)).Bottom - 2) / 10000f); } if (Game1.debugMode) { spriteBatch.DrawString(Game1.smallFont, string.Concat((object)__instance.parentSheetIndex), Game1.GlobalToLocal(Game1.viewport, ___drawPosition), Color.Yellow, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); } return(false); }
private void Start() { w = GetComponentInParent <MeleeWeapon>(); }
private void Display_RenderedWorld(object sender, RenderedWorldEventArgs e) { if (this.weapon != null && this.weaponSwingCooldown > this.SwingThreshold) { int frames = this.weapon.type.Value == 3 ? 4 : 7; int duration = this.CooldownTimeout - this.SwingThreshold; int tick = Math.Abs(this.weaponSwingCooldown - this.CooldownTimeout); int currentFrame = this.CurrentFrame(tick, duration, frames); Helper.DrawDuringUse(currentFrame, this.follower.FacingDirection, e.SpriteBatch, this.follower.getLocalPosition(Game1.viewport), this.follower, MeleeWeapon.getSourceRect(this.weapon.InitialParentTileIndex), this.weapon.type.Value, this.weapon.isOnSpecial); } }
/// <summary> /// An ItemAbility has been activated or deactivated. /// </summary> /// <param name="itemAbility">The ItemAbility activated or deactivated.</param> /// <param name="active">Was the ItemAbility activated?</param> private void OnItemAbilityActive(ItemAbility itemAbility, bool active) { if (!active || IsActive) { return; } // If another use ability is started or a use is active then the character shouldn't be able to counter attack. if (!(itemAbility is Block) || m_CharacterLocomotion.IsAbilityTypeActive <Use>()) { m_ImpactTime = -1; return; } // The block ability has been activated. The source of the block must be a melee weapon - counter attack doesn't work against non-melee weapons. var blockAbility = itemAbility as Block; m_OpponentMeleeWeapon = null; for (int i = 0; i < blockAbility.ImpactSources.Length; ++i) { if (blockAbility.ImpactSources[i] == null || !(blockAbility.ImpactSources[i] is MeleeWeapon)) { continue; } m_OpponentMeleeWeapon = blockAbility.ImpactSources[i] as MeleeWeapon; break; } if (m_OpponentMeleeWeapon == null) { return; } // The opponent must actively be attacking. m_OpponentLocomotion = m_OpponentMeleeWeapon.CharacterLocomotion; m_OpponentUseAbility = null; var useAbilities = m_OpponentLocomotion.GetAbilities <Use>(); if (useAbilities == null || useAbilities.Length == 0) { m_ImpactTime = -1; return; } for (int i = 0; i < useAbilities.Length; ++i) { if (!useAbilities[i].IsActive) { continue; } // The ability is active. Ensure it is using a melee weapon. for (int j = 0; j < useAbilities[i].UsableItems.Length; ++j) { var meleeWeapon = useAbilities[i].UsableItems[j] as MeleeWeapon; if (meleeWeapon != m_OpponentMeleeWeapon) { continue; } m_OpponentUseAbility = useAbilities[i]; break; } if (m_OpponentUseAbility != null) { break; } } if (m_OpponentUseAbility == null) { m_ImpactTime = -1; return; } m_ImpactTime = Time.time; }
private static void LoadItems() { ItemMenu.ItemsLoaded = true; ItemMenu.ItemList = new List <Item> { ToolFactory.getToolFromDescription(0, 0), ToolFactory.getToolFromDescription(0, 1), ToolFactory.getToolFromDescription(0, 2), ToolFactory.getToolFromDescription(0, 3), ToolFactory.getToolFromDescription(0, 4), ToolFactory.getToolFromDescription(1, 0), ToolFactory.getToolFromDescription(1, 1), ToolFactory.getToolFromDescription(1, 2), ToolFactory.getToolFromDescription(1, 3), ToolFactory.getToolFromDescription(1, 4), ToolFactory.getToolFromDescription(2, 0), ToolFactory.getToolFromDescription(2, 1), ToolFactory.getToolFromDescription(2, 2), ToolFactory.getToolFromDescription(2, 3), ToolFactory.getToolFromDescription(3, 0), ToolFactory.getToolFromDescription(3, 1), ToolFactory.getToolFromDescription(3, 2), ToolFactory.getToolFromDescription(3, 3), ToolFactory.getToolFromDescription(3, 4), ToolFactory.getToolFromDescription(4, 0), ToolFactory.getToolFromDescription(4, 1), ToolFactory.getToolFromDescription(4, 2), ToolFactory.getToolFromDescription(4, 3), ToolFactory.getToolFromDescription(4, 4), new MilkPail(), new Shears(), new Pan() }; foreach (KeyValuePair <string, string> o in CraftingRecipe.craftingRecipes) { CraftingRecipe rec = new CraftingRecipe(o.Key, false); Item item = rec.createItem(); if (item != null) { ItemMenu.ItemList.Add(item); } } for (int i = 0; i < 112; i++) { ItemMenu.ItemList.Add(new Wallpaper(i) { category = -24 }); } for (int i = 0; i < 40; i++) { ItemMenu.ItemList.Add(new Wallpaper(i, true) { category = -24 }); } foreach (KeyValuePair <int, string> o in Game1.content.Load <Dictionary <int, string> >("Data\\Boots")) { Item item = new Boots(o.Key); ItemMenu.ItemList.Add(item); } foreach (KeyValuePair <int, string> o in Game1.content.Load <Dictionary <int, string> >("Data\\hats")) { Item item = new Hat(o.Key); ItemMenu.ItemList.Add(item); } foreach (KeyValuePair <int, string> o in Game1.content.Load <Dictionary <int, string> >("Data\\Furniture")) { Item item = new Furniture(o.Key, Vector2.Zero); if (o.Key == 1466 || o.Key == 1468) { item = new TV(o.Key, Vector2.Zero); } ItemMenu.ItemList.Add(item); } foreach (KeyValuePair <int, string> o in Game1.content.Load <Dictionary <int, string> >("Data\\weapons")) { Item item = new MeleeWeapon(o.Key); if (o.Key >= 32 && o.Key <= 34) { item = new Slingshot(o.Key); } ItemMenu.ItemList.Add(item); } foreach (KeyValuePair <int, string> o in Game1.content.Load <Dictionary <int, string> >("Data\\Fish")) { Item item = new SObject(o.Key, 999); item.category = -4; ItemMenu.ItemList.Add(item); } foreach (KeyValuePair <int, string> o in Game1.bigCraftablesInformation) { if (ItemMenu.HasItem(o.Key, o.Value.Split('/')[0])) { continue; } ItemMenu.ItemList.Add(new SObject(Vector2.Zero, o.Key)); } foreach (KeyValuePair <int, string> o in Game1.objectInformation) { if (ItemMenu.HasItem(o.Key, o.Value.Split('/')[0])) { continue; } string[] info = o.Value.Split('/'); if (info.Length >= 3) { if (info[3].StartsWith("Ring")) { ItemMenu.ItemList.Add(new Ring(o.Key)); continue; } SObject item = new SObject(o.Key, 1); ItemMenu.ItemList.Add(item); if (item.category == -79) { ItemMenu.ItemList.Add(new SObject(Vector2.Zero, 348, item.Name + " Wine", false, true, false, false) { name = item.Name + " Wine", price = item.price * 3 }); } if (item.category == -75) { ItemMenu.ItemList.Add(new SObject(Vector2.Zero, 350, item.Name + " Juice", false, true, false, false) { name = item.Name + " Juice", price = (int)(item.price * 2.25d) }); } if (item.category == -79) { ItemMenu.ItemList.Add(new SObject(Vector2.Zero, 344, item.Name + " Jelly", false, true, false, false) { name = item.Name + " Jelly", price = 50 + item.Price * 2 }); } if (item.category == -75) { ItemMenu.ItemList.Add(new SObject(Vector2.Zero, 342, "Pickled " + item.Name, false, true, false, false) { name = "Pickled " + item.Name, price = 50 + item.Price * 2 }); } } } }
public OiledMeleeWeapon(MeleeWeapon meleeWeapon) : base("Oiled " + meleeWeapon.GetType(), meleeWeapon.GetDamage() + 3, meleeWeapon) { }
private static Vector2 DrawHoverText(SpriteBatch batch, string text, SpriteFont font, int xOffset = 0, int yOffset = 0, int moneyAmountToDisplayAtBottom = -1, string boldTitleText = null, int healAmountToDisplay = -1, string[] buffIconsToDisplay = null, Item hoveredItem = null) { Vector2 result = Vector2.Zero; if (string.IsNullOrEmpty(text)) { result = Vector2.Zero; } else { if (string.IsNullOrEmpty(boldTitleText)) { boldTitleText = null; } int num1 = 20; int infoWindowWidth = (int)Math.Max(healAmountToDisplay != -1 ? font.MeasureString(healAmountToDisplay.ToString() + "+ Energy" + (Game1.tileSize / 2)).X : 0, Math.Max(font.MeasureString(text).X, boldTitleText != null ? Game1.dialogueFont.MeasureString(boldTitleText).X : 0)) + Game1.tileSize / 2; int extraInfoBackgroundHeight = (int)Math.Max( num1 * 3, font.MeasureString(text).Y + Game1.tileSize / 2 + (moneyAmountToDisplayAtBottom > -1 ? (font.MeasureString(string.Concat(moneyAmountToDisplayAtBottom)).Y + 4.0) : 0) + (boldTitleText != null ? Game1.dialogueFont.MeasureString(boldTitleText).Y + (Game1.tileSize / 4) : 0) + (healAmountToDisplay != -1 ? 38 : 0)); if (buffIconsToDisplay != null) { for (int i = 0; i < buffIconsToDisplay.Length; ++i) { if (!buffIconsToDisplay[i].Equals("0")) { extraInfoBackgroundHeight += 34; } } extraInfoBackgroundHeight += 4; } string categoryName = null; if (hoveredItem != null) { extraInfoBackgroundHeight += (Game1.tileSize + 4) * hoveredItem.attachmentSlots(); categoryName = hoveredItem.getCategoryName(); if (categoryName.Length > 0) { extraInfoBackgroundHeight += (int)font.MeasureString("T").Y; } if (hoveredItem is MeleeWeapon) { extraInfoBackgroundHeight = (int)(Math.Max( num1 * 3, (boldTitleText != null ? Game1.dialogueFont.MeasureString(boldTitleText).Y + (Game1.tileSize / 4) : 0) + Game1.tileSize / 2) + font.MeasureString("T").Y + (moneyAmountToDisplayAtBottom > -1 ? font.MeasureString(string.Concat(moneyAmountToDisplayAtBottom)).Y + 4.0 : 0) + (hoveredItem as MeleeWeapon).getNumberOfDescriptionCategories() * Game1.pixelZoom * 12 + font.MeasureString(Game1.parseText((hoveredItem as MeleeWeapon).Description, Game1.smallFont, Game1.tileSize * 4 + Game1.tileSize / 4)).Y); infoWindowWidth = (int)Math.Max(infoWindowWidth, font.MeasureString("99-99 Damage").X + (15 * Game1.pixelZoom) + (Game1.tileSize / 2)); } else if (hoveredItem is Boots) { Boots hoveredBoots = hoveredItem as Boots; extraInfoBackgroundHeight = extraInfoBackgroundHeight - (int)font.MeasureString(text).Y + (int)(hoveredBoots.getNumberOfDescriptionCategories() * Game1.pixelZoom * 12 + font.MeasureString(Game1.parseText(hoveredBoots.description, Game1.smallFont, Game1.tileSize * 4 + Game1.tileSize / 4)).Y); infoWindowWidth = (int)Math.Max(infoWindowWidth, font.MeasureString("99-99 Damage").X + (15 * Game1.pixelZoom) + (Game1.tileSize / 2)); } else if (hoveredItem is StardewValley.Object && (hoveredItem as StardewValley.Object).Edibility != -300) { StardewValley.Object hoveredObject = hoveredItem as StardewValley.Object; healAmountToDisplay = (int)Math.Ceiling(hoveredObject.Edibility * 2.5) + hoveredObject.Quality * hoveredObject.Edibility; extraInfoBackgroundHeight += (Game1.tileSize / 2 + Game1.pixelZoom * 2) * (healAmountToDisplay > 0 ? 2 : 1); } } //Crafting ingredients were never used int xPos = Game1.getOldMouseX() + Game1.tileSize / 2 + xOffset; int yPos = Game1.getOldMouseY() + Game1.tileSize / 2 + yOffset; if (xPos + infoWindowWidth > Game1.viewport.Width) { xPos = Game1.viewport.Width - infoWindowWidth; yPos += Game1.tileSize / 4; } if (yPos + extraInfoBackgroundHeight > Game1.viewport.Height) { xPos += Game1.tileSize / 4; yPos = Game1.viewport.Height - extraInfoBackgroundHeight; } int hoveredItemHeight = (int)(hoveredItem == null || categoryName.Length <= 0 ? 0 : font.MeasureString("asd").Y); IClickableMenu.drawTextureBox( batch, Game1.menuTexture, new Rectangle(0, 256, 60, 60), xPos, yPos, infoWindowWidth, extraInfoBackgroundHeight, Color.White); if (boldTitleText != null) { IClickableMenu.drawTextureBox( batch, Game1.menuTexture, new Rectangle(0, 256, 60, 60), xPos, yPos, infoWindowWidth, (int)(Game1.dialogueFont.MeasureString(boldTitleText).Y + Game1.tileSize / 2 + hoveredItemHeight - Game1.pixelZoom), Color.White, 1, false); batch.Draw( Game1.menuTexture, new Rectangle(xPos + Game1.pixelZoom * 3, yPos + (int)Game1.dialogueFont.MeasureString(boldTitleText).Y + Game1.tileSize / 2 + hoveredItemHeight - Game1.pixelZoom, infoWindowWidth - Game1.pixelZoom * 6, Game1.pixelZoom), new Rectangle(44, 300, 4, 4), Color.White); batch.DrawString( Game1.dialogueFont, boldTitleText, new Vector2(xPos + Game1.tileSize / 4, yPos + Game1.tileSize / 4 + 4) + new Vector2(2, 2), Game1.textShadowColor); batch.DrawString( Game1.dialogueFont, boldTitleText, new Vector2(xPos + Game1.tileSize / 4, yPos + Game1.tileSize / 4 + 4) + new Vector2(0, 2), Game1.textShadowColor); batch.DrawString( Game1.dialogueFont, boldTitleText, new Vector2(xPos + Game1.tileSize / 4, yPos + Game1.tileSize / 4 + 4), Game1.textColor); yPos += (int)Game1.dialogueFont.MeasureString(boldTitleText).Y; } int yPositionToReturn = yPos; if (hoveredItem != null && categoryName.Length > 0) { yPos -= 4; Utility.drawTextWithShadow( batch, categoryName, font, new Vector2(xPos + Game1.tileSize / 4, yPos + Game1.tileSize / 4 + 4), hoveredItem.getCategoryColor(), 1, -1, 2, 2); yPos += (int)(font.MeasureString("T").Y + (boldTitleText != null ? Game1.tileSize / 4 : 0) + Game1.pixelZoom); } else { yPos += (boldTitleText != null ? Game1.tileSize / 4 : 0); } if (hoveredItem is Boots) { Boots boots = hoveredItem as Boots; Utility.drawTextWithShadow( batch, Game1.parseText( boots.description, Game1.smallFont, Game1.tileSize * 4 + Game1.tileSize / 4), font, new Vector2(xPos + Game1.tileSize / 4, yPos + Game1.tileSize / 4 + 4), Game1.textColor); yPos += (int)font.MeasureString( Game1.parseText( boots.description, Game1.smallFont, Game1.tileSize * 4 + Game1.tileSize / 4)).Y; if (boots.defenseBonus.Value > 0) { Utility.drawWithShadow( batch, Game1.mouseCursors, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom, yPos + Game1.tileSize / 4 + 4), new Rectangle(110, 428, 10, 10), Color.White, 0, Vector2.Zero, Game1.pixelZoom); Utility.drawTextWithShadow( batch, Game1.content.LoadString("Strings\\UI:ItemHover_DefenseBonus", new object[] { boots.defenseBonus.Value }), font, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom * 13, yPos + Game1.tileSize / 4 + Game1.pixelZoom * 3), Game1.textColor * 0.9f); yPos += (int)Math.Max(font.MeasureString("TT").Y, 12 * Game1.pixelZoom); } if (boots.immunityBonus.Value > 0) { Utility.drawWithShadow( batch, Game1.mouseCursors, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom, yPos + Game1.tileSize / 4 + 4), new Rectangle(150, 428, 10, 10), Color.White, 0, Vector2.Zero, Game1.pixelZoom); Utility.drawTextWithShadow( batch, Game1.content.LoadString("Strings\\UI:ItemHover_ImmunityBonus", new object[] { boots.immunityBonus.Value }), font, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom * 13, yPos + Game1.tileSize / 4 + Game1.pixelZoom * 3), Game1.textColor * 0.9f); yPos += (int)Math.Max(font.MeasureString("TT").Y, 12 * Game1.pixelZoom); } } else if (hoveredItem is MeleeWeapon) { MeleeWeapon meleeWeapon = hoveredItem as MeleeWeapon; Utility.drawTextWithShadow( batch, Game1.parseText(meleeWeapon.Description, Game1.smallFont, Game1.tileSize * 4 + Game1.tileSize / 4), font, new Vector2(xPos + Game1.tileSize / 4, yPos + Game1.tileSize / 4 + 4), Game1.textColor); yPos += (int)font.MeasureString(Game1.parseText(meleeWeapon.Description, Game1.smallFont, Game1.tileSize * 4 + Game1.tileSize / 4)).Y; if ((meleeWeapon as Tool).IndexOfMenuItemView != 47) { Utility.drawWithShadow( batch, Game1.mouseCursors, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom, yPos + Game1.tileSize / 4 + 4), new Rectangle(120, 428, 10, 10), Color.White, 0, Vector2.Zero, Game1.pixelZoom); Utility.drawTextWithShadow( batch, Game1.content.LoadString("Strings\\UI:ItemHover_Damage", new object[] { meleeWeapon.minDamage.Value, meleeWeapon.maxDamage.Value }), font, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom * 13, yPos + Game1.tileSize / 4 + Game1.pixelZoom * 3), Game1.textColor * 0.9f); yPos += (int)Math.Max(font.MeasureString("TT").Y, 12 * Game1.pixelZoom); if (meleeWeapon.speed.Value != (meleeWeapon.type.Value == 2 ? -8 : 0)) { Utility.drawWithShadow( batch, Game1.mouseCursors, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom, yPos + Game1.tileSize / 4 + 4), new Rectangle(130, 428, 10, 10), Color.White, 0, Vector2.Zero, Game1.pixelZoom, false, 1); bool flag = meleeWeapon.type.Value == 2 ? meleeWeapon.speed.Value < -8 : meleeWeapon.speed.Value < 0; string speedText = ((meleeWeapon.type.Value == 2 ? meleeWeapon.speed.Value + 8 : meleeWeapon.speed.Value) / 2).ToString(); Utility.drawTextWithShadow( batch, Game1.content.LoadString("Strings\\UI:ItemHover_Speed", new object[] { (meleeWeapon.speed.Value > 0 ? "+" : "") + speedText }), font, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom * 13, yPos + Game1.tileSize / 4 + Game1.pixelZoom * 3), flag ? Color.DarkRed : Game1.textColor * 0.9f); yPos += (int)Math.Max(font.MeasureString("TT").Y, 12 * Game1.pixelZoom); } if (meleeWeapon.addedDefense.Value > 0) { Utility.drawWithShadow( batch, Game1.mouseCursors, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom, yPos + Game1.tileSize / 4 + 4), new Rectangle(110, 428, 10, 10), Color.White, 0.0f, Vector2.Zero, Game1.pixelZoom, false, 1f); Utility.drawTextWithShadow( batch, Game1.content.LoadString("Strings\\UI:ItemHover_DefenseBonus", new object[] { meleeWeapon.addedDefense.Value }), font, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom * 13, yPos + Game1.tileSize / 4 + Game1.pixelZoom * 3), Game1.textColor * 0.9f); yPos += (int)Math.Max(font.MeasureString("TT").Y, 12 * Game1.pixelZoom); } if (meleeWeapon.critChance.Value / 0.02 >= 2.0) { Utility.drawWithShadow( batch, Game1.mouseCursors, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom, yPos + Game1.tileSize / 4 + 4), new Rectangle(40, 428, 10, 10), Color.White, 0.0f, Vector2.Zero, Game1.pixelZoom, false, 1f); Utility.drawTextWithShadow( batch, Game1.content.LoadString("Strings\\UI:ItemHover_CritChanceBonus", new object[] { meleeWeapon.critChance.Value / 0.02 }), font, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom * 13, yPos + Game1.tileSize / 4 + Game1.pixelZoom * 3), Game1.textColor * 0.9f); yPos += (int)Math.Max(font.MeasureString("TT").Y, 12 * Game1.pixelZoom); } if (((double)meleeWeapon.critMultiplier.Value - 3.0) / 0.02 >= 1.0) { Utility.drawWithShadow( batch, Game1.mouseCursors, new Vector2(xPos + Game1.tileSize / 4, yPos + Game1.tileSize / 4 + 4), new Rectangle(160, 428, 10, 10), Color.White, 0.0f, Vector2.Zero, Game1.pixelZoom, false, 1f); Utility.drawTextWithShadow( batch, Game1.content.LoadString("Strings\\UI:ItemHover_CritPowerBonus", new object[] { (int)((meleeWeapon.critMultiplier.Value - 3.0) / 0.02) }), font, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom * 11, yPos + Game1.tileSize / 4 + Game1.pixelZoom * 3), Game1.textColor * 0.9f); yPos += (int)Math.Max(font.MeasureString("TT").Y, 12 * Game1.pixelZoom); } if (meleeWeapon.knockback.Value != meleeWeapon.defaultKnockBackForThisType(meleeWeapon.type.Value)) { Utility.drawWithShadow( batch, Game1.mouseCursors, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom, yPos + Game1.tileSize / 4 + 4), new Rectangle(70, 428, 10, 10), Color.White, 0.0f, Vector2.Zero, Game1.pixelZoom, false, 1f); Utility.drawTextWithShadow( batch, Game1.content.LoadString( "Strings\\UI:ItemHover_Weight", new object[] { meleeWeapon.knockback.Value > meleeWeapon.defaultKnockBackForThisType(meleeWeapon.type.Value) ? "+" : "" + Math.Ceiling(Math.Abs(meleeWeapon.knockback.Value - meleeWeapon.defaultKnockBackForThisType(meleeWeapon.type.Value) * 10.0)) }), font, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom * 13, yPos + Game1.tileSize / 4 + Game1.pixelZoom * 3), Game1.textColor * 0.9f); yPos += (int)Math.Max(font.MeasureString("TT").Y, 12 * Game1.pixelZoom); } } } else if (text.Length > 1) { int textXPos = xPos + Game1.tileSize / 4; int textYPos = yPos + Game1.tileSize / 4 + 4; batch.DrawString( font, text, new Vector2(textXPos, textYPos) + new Vector2(2, 2), Game1.textShadowColor); batch.DrawString( font, text, new Vector2(textXPos, textYPos) + new Vector2(0, 2), Game1.textShadowColor); batch.DrawString( font, text, new Vector2(textXPos, textYPos) + new Vector2(2, 0), Game1.textShadowColor); batch.DrawString( font, text, new Vector2(textXPos, textYPos), Game1.textColor * 0.9f); yPos += (int)font.MeasureString(text).Y + 4; } if (healAmountToDisplay != -1) { Utility.drawWithShadow( batch, Game1.mouseCursors, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom, yPos + Game1.tileSize / 4), new Rectangle(healAmountToDisplay < 0 ? 140 : 0, 428, 10, 10), Color.White, 0.0f, Vector2.Zero, 3f, false, 0.95f); Utility.drawTextWithShadow( batch, Game1.content.LoadString("Strings\\UI:ItemHover_Energy", new object[] { ((healAmountToDisplay > 0 ? "+" : "") + healAmountToDisplay) }), font, new Vector2(xPos + Game1.tileSize / 4 + 34 + Game1.pixelZoom, yPos + Game1.tileSize / 4 + 8), Game1.textColor); yPos += 34; if (healAmountToDisplay > 0) { Utility.drawWithShadow( batch, Game1.mouseCursors, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom, yPos + Game1.tileSize / 4), new Rectangle(0, 438, 10, 10), Color.White, 0, Vector2.Zero, 3, false, 0.95f); Utility.drawTextWithShadow( batch, Game1.content.LoadString( "Strings\\UI:ItemHover_Health", new object[] { "+" + (healAmountToDisplay * 0.4) }), font, new Vector2(xPos + Game1.tileSize / 4 + 34 + Game1.pixelZoom, yPos + Game1.tileSize / 4 + 8), Game1.textColor); yPos += 34; } } if (buffIconsToDisplay != null) { for (int i = 0; i < buffIconsToDisplay.Length; ++i) { string buffIcon = buffIconsToDisplay[i]; if (buffIcon != "0") { Utility.drawWithShadow( batch, Game1.mouseCursors, new Vector2(xPos + Game1.tileSize / 4 + Game1.pixelZoom, yPos + Game1.tileSize / 4), new Rectangle(10 + i * 10, 428, 10, 10), Color.White, 0, Vector2.Zero, 3, false, 0.95f); string textToDraw = (buffIcon.SafeParseInt32() > 0 ? "+" : string.Empty) + buffIcon + " "; //if (i <= 10) // textToDraw = Game1.content.LoadString("Strings\\UI:ItemHover_Buff" + i, new object[] { textToDraw }); Utility.drawTextWithShadow( batch, textToDraw, font, new Vector2(xPos + Game1.tileSize / 4 + 34 + Game1.pixelZoom, yPos + Game1.tileSize / 4 + 8), Game1.textColor); yPos += 34; } } } if (hoveredItem != null && hoveredItem.attachmentSlots() > 0) { yPos += 16; hoveredItem.drawAttachments(batch, xPos + Game1.tileSize / 4, yPos); if (moneyAmountToDisplayAtBottom > -1) { yPos += Game1.tileSize * hoveredItem.attachmentSlots(); } } if (moneyAmountToDisplayAtBottom > -1) { } result = new Vector2(xPos, yPositionToReturn); } return(result); }
public static List <object> LoadPossibleTreasures(List <string> includeList, int minItemValue, int maxItemValue) { List <object> treasures = new List <object>(); int currentCount = 0; if (includeList.Contains("Weapon")) { foreach (KeyValuePair <int, string> kvp in Game1.content.Load <Dictionary <int, string> >("Data\\weapons")) { if (forbiddenWeapons.Contains(kvp.Key)) { continue; } int price = new MeleeWeapon(kvp.Key).salePrice(); if (CanAddTreasure(price, minItemValue, maxItemValue)) { treasures.Add(new Treasure(kvp.Key, price, "MeleeWeapon")); } } //context.Monitor.Log($"Added {treasures.Count - currentCount} weapons"); currentCount = treasures.Count; } if (includeList.Contains("Shirt") || includeList.Contains("Pants")) { foreach (KeyValuePair <int, string> kvp in Game1.clothingInformation) { int price = 0; if (includeList.Contains("Shirt") && kvp.Value.Split('/')[8].ToLower().Trim() == "shirt") { price = Convert.ToInt32(kvp.Value.Split('/')[5]); } else if (includeList.Contains("Pants") && kvp.Value.Split('/')[8].ToLower().Trim() == "pants") { price = Convert.ToInt32(kvp.Value.Split('/')[5]); } else { continue; } if (CanAddTreasure(price, minItemValue, maxItemValue)) { treasures.Add(new Treasure(kvp.Key, price, "Clothing")); } } //Monitor.Log($"Added {treasures.Count - currentCount} clothes"); currentCount = treasures.Count; } if (includeList.Contains("Hat")) { foreach (KeyValuePair <int, string> kvp in Game1.content.Load <Dictionary <int, string> >("Data\\hats")) { if (CanAddTreasure(1000, minItemValue, maxItemValue)) { treasures.Add(new Treasure(kvp.Key, 1000, "Hat")); } } //Monitor.Log($"Added {treasures.Count - currentCount} hats"); currentCount = treasures.Count; } if (includeList.Contains("Boots")) { foreach (KeyValuePair <int, string> kvp in Game1.content.Load <Dictionary <int, string> >("Data\\Boots")) { int price = Convert.ToInt32(kvp.Value.Split('/')[2]); if (CanAddTreasure(price, minItemValue, maxItemValue)) { treasures.Add(new Treasure(kvp.Key, price, "Boots")); } } //Monitor.Log($"Added {treasures.Count - currentCount} boots"); currentCount = treasures.Count; } if (includeList.Contains("BigCraftable")) { foreach (KeyValuePair <int, string> kvp in Game1.bigCraftablesInformation) { int price = new Object(Vector2.Zero, kvp.Key, false).sellToStorePrice(); if (CanAddTreasure(price, minItemValue, maxItemValue)) { treasures.Add(new Treasure(kvp.Key, price, "BigCraftable")); } } //Monitor.Log($"Added {treasures.Count - currentCount} boots"); currentCount = treasures.Count; } foreach (KeyValuePair <int, string> kvp in Game1.objectInformation) { if (kvp.Value.Split('/')[5] == "...") { continue; } string type = ""; int price = Convert.ToInt32(kvp.Value.Split('/')[1]); if (includeList.Contains("Ring") && kvp.Value.Split('/')[3] == "Ring") { type = "Ring"; } else if (includeList.Contains("Cooking") && kvp.Value.Split('/')[3].StartsWith("Cooking")) { type = "Cooking"; } else if (includeList.Contains("Seed") && kvp.Value.Split('/')[3].StartsWith("Seeds")) { type = "Seed"; } else if (includeList.Contains("Mineral") && kvp.Value.Split('/')[3].StartsWith("Mineral")) { type = "Mineral"; } else if (includeList.Contains("Fish") && kvp.Value.Split('/')[3].StartsWith("Fish")) { type = "Fish"; } else if (includeList.Contains("Relic") && kvp.Value.Split('/')[3].StartsWith("Arch")) { type = "Relic"; } else if (includeList.Contains("BasicObject") && kvp.Value.Split('/')[3].StartsWith("Basic")) { type = "BasicObject"; } if (type != "" && CanAddTreasure(price, minItemValue, maxItemValue)) { treasures.Add(new Treasure(kvp.Key, price, type)); } } //Monitor.Log($"Added {treasures.Count - currentCount} objects"); return(treasures); }
public static void AddEnchantments(MeleeWeapon weapon) { AdvancedMeleeWeapon amw = GetAdvancedWeapon(weapon, null); if (amw != null && amw.enchantments.Any()) { weapon.enchantments.Clear(); foreach (AdvancedEnchantmentData aed in amw.enchantments) { BaseWeaponEnchantment bwe = null; switch (aed.type) { case "vampiric": bwe = new VampiricEnchantment(); break; case "jade": bwe = new JadeEnchantment(); break; case "aquamarine": bwe = new AquamarineEnchantment(); break; case "topaz": bwe = new TopazEnchantment(); break; case "amethyst": bwe = new AmethystEnchantment(); break; case "ruby": bwe = new RubyEnchantment(); break; case "emerald": bwe = new EmeraldEnchantment(); break; case "haymaker": bwe = new HaymakerEnchantment(); break; case "bugkiller": bwe = new BugKillerEnchantment(); break; case "crusader": bwe = new CrusaderEnchantment(); break; case "magic": bwe = new MagicEnchantment(); break; default: bwe = new BaseWeaponEnchantment(); string key = aed.name; context.Helper.Reflection.GetField <string>(bwe, "_displayName").SetValue(key); break; } if (bwe != null) { weapon.enchantments.Add(bwe); //context.Monitor.Log($"added enchantment {aed.type} to {weapon.Name} {weapon.enchantments.Count}"); } } } }
public static Item getItem(string type, int index = -1, string name = "none") { Item item = null; if (type == "Object") { if (index != -1) { item = new StardewValley.Object(index, 1); } else if (name != "none") { item = new StardewValley.Object(Game1.objectInformation.getIndexByName(name), 1); } } else if (type == "BigObject") { if (index != -1) { item = new StardewValley.Object(Vector2.Zero, index); } else if (name != "none") { item = new StardewValley.Object(Vector2.Zero, Game1.bigCraftablesInformation.getIndexByName(name)); } } else if (type == "Ring") { if (index != -1) { item = new Ring(index); } else if (name != "none") { item = new Ring(Game1.objectInformation.getIndexByName(name)); } } else if (type == "Hat") { if (index != -1) { item = new Hat(index); } else if (name != "none") { item = new Hat(TMXLoaderMod.helper.Content.Load <Dictionary <int, string> >(@"Data/hats", ContentSource.GameContent).getIndexByName(name)); } } else if (type == "Boots") { if (index != -1) { item = new Boots(index); } else if (name != "none") { item = new Boots(TMXLoaderMod.helper.Content.Load <Dictionary <int, string> >(@"Data/Boots", ContentSource.GameContent).getIndexByName(name)); } } else if (type == "Clothing") { if (index != -1) { item = new Clothing(index); } else if (name != "none") { item = new Clothing(TMXLoaderMod.helper.Content.Load <Dictionary <int, string> >(@"Data/ClothingInformation", ContentSource.GameContent).getIndexByName(name)); } } else if (type == "TV") { if (index != -1) { item = new StardewValley.Objects.TV(index, Vector2.Zero); } else if (name != "none") { item = new TV(TMXLoaderMod.helper.Content.Load <Dictionary <int, string> >(@"Data/Furniture", ContentSource.GameContent).getIndexByName(name), Vector2.Zero); } } else if (type == "IndoorPot") { item = new StardewValley.Objects.IndoorPot(Vector2.Zero); } else if (type == "CrabPot") { item = new StardewValley.Objects.CrabPot(Vector2.Zero); } else if (type == "Chest") { item = new StardewValley.Objects.Chest(true); } else if (type == "Cask") { item = new StardewValley.Objects.Cask(Vector2.Zero); } else if (type == "Cask") { item = new StardewValley.Objects.Cask(Vector2.Zero); } else if (type == "Furniture") { if (index != -1) { item = new StardewValley.Objects.Furniture(index, Vector2.Zero); } else if (name != "none") { item = new Furniture(TMXLoaderMod.helper.Content.Load <Dictionary <int, string> >(@"Data/Furniture", ContentSource.GameContent).getIndexByName(name), Vector2.Zero); } } else if (type == "Sign") { item = new StardewValley.Objects.Sign(Vector2.Zero, index); } else if (type == "Wallpaper") { item = new StardewValley.Objects.Wallpaper(Math.Abs(index), false); } else if (type == "Floors") { item = new StardewValley.Objects.Wallpaper(Math.Abs(index), true); } else if (type == "MeleeWeapon") { if (index != -1) { item = new MeleeWeapon(index); } else if (name != "none") { item = new MeleeWeapon(TMXLoaderMod.helper.Content.Load <Dictionary <int, string> >(@"Data/weapons", ContentSource.GameContent).getIndexByName(name)); } } else if (type == "CustomObject" && PyTK.CustomElementHandler.CustomObjectData.collection.ContainsKey(name)) { item = PyTK.CustomElementHandler.CustomObjectData.collection[name].getObject(); } else if (type == "SDVType") { try { if (index == -1) { item = Activator.CreateInstance(PyUtils.getTypeSDV(name)) is Item i ? i : null; } else { item = Activator.CreateInstance(PyUtils.getTypeSDV(name), index) is Item i ? i : null; } } catch (Exception ex) { TMXLoaderMod.monitor.Log(ex.Message + ":" + ex.StackTrace, LogLevel.Error); TMXLoaderMod.monitor.Log("Couldn't load item SDVType: " + name); } } else if (type == "ByType") { try { if (index == -1) { item = Activator.CreateInstance(Type.GetType(name)) is Item i ? i : null; } else { item = Activator.CreateInstance(Type.GetType(name), index) is Item i ? i : null; } } catch (Exception ex) { TMXLoaderMod.monitor.Log(ex.Message + ":" + ex.StackTrace, LogLevel.Error); TMXLoaderMod.monitor.Log("Couldn't load item ByType: " + name); } } return(item); }
void Start() { if (Fork != null) weapon = Fork.GetComponent<MeleeWeapon> (); }
private void OpenTreasureEndFunction(FishingRod rod, Farmer user, int includeFish) { ModFishing.Instance.Monitor.Log("Successfully replaced treasure", LogLevel.Trace); ConfigMain.ConfigGlobalTreasure config = ModFishing.Instance.MainConfig.GlobalTreasureSettings; int clearWaterDistance = ModFishing.Instance.Helper.Reflection.GetField <int>(rod, "clearWaterDistance")?.GetValue() ?? 5; int whichFish = ModFishing.Instance.Helper.Reflection.GetField <int>(rod, "whichFish").GetValue(); int fishQuality = ModFishing.Instance.Helper.Reflection.GetField <int>(rod, "fishQuality").GetValue(); // Gain experience and call vanilla code for this user.gainExperience(5, 10 * (clearWaterDistance + 1)); rod.doneFishing(user, true); user.completelyStopAnimatingOrDoingAction(); // REWARDS List <Item> rewards = new List <Item>(); if (includeFish == 1) { rewards.Add(new SObject(whichFish, 1, false, -1, fishQuality)); } List <ITreasureData> possibleLoot = new List <ITreasureData>(ModFishing.Instance.TreasureConfig.PossibleLoot) .Where(treasure => treasure.IsValid(user)).ToList(); // Select rewards float chance = 1f; int streak = ModFishing.Instance.Api.GetStreak(user); while (possibleLoot.Count > 0 && rewards.Count < config.MaxTreasureQuantity && Game1.random.NextDouble() <= chance) { ITreasureData treasure = possibleLoot.Choose(Game1.random); // Choose an ID for the treasure IList <int> ids = treasure.PossibleIds(); int id = ids[Game1.random.Next(ids.Count)]; // Lost books have custom handling if (id == Objects.LostBook) { if (user.archaeologyFound == null || !user.archaeologyFound.ContainsKey(102) || user.archaeologyFound[102][0] >= 21) { possibleLoot.Remove(treasure); continue; } Game1.showGlobalMessage("You found a lost book. The library has been expanded."); } // Create reward item Item reward; if (treasure.MeleeWeapon) { reward = new MeleeWeapon(id); } else if (id >= Ring.ringLowerIndexRange && id <= Ring.ringUpperIndexRange) { reward = new Ring(id); } else if (id >= 504 && id <= 513) { reward = new Boots(id); } else { // Random quantity int count = Game1.random.Next(treasure.MinAmount, treasure.MaxAmount); reward = new SObject(Vector2.Zero, id, count); } // Add the reward rewards.Add(reward); // Check if this reward shouldn't be duplicated if (!config.AllowDuplicateLoot || !treasure.AllowDuplicates) { possibleLoot.Remove(treasure); } // Update chance chance *= config.AdditionalLootChance + streak * config.StreakAdditionalLootChance; } // Add bait if no rewards were selected. NOTE: This should never happen if (rewards.Count == 0) { ModFishing.Instance.Monitor.Log("Could not find any valid loot for the treasure chest. Check your treasure.json?", LogLevel.Warn); rewards.Add(new SObject(685, Game1.random.Next(2, 5) * 5)); } // Show rewards GUI ModFishing.Instance.Monitor.Log($"Treasure rewards: {string.Join(", ", rewards)}", LogLevel.Trace); Game1.activeClickableMenu = new ItemGrabMenu(rewards); ((ItemGrabMenu)Game1.activeClickableMenu).source = 3; user.completelyStopAnimatingOrDoingAction(); }
private void Awake() { parent = transform.GetComponentInParent <MeleeWeapon>(); }
public void EquipWeapon(MeleeWeapon wep) { if (equippedWeapon != wep) { equippedWeapon = wep; } }
private static void player_addMelee(object sender, EventArgsCommand e) { if (e.Command.CalledArgs.Length > 0) { if (e.Command.CalledArgs[0].IsInt32()) { var toAdd = new MeleeWeapon(e.Command.CalledArgs[0].AsInt32()); Game1.player.addItemByMenuIfNecessary(toAdd); Log.Async($"Given {toAdd.Name} to {Game1.player.Name}"); } else { Log.AsyncR("<item> is invalid"); } } else { Log.LogObjectValueNotSpecified(); } }
public UnitStrike( Unit attacker, Unit attackee, MeleeWeapon weapon ) : base("Strike", attacker) { this.attacker = attacker; this.attackee = attackee; this.weapon = weapon; result = attacker.relations.GetAttackResult( attackee ); }