/SuperAdventure.cs Secret
Last active
August 5, 2018 23:57
Star
You must be signed in to star a gist
Changes for Zodiark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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