2018-12-30 18:00:05 +08:00
|
|
|
using EventSystem.Framework.FunctionEvents;
|
2018-02-24 05:55:51 +08:00
|
|
|
using EventSystem.Framework.Information;
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
using StardewValley;
|
|
|
|
|
|
|
|
namespace EventSystem.Framework.Events
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Used to handle warp events on the map.</summary>
|
|
|
|
public class WarpEvent : MapEvent
|
2018-02-24 05:55:51 +08:00
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
private readonly WarpInformation warpInfo;
|
2018-02-24 05:55:51 +08:00
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Constructor for handling warp events.</summary>
|
2018-02-24 05:55:51 +08:00
|
|
|
/// <param name="Name">The name of the event.</param>
|
|
|
|
/// <param name="Location">The game location that this event is located at.</param>
|
|
|
|
/// <param name="Position">The x,y tile position of the event.</param>
|
|
|
|
/// <param name="playerEvents">The events to occur when the player enters the warp tile before the warp.</param>
|
|
|
|
/// <param name="WarpInfo">The information for warping the farmer.</param>
|
2018-12-30 18:00:05 +08:00
|
|
|
public WarpEvent(string Name, GameLocation Location, Vector2 Position, PlayerEvents playerEvents, WarpInformation WarpInfo)
|
|
|
|
: base(Name, Location, Position, playerEvents)
|
2018-02-24 05:55:51 +08:00
|
|
|
{
|
|
|
|
this.name = Name;
|
|
|
|
this.location = Location;
|
|
|
|
this.tilePosition = Position;
|
|
|
|
this.playerEvents = playerEvents;
|
|
|
|
this.warpInfo = WarpInfo;
|
|
|
|
|
|
|
|
this.doesInteractionNeedToRun = true;
|
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Occurs when the player enters the warp tile event position.</summary>
|
2018-03-06 15:46:24 +08:00
|
|
|
public override bool OnPlayerEnter()
|
2018-02-24 05:55:51 +08:00
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
if (!base.OnPlayerEnter())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
Game1.warpFarmer(this.warpInfo.targetMapName, this.warpInfo.targetX, this.warpInfo.targetY, this.warpInfo.facingDirection, this.warpInfo.isStructure);
|
|
|
|
return true;
|
2018-02-24 05:55:51 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Runs when the player is not on the tile and resets player interaction.</summary>
|
2018-03-06 15:46:24 +08:00
|
|
|
public override bool OnPlayerLeave()
|
2018-02-24 05:55:51 +08:00
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
if (!base.OnPlayerLeave()) return false;
|
2018-03-06 15:46:24 +08:00
|
|
|
return true;
|
2018-02-24 05:55:51 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Used to update the event and check for interaction.</summary>
|
2018-02-24 05:55:51 +08:00
|
|
|
public override void update()
|
|
|
|
{
|
|
|
|
this.OnPlayerEnter();
|
|
|
|
this.OnPlayerLeave();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|