/// <summary> /// Event Handler for when Player Interacts with NPC /// </summary> /// <param name="id"></param> private void HandleNpcInteraction(int id) { Npc npc = _gameUniverse.GetNpcById(id); if (!(_gamePlayer.NpcsInteractedWith.Contains(npc))) { //Add npc to npc interacted with list _gamePlayer.NpcsInteractedWith.Add(npc); if (npc is IExperiencePoints) { IExperiencePoints npcXp = (IExperiencePoints)npc; _gamePlayer.ExperiencePoints += npcXp.XP; } } //If player finds a black cat and interacts with it, assign the cat a new location if (npc.Name == "Black Cat") { npc.LocationID = _gameUniverse.AssignRandomLocation(npc); } else if (npc.Name == "Cloaked Figure") { if (_currentLocation.LocationID == 9) { GrantRoomAccess(_currentLocation.LocationID + 1); npc.LocationID = _currentLocation.LocationID + 1; } else { bool ready = IsPlayerReady(); if (ready == false) { SetPlayerBackToStart(); } else { Npc spiritNpc = _gameUniverse.GetNpcById(6); Spirit spirit = (Spirit)spiritNpc; spirit.Ready = true; GrantRoomAccess(_currentLocation.LocationID + 1); } } } }
/// <summary> /// Assign XP to every location, object, npc in the game /// </summary> private void AssignXP() { foreach (Location l in _gameUniverse.Locations) { l.ExperiencePoints = _gameUniverse.GetRandom(12, 30); } foreach (GameObject g in _gameUniverse.GameObjects) { if (g is PlayerObject) { PlayerObject p = (PlayerObject)g; g.ExperiencePoints = _gameUniverse.GetRandom(6, 12); } } foreach (Npc n in _gameUniverse.Npcs) { if (n is IExperiencePoints) { IExperiencePoints i = (IExperiencePoints)n; i.XP = _gameUniverse.GetRandom(6, 12); } } }