Skip to content

Instantly share code, notes, and snippets.

@ScottLilly
Last active August 5, 2018 23:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ScottLilly/646fc4a9b39746b5031d018ecffd3367 to your computer and use it in GitHub Desktop.
Changes for Zodiark
public SuperAdventure()
{
InitializeComponent();
SetCurrentPlayer(new Player(10, 10, 20, 0));
}
private void SetCurrentPlayer(Player player)
{
_player = player;
_player.Inventory.Add(new InventoryItem(World.ItemByID(World.ITEM_ID_RUSTY_SWORD), 1));
_player.Inventory.Add(new InventoryItem(World.ItemByID(World.ITEM_ID_HEALING_POTION), 1));
MoveTo(World.LocationByID(World.LOCATION_ID_HOME));
UpdateInventoryListInUI(); //shows weapon at the beginning, if any
UpdatePotionListInUI(); //shows potion at the beginning, if any
UpdatePlayerStats(); //shows current stats at the beginning
}
public void ResetByDeath()
{
List<PlayerQuest> previousQuests = _player.Quests;
List<InventoryItem> previousInventory = _player.Inventory;
List<InventoryItem> itemsToEnterPlaces = new List<InventoryItem>();
foreach(InventoryItem ii in previousInventory)
{
foreach(Location location in World.Locations)
{
if(location.ItemRequiredToEnter != null)
{
if(ii.Details == location.ItemRequiredToEnter)
{
itemsToEnterPlaces.Add(ii); //stores items that are required to enter locations
}
}
}
}
// Create a new Player object, and fill it with:
// The old player object's items that are needed to enter a location
// The old player object's quests
Player newPlayer = new Player(_player.CurrentHitPoints, _player.MaximumHitPoints, 20, _player.ExperiencePoints);
foreach(InventoryItem item in itemsToEnterPlaces)
{
newPlayer.Inventory.Add(item); //keeps only items that are required to enter places
}
newPlayer.Quests = previousQuests; //keeps quest list and quests done when you die
SetCurrentPlayer(newPlayer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment