protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinDC, MaxDC); if (damage == 0) return; int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.ACAgility); ActionList.Add(action); if (Target.Dead) FindTarget(); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); Broadcast(new S.ObjectMagic { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Spell = Spell.ThunderBolt, TargetID = Target.ObjectID, Target = Target.CurrentLocation, Cast = true, Level = 3 }); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinMC, MaxMC); if (damage == 0) return; DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MAC); ActionList.Add(action); if (Target.Dead) FindTarget(); }
public static Countdown Queue(TimeSpan delay, DelayedAction action) { var counter = new Countdown(); counter.Elapsed += (object sender, EventArgs e) => action(); counter.Start(delay); return counter; }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); byte spelltype = Envir.Random.Next(2) == 0 ? (byte)1 : (byte)2; Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = spelltype }); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinDC, MaxDC); if (damage == 0) return; DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MAC); ActionList.Add(action); if (Target.Dead) FindTarget(); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1); if (!ranged) { ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinDC, MaxDC); Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); if (damage == 0) return; Target.Attacked(this, damage, DefenceType.ACAgility); } else { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinMC, MaxMC); if (damage == 0) return; int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MACAgility); ActionList.Add(action); if (Envir.Random.Next(8) == 0) { Target.ApplyPoison(new Poison { Owner = this, Duration = 15, PType = PoisonType.Slow, TickSpeed = 1000 }, this); } if (Envir.Random.Next(15) == 0) { Target.ApplyPoison(new Poison { Owner = this, PType = PoisonType.Frozen, Duration = 5, TickSpeed = 1000 }, this); } } if (Target.Dead) FindTarget(); }
public override void Process(DelayedAction action) { switch (action.Type) { case DelayedType.Damage: CompleteAttack(action.Params); break; } }
public PagedWidgetContainer() { Pages = new ObservableCollection<PageViewModel>(); Rearrange = new DelayedAction(); InitializeComponent(); Init(); }
public void StartDelayedAction(string name, Action action, TimeSpan delay) { DelayedAction da; if (!pending.TryGetValue(name, out da)) { da = new DelayedAction(); pending[name] = da; } da.StartDelayTimer(action, delay); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1); if (!ranged) { ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); LineAttack(2); } else { if (Envir.Random.Next(5) == 0) { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinMC, MaxMC); if (damage == 0) return; int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MACAgility); ActionList.Add(action); } else { MoveTo(Target.CurrentLocation); } } if (Target.Dead) FindTarget(); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); if((HP * 100 / MaxHP) < 20 && MassAttackTime < Envir.Time) { ShockTime = 0; ActionTime = Envir.Time + 500; AttackTime = Envir.Time + (AttackSpeed); Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); List<MapObject> targets = FindAllTargets(7, CurrentLocation, false); if (targets.Count == 0) return; int damage = GetAttackPower(MinDC, MaxDC); for (int i = 0; i < targets.Count; i++) { int delay = Functions.MaxDistance(CurrentLocation, targets[i].CurrentLocation) * 50 + 750; //50 MS per Step DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.ACAgility); ActionList.Add(action); } MassAttackTime = Envir.Time + 2000 + (Envir.Random.Next(5) * 1000); ActionTime = Envir.Time + 800; AttackTime = Envir.Time + (AttackSpeed); return; } if (Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange - 1) && Envir.Random.Next(3) == 0) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); LineAttack(AttackRange - Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) + 1, true); } else { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); LineAttack(AttackRange); } ShockTime = 0; ActionTime = Envir.Time + 500; AttackTime = Envir.Time + (AttackSpeed); }
public override void Process(DelayedAction action) { switch (action.Type) { case DelayedType.Damage: CompleteAttack(action.Params); break; case DelayedType.Recall: PetRecall((MapObject)action.Params[0]); break; } }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; if (Envir.Random.Next(8) != 0) { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); int damage = GetAttackPower(MinDC, MaxDC); if (damage == 0) return; int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MACAgility); ActionList.Add(action); } else { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 }); if (Envir.Random.Next(Settings.PoisonResistWeight) >= Target.PoisonResist) { int levelgap = 50 - Target.Level; if (Envir.Random.Next(20) < 4 + levelgap) Target.ApplyPoison(new Poison { Owner = this, Duration = 5, PType = PoisonType.Slow, TickSpeed = 1000, }, this); } } if (Target.Dead) FindTarget(); }
/// <summary>Constructor.</summary> public Textbox() { // Setup initial conditions. Container.AddClass(ClassTextbox); // Create INPUT. input = Html.CreateElement("input"); input.Attribute(Html.Type, "text"); input.AppendTo(Container); input.AddClass(ClassTextbox); // Set initial size. Height = 40; // Assign focus control to the input element. ChangeFocusElement(input); Focus.BrowserHighlighting = false; Focus.CanFocus = true; // Setup padding. padding = new Spacing().Sync(input, OnBeforePaddingSync); padding.Change(10, 5); // Create child objects. eventDelay = new DelayedAction(0.3, OnDelayElapsed); // Wire up events. Container.MouseDown(delegate { FocusOnClick(); }); input.Keyup(delegate(jQueryEvent e) { if (previousText != Text) FireTextChanged(); if (Int32.Parse(e.Which) == (int)Key.Enter) FireEnterPress(); }); input.MouseDown(delegate { OnInputMouseDown(); }); input.MouseUp(delegate { OnInputMouseUp(); }); Focus.GotFocus += OnGotFocus; Focus.LostFocus += OnLostFocus; IsEnabledChanged += delegate { SyncEnabled(); }; SizeChanged += delegate { UpdateLayout(); }; // Sync size and shape. SyncCornerRadius(); // Finish up. previousText = Text; FireSizeChanged(); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinDC, MaxDC); if (!ranged) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); if (damage == 0) return; Target.Attacked(this, damage, DefenceType.MACAgility); } else { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); AttackTime = Envir.Time + AttackSpeed + 500; if (damage == 0) return; DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MAC); ActionList.Add(action); } if (Target.Dead) FindTarget(); }
protected override void Attack() { ShockTime = 0; if (!Target.IsAttackTarget(this)) { Target = null; return; } Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); if(Functions.InRange(Target.CurrentLocation, CurrentLocation, 1)) { base.Attack(); } else { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); List<MapObject> targets = FindAllTargets(2, Target.CurrentLocation, false); int damage = GetAttackPower(MinMC, MaxMC); if (damage > 0 && targets.Count > 0) { for (int i = 0; i < targets.Count; i++) { if (Envir.Random.Next(Settings.MagicResistWeight) >= targets[i].MagicResist) { DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, targets[i], damage, DefenceType.MACAgility); ActionList.Add(action); } } } } AttackTime = Envir.Time + AttackSpeed; ActionTime = Envir.Time + 300; }
public PinPanel(jQueryObject container) : base(container) { // Setup initial conditions. hideDelay = new DelayedAction(DefaultHideDelay, OnHideDelayElapsed); // Insert the pin button. pin = ImageButtonFactory.Create(ImageButtons.PushPin); IButtonView view = pin.CreateView(); view.Container.AddClass(ButtonCssClass); Container.Append(view.Container); // Wire up events. pin.IsPressedChanged += delegate { IsPinned = pin.IsPressed; }; Container.MouseEnter(delegate { hideDelay.Stop(); }); Container.MouseLeave(delegate { hideDelay.Start(); }); // Finish up. SyncButton(); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1); if(ranged || Envir.Time > _thrustTime) { if (ranged && Envir.Random.Next(2) == 0) { MoveTo(Target.CurrentLocation); ActionTime = Envir.Time + 300; return; } Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); AttackTime = Envir.Time + AttackSpeed; DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500); ActionList.Add(action); _thrustTime = Envir.Time + 5000; return; } base.Attack(); if (Target.Dead) FindTarget(); }
public static bool placementAction(CoreObject cObj, GameLocation location, int x, int y, StardewValley.Farmer who = null, bool playSound = true) { Vector2 vector = new Vector2((float)(x / Game1.tileSize), (float)(y / Game1.tileSize)); // cObj.health = 10; if (who != null) { cObj.owner = who.uniqueMultiplayerID; } else { cObj.owner = Game1.player.uniqueMultiplayerID; } if (!cObj.bigCraftable && !(cObj is Furniture)) { int num = cObj.ParentSheetIndex; if (num <= 298) { if (num > 94) { bool result; switch (num) { case 286: { using (List <TemporaryAnimatedSprite> .Enumerator enumerator = Game1.currentLocation.temporarySprites.GetEnumerator()) { while (enumerator.MoveNext()) { if (enumerator.Current.position.Equals(vector * (float)Game1.tileSize)) { result = false; return(result); } } } int num2 = Game1.random.Next(); Game1.playSound("thudStep"); Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(cObj.parentSheetIndex, 100f, 1, 24, vector * (float)Game1.tileSize, true, false, Game1.currentLocation, who) { shakeIntensity = 0.5f, shakeIntensityChange = 0.002f, extraInfoForEndBehavior = num2, endFunction = new TemporaryAnimatedSprite.endBehavior(Game1.currentLocation.removeTemporarySpritesWithID) }); Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 3f) * (float)Game1.pixelZoom, true, false, (float)(y + 7) / 10000f, 0f, Color.Yellow, (float)Game1.pixelZoom, 0f, 0f, 0f, false) { id = (float)num2 }); Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 3f) * (float)Game1.pixelZoom, true, true, (float)(y + 7) / 10000f, 0f, Color.Orange, (float)Game1.pixelZoom, 0f, 0f, 0f, false) { delayBeforeAnimationStart = 100, id = (float)num2 }); Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 3f) * (float)Game1.pixelZoom, true, false, (float)(y + 7) / 10000f, 0f, Color.White, (float)Game1.pixelZoom * 0.75f, 0f, 0f, 0f, false) { delayBeforeAnimationStart = 200, id = (float)num2 }); if (Game1.fuseSound != null && !Game1.fuseSound.IsPlaying) { Game1.fuseSound = Game1.soundBank.GetCue("fuse"); Game1.fuseSound.Play(); } return(true); } case 287: { using (List <TemporaryAnimatedSprite> .Enumerator enumerator = Game1.currentLocation.temporarySprites.GetEnumerator()) { while (enumerator.MoveNext()) { if (enumerator.Current.position.Equals(vector * (float)Game1.tileSize)) { result = false; return(result); } } } int num2 = Game1.random.Next(); Game1.playSound("thudStep"); Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(cObj.parentSheetIndex, 100f, 1, 24, vector * (float)Game1.tileSize, true, false, Game1.currentLocation, who) { shakeIntensity = 0.5f, shakeIntensityChange = 0.002f, extraInfoForEndBehavior = num2, endFunction = new TemporaryAnimatedSprite.endBehavior(Game1.currentLocation.removeTemporarySpritesWithID) }); Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize, true, false, (float)(y + 7) / 10000f, 0f, Color.Yellow, (float)Game1.pixelZoom, 0f, 0f, 0f, false) { id = (float)num2 }); Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize, true, false, (float)(y + 7) / 10000f, 0f, Color.Orange, (float)Game1.pixelZoom, 0f, 0f, 0f, false) { delayBeforeAnimationStart = 100, id = (float)num2 }); Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize, true, false, (float)(y + 7) / 10000f, 0f, Color.White, (float)Game1.pixelZoom * 0.75f, 0f, 0f, 0f, false) { delayBeforeAnimationStart = 200, id = (float)num2 }); if (Game1.fuseSound != null && !Game1.fuseSound.IsPlaying) { Game1.fuseSound = Game1.soundBank.GetCue("fuse"); Game1.fuseSound.Play(); } return(true); } case 288: { using (List <TemporaryAnimatedSprite> .Enumerator enumerator = Game1.currentLocation.temporarySprites.GetEnumerator()) { while (enumerator.MoveNext()) { if (enumerator.Current.position.Equals(vector * (float)Game1.tileSize)) { result = false; return(result); } } } int num2 = Game1.random.Next(); Game1.playSound("thudStep"); Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(cObj.parentSheetIndex, 100f, 1, 24, vector * (float)Game1.tileSize, true, false, Game1.currentLocation, who) { shakeIntensity = 0.5f, shakeIntensityChange = 0.002f, extraInfoForEndBehavior = num2, endFunction = new TemporaryAnimatedSprite.endBehavior(Game1.currentLocation.removeTemporarySpritesWithID) }); Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 0f) * (float)Game1.pixelZoom, true, false, (float)(y + 7) / 10000f, 0f, Color.Yellow, (float)Game1.pixelZoom, 0f, 0f, 0f, false) { id = (float)num2 }); Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 0f) * (float)Game1.pixelZoom, true, true, (float)(y + 7) / 10000f, 0f, Color.Orange, (float)Game1.pixelZoom, 0f, 0f, 0f, false) { delayBeforeAnimationStart = 100, id = (float)num2 }); Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 0f) * (float)Game1.pixelZoom, true, false, (float)(y + 7) / 10000f, 0f, Color.White, (float)Game1.pixelZoom * 0.75f, 0f, 0f, 0f, false) { delayBeforeAnimationStart = 200, id = (float)num2 }); if (Game1.fuseSound != null && !Game1.fuseSound.IsPlaying) { Game1.fuseSound = Game1.soundBank.GetCue("fuse"); Game1.fuseSound.Play(); } return(true); } default: if (num != 297) { if (num != 298) { goto IL_FD7; } if (location.objects.ContainsKey(vector)) { return(false); } location.objects.Add(vector, new Fence(vector, 5, false)); Game1.playSound("axe"); return(true); } else { if (location.objects.ContainsKey(vector) || location.terrainFeatures.ContainsKey(vector)) { return(false); } location.terrainFeatures.Add(vector, new Grass(1, 4)); Game1.playSound("dirtyHit"); return(true); } break; } return(result); } if (num != 93) { if (num == 94) { if (location.objects.ContainsKey(vector)) { return(false); } new Torch(vector, 1, 94).placementAction(location, x, y, who); return(true); } } else { if (location.objects.ContainsKey(vector)) { return(false); } Utility.removeLightSource((int)(cObj.tileLocation.X * 2000f + cObj.tileLocation.Y)); Utility.removeLightSource((int)Game1.player.uniqueMultiplayerID); new Torch(vector, 1).placementAction(location, x, y, (who == null) ? Game1.player : who); return(true); } } else if (num <= 401) { switch (num) { case 309: case 310: case 311: { bool flag = location.terrainFeatures.ContainsKey(vector) && location.terrainFeatures[vector] is HoeDirt && (location.terrainFeatures[vector] as HoeDirt).crop == null; if (!flag && (location.objects.ContainsKey(vector) || location.terrainFeatures.ContainsKey(vector) || (!(location is Farm) && !location.name.Contains("Greenhouse")))) { Game1.showRedMessage("Invalid Position"); return(false); } string text = location.doesTileHaveProperty(x, y, "NoSpawn", "Back"); if ((text == null || (!text.Equals("Tree") && !text.Equals("All"))) && (flag || (location.isTileLocationOpen(new Location(x * Game1.tileSize, y * Game1.tileSize)) && !location.isTileOccupied(new Vector2((float)x, (float)y), "") && location.doesTileHaveProperty(x, y, "Water", "Back") == null))) { int which = 1; num = cObj.parentSheetIndex; if (num != 310) { if (num == 311) { which = 3; } } else { which = 2; } location.terrainFeatures.Remove(vector); location.terrainFeatures.Add(vector, new Tree(which, 0)); Game1.playSound("dirtyHit"); return(true); } break; } default: switch (num) { case 322: if (location.objects.ContainsKey(vector)) { return(false); } location.objects.Add(vector, new Fence(vector, 1, false)); Game1.playSound("axe"); return(true); case 323: if (location.objects.ContainsKey(vector)) { return(false); } location.objects.Add(vector, new Fence(vector, 2, false)); Game1.playSound("stoneStep"); return(true); case 324: if (location.objects.ContainsKey(vector)) { return(false); } location.objects.Add(vector, new Fence(vector, 3, false)); Game1.playSound("hammer"); return(true); case 325: if (location.objects.ContainsKey(vector)) { return(false); } location.objects.Add(vector, new Fence(vector, 4, true)); Game1.playSound("axe"); return(true); case 326: case 327: case 330: case 332: break; case 328: if (location.terrainFeatures.ContainsKey(vector)) { return(false); } location.terrainFeatures.Add(vector, new Flooring(0)); Game1.playSound("axchop"); return(true); case 329: if (location.terrainFeatures.ContainsKey(vector)) { return(false); } location.terrainFeatures.Add(vector, new Flooring(1)); Game1.playSound("thudStep"); return(true); case 331: if (location.terrainFeatures.ContainsKey(vector)) { return(false); } location.terrainFeatures.Add(vector, new Flooring(2)); Game1.playSound("axchop"); return(true); case 333: if (location.terrainFeatures.ContainsKey(vector)) { return(false); } location.terrainFeatures.Add(vector, new Flooring(3)); Game1.playSound("thudStep"); return(true); default: if (num == 401) { if (location.terrainFeatures.ContainsKey(vector)) { return(false); } location.terrainFeatures.Add(vector, new Flooring(4)); Game1.playSound("thudStep"); return(true); } break; } break; } } else { switch (num) { case 405: if (location.terrainFeatures.ContainsKey(vector)) { return(false); } location.terrainFeatures.Add(vector, new Flooring(6)); Game1.playSound("woodyStep"); return(true); case 406: case 408: case 410: break; case 407: if (location.terrainFeatures.ContainsKey(vector)) { return(false); } location.terrainFeatures.Add(vector, new Flooring(5)); Game1.playSound("dirtyHit"); return(true); case 409: if (location.terrainFeatures.ContainsKey(vector)) { return(false); } location.terrainFeatures.Add(vector, new Flooring(7)); Game1.playSound("stoneStep"); return(true); case 411: if (location.terrainFeatures.ContainsKey(vector)) { return(false); } location.terrainFeatures.Add(vector, new Flooring(8)); Game1.playSound("stoneStep"); return(true); default: if (num != 415) { if (num == 710) { if (location.objects.ContainsKey(vector) || location.doesTileHaveProperty((int)vector.X, (int)vector.Y, "Water", "Back") == null) { return(false); } new CrabPot(vector, 1).placementAction(location, x, y, who); return(true); } } else { if (location.terrainFeatures.ContainsKey(vector)) { return(false); } location.terrainFeatures.Add(vector, new Flooring(9)); Game1.playSound("stoneStep"); return(true); } break; } } } else { int num = cObj.ParentSheetIndex; if (num <= 130) { if (num == 71) { if (location is MineShaft) { if ((location as MineShaft).mineLevel != 120 && (location as MineShaft).recursiveTryToCreateLadderDown(vector, "hoeHit", 16)) { return(true); } Game1.showRedMessage("Unsuitable Location"); } return(false); } if (num == 130) { if (location.objects.ContainsKey(vector) || Game1.currentLocation is MineShaft) { Game1.showRedMessage("Unsuitable Location"); return(false); } location.objects.Add(vector, new Chest(true) { shakeTimer = 50 }); Game1.playSound("axe"); return(true); } } else { switch (num) { case 143: case 144: case 145: case 146: case 147: case 148: case 149: case 150: case 151: if (location.objects.ContainsKey(vector)) { return(false); } new Torch(vector, cObj.parentSheetIndex, true) { shakeTimer = 25 }.placementAction(location, x, y, who); return(true); default: if (num == 163) { location.objects.Add(vector, new Cask(vector)); Game1.playSound("hammer"); } break; } } } IL_FD7: if (cObj.name.Equals("Tapper")) { if (location.terrainFeatures.ContainsKey(vector) && location.terrainFeatures[vector] is Tree && (location.terrainFeatures[vector] as Tree).growthStage >= 5 && !(location.terrainFeatures[vector] as Tree).stump && !location.objects.ContainsKey(vector)) { cObj.tileLocation = vector; location.objects.Add(vector, cObj); int treeType = (location.terrainFeatures[vector] as Tree).treeType; (location.terrainFeatures[vector] as Tree).tapped = true; switch (treeType) { case 1: cObj.heldObject = new StardewValley.Object(725, 1, false, -1, 0); cObj.minutesUntilReady = 13000 - Game1.timeOfDay; break; case 2: cObj.heldObject = new StardewValley.Object(724, 1, false, -1, 0); cObj.minutesUntilReady = 16000 - Game1.timeOfDay; break; case 3: cObj.heldObject = new StardewValley.Object(726, 1, false, -1, 0); cObj.minutesUntilReady = 10000 - Game1.timeOfDay; break; case 7: cObj.heldObject = new StardewValley.Object(420, 1, false, -1, 0); cObj.minutesUntilReady = 3000 - Game1.timeOfDay; if (!Game1.currentSeason.Equals("fall")) { cObj.heldObject = new StardewValley.Object(404, 1, false, -1, 0); cObj.minutesUntilReady = 6000 - Game1.timeOfDay; } break; } Game1.playSound("axe"); return(true); } return(false); } else if (cObj.name.Contains("Sapling")) { Vector2 key = default(Vector2); for (int i = x / Game1.tileSize - 2; i <= x / Game1.tileSize + 2; i++) { for (int j = y / Game1.tileSize - 2; j <= y / Game1.tileSize + 2; j++) { key.X = (float)i; key.Y = (float)j; if (location.terrainFeatures.ContainsKey(key) && (location.terrainFeatures[key] is Tree || location.terrainFeatures[key] is FruitTree)) { Game1.showRedMessage("Too close to another tree"); return(false); } } } if (location.terrainFeatures.ContainsKey(vector)) { if (!(location.terrainFeatures[vector] is HoeDirt) || (location.terrainFeatures[vector] as HoeDirt).crop != null) { return(false); } location.terrainFeatures.Remove(vector); } if (location is Farm && (location.doesTileHaveProperty((int)vector.X, (int)vector.Y, "Diggable", "Back") != null || location.doesTileHavePropertyNoNull((int)vector.X, (int)vector.Y, "Type", "Back").Equals("Grass"))) { Game1.playSound("dirtyHit"); DelayedAction.playSoundAfterDelay("coin", 100); location.terrainFeatures.Add(vector, new FruitTree(cObj.parentSheetIndex)); return(true); } Game1.showRedMessage("Can't be planted here."); return(false); } else { //Game1.showRedMessage("STEP 1"); if (cObj.category == -74) { return(true); } if (!cObj.performDropDownAction(who)) { CoreObject @object = (CoreObject)cObj.getOne(); @object.shakeTimer = 50; @object.tileLocation = vector; @object.performDropDownAction(who); if (location.objects.ContainsKey(vector)) { if (location.objects[vector].ParentSheetIndex != cObj.parentSheetIndex) { Game1.createItemDebris(location.objects[vector], vector * (float)Game1.tileSize, Game1.random.Next(4)); location.objects[vector] = @object; } } else { // Game1.showRedMessage("STEP 2"); //Log.Info(vector); Vector2 newVec = new Vector2(vector.X, vector.Y); // cObj.boundingBox.Inflate(32, 32); location.objects.Add(newVec, cObj); } @object.initializeLightSource(vector); } if (playSound == true) { Game1.playSound("woodyStep"); } else { //Log.AsyncG("restoring item from file"); } //Log.AsyncM("Placed and object"); cObj.locationsName = location.name; Lists.trackedObjectList.Add(cObj); return(true); } }
public virtual void PerformCompleteAnimation() { if (upgradeName.Contains("Volcano")) { for (int j = 0; j < 16; j++) { locationRef.Value.temporarySprites.Add(new TemporaryAnimatedSprite(5, Utility.getRandomPositionInThisRectangle(upgradeRect, Game1.random) * 64f, Color.White) { motion = new Vector2(Game1.random.Next(-1, 2), -1f), scale = 1f, layerDepth = 1f, drawAboveAlwaysFront = true, delayBeforeAnimationStart = j * 15 }); TemporaryAnimatedSprite t4 = new TemporaryAnimatedSprite("LooseSprites\\Cursors2", new Microsoft.Xna.Framework.Rectangle(65, 229, 16, 6), Utility.getRandomPositionInThisRectangle(upgradeRect, Game1.random) * 64f, Game1.random.NextDouble() < 0.5, 0f, Color.White) { motion = new Vector2(Game1.random.Next(-2, 3), -16f), acceleration = new Vector2(0f, 0.5f), rotationChange = (float)Game1.random.Next(-4, 5) * 0.05f, scale = 4f, animationLength = 1, totalNumberOfLoops = 1, interval = 1000 + Game1.random.Next(500), layerDepth = 1f, drawAboveAlwaysFront = true, yStopCoordinate = (upgradeRect.Bottom + 1) * 64 }; t4.reachedStopCoordinate = t4.bounce; locationRef.Value.TemporarySprites.Add(t4); t4 = new TemporaryAnimatedSprite("LooseSprites\\Cursors2", new Microsoft.Xna.Framework.Rectangle(65, 229, 16, 6), Utility.getRandomPositionInThisRectangle(upgradeRect, Game1.random) * 64f, Game1.random.NextDouble() < 0.5, 0f, Color.White) { motion = new Vector2(Game1.random.Next(-2, 3), -16f), acceleration = new Vector2(0f, 0.5f), rotationChange = (float)Game1.random.Next(-4, 5) * 0.05f, scale = 4f, animationLength = 1, totalNumberOfLoops = 1, interval = 1000 + Game1.random.Next(500), layerDepth = 1f, drawAboveAlwaysFront = true, yStopCoordinate = (upgradeRect.Bottom + 1) * 64 }; t4.reachedStopCoordinate = t4.bounce; locationRef.Value.TemporarySprites.Add(t4); } if (locationRef.Value == Game1.currentLocation) { Game1.flashAlpha = 1f; Game1.playSound("boulderBreak"); } } else if ((string)upgradeName == "House") { for (int i = 0; i < 16; i++) { locationRef.Value.temporarySprites.Add(new TemporaryAnimatedSprite(5, Utility.getRandomPositionInThisRectangle(upgradeRect, Game1.random) * 64f, Color.White) { motion = new Vector2(Game1.random.Next(-1, 2), -1f), scale = 1f, layerDepth = 1f, drawAboveAlwaysFront = true, delayBeforeAnimationStart = i * 15 }); TemporaryAnimatedSprite t2 = new TemporaryAnimatedSprite("LooseSprites\\Cursors2", new Microsoft.Xna.Framework.Rectangle(49 + 16 * Game1.random.Next(3), 229, 16, 6), Utility.getRandomPositionInThisRectangle(upgradeRect, Game1.random) * 64f, Game1.random.NextDouble() < 0.5, 0f, Color.White) { motion = new Vector2(Game1.random.Next(-2, 3), -16f), acceleration = new Vector2(0f, 0.5f), rotationChange = (float)Game1.random.Next(-4, 5) * 0.05f, scale = 4f, animationLength = 1, totalNumberOfLoops = 1, interval = 1000 + Game1.random.Next(500), layerDepth = 1f, drawAboveAlwaysFront = true, yStopCoordinate = (upgradeRect.Bottom + 1) * 64 }; t2.reachedStopCoordinate = t2.bounce; locationRef.Value.TemporarySprites.Add(t2); t2 = new TemporaryAnimatedSprite("LooseSprites\\Cursors2", new Microsoft.Xna.Framework.Rectangle(49 + 16 * Game1.random.Next(3), 229, 16, 6), Utility.getRandomPositionInThisRectangle(upgradeRect, Game1.random) * 64f, Game1.random.NextDouble() < 0.5, 0f, Color.White) { motion = new Vector2(Game1.random.Next(-2, 3), -16f), acceleration = new Vector2(0f, 0.5f), rotationChange = (float)Game1.random.Next(-4, 5) * 0.05f, scale = 4f, animationLength = 1, totalNumberOfLoops = 1, interval = 1000 + Game1.random.Next(500), layerDepth = 1f, drawAboveAlwaysFront = true, yStopCoordinate = (upgradeRect.Bottom + 1) * 64 }; t2.reachedStopCoordinate = t2.bounce; locationRef.Value.TemporarySprites.Add(t2); } if (locationRef.Value == Game1.currentLocation) { Game1.flashAlpha = 1f; Game1.playSound("boulderBreak"); } } else if (((string)upgradeName == "Resort" || (string)upgradeName == "Trader" || (string)upgradeName == "Obelisk") && locationRef.Value == Game1.currentLocation) { Game1.flashAlpha = 1f; } if (locationRef.Value == Game1.currentLocation && (string)upgradeName != "Hut") { DelayedAction.playSoundAfterDelay("secret1", 800); } }
public override void receiveLeftClick(int x, int y, bool playSound = true) { base.receiveLeftClick(x, y, playSound); lastTick = Game1.ticks; if (Game1.activeClickableMenu == null) { return; } if (isCheckingOut) { if (cancelButton.containsPoint(x, y)) { isCheckingOut = false; Game1.playSound("cancel"); } else if (nextDayShippingButton.containsPoint(x, y)) { isNextDayShipping = true; Game1.playSound("select"); } else if (twoDayShippingButton.containsPoint(x, y)) { isNextDayShipping = false; Game1.playSound("select"); } else if (purchaseButton.containsPoint(x, y)) { if (canAffordOrder) { // Close this menu base.exitThisMenu(); // Create mail order if (JojaMail.CreateMailOrder(Game1.player, isNextDayShipping ? 1 : 2, itemsInCart.Keys.Select(i => i as Item).ToList())) { this.monitor.Log("Order placed via JojaMail!", LogLevel.Debug); // Display order success dialog if (isNextDayShipping) { Game1.player.Money = Game1.player.Money - (itemsInCart.Keys.Sum(i => i.Stack * itemsInCart[i][0]) + (itemsInCart.Keys.Sum(i => i.Stack * itemsInCart[i][0]) / nextDayShippingFee)); Game1.activeClickableMenu = new DialogueBox("Your order has been placed! ^It will arrive tomorrow."); } else { Game1.player.Money = Game1.player.Money - itemsInCart.Keys.Sum(i => i.Stack * itemsInCart[i][0]); Game1.activeClickableMenu = new DialogueBox("Your order has been placed! ^It will arrive in 2 days."); } Game1.playSound("moneyDial"); Game1.dayTimeMoneyBox.moneyShakeTimer = 1000; } else { this.monitor.Log("Issue ordering items, failed to dispatch JojaMail!", LogLevel.Error); // Display order error dialog Game1.activeClickableMenu = new DialogueBox($"Order failed to place! Please try again later."); } } else { // Shake money bag Game1.dayTimeMoneyBox.moneyShakeTimer = 2000; Game1.playSound("cancel"); } } return; } if (this.scrollBar.containsPoint(x, y)) { this.scrolling = true; } else if (randomSaleButton.containsPoint(x, y)) { // Move the forSaleButtons until the randomSaleItem is displayed for (this.currentItemIndex = 0; this.currentItemIndex < Math.Max(0, this.forSale.Count - buttonScrollingOffset); currentItemIndex++) { bool matchedItem = false; for (int i = 0; i < this.forSaleButtons.Count; i++) { int index = (this.currentItemIndex * 2) + i; if (this.forSale[index] == randomSaleItem) { matchedItem = true; break; } } if (matchedItem) { break; } } this.setScrollBarToCurrentIndex(); this.updateSaleButtonNeighbors(); } else if ((checkoutButton.containsPoint(x, y) || cartQuantity.containsPoint(x, y)) && itemsInCart.Count > 0) { this.monitor.Log("Starting checkout..."); isCheckingOut = true; } else { for (int i = 0; i < this.forSaleButtons.Count; i++) { if ((this.currentItemIndex * 2) + i >= this.forSale.Count || !this.forSaleButtons[i].containsPoint(x, y)) { continue; } int index = (this.currentItemIndex * 2) + i; if (this.forSale[index] != null) { // Skip if we're at max for the cart size if (itemsInCart.Count >= maxUniqueCartItems && !itemsInCart.ContainsKey(this.forSale[index])) { continue; } // DEBUG: monitor.Log($"{index} | {this.forSale[index].Name}"); int toBuy = (!Game1.oldKBState.IsKeyDown(Keys.LeftShift)) ? 1 : 5; toBuy = Math.Min(toBuy, this.forSale[index].maximumStackSize()); // Skip if we're trying to buy more then what we can in a stack via mail if (itemsInCart.ContainsKey(this.forSale[index]) && (itemsInCart[this.forSale[index]][1] >= this.forSale[index].maximumStackSize() || itemsInCart[this.forSale[index]][1] + toBuy > this.forSale[index].maximumStackSize())) { continue; } if (this.tryToPurchaseItem(this.forSale[index], toBuy, x, y, index)) { DelayedAction.playSoundAfterDelay("coin", 100); } else { Game1.dayTimeMoneyBox.moneyShakeTimer = 1000; Game1.playSound("cancel"); } } this.updateSaleButtonNeighbors(); this.setScrollBarToCurrentIndex(); return; } } }
public override bool beginUsing(GameLocation location, int x, int y, StardewValley.Farmer who) { x = (int)who.GetToolLocation(false).X; y = (int)who.GetToolLocation(false).Y; Rectangle rectangle = new Rectangle(x - Game1.tileSize / 2, y - Game1.tileSize / 2, Game1.tileSize, Game1.tileSize); if (!DataLoader.ModConfig.DisableMeat) { if (location is Farm) { foreach (FarmAnimal farmAnimal in (location as Farm).animals.Values) { if (farmAnimal.GetBoundingBox().Intersects(rectangle)) { if (farmAnimal == this._tempAnimal) { this._animal = farmAnimal; break; } else { this._tempAnimal = farmAnimal; ICue hurtSound; if (!DataLoader.ModConfig.Softmode) { if (farmAnimal.sound.Value != null) { hurtSound = Game1.soundBank.GetCue(farmAnimal.sound.Value); hurtSound.SetVariable("Pitch", 1800); hurtSound.Play(); } } else { hurtSound = Game1.soundBank.GetCue("toolCharge"); hurtSound.SetVariable("Pitch", 5000f); hurtSound.Play(); } break; } } } } else if (location is AnimalHouse) { foreach (FarmAnimal farmAnimal in (location as AnimalHouse).animals.Values) { if (farmAnimal.GetBoundingBox().Intersects(rectangle)) { if (farmAnimal == this._tempAnimal) { this._animal = farmAnimal; break; } else { this._tempAnimal = farmAnimal; ICue hurtSound; if (!DataLoader.ModConfig.Softmode) { if (farmAnimal.sound.Value != null) { hurtSound = Game1.soundBank.GetCue(farmAnimal.sound.Value); hurtSound.SetVariable("Pitch", 1800); hurtSound.Play(); } } else { hurtSound = Game1.soundBank.GetCue("toolCharge"); hurtSound.SetVariable("Pitch", 5000f); hurtSound.Play(); } break; } } } } } this.Update(who.facingDirection, 0, who); if (this._tempAnimal != null && this._tempAnimal.age.Value < (int)this._tempAnimal.ageWhenMature.Value) { string dialogue = DataLoader.i18n.Get("Tool.MeatCleaver.TooYoung" + _sufix, new { animalName = this._tempAnimal.displayName }); DelayedAction.showDialogueAfterDelay(dialogue, 150); this._tempAnimal = null; } who.EndUsingTool(); return(true); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); int damage = GetAttackPower(MinDC, MaxDC); int distance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation); int delay = distance * 50 + 750; //50 MS per Step int rd = RandomUtils.Next(100); if (rd < 50) { attType = 0; } else if (rd < 80) { attType = 1; } else { attType = 2; } if (attType == 0) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.ACAgility); ActionList.Add(action); } if (attType == 1) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage * 2, DefenceType.MAC); ActionList.Add(action); } if (attType == 2) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 }); List <MapObject> list = FindAllTargets(3, CurrentLocation, false); foreach (MapObject ob in list) { if (!ob.IsAttackTarget(this)) { continue; } DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage * 3 / 2, DefenceType.MAC); ActionList.Add(action); //冰冻 if (RandomUtils.Next(Settings.PoisonResistWeight) >= Target.PoisonResist && RandomUtils.Next(2) == 1) { ob.ApplyPoison(new Poison { Owner = this, Duration = RandomUtils.Next(4, 10), PType = PoisonType.Slow, Value = damage / 3, TickSpeed = 1000 }, this); if (RandomUtils.Next(5) == 1) { ob.ApplyPoison(new Poison { Owner = this, Duration = RandomUtils.Next(2, 5), PType = PoisonType.Frozen, Value = damage / 3, TickSpeed = 1000 }, this); } } } } ShockTime = 0; ActionTime = Envir.Time + 500; AttackTime = Envir.Time + (AttackSpeed); }
public static void DelayLocalAction(DelayedAction delayedAction) { UFE.delayedLocalActions.Add(delayedAction); }
protected void Init() { MouseMove += new MouseEventHandler(OnMouseMove); Loaded += (sender, e) => OnLoaded(); SizeChanged += (sender, e) => Rearrange.Postpone(); Canvas = new Canvas(); Widgets = new List<WidgetItemContainer>(); Action = EditAction.None; Rearrange = new DelayedAction(); Edit = new DelayedAction<MouseButtonEventArgs>(); XUnit = 50; YUnit = 50; Content = Canvas; Edit.Action = (e) => { Handle_Mouse_Up(e); }; //Rearrange.Action = () => //{ // var map = GetMap(); // foreach (var container in Widgets) // { // var spot = map.FindArea(container.DWidth(XUnit), container.DHeight(YUnit)); // if (spot != null) // { // Canvas.SetTop(container, spot.Y * YUnit); // Canvas.SetLeft(container, spot.X * XUnit); // map.Set_ActualBusy(container, XUnit, YUnit); // } // } //}; var colors = new Color[] { Colors.Red, Colors.Blue, Colors.Gray, Colors.Green}; var rnd = new Random(DateTime.Now.Millisecond); Background = new SolidColorBrush(colors[rnd.Next(4)]); }
public override void receiveLeftClick(int x, int y, bool playSound = true) { foreach (ClickableComponent current in this.equipmentIcons) { if (current.containsPoint(x, y)) { bool flag = this.heldItem == null; string name = current.name; if (!(name == "Hat")) { if (!(name == "Left Ring")) { if (!(name == "Right Ring")) { if (name == "Boots") { if (this.heldItem == null || this.heldItem is Boots) { Boots boots = (Boots)this.heldItem; this.heldItem = Game1.player.boots; Game1.player.boots = boots; if (this.heldItem != null) { (this.heldItem as Boots).onUnequip(); } if (Game1.player.boots != null) { Game1.player.boots.onEquip(); } if (this.heldItem == null) { Game1.playSound("sandyStep"); DelayedAction.playSoundAfterDelay("sandyStep", 150); } else { Game1.playSound("dwop"); } } } } else if (this.heldItem == null || this.heldItem is Ring) { Ring rightRing = (Ring)this.heldItem; this.heldItem = Game1.player.rightRing; Game1.player.rightRing = rightRing; if (this.heldItem != null) { (this.heldItem as Ring).onUnequip(Game1.player); } if (Game1.player.rightRing != null) { Game1.player.rightRing.onEquip(Game1.player); } if (this.heldItem == null) { Game1.playSound("crit"); } else { Game1.playSound("dwop"); } } } else if (this.heldItem == null || this.heldItem is Ring) { Ring leftRing = (Ring)this.heldItem; this.heldItem = Game1.player.leftRing; Game1.player.leftRing = leftRing; if (this.heldItem != null) { (this.heldItem as Ring).onUnequip(Game1.player); } if (Game1.player.leftRing != null) { Game1.player.leftRing.onEquip(Game1.player); } if (this.heldItem == null) { Game1.playSound("crit"); } else { Game1.playSound("dwop"); } } } else if (this.heldItem == null || this.heldItem is Hat) { Hat hat = (Hat)this.heldItem; this.heldItem = Game1.player.hat; Game1.player.hat = hat; if (this.heldItem == null) { Game1.playSound("grassyStep"); } else { Game1.playSound("dwop"); } } if (flag && this.heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift)) { for (int i = 0; i < Game1.player.items.Count; i++) { if (Game1.player.items[i] == null || Game1.player.items[i].canStackWith(this.heldItem)) { if (Game1.player.CurrentToolIndex == i && this.heldItem != null) { this.heldItem.actionWhenBeingHeld(Game1.player); } this.heldItem = Utility.addItemToInventory(this.heldItem, i, this.inventory.actualInventory, null); if (Game1.player.CurrentToolIndex == i && this.heldItem != null) { this.heldItem.actionWhenStopBeingHeld(Game1.player); } Game1.playSound("stoneStep"); return; } } } } } this.heldItem = this.inventory.leftClick(x, y, this.heldItem, !Game1.oldKBState.IsKeyDown(Keys.LeftShift)); if (this.heldItem != null && this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).ParentSheetIndex == 434) { Game1.playSound("smallSelect"); Game1.playerEatObject(this.heldItem as StardewValley.Object, true); this.heldItem = null; Game1.exitActiveMenu(); } else if (this.heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift)) { if (this.heldItem is Ring) { if (Game1.player.leftRing == null) { Game1.player.leftRing = (this.heldItem as Ring); (this.heldItem as Ring).onEquip(Game1.player); this.heldItem = null; Game1.playSound("crit"); return; } if (Game1.player.rightRing == null) { Game1.player.rightRing = (this.heldItem as Ring); (this.heldItem as Ring).onEquip(Game1.player); this.heldItem = null; Game1.playSound("crit"); return; } } else if (this.heldItem is Hat) { if (Game1.player.hat == null) { Game1.player.hat = (this.heldItem as Hat); Game1.playSound("grassyStep"); this.heldItem = null; return; } } else if (this.heldItem is Boots && Game1.player.boots == null) { Game1.player.boots = (this.heldItem as Boots); (this.heldItem as Boots).onEquip(); Game1.playSound("sandyStep"); DelayedAction.playSoundAfterDelay("sandyStep", 150); this.heldItem = null; return; } if (this.inventory.getInventoryPositionOfClick(x, y) >= 12) { for (int j = 0; j < 12; j++) { if (Game1.player.items[j] == null || Game1.player.items[j].canStackWith(this.heldItem)) { if (Game1.player.CurrentToolIndex == j && this.heldItem != null) { this.heldItem.actionWhenBeingHeld(Game1.player); } this.heldItem = Utility.addItemToInventory(this.heldItem, j, this.inventory.actualInventory, null); if (this.heldItem != null) { this.heldItem.actionWhenStopBeingHeld(Game1.player); } Game1.playSound("stoneStep"); return; } } } } if (this.portrait.containsPoint(x, y)) { this.portrait.name = (this.portrait.name.Equals("32") ? "8" : "32"); } if (this.heldItem != null && this.trashCan.containsPoint(x, y) && this.heldItem.canBeTrashed()) { if (this.heldItem is StardewValley.Object && Game1.player.specialItems.Contains((this.heldItem as StardewValley.Object).parentSheetIndex)) { Game1.player.specialItems.Remove((this.heldItem as StardewValley.Object).parentSheetIndex); } this.heldItem = null; Game1.playSound("trashcan"); } else if (this.heldItem != null && !this.isWithinBounds(x, y) && this.heldItem.canBeTrashed()) { Game1.playSound("throwDownITem"); Game1.createItemDebris(this.heldItem, Game1.player.getStandingPosition(), Game1.player.FacingDirection); this.heldItem = null; } if (this.organizeButton != null && this.organizeButton.containsPoint(x, y)) { ItemGrabMenu.organizeItemsInList(Game1.player.items); Game1.playSound("Ship"); } }
protected void Init() { MouseMove += new MouseEventHandler(OnMouseMove); Loaded += (sender, e) => OnLoaded(); SizeChanged += (sender, e) => Rearrange.Postpone(); Widgets = new List<WidgetItemContainer>(); Action = EditAction.None; Rearrange = new DelayedAction(); XUnit = 50; YUnit = 50; Rearrange.Action = () => { var map = GetMap(); //map.AutoEnlargeX = true; map.AutoEnlargeY = true; foreach (var container in Widgets) { var spot = map.FindArea(container.DWidth(XUnit), container.DHeight(YUnit)); if (spot != null) { Canvas.SetTop(container, spot.Y * YUnit); Canvas.SetLeft(container, spot.X * XUnit); map.Set_ActualBusy(container, XUnit, YUnit); } } InvalidateArrange(); }; var colors = new Color[] { Colors.Red, Colors.Blue, Colors.Gray, Colors.Green}; var rnd = new Random(DateTime.Now.Millisecond); Background = new SolidColorBrush(colors[rnd.Next(4)]); }
internal static void StrikeLightningSafely() { Random random = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed + Game1.timeOfDay); if (random.NextDouble() < 0.125 + Game1.dailyLuck + Game1.player.luckLevel.Value / 100.0) { if (Game1.currentLocation.IsOutdoors && !(Game1.currentLocation is Desert) && !Game1.newDay) { Game1.flashAlpha = (float)(0.5 + random.NextDouble()); Game1.playSound("thunder"); } GameLocation locationFromName = Game1.getLocationFromName("Farm"); List <Vector2> source = new List <Vector2>(); foreach (KeyValuePair <Vector2, SObject> pair in locationFromName.objects.Pairs) { if (pair.Value.bigCraftable.Value && pair.Value.ParentSheetIndex == 9) { source.Add(pair.Key); } } if (source.Count > 0) { for (int index1 = 0; index1 < 2; ++index1) { Vector2 index2 = source.ElementAt <Vector2>(random.Next(source.Count)); if (locationFromName.objects[index2].heldObject.Value == null) { locationFromName.objects[index2].heldObject.Value = new SObject(787, 1, false, -1, 0); locationFromName.objects[index2].MinutesUntilReady = 3000 - Game1.timeOfDay; locationFromName.objects[index2].shakeTimer = 1000; if (!(Game1.currentLocation is Farm)) { return; } Utility.drawLightningBolt(index2 * 64f + new Vector2(32f, 0.0f), locationFromName); return; } } } if (random.NextDouble() >= 0.25 - Game1.dailyLuck - Game1.player.luckLevel.Value / 100.0) { return; } Vector2 pos = locationFromName.terrainFeatures.Pairs.ElementAt(random.Next(locationFromName.terrainFeatures.Count())).Key; Utility.drawLightningBolt(pos * 64f + new Vector2(32f, (float)sbyte.MinValue), locationFromName); } else { if (random.NextDouble() >= 0.1 || !Game1.currentLocation.IsOutdoors || (Game1.currentLocation is Desert || Game1.newDay)) { return; } Game1.flashAlpha = (float)(0.5 + random.NextDouble()); if (random.NextDouble() < 0.5) { DelayedAction.screenFlashAfterDelay((float)(0.3 + random.NextDouble()), random.Next(500, 1000), ""); } DelayedAction.playSoundAfterDelay("thunder_small", random.Next(500, 1500), (GameLocation)null); } }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; if (!ranged) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); if (damage == 0) { return; } Target.Attacked(this, damage, DefenceType.MACAgility); } else { if (Envir.Random.Next(3) > 0) { AttackTime = Envir.Time + AttackSpeed + 500; Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 }); int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]); if (damage == 0) { return; } LineAttack(6, 500, DefenceType.MACAgility); DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC); ActionList.Add(action); } else { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 }); int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]); AttackTime = Envir.Time + AttackSpeed + 500; if (damage == 0) { return; } DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC); ActionList.Add(action); } } }
/********* ** Private methods *********/ /// <summary>The method to call before <see cref="MilkPail.beginUsing"/>.</summary> private static bool Before_BeginUsing(Shears __instance, GameLocation location, int x, int y, Farmer who, ref bool __result) { x = (int)who.GetToolLocation().X; y = (int)who.GetToolLocation().Y; Rectangle toolRect = new Rectangle(x - 32, y - 32, 64, 64); var animalField = Mod.Instance.Helper.Reflection.GetField <FarmAnimal>(__instance, "animal"); var animal = animalField.GetValue(); if (location is IAnimalLocation animalLoc) { animalField.SetValue(animal = Utility.GetBestHarvestableFarmAnimal(animalLoc.Animals.Values, __instance, toolRect)); } if (animal != null && animal.currentProduce.Value > 0 && (animal.age.Value >= animal.ageWhenMature.Value && animal.toolUsedForHarvest.Value.Equals(__instance.BaseName)) && who.couldInventoryAcceptThisObject(animal.currentProduce.Value, 1)) { animal.doEmote(20); animal.friendshipTowardFarmer.Value = Math.Min(1000, animal.friendshipTowardFarmer.Value + 5); who.currentLocation.localSound("Milking"); animal.pauseTimer = 1500; } else if (animal != null && animal.currentProduce.Value > 0 && animal.age.Value >= animal.ageWhenMature.Value) { if (who != null && Game1.player.Equals(who)) { if (!animal.toolUsedForHarvest.Value.Equals(__instance.BaseName)) { if (animal.toolUsedForHarvest.Value != null && !animal.toolUsedForHarvest.Value.Equals("null")) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:MilkPail.cs.14167", animal.toolUsedForHarvest.Value)); } } else if (!who.couldInventoryAcceptThisObject(animal.currentProduce.Value, 1)) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588")); } } } else if (who != null && Game1.player.Equals(who)) { DelayedAction.playSoundAfterDelay("fishingRodBend", 300); DelayedAction.playSoundAfterDelay("fishingRodBend", 1200); string dialogue = ""; if (animal != null && !animal.toolUsedForHarvest.Value.Equals(__instance.BaseName)) { dialogue = Game1.content.LoadString("Strings\\StringsFromCSFiles:MilkPail.cs.14175", animal.displayName); } if (animal != null && animal.isBaby() && animal.toolUsedForHarvest.Value.Equals(__instance.BaseName)) { dialogue = Game1.content.LoadString("Strings\\StringsFromCSFiles:MilkPail.cs.14176", animal.displayName); } if (animal != null && animal.age.Value >= animal.ageWhenMature.Value && animal.toolUsedForHarvest.Value.Equals(__instance.BaseName)) { dialogue = Game1.content.LoadString("Strings\\StringsFromCSFiles:MilkPail.cs.14177", animal.displayName); } if (dialogue.Length > 0) { DelayedAction.showDialogueAfterDelay(dialogue, 1000); } } who.Halt(); int currentFrame = who.FarmerSprite.CurrentFrame; who.FarmerSprite.animateOnce(287 + who.FacingDirection, 50f, 4); who.FarmerSprite.oldFrame = currentFrame; who.UsingTool = true; who.CanMove = false; return(true); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1); if (!ranged) { ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinDC, MaxDC); Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); if (damage == 0) { return; } Target.Attacked(this, damage, DefenceType.ACAgility); } else { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinMC, MaxMC); if (damage == 0) { return; } int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MACAgility); ActionList.Add(action); if (Envir.Random.Next(8) == 0) { Target.ApplyPoison(new Poison { Owner = this, Duration = 15, PType = PoisonType.Slow, TickSpeed = 1000 }, this); } if (Envir.Random.Next(15) == 0) { Target.ApplyPoison(new Poison { Owner = this, PType = PoisonType.Frozen, Duration = 5, TickSpeed = 1000 }, this); } } if (Target.Dead) { FindTarget(); } }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; if (!ranged) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); int damage = GetAttackPower(MinDC, MaxDC); if (damage == 0) { return; } Target.Attacked(this, damage, DefenceType.ACAgility); } else { { if (Envir.Random.Next(3) > 0) { //Ice Attack Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); AttackTime = Envir.Time + AttackSpeed + 500; int damage = GetAttackPower(MinMC, MaxMC); if (damage == 0) { return; } DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MAC); ActionList.Add(action); if (Envir.Random.Next(Settings.PoisonResistWeight) >= Target.PoisonResist) { if (Envir.Random.Next(5) == 0) { Target.ApplyPoison(new Poison { Owner = this, Duration = 5, PType = PoisonType.Slow, Value = GetAttackPower(MinSC, MaxSC), TickSpeed = 1000 }, this); } if (Envir.Random.Next(10) == 0) { Target.ApplyPoison(new Poison { Owner = this, Duration = 3, PType = PoisonType.Frozen, Value = GetAttackPower(MinSC, MaxSC), TickSpeed = 1000 }, this); } } } else { //Fire Attack Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 }); AttackTime = Envir.Time + AttackSpeed + 500; int damage = GetAttackPower(MinMC, MaxMC); if (damage == 0) { return; } DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MAC); ActionList.Add(action); } } } if (Target.Dead) { FindTarget(); } }
public static void Add(Action func, int time) { var action = new DelayedAction(time, func); ActionList.Add(action); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } DelayedAction action; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1); int damage = 0; if (ranged) { if (tornado) { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0, TargetID = Target.ObjectID }); damage = GetAttackPower(MinDC, MaxDC); List<MapObject> targets = FindAllTargets(1, Target.CurrentLocation); for (int i = 0; i < targets.Count; i++) { action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 1000, targets[i], damage, DefenceType.ACAgility); ActionList.Add(action); } ActionTime = Envir.Time + 800; AttackTime = Envir.Time + AttackSpeed; tornado = false; return; } } if (!ranged) { if (stomp) { //Foot stomp Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 }); MirDirection dir = Functions.PreviousDir(Direction); Point tar; Cell cell; damage = GetAttackPower(MinDC, MaxDC); for (int i = 0; i < 8; i++) { tar = Functions.PointMove(CurrentLocation, dir, 1); dir = Functions.NextDir(dir); if (!CurrentMap.ValidPoint(tar)) continue; cell = CurrentMap.GetCell(tar); if (cell.Objects == null) continue; for (int o = 0; o < cell.Objects.Count; o++) { MapObject ob = cell.Objects[o]; if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) continue; if (!ob.IsAttackTarget(this)) continue; action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, AttackType.Stomp); ActionList.Add(action); break; } } ActionTime = Envir.Time + 800; AttackTime = Envir.Time + AttackSpeed; stomp = false; return; } switch (Envir.Random.Next(2)) { case 0: //Slash Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); damage = GetAttackPower(MinDC, MaxDC); action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, AttackType.SingleSlash); ActionList.Add(action); damage = GetAttackPower(MinDC, MaxDC); action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.ACAgility, AttackType.SingleSlash); ActionList.Add(action); break; case 1: //Two hand slash Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); damage = GetAttackPower(MinDC, MaxDC); action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, AttackType.SingleSlash); ActionList.Add(action); break; } if (Envir.Random.Next(5) == 0) stomp = true; if (Envir.Random.Next(2) == 0) tornado = true; } ActionTime = Envir.Time + 500; AttackTime = Envir.Time + AttackSpeed; ShockTime = 0; }
private void LineAttack(int distance) { int damage = GetAttackPower(MinDC, MaxDC); if (damage == 0) return; for (int i = 1; i <= distance; i++) { Point target = Functions.PointMove(CurrentLocation, Direction, i); if (target == Target.CurrentLocation) Target.Attacked(this, damage, DefenceType.MACAgility); else { if (!CurrentMap.ValidPoint(target)) continue; Cell cell = CurrentMap.GetCell(target); if (cell.Objects == null) continue; for (int o = 0; o < cell.Objects.Count; o++) { MapObject ob = cell.Objects[o]; if (ob.Race == ObjectType.Monster || ob.Race == ObjectType.Player) { if (!ob.IsAttackTarget(this)) continue; int delay = Functions.MaxDistance(CurrentLocation, ob.CurrentLocation) * 50 + 300; //50 MS per Step DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, DefenceType.MACAgility); ActionList.Add(action); } else continue; break; } } } }
public static void DelaySynchronizedAction(DelayedAction delayedAction) { UFE.delayedSynchronizedActions.Add(delayedAction); }
protected void playSound(string soundName, int delay = 0) { DelayedAction.playSoundAfterDelay(soundName, delay, Game1.currentLocation); }
protected override void Attack() { if (!Target.IsAttackTarget(this) || NoAttack) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !InAttackRange(); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(MinDC, MaxDC); if (!ranged && Envir.Random.Next(5) > 0) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); if (damage == 0) return; Target.Attacked(this, damage, DefenceType.MACAgility); } else { AttackTime = Envir.Time + AttackSpeed + 500; if (damage == 0) return; if (InRangedAttackRange(PoisonAttackRange) && Envir.Random.Next(6) == 0) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); if (Envir.Random.Next(Settings.PoisonResistWeight) >= Target.PoisonResist) { Target.ApplyPoison(new Poison { Owner = this, Duration = 6, PType = PoisonType.Red, TickSpeed = 2000 }, this); } } else { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MAC); ActionList.Add(action); } } if (Target.Dead) FindTarget(); }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; switch (Envir.Random.Next(0, 6)) { case 0: { Retreat(); } break; case 1: { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); if (damage == 0) { return; } DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 400, Target, damage / 2, DefenceType.ACAgility); ActionList.Add(action); action = new DelayedAction(DelayedType.Damage, Envir.Time + 600, Target, damage / 2, DefenceType.ACAgility); ActionList.Add(action); action = new DelayedAction(DelayedType.Damage, Envir.Time + 800, Target, damage / 2, DefenceType.ACAgility); ActionList.Add(action); } break; default: { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); if (damage == 0) { return; } DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 400, Target, damage, DefenceType.ACAgility); ActionList.Add(action); } break; } }
public override void receiveLeftClick(int x, int y, bool playSound = true) { foreach (ClickableComponent c in equipmentIcons) { if (c.containsPoint(x, y)) { bool heldItemWasNull = !checkHeldItem(); switch (c.name) { case "Hat": if (checkHeldItem((Item i) => i == null || i is Hat || i is Pan)) { Hat tmp = (Game1.player.CursorSlotItem is Pan) ? new Hat(71) : ((Hat)takeHeldItem()); Item heldItem2 = (Hat)Game1.player.hat; heldItem2 = Utility.PerformSpecialItemGrabReplacement(heldItem2); setHeldItem(heldItem2); Game1.player.hat.Value = tmp; if (Game1.player.hat.Value != null) { Game1.playSound("grassyStep"); } else if (checkHeldItem()) { Game1.playSound("dwop"); } } break; case "Left Ring": if (checkHeldItem((Item i) => i == null || i is Ring)) { Ring tmp2 = (Ring)takeHeldItem(); if (Game1.player.leftRing.Value != null) { Game1.player.leftRing.Value.onUnequip(Game1.player, Game1.currentLocation); } setHeldItem((Ring)Game1.player.leftRing); Game1.player.leftRing.Value = tmp2; if (Game1.player.leftRing.Value != null) { Game1.player.leftRing.Value.onEquip(Game1.player, Game1.currentLocation); Game1.playSound("crit"); } else if (checkHeldItem()) { Game1.playSound("dwop"); } } break; case "Right Ring": if (checkHeldItem((Item i) => i == null || i is Ring)) { Ring tmp3 = (Ring)takeHeldItem(); if (Game1.player.rightRing.Value != null) { Game1.player.rightRing.Value.onUnequip(Game1.player, Game1.currentLocation); } setHeldItem((Ring)Game1.player.rightRing); Game1.player.rightRing.Value = tmp3; if (Game1.player.rightRing.Value != null) { Game1.player.rightRing.Value.onEquip(Game1.player, Game1.currentLocation); Game1.playSound("crit"); } else if (checkHeldItem()) { Game1.playSound("dwop"); } } break; case "Boots": if (checkHeldItem((Item i) => i == null || i is Boots)) { Boots tmp4 = (Boots)takeHeldItem(); if (Game1.player.boots.Value != null) { Game1.player.boots.Value.onUnequip(); } setHeldItem((Boots)Game1.player.boots); Game1.player.boots.Value = tmp4; if (Game1.player.boots.Value != null) { Game1.player.boots.Value.onEquip(); Game1.playSound("sandyStep"); DelayedAction.playSoundAfterDelay("sandyStep", 150); } else if (checkHeldItem()) { Game1.playSound("dwop"); } } break; case "Shirt": if (checkHeldItem((Item i) => i == null || (i is Clothing && (i as Clothing).clothesType.Value == 0))) { Clothing tmp5 = (Clothing)takeHeldItem(); Item heldItem4 = (Clothing)Game1.player.shirtItem; heldItem4 = Utility.PerformSpecialItemGrabReplacement(heldItem4); setHeldItem(heldItem4); Game1.player.shirtItem.Value = tmp5; if (Game1.player.shirtItem.Value != null) { Game1.playSound("sandyStep"); } else if (checkHeldItem()) { Game1.playSound("dwop"); } } break; case "Pants": if (checkHeldItem((Item i) => i == null || (i is Clothing && (i as Clothing).clothesType.Value == 1) || (i is Object && (int)i.parentSheetIndex == 71))) { Clothing tmp6 = (Game1.player.CursorSlotItem is Object && (int)Game1.player.CursorSlotItem.parentSheetIndex == 71) ? new Clothing(15) : ((Clothing)takeHeldItem()); Item heldItem6 = (Clothing)Game1.player.pantsItem; heldItem6 = Utility.PerformSpecialItemGrabReplacement(heldItem6); setHeldItem(heldItem6); Game1.player.pantsItem.Value = tmp6; if (Game1.player.pantsItem.Value != null) { Game1.playSound("sandyStep"); } else if (checkHeldItem()) { Game1.playSound("dwop"); } } break; } if (heldItemWasNull && checkHeldItem() && Game1.oldKBState.IsKeyDown(Keys.LeftShift)) { int l; for (l = 0; l < Game1.player.items.Count; l++) { if (Game1.player.items[l] == null || checkHeldItem((Item item) => Game1.player.items[l].canStackWith(item))) { if (Game1.player.CurrentToolIndex == l && checkHeldItem()) { Game1.player.CursorSlotItem.actionWhenBeingHeld(Game1.player); } setHeldItem(Utility.addItemToInventory(takeHeldItem(), l, inventory.actualInventory)); if (Game1.player.CurrentToolIndex == l && checkHeldItem()) { Game1.player.CursorSlotItem.actionWhenStopBeingHeld(Game1.player); } Game1.playSound("stoneStep"); return; } } } } } setHeldItem(inventory.leftClick(x, y, takeHeldItem(), !Game1.oldKBState.IsKeyDown(Keys.LeftShift))); if (checkHeldItem((Item i) => i != null && i is Object && (i as Object).ParentSheetIndex == 434)) { Game1.playSound("smallSelect"); Game1.player.eatObject(takeHeldItem() as Object, overrideFullness: true); Game1.exitActiveMenu(); } else if (checkHeldItem() && Game1.oldKBState.IsKeyDown(Keys.LeftShift)) { if (checkHeldItem((Item i) => i is Ring)) { if (Game1.player.leftRing.Value == null) { Game1.player.leftRing.Value = (takeHeldItem() as Ring); Game1.player.leftRing.Value.onEquip(Game1.player, Game1.currentLocation); Game1.playSound("crit"); return; } if (Game1.player.rightRing.Value == null) { Game1.player.rightRing.Value = (takeHeldItem() as Ring); Game1.player.rightRing.Value.onEquip(Game1.player, Game1.currentLocation); Game1.playSound("crit"); return; } } else if (checkHeldItem((Item i) => i is Hat)) { if (Game1.player.hat.Value == null) { Game1.player.hat.Value = (takeHeldItem() as Hat); Game1.playSound("grassyStep"); return; } } else if (checkHeldItem((Item i) => i is Boots)) { if (Game1.player.boots.Value == null) { Game1.player.boots.Value = (takeHeldItem() as Boots); Game1.player.boots.Value.onEquip(); Game1.playSound("sandyStep"); DelayedAction.playSoundAfterDelay("sandyStep", 150); return; } } else if (checkHeldItem((Item i) => i is Clothing && (i as Clothing).clothesType.Value == 0)) { if (Game1.player.shirtItem.Value == null) { Game1.player.shirtItem.Value = (takeHeldItem() as Clothing); Game1.playSound("sandyStep"); DelayedAction.playSoundAfterDelay("sandyStep", 150); return; } } else if (checkHeldItem((Item i) => i is Clothing && (i as Clothing).clothesType.Value == 1) && Game1.player.pantsItem.Value == null) { Game1.player.pantsItem.Value = (takeHeldItem() as Clothing); Game1.playSound("sandyStep"); DelayedAction.playSoundAfterDelay("sandyStep", 150); return; } if (inventory.getInventoryPositionOfClick(x, y) >= 12) { int k; for (k = 0; k < 12; k++) { if (Game1.player.items[k] == null || checkHeldItem((Item item) => Game1.player.items[k].canStackWith(item))) { if (Game1.player.CurrentToolIndex == k && checkHeldItem()) { Game1.player.CursorSlotItem.actionWhenBeingHeld(Game1.player); } setHeldItem(Utility.addItemToInventory(takeHeldItem(), k, inventory.actualInventory)); if (checkHeldItem()) { Game1.player.CursorSlotItem.actionWhenStopBeingHeld(Game1.player); } Game1.playSound("stoneStep"); return; } } } else if (inventory.getInventoryPositionOfClick(x, y) < 12) { int j; for (j = 12; j < Game1.player.items.Count; j++) { if (Game1.player.items[j] == null || checkHeldItem((Item item) => Game1.player.items[j].canStackWith(item))) { if (Game1.player.CurrentToolIndex == j && checkHeldItem()) { Game1.player.CursorSlotItem.actionWhenBeingHeld(Game1.player); } setHeldItem(Utility.addItemToInventory(takeHeldItem(), j, inventory.actualInventory)); if (checkHeldItem()) { Game1.player.CursorSlotItem.actionWhenStopBeingHeld(Game1.player); } Game1.playSound("stoneStep"); return; } } } } if (portrait.containsPoint(x, y)) { portrait.name = (portrait.name.Equals("32") ? "8" : "32"); } if (trashCan.containsPoint(x, y) && checkHeldItem((Item i) => i?.canBeTrashed() ?? false)) { Utility.trashItem(takeHeldItem()); if (Game1.options.SnappyMenus) { snapCursorToCurrentSnappedComponent(); } } else if (!isWithinBounds(x, y) && checkHeldItem((Item i) => i?.canBeTrashed() ?? false)) { Game1.playSound("throwDownITem"); Game1.createItemDebris(takeHeldItem(), Game1.player.getStandingPosition(), Game1.player.FacingDirection).DroppedByPlayerID.Value = Game1.player.UniqueMultiplayerID; } if (organizeButton != null && organizeButton.containsPoint(x, y)) { ItemGrabMenu.organizeItemsInList(Game1.player.items); Game1.playSound("Ship"); } if (junimoNoteIcon != null && junimoNoteIcon.containsPoint(x, y) && readyToClose()) { Game1.activeClickableMenu = new JunimoNoteMenu(fromGameMenu: true); } }
private void Update() { Rules rules = gameManager.Rules; // Check if trick is finished if (gameManager.Rules.TrickIsFinished(Game.CurrentTrick)) { LastTrickWinner = rules.TrickWinner(Game.CurrentTrick); } else { // Reset last trick winner when trick is cleared LastTrickWinner = -1; } // Make AI actions for (int i = 0; i < Game.NumberOfPlayers; i++) { int player = i; // Check if player is an AI player if (GetPlayerByIndex(player) is HumanPlayerViewModel == false) { // No delay for pass actions if (rules.CanPassCards(player)) { aiPlayer.MakeAction(gameManager, player); } // Delay play actions if (rules.CanPlay(player)) { delayedAction = new DelayedAction(); delayedAction.Delay = aiDelay; delayedAction.Action = new Action(() => { aiPlayer.MakeAction(gameManager, player); }); delayedAction.Execute(); } } } // Check if waiting for new turn if (rules.CanStartNewTurn()) { gameManager.StartNewTurn(); } // Ceck if trick is finished if (rules.CanClearTrick()) { delayedAction = new DelayedAction(); delayedAction.Delay = clearTrickDelay; delayedAction.Action = new Action(() => { gameManager.ClearTrick(); }); delayedAction.Execute(); } }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); int damage = GetAttackPower(MinDC, MaxDC); if (_stage == 1) { damage = damage * 3 / 2; } int distance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation); int delay = distance * 50 + 500; //50 MS per Step DelayedAction action = null; byte _AttackType = AttackType; int rd = RandomUtils.Next(100); if (rd < 60) { AttackType = 0; } else if (rd < 80) { AttackType = 1; } else { AttackType = 2; } //狂暴状态增加这个的几率 if (_AttackType != 1 && _stage == 1 && RandomUtils.Next(100) < 30) { AttackType = 1; } if (_AttackType == 1 && RandomUtils.Next(100) < 60) { AttackType = 2; } switch (AttackType) { case 0: Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage * 3 / 2, DefenceType.ACAgility); ActionList.Add(action); break; case 1: Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); List <MapObject> list = CurrentMap.getMapObjects(Target.CurrentLocation.X, Target.CurrentLocation.Y, 2); foreach (MapObject ob in list) { if (!ob.IsAttackTarget(this)) { continue; } action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, DefenceType.MACAgility); ActionList.Add(action); if (ob.Race == ObjectType.Player) { //范围冰冻 if (RandomUtils.Next(Settings.PoisonResistWeight) >= Target.PoisonResist) { Target.ApplyPoison(new Poison { Owner = this, Duration = RandomUtils.Next(3, 5), PType = PoisonType.Frozen, Value = damage, TickSpeed = 1000 }, this); } } else { //范围冰冻 if (RandomUtils.Next(Settings.PoisonResistWeight) >= Target.PoisonResist) { Target.ApplyPoison(new Poison { Owner = this, Duration = RandomUtils.Next(8, 20), PType = PoisonType.Frozen, Value = damage, TickSpeed = 1000 }, this); } } } break; case 2: Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 }); action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage * 3 / 2, DefenceType.MACAgility); ActionList.Add(action); action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 800, Target, damage * 2, DefenceType.MACAgility); ActionList.Add(action); break; } ShockTime = 0; ActionTime = Envir.Time + 500; AttackTime = Envir.Time + (AttackSpeed); }
public override void UpdateWhenCurrentLocation(GameTime time) { base.UpdateWhenCurrentLocation(time); foreach (SuspensionBridge suspensionBridge in suspensionBridges) { suspensionBridge.Update(time); } if (!caveOpened && Utility.isOnScreen(Utility.PointToVector2(boulderPosition.Location), 1)) { boulderKnockTimer -= (float)time.ElapsedGameTime.TotalMilliseconds; boulderTextTimer -= (float)time.ElapsedGameTime.TotalMilliseconds; if (doneHittingBoulderWithToolTimer > 0f) { doneHittingBoulderWithToolTimer -= (float)time.ElapsedGameTime.TotalMilliseconds; if (doneHittingBoulderWithToolTimer <= 0f) { boulderTextTimer = 2000f; boulderTextString = Game1.content.LoadString("Strings\\Locations:IslandNorth_CaveTool_" + Game1.random.Next(4)); } } if (boulderKnocksLeft > 0) { if (boulderKnockTimer < 0f) { Game1.playSound("hammer"); boulderKnocksLeft--; boulderKnockTimer = 500f; if (boulderKnocksLeft == 0 && Game1.random.NextDouble() < 0.5) { DelayedAction.functionAfterDelay(delegate { boulderTextTimer = 2000f; boulderTextString = Game1.content.LoadString("Strings\\Locations:IslandNorth_CaveHelp_" + Game1.random.Next(4)); }, 1000); } } } else if (Game1.random.NextDouble() < 0.002 && boulderTextTimer < -500f) { boulderKnocksLeft = Game1.random.Next(3, 6); } } if (!_sawFlameSpriteSouth && Utility.isThereAFarmerWithinDistance(new Vector2(36f, 79f), 5, this) == Game1.player) { Game1.addMailForTomorrow("Saw_Flame_Sprite_North_South", noLetter: true); TemporaryAnimatedSprite v4 = getTemporarySpriteByID(999); if (v4 != null) { v4.yPeriodic = false; v4.xPeriodic = false; v4.sourceRect.Y = 0; v4.sourceRectStartingPos.Y = 0f; v4.motion = new Vector2(1f, -4f); v4.acceleration = new Vector2(0f, -0.04f); v4.drawAboveAlwaysFront = true; } localSound("magma_sprite_spot"); v4 = getTemporarySpriteByID(998); if (v4 != null) { v4.yPeriodic = false; v4.xPeriodic = false; v4.motion = new Vector2(1f, -4f); v4.acceleration = new Vector2(0f, -0.04f); } _sawFlameSpriteSouth = true; } if (!_sawFlameSpriteNorth && Utility.isThereAFarmerWithinDistance(new Vector2(41f, 30f), 5, this) == Game1.player) { Game1.addMailForTomorrow("Saw_Flame_Sprite_North_North", noLetter: true); TemporaryAnimatedSprite v2 = getTemporarySpriteByID(9999); if (v2 != null) { v2.yPeriodic = false; v2.xPeriodic = false; v2.sourceRect.Y = 0; v2.sourceRectStartingPos.Y = 0f; v2.motion = new Vector2(0f, -4f); v2.acceleration = new Vector2(0f, -0.04f); v2.yStopCoordinate = 1216; v2.reachedStopCoordinate = delegate { removeTemporarySpritesWithID(9999); }; } localSound("magma_sprite_spot"); v2 = getTemporarySpriteByID(9998); if (v2 != null) { v2.yPeriodic = false; v2.xPeriodic = false; v2.motion = new Vector2(0f, -4f); v2.acceleration = new Vector2(0f, -0.04f); v2.yStopCoordinate = 1280; v2.reachedStopCoordinate = delegate { removeTemporarySpritesWithID(9998); }; } _sawFlameSpriteNorth = true; } if (hasTriedFirstEntryDigSiteLoad) { return; } if (Game1.IsMasterGame && !Game1.player.hasOrWillReceiveMail("ISLAND_NORTH_DIGSITE_LOAD")) { Game1.addMail("ISLAND_NORTH_DIGSITE_LOAD", noLetter: true); for (int i = 0; i < 40; i++) { digSiteUpdate(); } } hasTriedFirstEntryDigSiteLoad = true; }
public override void leftClickHeld(int x, int y) { base.leftClickHeld(x, y); if (this.scrolling) { int y2 = this.scrollBar.bounds.Y; this.scrollBar.bounds.Y = Math.Min(scrollBarRunner.Bottom - 35, Math.Max(y, scrollBarRunner.Top)); float percentage = (float)(y - this.scrollBarRunner.Y) / (float)this.scrollBarRunner.Height; int correctedForSaleCount = (this.forSale.Count % 2 == 0 ? this.forSale.Count : this.forSale.Count + 1); this.currentItemIndex = Math.Min((correctedForSaleCount - buttonScrollingOffset) / 2, Math.Max(0, (int)(((float)correctedForSaleCount / 2) * percentage))); this.updateSaleButtonNeighbors(); } else if (isCheckingOut) { return; } else if (Game1.ticks >= lastTick + (60 * numberOfSecondsToDelayInput)) { for (int i = 0; i < this.forSaleButtons.Count; i++) { if (this.currentItemIndex + i >= this.forSale.Count || !this.forSaleButtons[i].containsPoint(x, y)) { continue; } int index = (this.currentItemIndex * 2) + i; if (itemsInCart.Count >= maxUniqueCartItems && !itemsInCart.ContainsKey(this.forSale[index])) { continue; } if (this.forSale[index] != null) { // Skip if we're at max for the cart size if (itemsInCart.Count >= maxUniqueCartItems && !itemsInCart.ContainsKey(this.forSale[index])) { continue; } // DEBUG: monitor.Log($"{index} | {this.forSale[index].Name}"); int toBuy = (!Game1.oldKBState.IsKeyDown(Keys.LeftShift)) ? 1 : 5; toBuy = Math.Min(toBuy, this.forSale[index].maximumStackSize()); // Skip if we're trying to buy more then what we can in a stack via mail if (itemsInCart.ContainsKey(this.forSale[index]) && (itemsInCart[this.forSale[index]][1] >= this.forSale[index].maximumStackSize() || itemsInCart[this.forSale[index]][1] + toBuy > this.forSale[index].maximumStackSize())) { continue; } if (this.tryToPurchaseItem(this.forSale[index], toBuy, x, y, index)) { DelayedAction.playSoundAfterDelay("coin", 100); } else { Game1.dayTimeMoneyBox.moneyShakeTimer = 1000; Game1.playSound("cancel"); } } this.updateSaleButtonNeighbors(); this.setScrollBarToCurrentIndex(); return; } } }
public virtual void Defer(DelayedAction action, int frames) { Defer(action, frames, SubscriptionType.Update); }
public override void DoFunction(GameLocation location, int x, int y, int power, StardewValley.Farmer who) { this.lastUser = who; //base.DoFunction(location, x, y, power, who); power = who.toolPower; who.stopJittering(); List <Vector2> source = IridiumTiles.AFTiles(new Vector2((float)(x / Game1.tileSize), (float)(y / Game1.tileSize)), power, who); if (location.doesTileHaveProperty(x / Game1.tileSize, y / Game1.tileSize, "Water", "Back") != null || location.doesTileHaveProperty(x / Game1.tileSize, y / Game1.tileSize, "WaterSource", "Back") != null || location is BuildableGameLocation && (location as BuildableGameLocation).getBuildingAt(source.First <Vector2>()) != null && ((location as BuildableGameLocation).getBuildingAt(source.First <Vector2>()).buildingType.Equals("Well") && (location as BuildableGameLocation).getBuildingAt(source.First <Vector2>()).daysOfConstructionLeft <= 0)) { who.jitterStrength = 0.5f; switch (this.upgradeLevel) { case 0: this.waterCanMax = 40; break; case 1: this.waterCanMax = 55; break; case 2: this.waterCanMax = 70; break; case 3: this.waterCanMax = 85; break; case 4: this.waterCanMax = 100; break; } this.waterLeft = this.waterCanMax; Game1.playSound("slosh"); DelayedAction.playSoundAfterDelay("glug", 250); } else if (this.waterLeft > 0) { who.Stamina -= (float)(2 * (power + 1)) - (float)who.FarmingLevel * 0.1f; int num = 0; foreach (Vector2 index in source) { //UP function in process if (location.terrainFeatures.ContainsKey(index)) { if (location.terrainFeatures.ContainsKey(index) && location.terrainFeatures[index].GetType() == typeof(HoeDirt)) { HoeDirt joeDirt = new HoeDirt(); if (location.terrainFeatures.ContainsKey(index) && location.terrainFeatures[index].GetType() == typeof(HoeDirt)) { joeDirt = (HoeDirt)location.terrainFeatures[index]; } IridiumTiles.perfWaterAction(this, 0, index, (GameLocation)null, joeDirt); } location.terrainFeatures[index].performToolAction((Tool)this, 0, index, (GameLocation)null); } if (location.objects.ContainsKey(index)) { location.Objects[index].performToolAction((Tool)this); } location.performToolAction((Tool)this, (int)index.X, (int)index.Y); location.temporarySprites.Add(new TemporaryAnimatedSprite(13, new Vector2(index.X * (float)Game1.tileSize, index.Y * (float)Game1.tileSize), Color.White, 10, Game1.random.NextDouble() < 0.5, 70f, 0, Game1.tileSize, (float)(((double)index.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2)) / 10000.0 - 0.00999999977648258), -1, 0) { delayBeforeAnimationStart = 200 + num * 10 }); ++num; } this.waterLeft -= power + 1; Vector2 vector2 = new Vector2(who.position.X - (float)(Game1.tileSize / 2) - (float)Game1.pixelZoom, who.position.Y - (float)(Game1.tileSize / 4) - (float)Game1.pixelZoom); switch (who.facingDirection) { case 0: vector2 = Vector2.Zero; break; case 1: vector2.X += (float)(Game1.tileSize * 2 + Game1.pixelZoom * 2); break; case 2: vector2.X += (float)(Game1.tileSize + Game1.pixelZoom * 2); vector2.Y += (float)(Game1.tileSize / 2 + Game1.pixelZoom * 3); break; } if (vector2.Equals(Vector2.Zero)) { return; } for (int index = 0; index < 30; ++index) { location.temporarySprites.Add(new TemporaryAnimatedSprite(Game1.staminaRect, new Microsoft.Xna.Framework.Rectangle(0, 0, 1, 1), 999f, 1, 999, vector2 + new Vector2((float)(Game1.random.Next(-3, 0) * Game1.pixelZoom), (float)(Game1.random.Next(2) * Game1.pixelZoom)), false, false, (float)(who.GetBoundingBox().Bottom + Game1.tileSize / 2) / 10000f, 0.04f, Game1.random.NextDouble() < 0.5 ? Color.DeepSkyBlue : Color.LightBlue, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { delayBeforeAnimationStart = index * 15, motion = new Vector2((float)Game1.random.Next(-10, 11) / 100f, 0.5f), acceleration = new Vector2(0.0f, 0.1f) }); } } else { who.doEmote(4); Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:WateringCan.cs.14335")); } }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1); if (!ranged) { switch (Envir.Random.Next(5)) { case 0: case 1: case 2: base.Attack(); //swipe break; case 3: { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); if (damage == 0) { return; } DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, true); ActionList.Add(action); } break; case 4: { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 }); DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, 0, DefenceType.ACAgility, false); ActionList.Add(action); } break; } PoisonTarget(Target, 15, 5, PoisonType.Bleeding); } else { if (Envir.Random.Next(2) == 0) { MoveTo(Target.CurrentLocation); } else { switch (Envir.Random.Next(2)) { case 0: Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); SpawnSlaves(); //spawn huggers break; case 1: { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]) * 3; if (damage == 0) { return; } DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.ACAgility); ActionList.Add(action); } break; } } ShockTime = 0; ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; } }
public static bool plantSappling() { if (Lists.saplingNames.Contains(Game1.player.ActiveObject.name)) { Vector2 vector = Game1.currentCursorTile; GameLocation location = Game1.player.currentLocation; Vector2 key = default(Vector2); for (int i = (int)vector.X / Game1.tileSize - 2; i <= vector.X / Game1.tileSize + 2; i++) { for (int j = (int)vector.Y / Game1.tileSize - 2; j <= vector.Y / Game1.tileSize + 2; j++) { key.X = (float)i; key.Y = (float)j; if (location.terrainFeatures.ContainsKey(key) && (location.terrainFeatures[key] is Tree || location.terrainFeatures[key] is FruitTree)) { Game1.showRedMessage("Too close to another tree"); return(false); } } } if (location.terrainFeatures.ContainsKey(vector)) { if (!(location.terrainFeatures[vector] is HoeDirt) || (location.terrainFeatures[vector] as HoeDirt).crop != null) { // Log.AsyncC("UMMM BUT BUT BUT"); return(false); } location.terrainFeatures.Remove(vector); } if ((location.doesTileHaveProperty((int)vector.X, (int)vector.Y, "Diggable", "Back") != null || location.doesTileHavePropertyNoNull((int)vector.X, (int)vector.Y, "Type", "Back").Equals("Grass"))) { Game1.playSound("dirtyHit"); DelayedAction.playSoundAfterDelay("coin", 100); location.terrainFeatures.Add(vector, new FruitTree(Game1.player.ActiveObject.parentSheetIndex)); return(true); } else { // Game1.playSound("dirtyHit"); int which = 1; int num = Game1.player.ActiveObject.parentSheetIndex; if (num != 310) { if (num == 311) { which = 3; } } else { which = 2; } location.terrainFeatures.Remove(vector); location.terrainFeatures.Add(vector, new Tree(which, 0)); Game1.player.reduceActiveItemByOne(); Game1.playSound("dirtyHit"); DelayedAction.playSoundAfterDelay("coin", 100); } Game1.showRedMessage("Can't be planted here."); return(false); } //Log.AsyncR("MAKES NO SENSE"); return(false); }
public static bool Prefix(SObject __instance, ref bool __result, GameLocation location, int x, int y, Farmer who) { //Not a sapling if (!__instance.Name.Contains("Sapling")) { return(true); } Vector2 index1 = new Vector2((float)(x / 64), (float)(y / 64)); //The original code has a check for this, but execution never actually reaches here because saplings aren't allowed to be placed on dirt //Terrain feature at the position if (location.terrainFeatures.TryGetValue(index1, out TerrainFeature feature)) { //Not dirt or the dirt has a crop if (!(feature is HoeDirt dirt) || dirt.crop != null) { return(true); } } bool nearbyTree = false; Vector2 key = new Vector2(); for (int index2 = x / 64 - 2; index2 <= x / 64 + 2; ++index2) { for (int index3 = y / 64 - 2; index3 <= y / 64 + 2; ++index3) { key.X = (float)index2; key.Y = (float)index3; if (location.terrainFeatures.ContainsKey(key) && (location.terrainFeatures[key] is Tree || location.terrainFeatures[key] is FruitTree)) { nearbyTree = true; break; } } if (nearbyTree) { break; } } bool correctTileProperties = location is Farm ? ((location.doesTileHaveProperty((int)index1.X, (int)index1.Y, "Diggable", "Back") != null || location.doesTileHavePropertyNoNull((int)index1.X, (int)index1.Y, "Type", "Back").Equals("Grass")) && !location.doesTileHavePropertyNoNull((int)index1.X, (int)index1.Y, "NoSpawn", "Back").Equals("Tree")) : (location.IsGreenhouse && (location.doesTileHaveProperty((int)index1.X, (int)index1.Y, "Diggable", "Back") != null || location.doesTileHavePropertyNoNull((int)index1.X, (int)index1.Y, "Type", "Back").Equals("Stone"))); bool gameValidLocation = location is Farm || location.IsGreenhouse; //If the game would return true, let it run if (gameValidLocation && correctTileProperties && !nearbyTree) { return(true); } //If not at farm or greenhouse and not allowed to plant outside farm, show an error bool failedBecauseOutsideFarm = !gameValidLocation && !BetterFruitTreesMod.Instance.Config.Allow_Placing_Fruit_Trees_Outside_Farm; //If at farm or greenhouse and tile properties are wrong and no dangerous planting allowed, show an error bool failedBecauseDangerousPlant = gameValidLocation && !correctTileProperties && !BetterFruitTreesMod.Instance.Config.Allow_Dangerous_Planting; if (failedBecauseOutsideFarm || failedBecauseDangerousPlant) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Object.cs.13068")); __result = false; return(false); } //Place sapling location.playSound("dirtyHit"); DelayedAction.playSoundAfterDelay("coin", 100); //If the game was going to place a tree, it removed anything at the tree index, so we do the same location.terrainFeatures.Remove(index1); location.terrainFeatures.Add(index1, new FruitTree(__instance.ParentSheetIndex) { GreenHouseTree = location.IsGreenhouse, GreenHouseTileTree = location.doesTileHavePropertyNoNull((int)index1.X, (int)index1.Y, "Type", "Back") .Equals("Stone") }); __result = true; return(false); }
public override void receiveLeftClick(int x, int y, bool playSound = true) { if (this.freeze) { return; } if (string.IsNullOrEmpty(this.TargetLocation)) { base.receiveLeftClick(x, y, playSound); } if (this.cancelButton.containsPoint(x, y)) { if (string.IsNullOrEmpty(this.TargetLocation)) { exitThisMenu(true); Game1.player.forceCanMove(); Game1.playSound("bigDeSelect"); } else { if (this.moving && this.buildingToMove != null) { Game1.playSound("cancel"); return; } Game1.globalFadeToBlack(new Game1.afterFadeFunction(returnToCarpentryMenu), 0.02f); Game1.playSound("smallSelect"); return; } } if (string.IsNullOrEmpty(this.TargetLocation) && this.backButton.containsPoint(x, y)) { this.currentBlueprintIndex = this.currentBlueprintIndex - 1; if (this.currentBlueprintIndex < 0) { this.currentBlueprintIndex = this.blueprints.Count - 1; } setNewActiveBlueprint(); Game1.playSound("shwip"); this.backButton.scale = this.backButton.baseScale; } if (string.IsNullOrEmpty(this.TargetLocation) && this.forwardButton.containsPoint(x, y)) { this.currentBlueprintIndex = (this.currentBlueprintIndex + 1) % this.blueprints.Count; setNewActiveBlueprint(); this.backButton.scale = this.backButton.baseScale; Game1.playSound("shwip"); } if (string.IsNullOrEmpty(this.TargetLocation) && this.demolishButton.containsPoint(x, y)) { Game1.globalFadeToBlack(this.setUpForBuildingPlacement, 0.02f); Game1.playSound("smallSelect"); this.TargetLocation = "Farm"; this.demolishing = true; } if (string.IsNullOrEmpty(this.TargetLocation) && this.moveButton.containsPoint(x, y)) { Game1.globalFadeToBlack(this.setUpForBuildingPlacement, 0.02f); Game1.playSound("smallSelect"); this.TargetLocation = "Farm"; this.moving = true; } if (this.okButton.containsPoint(x, y) && string.IsNullOrEmpty(this.TargetLocation) && (Game1.player.money >= this.price && this.blueprints[this.currentBlueprintIndex].doesFarmerHaveEnoughResourcesToBuild())) { Game1.globalFadeToBlack(this.setUpForBuildingPlacement, 0.02f); Game1.playSound("smallSelect"); this.TargetLocation = "Farm"; } if (string.IsNullOrEmpty(this.TargetLocation) || this.freeze || Game1.globalFade) { return; } if (this.demolishing) { Building buildingAt = ((BuildableGameLocation)Game1.getLocationFromName(this.TargetLocation)).getBuildingAt(new Vector2(((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), ((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize))); if (buildingAt != null && (buildingAt.daysOfConstructionLeft > 0 || buildingAt.daysUntilUpgrade > 0)) { Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_DuringConstruction"), Color.Red, 3500f)); } else if (buildingAt != null && buildingAt.indoors != null && (buildingAt.indoors is AnimalHouse && (buildingAt.indoors as AnimalHouse).animalsThatLiveHere.Count > 0)) { Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_AnimalsHere"), Color.Red, 3500f)); } else { if (buildingAt == null || !((BuildableGameLocation)Game1.getLocationFromName(this.TargetLocation)).destroyStructure(buildingAt)) { return; } int num1 = buildingAt.tileY; int num2 = buildingAt.tilesHigh; Game1.flashAlpha = 1f; buildingAt.showDestroyedAnimation(Game1.getLocationFromName(this.TargetLocation)); Game1.playSound("explosion"); Utility.spreadAnimalsAround(buildingAt, (Farm)Game1.getLocationFromName(this.TargetLocation)); DelayedAction.fadeAfterDelay(this.returnToCarpentryMenu, 1500); this.freeze = true; } } else if (this.upgrading) { Building buildingAt = ((BuildableGameLocation)Game1.getLocationFromName(this.TargetLocation)).getBuildingAt(new Vector2(((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), ((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize))); if (buildingAt != null && this.CurrentBlueprint.name != null && buildingAt.buildingType.Equals(this.CurrentBlueprint.nameOfBuildingToUpgrade)) { this.CurrentBlueprint.consumeResources(); buildingAt.daysUntilUpgrade = 2; buildingAt.showUpgradeAnimation(Game1.getLocationFromName(this.TargetLocation)); Game1.playSound("axe"); DelayedAction.fadeAfterDelay(this.returnToCarpentryMenuAfterSuccessfulBuild, 1500); this.freeze = true; } else { if (buildingAt == null) { return; } Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\UI:Carpenter_CantUpgrade_BuildingType"), Color.Red, 3500f)); } } else if (this.moving) { if (this.buildingToMove == null) { this.buildingToMove = ((BuildableGameLocation)Game1.getLocationFromName(this.TargetLocation)).getBuildingAt(new Vector2(((Game1.viewport.X + Game1.getMouseX()) / Game1.tileSize), ((Game1.viewport.Y + Game1.getMouseY()) / Game1.tileSize))); if (this.buildingToMove == null) { return; } if (this.buildingToMove.daysOfConstructionLeft > 0) { this.buildingToMove = null; } else { ((BuildableGameLocation)Game1.getLocationFromName(this.TargetLocation)).buildings.Remove(this.buildingToMove); Game1.playSound("axchop"); } } else if (((BuildableGameLocation)Game1.getLocationFromName(this.TargetLocation)).buildStructure(this.buildingToMove, new Vector2(((Game1.viewport.X + Game1.getMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getMouseY()) / Game1.tileSize)), false, Game1.player)) { this.buildingToMove = null; Game1.playSound("axchop"); DelayedAction.playSoundAfterDelay("dirtyHit", 50); DelayedAction.playSoundAfterDelay("dirtyHit", 150); } else { Game1.playSound("cancel"); } } else if (tryToBuild()) { this.CurrentBlueprint.consumeResources(); DelayedAction.fadeAfterDelay(new Game1.afterFadeFunction(returnToCarpentryMenuAfterSuccessfulBuild), 2000); this.freeze = true; } else { Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\UI:Carpenter_CantBuild"), Color.Red, 3500f)); } }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 3); if (Envir.Time > _PoisonRainTime) { //TODO - Animation broken as too large //Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 }); //int damage = GetAttackPower(Stats[Stat.MinSC], Stats[Stat.MaxSC] * 2); //if (damage == 0) return; //DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.ACAgility, true); //ActionList.Add(action); _PoisonRainTime = Envir.Time + 30000; //return; } if (!ranged && Envir.Random.Next(4) > 0) { if (Envir.Time > _PoisonTime) //Poison { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 }); int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); if (damage == 0) { return; } DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MACAgility, true, false); ActionList.Add(action); _PoisonTime = Envir.Time + 20000; return; } if (Envir.Random.Next(3) > 0) //Normal { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); if (damage == 0) { return; } DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.ACAgility, false, false); ActionList.Add(action); } else //Front Stomp { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); var damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); if (damage == 0) { return; } TriangleAttack(damage, 3, 2, 500, DefenceType.ACAgility, false); } } else { if (Envir.Random.Next(5) == 0) { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 }); int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]); if (damage == 0) { return; } ProjectileAttack(damage, DefenceType.MACAgility); } } }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); if (Functions.InRange(CurrentLocation, Target.CurrentLocation, 3)) { if (Envir.Random.Next(2) == 0 || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 2)) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); int damage = GetAttackPower(MinMC, MaxMC); if (damage == 0) return; List<MapObject> targets = FindAllTargets(3, CurrentLocation, false); if (targets.Count == 0) return; for (int i = 0; i < targets.Count; i++) { DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, targets[i], damage, DefenceType.MACAgility); ActionList.Add(action); } } else { WalkAway(); } } else { Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 }); List<MapObject> targets = FindAllTargets(3, Target.CurrentLocation, false); if (targets.Count == 0) return; for (int i = 0; i < targets.Count; i++) { int damage = GetAttackPower(MinDC, MaxDC); if (damage == 0) continue; int delay = Functions.MaxDistance(CurrentLocation, targets[i].CurrentLocation) * 50 + 500; //50 MS per Step DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, targets[i], damage, DefenceType.ACAgility); ActionList.Add(action); } } ActionTime = Envir.Time + 500; AttackTime = Envir.Time + AttackSpeed; if (Target.Dead) FindTarget(); }
protected override void ProcessTarget() { if (Target == null || !CanAttack) { return; } if (Target.Dead) { FindTarget(); return; } Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); #region Push Attack if (Envir.Time > pushTime - (PushTime / 2) && !PushWarn) { Broadcast(new S.Chat { Type = ChatType.Shout2, Message = string.Format("Be gone already you pesky ants!") }); PushWarn = true; } if (Envir.Time > pushTime) { List <MapObject> list = FindAllTargets(PushAttackRange, CurrentLocation, false); if (list != null && list.Count > 0) { for (int i = 0; i < list.Count; i++) { if (list[i].IsAttackTarget(this)) { list[i].Attacked(this, GetAttackPower(MinDC + MinDCBoost, MaxDC + MaxDCBoost), DefenceType.Repulsion); MirDirection dir = Functions.DirectionFromPoint(CurrentLocation, list[i].CurrentLocation); list[i].Pushed(this, dir, 5); } } } _lastHitTime = Envir.Time + _LastHitTime; PushTime = Settings.Second * Envir.Random.Next(30, 60); pushTime = Envir.Time + PushTime; PushWarn = false; } #endregion #region Lowest HP Attack else if (Envir.Time > lowestHPAttackTime) { byte lowestHP = 100; MapObject lowestObj = null; List <MapObject> list = FindAllTargets(LowestAttackRange, CurrentLocation, false); if (list != null && list.Count > 0) { for (int i = 0; i < list.Count; i++) { if (list[i].IsAttackTarget(this)) { if (list[i].PercentHealth < lowestHP) { lowestHP = list[i].PercentHealth; lowestObj = list[i]; } } } } if (lowestObj != null) { if (lowestObj.Attacked(this, GetAttackPower(MinSC + MinSCBoost, MaxSC + MaxSCBoost), DefenceType.None) > 0) { if (lowestObj.Race == ObjectType.Player) { Broadcast(new S.Chat { Message = string.Format("{0} how does it feel to see true POWER!", lowestObj.Name), Type = ChatType.Shout2 }); } Broadcast(new S.ObjectAttack { Direction = Direction, Location = CurrentLocation, ObjectID = ObjectID, Type = 4 }); } } LowestHPAttackTime = Settings.Second * Envir.Random.Next(20, 35); lowestHPAttackTime = Envir.Time + LowestHPAttackTime; } #endregion #region The Ultimate Attack else if (Envir.Time > ultimateAttackTime) { List <MapObject> list = FindAllTargets(UltimateAttackRange, CurrentLocation, false); int hitCount = 0; if (list != null && list.Count > 0) { for (int i = 0; i < list.Count; i++) { if (list[i].IsAttackTarget(this)) { if (list[i].Attacked(this, GetAttackPower(MinDC + MinDCBoost, MaxDC + MaxDCBoost), DefenceType.ACAgility) > 0) { hitCount++; } } } } if (hitCount > 0) { Broadcast(new S.ObjectAttack { Direction = Direction, Type = 3, ObjectID = ObjectID, Location = CurrentLocation }); } UltimateAttackTime = Settings.Second * Envir.Random.Next(15, 45); ultimateAttackTime = Envir.Time + UltimateAttackTime; _lastHitTime = Envir.Time + _LastHitTime; } #endregion #region Order all mobs to current Location, might be funny lol else if (Envir.Time > orderMobTime) { for (int x = CurrentLocation.X - OrderMobRange; x < CurrentLocation.X + OrderMobRange / 2; x++) { for (int y = CurrentLocation.Y - OrderMobRange; y < CurrentLocation.Y + OrderMobRange / 2; y++) { Point tmp = new Point(x, y); if (!CurrentMap.ValidPoint(tmp)) { continue; } Cell cell = CurrentMap.GetCell(tmp); if (cell.Objects == null) { continue; } for (int i = 0; i < cell.Objects.Count; i++) { if (cell.Objects[i].Race == ObjectType.Monster) { MonsterObject tmo = (MonsterObject)cell.Objects[i]; if (tmo != null && !tmo.Dead) { bool routeExists = false; // Check if the route list is valid before trying to add to a null object if (tmo.Route == null) { // It was null so we'll create one tmo.Route = new List <RouteInfo>(); } // Now add the route, not sure what the delay is meant to be.. else { if (tmo.Route.Count > 0) { for (int o = 0; o < tmo.Route.Count; o++) { if (tmo.Route[o].Location == CurrentLocation) { routeExists = true; } } } } // If Route already exists (I.E it was already set to the current location) if (routeExists) { continue; } // Route wasn't for the Current location so Add a new route to our current location. tmo.Route.Add(new RouteInfo() { Delay = 0, Location = CurrentLocation }); } } } } } // Broadcast a message notifying players of any monsters in range coming to aid Mob01 Broadcast(new S.Chat { Message = string.Format("{0}>Come forth my brothers in arms!", Name), Type = ChatType.Shout2 }); // Set the next Order time randomly OrderMobTime = Settings.Second * Envir.Random.Next(15, 50); // Now set the order time with the random cool-down orderMobTime = Envir.Time + OrderMobTime; } #endregion #region The Class Attack else if (Envir.Time > classAttackTime) { MirClass lastClass = MirClass.Wizard; int repeatCount = 0; REPEAT: List <MapObject> list = FindAllTargets(ClassAttackRange, CurrentLocation, false); if (list != null && list.Count > 0) { for (int i = list.Count - 1; i > 0; i--) { if (list[i].IsAttackTarget(this)) { if (list[i].Race == ObjectType.Player) { PlayerObject temp = (PlayerObject)list[i]; if (temp.Class != lastClass) { list.RemoveAt(i); } } } } } if (repeatCount < 5) { repeatCount++; if (list != null && list.Count > 0) { list[0].Attacked(this, GetAttackPower(MinMC + MinMCBoost, MaxMC + MaxMCBoost), DefenceType.MAC); _lastHitTime = Envir.Time + _LastHitTime; } else { if (lastClass == MirClass.Wizard) { lastClass = MirClass.Taoist; } else if (lastClass == MirClass.Taoist) { lastClass = MirClass.Assassin; } else if (lastClass == MirClass.Assassin) { lastClass = MirClass.Warrior; } else if (lastClass == MirClass.Warrior) { lastClass = MirClass.Archer; } else if (lastClass == MirClass.Archer) { lastClass = MirClass.Wizard; } goto REPEAT; } } ClassAttackTime = Settings.Second * Envir.Random.Next(5, 15); classAttackTime = Envir.Time + ClassAttackTime; } #endregion #region The Debuff Attack else if (Envir.Time > debuffTime) { List <MapObject> list = FindAllTargets(DebuffAttackRange, CurrentLocation, false); DebuffTime = Settings.Second * Envir.Random.Next(3, 10); BuffDuration = Settings.Second * Envir.Random.Next(5, 8); if (BuffDuration > DebuffTime) { DebuffTime = BuffDuration; } for (int i = 0; i < list.Count; i++) { if (list[i].IsAttackTarget(this)) { if (list[i].Attacked(this, GetAttackPower(MinSC, MaxSC), DefenceType.ACAgility) > 0) { list[i].AddBuff(new Buff { Caster = this, Type = BuffType.WonderDrug, ExpireTime = Envir.Time + DebuffTime, ObjectID = list[i].ObjectID, Values = new int[] { 2, 3, 1, 5, 25 } }); MinDCBoost += 1; MaxDCBoost += 5; MinMCBoost += 1; MaxMCBoost += 5; MinSCBoost += 1; MaxSCBoost += 5; MinMACBoost += 1; MaxMACBoost += 5; MinACBoost += 1; MaxACBoost += 5; AgilBoost += 2; AccBoost += 3; HealthBoost += 25; } } } buffDuration = Envir.Time + BuffDuration; debuffTime = Envir.Time + DebuffTime; _lastHitTime = Envir.Time + _LastHitTime; } #endregion #region SpellObject Spawning else if (Envir.Time > randomMapAttackTime) { List <Point> locations = new List <Point>(); RandomMapAttackTime = Settings.Second * Envir.Random.Next(8, 23); for (int i = 0; i < 32; i++) { Point loc = GetRandomPoint(15, RandomMapAttackRange, CurrentMap); if (CurrentMap.ValidPoint(loc)) { locations.Add(loc); } } for (int i = 0; i < locations.Count; i++) { // Damage Location Duration DelayedAction spell = new DelayedAction(DelayedType.MonsterMagic, Envir.Time + 800, this, Spell.SpecialMob, GetAttackPower(MinMC + MinMCBoost, MaxMC + MaxMCBoost), locations[i], RandomMapAttackTime); CurrentMap.ActionList.Add(spell); } randomMapAttackTime = Envir.Time + RandomMapAttackTime; } #endregion #region Normal Attacks else if (InAttackRange() && !WalkAway) { Target.Attacked(this, GetAttackPower(MinDC, MaxDC), DefenceType.ACAgility); Broadcast(new S.ObjectAttack { Type = 0, Direction = Direction, Location = CurrentLocation, ObjectID = ObjectID }); _lastHitTime = Envir.Time + _LastHitTime; } else if (InAttackRange() && WalkAway) { // Range attack once < 25% health remaining Target.Attacked(this, GetAttackPower(MinMC, MaxMC), DefenceType.MACAgility); Broadcast(new S.ObjectAttack { Type = 1, Direction = Direction, Location = CurrentLocation, ObjectID = ObjectID }); _lastHitTime = Envir.Time + _LastHitTime; } #endregion #region Check if Target died, find a new target if (Target.Dead) { FindTarget(); return; } #endregion if (Envir.Time < ShockTime) { Target = null; return; } #region Walk away behaviour if (WalkAway) { int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation); if (dist >= 13) { MoveTo(Target.CurrentLocation); } else { MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation); if (Walk(dir)) { return; } switch (Envir.Random.Next(2)) //No favour { case 0: for (int i = 0; i < 7; i++) { dir = Functions.NextDir(dir); if (Walk(dir)) { return; } } break; default: for (int i = 0; i < 7; i++) { dir = Functions.PreviousDir(dir); if (Walk(dir)) { return; } } break; } } } else { MoveTo(Target.CurrentLocation); } #endregion }
protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !InAttackRange(); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage; if (!ranged && Envir.Random.Next(3) > 0) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); damage = GetAttackPower(MinDC, MaxDC); if (damage == 0) return; List<MapObject> targets = FindAllTargets(1, CurrentLocation); if (targets.Count == 0) return; int levelgap; for (int i = 0; i < targets.Count; i++) { if (targets[i].IsAttackTarget(this)) { levelgap = 60 - targets[i].Level; if (Envir.Random.Next(20) < 4 + levelgap) { if (targets[i].Pushed(this, Functions.DirectionFromPoint(CurrentLocation, targets[i].CurrentLocation), 3 + Envir.Random.Next(3)) > 0 && Envir.Random.Next(8) == 0) { targets[i].ApplyPoison(new Poison { PType = PoisonType.Paralysis, Duration = 5, TickSpeed = 1000 }); } } } } LineAttack(2); } else { AttackTime = Envir.Time + AttackSpeed + 500; Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); damage = GetAttackPower(MinMC, MaxMC); if (damage == 0) return; DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MAC); ActionList.Add(action); } if (Target.Dead) FindTarget(); }
private void doGridLayoutLeftClick(ButtonPressedEventArgs e) { var forSale = Helper.Reflection.GetField <List <ISalable> >(shop, "forSale").GetValue(); var itemPriceAndStock = Helper.Reflection.GetField <Dictionary <ISalable, int[]> >(shop, "itemPriceAndStock").GetValue(); var currency = Helper.Reflection.GetField <int>(shop, "currency").GetValue(); var animations = Helper.Reflection.GetField <List <TemporaryAnimatedSprite> >(shop, "animations").GetValue(); var poof = Helper.Reflection.GetField <TemporaryAnimatedSprite>(shop, "poof").GetValue(); var heldItem = Helper.Reflection.GetField <ISalable>(shop, "heldItem").GetValue(); var currentItemIndex = Helper.Reflection.GetField <int>(shop, "currentItemIndex").GetValue(); var sellPercentage = Helper.Reflection.GetField <float>(shop, "sellPercentage").GetValue(); var scrollBar = Helper.Reflection.GetField <ClickableTextureComponent>(shop, "scrollBar").GetValue(); var scrollBarRunner = Helper.Reflection.GetField <Rectangle>(shop, "scrollBarRunner").GetValue(); var downArrow = Helper.Reflection.GetField <ClickableTextureComponent>(shop, "downArrow").GetValue(); var upArrow = Helper.Reflection.GetField <ClickableTextureComponent>(shop, "upArrow").GetValue(); const int UNIT_WIDTH = 160; const int UNIT_HEIGHT = 144; int unitsWide = (shop.width - 32) / UNIT_WIDTH; int x = (int)e.Cursor.ScreenPixels.X; int y = (int)e.Cursor.ScreenPixels.Y; if (shop.upperRightCloseButton.containsPoint(x, y)) { shop.exitThisMenu(true); return; } // Copying a lot from left click code if (downArrow.containsPoint(x, y) && currentItemIndex < Math.Max(0, forSale.Count - 18)) { downArrow.scale = downArrow.baseScale; Helper.Reflection.GetField <int>(shop, "currentItemIndex").SetValue(currentItemIndex += 1); if (forSale.Count > 0) { scrollBar.bounds.Y = scrollBarRunner.Height / Math.Max(1, (forSale.Count / 6) - 1 + 1) * currentItemIndex + upArrow.bounds.Bottom + 4; if (currentItemIndex == forSale.Count / 6 - 1) { scrollBar.bounds.Y = downArrow.bounds.Y - scrollBar.bounds.Height - 4; } } Game1.playSound("shwip"); } else if (upArrow.containsPoint(x, y) && currentItemIndex > 0) { upArrow.scale = upArrow.baseScale; Helper.Reflection.GetField <int>(shop, "currentItemIndex").SetValue(currentItemIndex -= 1); if (forSale.Count > 0) { scrollBar.bounds.Y = scrollBarRunner.Height / Math.Max(1, (forSale.Count / 6) - 1 + 1) * currentItemIndex + upArrow.bounds.Bottom + 4; if (currentItemIndex == forSale.Count / 6 - 1) { scrollBar.bounds.Y = downArrow.bounds.Y - scrollBar.bounds.Height - 4; } } Game1.playSound("shwip"); } else if (scrollBarRunner.Contains(x, y)) { int y1 = scrollBar.bounds.Y; scrollBar.bounds.Y = Math.Min(shop.yPositionOnScreen + shop.height - 64 - 12 - scrollBar.bounds.Height, Math.Max(y, shop.yPositionOnScreen + upArrow.bounds.Height + 20)); currentItemIndex = Math.Min(forSale.Count / 6 - 1, Math.Max(0, (int)((double)forSale.Count / 6 * (double)((float)(y - scrollBarRunner.Y) / (float)scrollBarRunner.Height)))); Helper.Reflection.GetField <int>(shop, "currentItemIndex").SetValue(currentItemIndex); if (forSale.Count > 0) { scrollBar.bounds.Y = scrollBarRunner.Height / Math.Max(1, (forSale.Count / 6) - 1 + 1) * currentItemIndex + upArrow.bounds.Bottom + 4; if (currentItemIndex == forSale.Count / 6 - 1) { scrollBar.bounds.Y = downArrow.bounds.Y - scrollBar.bounds.Height - 4; } } int y2 = scrollBar.bounds.Y; if (y1 == y2) { return; } Game1.playSound("shiny4"); } Vector2 clickableComponent = shop.inventory.snapToClickableComponent(x, y); if (heldItem == null) { Item obj = shop.inventory.leftClick(x, y, null, false); if (obj != null) { if (shop.onSell != null) { shop.onSell(obj); } else { ShopMenu.chargePlayer(Game1.player, currency, -((obj is StardewValley.Object ? (int)((double)(obj as StardewValley.Object).sellToStorePrice() * (double)sellPercentage) : (int)((double)(obj.salePrice() / 2) * (double)sellPercentage)) * obj.Stack)); int num = obj.Stack / 8 + 2; for (int index = 0; index < num; ++index) { animations.Add(new TemporaryAnimatedSprite("TileSheets\\debris", new Rectangle(Game1.random.Next(2) * 16, 64, 16, 16), 9999f, 1, 999, clickableComponent + new Vector2(32f, 32f), false, false) { alphaFade = 0.025f, motion = new Vector2((float)Game1.random.Next(-3, 4), -4f), acceleration = new Vector2(0.0f, 0.5f), delayBeforeAnimationStart = index * 25, scale = 2f }); animations.Add(new TemporaryAnimatedSprite("TileSheets\\debris", new Rectangle(Game1.random.Next(2) * 16, 64, 16, 16), 9999f, 1, 999, clickableComponent + new Vector2(32f, 32f), false, false) { scale = 4f, alphaFade = 0.025f, delayBeforeAnimationStart = index * 50, motion = Utility.getVelocityTowardPoint(new Point((int)clickableComponent.X + 32, (int)clickableComponent.Y + 32), new Vector2((float)(shop.xPositionOnScreen - 36), (float)(shop.yPositionOnScreen + shop.height - shop.inventory.height - 16)), 8f), acceleration = Utility.getVelocityTowardPoint(new Point((int)clickableComponent.X + 32, (int)clickableComponent.Y + 32), new Vector2((float)(shop.xPositionOnScreen - 36), (float)(shop.yPositionOnScreen + shop.height - shop.inventory.height - 16)), 0.5f) }); } if (obj is StardewValley.Object && (obj as StardewValley.Object).Edibility != -300) { Item one = obj.getOne(); one.Stack = obj.Stack; (Game1.getLocationFromName("SeedShop") as StardewValley.Locations.SeedShop).itemsToStartSellingTomorrow.Add(one); } Game1.playSound("sell"); Game1.playSound("purchase"); } } } else { heldItem = shop.inventory.leftClick(x, y, (Item)heldItem, true); Helper.Reflection.GetField <ISalable>(shop, "heldItem").SetValue(heldItem); } for (int i = currentItemIndex * unitsWide; i < forSale.Count && i < currentItemIndex * unitsWide + unitsWide * 3; ++i) { int ix = i % unitsWide; int iy = i / unitsWide; Rectangle rect = new Rectangle(shop.xPositionOnScreen + 16 + ix * UNIT_WIDTH, shop.yPositionOnScreen + 16 + iy * UNIT_HEIGHT - currentItemIndex * UNIT_HEIGHT, UNIT_WIDTH, UNIT_HEIGHT); if (rect.Contains(x, y) && forSale[i] != null) { int numberToBuy = Math.Min(Game1.oldKBState.IsKeyDown(Keys.LeftShift) ? Math.Min(Math.Min(5, ShopMenu.getPlayerCurrencyAmount(Game1.player, currency) / Math.Max(1, itemPriceAndStock[forSale[i]][0])), Math.Max(1, itemPriceAndStock[forSale[i]][1])) : 1, forSale[i].maximumStackSize()); if (numberToBuy == -1) { numberToBuy = 1; } var tryToPurchaseItem = Helper.Reflection.GetMethod(shop, "tryToPurchaseItem"); if (numberToBuy > 0 && tryToPurchaseItem.Invoke <bool>(forSale[i], heldItem, numberToBuy, x, y, i)) { itemPriceAndStock.Remove(forSale[i]); forSale.RemoveAt(i); } else if (numberToBuy <= 0) { Game1.dayTimeMoneyBox.moneyShakeTimer = 1000; Game1.playSound("cancel"); } if (heldItem != null && Game1.options.SnappyMenus && (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ShopMenu) && Game1.player.addItemToInventoryBool((Item)heldItem, false)) { heldItem = (Item)null; Helper.Reflection.GetField <ISalable>(shop, "heldItem").SetValue(heldItem); DelayedAction.playSoundAfterDelay("coin", 100, (GameLocation)null); } } } }
public void ViewLoaded() { delayedLocationUpdate = new DelayedAction(View.Dispatcher); nextRainUpdate = new DelayedAction(View.Dispatcher, 3 * 60 * 1000); NetworkChange.NetworkAddressChanged += (sender, args) => UpdateState(); UpdateEntriesImage(); UpdateState(); InitializeGeolocator(); }
private void doGridLayoutRightClick(ButtonPressedEventArgs e) { var forSale = Helper.Reflection.GetField <List <ISalable> >(shop, "forSale").GetValue(); var itemPriceAndStock = Helper.Reflection.GetField <Dictionary <ISalable, int[]> >(shop, "itemPriceAndStock").GetValue(); var currency = Helper.Reflection.GetField <int>(shop, "currency").GetValue(); var animations = Helper.Reflection.GetField <List <TemporaryAnimatedSprite> >(shop, "animations").GetValue(); var poof = Helper.Reflection.GetField <TemporaryAnimatedSprite>(shop, "poof").GetValue(); var heldItem = Helper.Reflection.GetField <ISalable>(shop, "heldItem").GetValue(); var currentItemIndex = Helper.Reflection.GetField <int>(shop, "currentItemIndex").GetValue(); var sellPercentage = Helper.Reflection.GetField <float>(shop, "sellPercentage").GetValue(); const int UNIT_WIDTH = 160; const int UNIT_HEIGHT = 144; int unitsWide = (shop.width - 32) / UNIT_WIDTH; int x = (int)e.Cursor.ScreenPixels.X; int y = (int)e.Cursor.ScreenPixels.Y; if (shop.upperRightCloseButton.containsPoint(x, y)) { shop.exitThisMenu(true); return; } // Copying a lot from right click code Vector2 clickableComponent = shop.inventory.snapToClickableComponent(x, y); if (heldItem == null) { Item obj = shop.inventory.rightClick(x, y, null, false); if (obj != null) { if (shop.onSell != null) { shop.onSell(obj); } else { ShopMenu.chargePlayer(Game1.player, currency, -((obj is StardewValley.Object ? (int)((double)(obj as StardewValley.Object).sellToStorePrice() * (double)sellPercentage) : (int)((double)(obj.salePrice() / 2) * (double)sellPercentage)) * obj.Stack)); Item obj2 = (Item)null; if (Game1.mouseClickPolling > 300) { Game1.playSound("purchaseRepeat"); } else { Game1.playSound("purchaseClick"); } animations.Add(new TemporaryAnimatedSprite("TileSheets\\debris", new Rectangle(Game1.random.Next(2) * 64, 256, 64, 64), 9999f, 1, 999, clickableComponent + new Vector2(32f, 32f), false, false) { alphaFade = 0.025f, motion = Utility.getVelocityTowardPoint(new Point((int)clickableComponent.X + 32, (int)clickableComponent.Y + 32), Game1.dayTimeMoneyBox.position + new Vector2(96f, 196f), 12f), acceleration = Utility.getVelocityTowardPoint(new Point((int)clickableComponent.X + 32, (int)clickableComponent.Y + 32), Game1.dayTimeMoneyBox.position + new Vector2(96f, 196f), 0.5f) }); if (obj is StardewValley.Object && (obj as StardewValley.Object).Edibility != -300) { (Game1.getLocationFromName("SeedShop") as StardewValley.Locations.SeedShop).itemsToStartSellingTomorrow.Add(obj.getOne()); } if (shop.inventory.getItemAt(x, y) == null) { Game1.playSound("sell"); animations.Add(new TemporaryAnimatedSprite(5, clickableComponent + new Vector2(32f, 32f), Color.White, 8, false, 100f, 0, -1, -1f, -1, 0) { motion = new Vector2(0.0f, -0.5f) }); } } } } else { heldItem = shop.inventory.leftClick(x, y, (Item)heldItem, true); Helper.Reflection.GetField <ISalable>(shop, "heldItem").SetValue(heldItem); } for (int i = currentItemIndex * unitsWide; i < forSale.Count && i < currentItemIndex * unitsWide + unitsWide * 3; ++i) { int ix = i % unitsWide; int iy = i / unitsWide; Rectangle rect = new Rectangle(shop.xPositionOnScreen + 16 + ix * UNIT_WIDTH, shop.yPositionOnScreen + 16 + iy * UNIT_HEIGHT - currentItemIndex * UNIT_HEIGHT, UNIT_WIDTH, UNIT_HEIGHT); if (rect.Contains(x, y) && forSale[i] != null) { int index2 = i; if (forSale[index2] == null) { break; } int numberToBuy = Game1.oldKBState.IsKeyDown(Keys.LeftShift) ? Math.Min(Math.Min(5, ShopMenu.getPlayerCurrencyAmount(Game1.player, currency) / itemPriceAndStock[forSale[index2]][0]), itemPriceAndStock[forSale[index2]][1]) : 1; var tryToPurchaseItem = Helper.Reflection.GetMethod(shop, "tryToPurchaseItem"); if (numberToBuy > 0 && tryToPurchaseItem.Invoke <bool>(forSale[index2], heldItem, numberToBuy, x, y, index2)) { itemPriceAndStock.Remove(forSale[index2]); forSale.RemoveAt(index2); } if (heldItem == null || !Game1.options.SnappyMenus || (Game1.activeClickableMenu == null || !(Game1.activeClickableMenu is ShopMenu)) || !Game1.player.addItemToInventoryBool((Item)heldItem, false)) { break; } heldItem = (Item)null; Helper.Reflection.GetField <ISalable>(shop, "heldItem").SetValue(heldItem); DelayedAction.playSoundAfterDelay("coin", 100, (GameLocation)null); break; } } }
public virtual void Defer(DelayedAction action) { Defer(action, SubscriptionType.Update); }
static public void EquipmentClick(StardewValley.Menus.ClickableComponent icon) { // Check that item type is compatible. // And play corresponding sound. var helditem = Game1.player.CursorSlotItem; if (helditem == null) { if (icon.item == null) { return; } Game1.playSound("dwop"); } else { switch (icon.name) { case "Hat": if (!(helditem is Hat)) { return; } Game1.playSound("grassyStep"); break; case "Boots": if (!(helditem is Boots)) { return; } Game1.playSound("sandyStep"); DelayedAction.playSoundAfterDelay("sandyStep", 150, null); break; default: if (!(helditem is Ring)) { return; } Game1.playSound("crit"); break; } } // I have no idea why StardewValley does this in InventoryPage::setHeldItem, but I guess it might be important. if (helditem != null) { helditem.NetFields.Parent = null; } // Update inventory ActualRings ar = actualdata.GetValue(Game1.player, FarmerNotFound); switch (icon.name) { case "Hat": Game1.player.hat.Set(helditem as Hat); break; case "Left Ring": Game1.player.leftRing.Set(helditem as Ring); break; case "Right Ring": Game1.player.rightRing.Set(helditem as Ring); break; case "Boots": Game1.player.boots.Set(helditem as Boots); break; case "Extra Ring 1": ar.ring1.Set(helditem as Ring); break; case "Extra Ring 2": ar.ring2.Set(helditem as Ring); break; case "Extra Ring 3": ar.ring3.Set(helditem as Ring); break; case "Extra Ring 4": ar.ring4.Set(helditem as Ring); break; default: mon.Log($"ERROR: Trying to fit equipment item into invalid slot '{icon.name}'", LogLevel.Error); return; } // Equip/unequip (icon.item as Ring)?.onUnequip(Game1.player, Game1.currentLocation); (icon.item as Boots)?.onUnequip(); (helditem as Ring)?.onEquip(Game1.player, Game1.currentLocation); (helditem as Boots)?.onEquip(); // Swap items Game1.player.CursorSlotItem = icon.item; icon.item = helditem; }
public static bool Prefix(Object __instance, GameLocation location, int x, int y, Farmer who, ref bool __result) { Vector2 placementTile = new Vector2((float)(x / 64), (float)(y / 64)); if (!Config.EnableMod || location.terrainFeatures.ContainsKey(placementTile)) { return(true); } if (!CanPlaceTreeHere(location, placementTile)) { return(true); } if (__instance.isSapling() && __instance.ParentSheetIndex != 251) { location.playSound("dirtyHit"); DelayedAction.playSoundAfterDelay("coin", 100, null, -1); bool actAsGreenhouse = location.IsGreenhouse || ((__instance.ParentSheetIndex == 69 || __instance.ParentSheetIndex == 835) && location is IslandWest); location.terrainFeatures.Add(placementTile, new FruitTree(__instance.ParentSheetIndex) { GreenHouseTree = actAsGreenhouse, GreenHouseTileTree = location.doesTileHavePropertyNoNull((int)placementTile.X, (int)placementTile.Y, "Type", "Back").Equals("Stone") }); return(false); for (int i = 0; i < 29; i++) { location.terrainFeatures[placementTile].dayUpdate(location, placementTile); } } int whichTree; switch (__instance.ParentSheetIndex) { case 309: whichTree = 1; break; case 310: whichTree = 2; break; case 311: whichTree = 3; break; case 897: whichTree = 7; break; case 292: whichTree = 8; break; default: return(true); } location.terrainFeatures.Add(placementTile, new Tree(whichTree, 0)); location.playSound("dirtyHit"); __result = true; return(false); }
public static bool beginUsing(MilkPail __instance, GameLocation location, int x, int y, StardewValley.Farmer who, ref bool __result) { if (!IsParticipantRibbon(__instance)) { return(true); } string participantRibbonId = __instance.modData[ParticipantRibbonKey]; x = (int)who.GetToolLocation(false).X; y = (int)who.GetToolLocation(false).Y; Rectangle rectangle = new Rectangle(x - Game1.tileSize / 2, y - Game1.tileSize / 2, Game1.tileSize, Game1.tileSize); if (!DataLoader.ModConfig.DisableAnimalContest) { if (location is Farm farm) { foreach (FarmAnimal farmAnimal in farm.animals.Values) { if (farmAnimal.GetBoundingBox().Intersects(rectangle)) { Animals[participantRibbonId] = farmAnimal; break; } } if (!Animals.ContainsKey(participantRibbonId) || Animals[participantRibbonId] == null) { foreach (Pet localPet in farm.characters.Where(i => i is Pet)) { if (localPet.GetBoundingBox().Intersects(rectangle)) { Pets[participantRibbonId] = localPet; break; } } } } else if (location is AnimalHouse animalHouse) { foreach (FarmAnimal farmAnimal in animalHouse.animals.Values) { if (farmAnimal.GetBoundingBox().Intersects(rectangle)) { Animals[participantRibbonId] = farmAnimal; break; } } } else if (location is FarmHouse) { foreach (Pet localPet in location.characters.Where(i => i is Pet)) { if (localPet.GetBoundingBox().Intersects(rectangle)) { Pets[participantRibbonId] = localPet; break; } } } } string dialogue = ""; Animals.TryGetValue(participantRibbonId, out FarmAnimal animal); if (animal != null) { if (animal.isBaby()) { dialogue = DataLoader.i18n.Get("Tool.ParticipantRibbon.CantBeBaby"); } else if (AnimalContestController.HasParticipated(animal)) { dialogue = DataLoader.i18n.Get("Tool.ParticipantRibbon.HasAlreadyParticipatedContest", new { animalName = animal.displayName }); } else if (AnimalContestController.IsNextParticipant(animal)) { dialogue = DataLoader.i18n.Get("Tool.ParticipantRibbon.IsAlreadyParticipant", new { animalName = animal.displayName }); } else if (AnimalContestController.GetNextContestParticipant() is Character participant) { string participantName = participant.displayName; dialogue = DataLoader.i18n.Get("Tool.ParticipantRibbon.AnotherParticipantAlready", new { participantName }); } else { animal.doEmote(8, true); if (who != null && Game1.player.Equals(who)) { animal.makeSound(); } animal.pauseTimer = 200; } } Pets.TryGetValue(participantRibbonId, out Pet pet); if (pet != null) { if (AnimalContestController.IsNextParticipant(pet)) { dialogue = DataLoader.i18n.Get("Tool.ParticipantRibbon.IsAlreadyParticipant", new { animalName = pet.displayName }); } else if (AnimalContestController.GetNextContestParticipant() is Character character) { string participantName = character.displayName; dialogue = DataLoader.i18n.Get("Tool.ParticipantRibbon.AnotherParticipantAlready", new { participantName }); } else { pet.doEmote(8, true); if (who != null && Game1.player.Equals(who)) { pet.playContentSound(); } pet.Halt(); pet.CurrentBehavior = 0; pet.Halt(); pet.Sprite.setCurrentAnimation( new List <FarmerSprite.AnimationFrame>() { new FarmerSprite.AnimationFrame(18, 200) }); } } if (dialogue.Length > 0) { if (who != null && Game1.player.Equals(who)) { DelayedAction.showDialogueAfterDelay(dialogue, 150); } Pets[participantRibbonId] = pet = null; Animals[participantRibbonId] = animal = null; } who.Halt(); int currentFrame = who.FarmerSprite.CurrentFrame; if (animal != null || pet != null) { switch (who.FacingDirection) { case 0: who.FarmerSprite.animateOnce(new FarmerSprite.AnimationFrame[1] { new FarmerSprite.AnimationFrame(62, 200, false, false, new AnimatedSprite.endOfAnimationBehavior(StardewValley.Farmer.useTool), true) }); break; case 1: who.FarmerSprite.animateOnce(new FarmerSprite.AnimationFrame[1] { new FarmerSprite.AnimationFrame(58, 200, false, false, new AnimatedSprite.endOfAnimationBehavior(StardewValley.Farmer.useTool), true) }); break; case 2: who.FarmerSprite.animateOnce(new FarmerSprite.AnimationFrame[1] { new FarmerSprite.AnimationFrame(54, 200, false, false, new AnimatedSprite.endOfAnimationBehavior(StardewValley.Farmer.useTool), true) }); break; case 3: who.FarmerSprite.animateOnce(new FarmerSprite.AnimationFrame[1] { new FarmerSprite.AnimationFrame(58, 200, false, true, new AnimatedSprite.endOfAnimationBehavior(StardewValley.Farmer.useTool), true) }); break; } } else { who.FarmerSprite.animateOnce(new FarmerSprite.AnimationFrame[1] { new FarmerSprite.AnimationFrame(currentFrame, 0, false, who.FacingDirection == 3, new AnimatedSprite.endOfAnimationBehavior(StardewValley.Farmer.useTool), true) }); } who.FarmerSprite.oldFrame = currentFrame; who.UsingTool = true; who.CanMove = false; __result = true; return(false); }