Skip to content

Instantly share code, notes, and snippets.

@ScottLilly ScottLilly/SuperAdventure.cs Secret
Last active Aug 5, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.