2018-03-17 19:39:46 +08:00
|
|
|
|
using CustomNPCFramework.Framework.ModularNPCS;
|
|
|
|
|
using CustomNPCFramework.Framework.ModularNPCS.ModularRenderers;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using StardewValley;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace CustomNPCFramework.Framework.NPCS
|
|
|
|
|
{
|
2018-03-20 14:01:43 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Extended merchant npc from ExtendedNPC.
|
|
|
|
|
/// </summary>
|
2018-03-17 19:39:46 +08:00
|
|
|
|
class MerchantNPC: ExtendedNPC
|
|
|
|
|
{
|
2018-03-20 14:01:43 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Thelist of items this npc has for sale.
|
|
|
|
|
/// </summary>
|
2018-03-17 19:39:46 +08:00
|
|
|
|
public List<Item> stock;
|
2018-03-20 14:01:43 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructor.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Stock">The list of items this npc will sell.</param>
|
|
|
|
|
/// <param name="sprite">The sprite for the npc to use.</param>
|
|
|
|
|
/// <param name="renderer">The renderer for the npc to use.</param>
|
|
|
|
|
/// <param name="position">The position for the npc to use.</param>
|
|
|
|
|
/// <param name="facingDirection">The facing direction for the player to face.</param>
|
|
|
|
|
/// <param name="name">The name for the npc.</param>
|
2018-03-17 19:39:46 +08:00
|
|
|
|
public MerchantNPC(List<Item> Stock, Sprite sprite, BasicRenderer renderer,Vector2 position,int facingDirection,string name): base(sprite,renderer,position,facingDirection,name)
|
|
|
|
|
{
|
|
|
|
|
this.stock = Stock;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-18 12:49:22 +08:00
|
|
|
|
|
2018-03-20 14:01:43 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructor.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Stock">The list of items for the npc to sell.</param>
|
|
|
|
|
/// <param name="npcBase">The npc base for the character to be expanded upon.</param>
|
2018-05-01 09:21:31 +08:00
|
|
|
|
public MerchantNPC(List<Item> Stock, ExtendedNPC npcBase) : base(npcBase.spriteInformation, npcBase.characterRenderer, npcBase.portraitInformation, npcBase.position, npcBase.facingDirection, npcBase.Name)
|
2018-03-17 19:39:46 +08:00
|
|
|
|
{
|
|
|
|
|
this.stock = Stock;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-20 14:01:43 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Used to interact with the npc. When interacting pulls up a shop menu for the npc with their current stock.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="who"></param>
|
|
|
|
|
/// <param name="l"></param>
|
|
|
|
|
/// <returns></returns>
|
2018-03-17 19:39:46 +08:00
|
|
|
|
public override bool checkAction(StardewValley.Farmer who, GameLocation l)
|
|
|
|
|
{
|
|
|
|
|
if (Game1.activeClickableMenu == null)
|
|
|
|
|
{
|
|
|
|
|
Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(this.stock);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return base.checkAction(Game1.player, Game1.player.currentLocation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|