Fix some MP bugs, implement information butotn.

This commit is contained in:
SilicaAndPina 2020-11-04 21:39:36 +13:00
parent 22b7d0fa27
commit 34460e6967
11 changed files with 163 additions and 29 deletions

View file

@ -72,6 +72,20 @@ namespace HISP.Game
}
}
public static bool IsDroppedItemExist(int randomId)
{
try
{
GetDroppedItemById(randomId);
return true;
}
catch(KeyNotFoundException)
{
return false;
}
}
public static DroppedItem GetDroppedItemById(int randomId)
{

View file

@ -83,6 +83,20 @@ namespace HISP.Game
}
throw new KeyNotFoundException("id: " + id + " is not a throwable item.");
}
public static bool ItemIdExist(int id)
{
try
{
GetItemById(id);
return true;
}
catch(KeyNotFoundException)
{
return false;
}
}
public static ItemInformation GetItemById(int id)
{
foreach(ItemInformation item in Items)

View file

@ -66,11 +66,10 @@ namespace HISP.Game
overlayPassable = true;
bool tilePassable = false;
if (terrainPassable || overlayPassable)
if (terrainPassable || overlayPassable && otileId != 0)
tilePassable = true;
if (!overlayPassable && (tileId != 0 && otileId != 0))
tilePassable = false;
Logger.DebugPrint("Overlay: " + otileId + " Terrain: " + tileId);
return tilePassable;

View file

@ -65,6 +65,8 @@ namespace HISP.Game
public static string GrabbedItemMessage;
public static string GrabbedAllObjectsMessage;
public static string DroppedAnItemMessage;
public static string ItemInformationFormat;
// Inventory
public static string InventoryItemFormat;
@ -83,6 +85,7 @@ namespace HISP.Game
public static string NpcReplyFormat;
public static string NpcInformationButton;
public static string NpcTalkButton;
public static string NpcInformationFormat;
// Meta
public static string IsleFormat;
@ -115,6 +118,15 @@ namespace HISP.Game
public static string BoatCutscene;
public static string WagonCutscene;
public static string BallonCutscene;
public static string FormatNpcInformation(string name, string description)
{
return NpcInformationFormat.Replace("%NAME%", name).Replace("%DESCRIPTION%", description);
}
public static string FormatItemInformation(string name, string description)
{
return ItemInformationFormat.Replace("%NAME%", name).Replace("%DESCRIPTION%", description);
}
public static string FormatNpcChatpoint(string name, string shortDescription, string chatText)
{
return NpcChatpointFormat.Replace("%NAME%", name).Replace("%DESCRIPTION%", shortDescription).Replace("%TEXT%", chatText);

View file

@ -30,6 +30,7 @@ namespace HISP.Game
User[] nearbyUsers = GameServer.GetNearbyUsers(x, y, true, true);
if (nearbyUsers.Length > 1)
{
playersNearby += Messages.Seperator;
playersNearby += Messages.NearbyPlayers;
playersNearby += Messages.Seperator;
@ -76,7 +77,6 @@ namespace HISP.Game
private static string buildCommonInfo(int x, int y)
{
string message = "";
message += buildNearbyString(x, y);
// Dropped Items
@ -124,6 +124,22 @@ namespace HISP.Game
}
return message;
}
public static string BuildNpcInfo(Npc.NpcEntry npcInfo)
{
string message = "";
message += Messages.FormatNpcInformation(npcInfo.Name, npcInfo.LongDescription);
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
public static string BuildItemInfo(Item.ItemInformation itemInfo)
{
string message = "";
message += Messages.FormatItemInformation(itemInfo.Name, itemInfo.Description);
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
public static string BuildTransportInfo(Transport.TransportPoint transportPoint)
{
string message = "";
@ -151,8 +167,9 @@ namespace HISP.Game
if (specialTile.Description != null && specialTile.Description != "")
message += specialTile.Description;
message += buildNpc(user, specialTile.X, specialTile.Y);
string npc = buildNpc(user, specialTile.X, specialTile.Y);
message += npc;
if (specialTile.Code == null)
message += buildCommonInfo(specialTile.X, specialTile.Y);
@ -259,6 +276,7 @@ namespace HISP.Game
message += buildNpc(user, x, y);
message += buildCommonInfo(x, y);
return message;
}

View file

@ -84,6 +84,18 @@ namespace HISP.Game
throw new KeyNotFoundException("Npc chatpoint id: " + chatpointId + " not found!");
}
public static bool NpcExists(int id)
{
try
{
GetNpcById(id);
return true;
}
catch (KeyNotFoundException)
{
return false;
}
}
public static NpcEntry GetNpcById(int id)
{
foreach(NpcEntry npc in NpcList)