private void SpawnLoot(Lootable item, Transform spawnLocation) { Instantiate(item, spawnLocation.position + new Vector3(0, spawnLootHeightOffset, 0), spawnLocation.rotation); if (bDebug) { Debug.Log("Spawned loot at " + (spawnLocation.position + new Vector3(0, spawnLootHeightOffset, 0))); } }
private void btnInspect_Click(object sender, EventArgs e) { Lootable selectedLootable = (Lootable)cboInspect.SelectedItem; if (selectedLootable.IsLooted == false) { UpdateInspectListInUI(); selectedLootable.IsLooted = true; _looted = true; } }
public void ShouldReturnLootableTag() { // Arrange Lootable lootable = this.CreateLootable(); // Act List <string> result = lootable.GetTags(); // Assert CollectionAssert.Contains(result, "Lootable"); }
public void ShouldSetLoot() { // Arrange Lootable lootable = this.CreateLootable(); // Act lootable.AddLoot(this.pickable.Object); // Assert Assert.AreEqual(lootable.GetLoot(), this.pickable.Object); }
public void ShouldSetAndGetCoordinates() { // Arrange Lootable lootable = this.CreateLootable(); Coordinates xy = this.CreateNewCoordinates(); // Act lootable.SetCords(xy); // Assert Assert.AreEqual(lootable.GetCords(), xy); }
internal void Search(Lootable loot) { if (!Idling()) { return; } Speak(SoundBank.GoblinSound.Grunt); navMeshAgent.SetDestination(loot.transform.position); LootTarget = loot; ChangeState(CharacterState.Searching, true); }
public void OnCollisionEnter2D(Collision2D coll) { Debug.Log("PlayerLooter:CollisionEnter"); Collider2D other = coll.collider; Lootable lootable = other.gameObject.GetComponent <Lootable>(); if (lootable != null) { //pick up the item Collider2D thisCollider = gameObject.GetComponent <Collider2D>(); Debug.Log("PlayerLooter:Collided with loot"); lootable.PickUp(gameObject, coll, thisCollider); } }
private void LootInspectedItem() { Lootable selectedLootable = (Lootable)cboInspect.SelectedItem; Item selectedItem = (Item)cboContents.SelectedItem; _player.AddItemToInventory(selectedLootable.lootContent(selectedItem)); _currentContents.Remove(selectedItem); _currentContents.TrimExcess(); rtbMessages.Text += "You move the " + selectedItem.Name + " from the " + selectedLootable.Name + " to your inventory." + Environment.NewLine; if (_currentContents.Count == 0) { rtbMessages.Text += "The " + selectedLootable.Name + " is empty!" + Environment.NewLine; } cboContents.Items.Remove(selectedItem); UpdateInspectListInUI(); UpdateInventoryListInUI(); }
private void DisplayTooltipInfo(Lootable lootable) { //StringBuilder if extra appending is needed. StringBuilder text = new StringBuilder(); //Display title text. text.Append("<size=125%><align=center>").Append(lootable.GetColoredName()).Append("</size>"); nameText.text = text.ToString(); text.Clear(); statsText.text = lootable.GetTooltipStatsText(); notesText.text = lootable.GetTooltipNotesText(); instance.gameObject.SetActive(true); popupObject.transform.position = RectTransformUtility.WorldToScreenPoint(mainCamera, lootable.transform.position + new Vector3(0, 1, 0)); LayoutRebuilder.ForceRebuildLayoutImmediate(popupObject); }
void PickUpLoot() { Transform camera = Camera.main.transform; RaycastHit hit; if (Physics.Raycast(camera.position, camera.forward, out hit, 4)) { Lootable lootable = hit.collider.GetComponent <Lootable>(); if (lootable != null) { if (inventory.AddItem(lootable.loot)) { CmdDestroyLoot(lootable.gameObject); } } } }
public void OnCollisionEnter2D(Collision2D coll) { Collider2D other = coll.collider; Lootable lootable = other.gameObject.GetComponent <Lootable>(); if (lootable != null && monsterLoot != null) { monsterLoot.carrying.Add(lootable.gameObject); lootable.transform.parent = monsterLoot.transform; lootable.gameObject.SetActive(false); if (lootSound != null) { lootSound.PlayEffect(); } } }
void CreateLootableInstance() { lootable = CreateInstance <Lootable>(); lootable.itemType = itemType; }
private void MoveTo(Location newLocation) { if (!_player.HasRequiredItemToEnterThisLocation(newLocation)) { rtbMessages.Text += "You must have a " + newLocation.ItemRequiredEntry.Name + " to enter this location." + Environment.NewLine; ScrollToBottomOfMessages(); return; } _player.CurrentLocation = newLocation; btnNorth.Visible = (newLocation.LocationNorth != null); btnEast.Visible = (newLocation.LocationEast != null); btnSouth.Visible = (newLocation.LocationSouth != null); btnWest.Visible = (newLocation.LocationWest != null); btnInside.Visible = (newLocation.LocationInside != null); btnOutside.Visible = (newLocation.LocationOutside != null); rtbLocation.Text = newLocation.Name + Environment.NewLine; rtbLocation.Text += newLocation.Description + Environment.NewLine; UpdatePlayerStats(); if (newLocation.LootableHere != null) { newLocation.LocationEnvironment.Clear(); rtbMessages.Text += "You see a " + newLocation.LootableHere.Name + Environment.NewLine; newLocation.AddObjectToEnvironment(newLocation.LootableHere); Lootable standardLootable = World.LootableByID(newLocation.LootableHere.ID); _currentLootable = new Lootable(standardLootable.ID, standardLootable.Name, standardLootable.NamePlural, standardLootable.Capacity, standardLootable.IsLooted); foreach (Item lootItem in standardLootable.Contents) { _currentLootable.Contents.Add(lootItem); } _looted = _currentLootable.IsLooted; UpdateEnvironmentListInUI(); } if (newLocation.QuestHere != null) { bool playerAlreadyHasQuest = _player.HasThisQuest(newLocation.QuestHere); bool playerAlreadyCompletedQuest = _player.CompletedThisQuest(newLocation.QuestHere); if (playerAlreadyHasQuest) { if (!playerAlreadyCompletedQuest) { bool playerHasAllItemsToCompleteQuest = _player.HasAllQuestCompleteItems(newLocation.QuestHere); bool playerAtQuestDestination = _player.AtQuestDestinationToCompleteQuest(newLocation.QuestHere); if (playerHasAllItemsToCompleteQuest || playerAtQuestDestination) { rtbMessages.Text += Environment.NewLine; rtbMessages.Text += "You complete the " + newLocation.QuestHere.Name + " quest." + Environment.NewLine; ScrollToBottomOfMessages(); rtbMessages.Text += "You receive: " + Environment.NewLine; rtbMessages.Text += newLocation.QuestHere.RewardExperiencePoints.ToString() + " experience points" + Environment.NewLine; rtbMessages.Text += newLocation.QuestHere.RewardGold.ToString() + " gold" + Environment.NewLine; ScrollToBottomOfMessages(); rtbMessages.Text += Environment.NewLine; _player.AddItemToInventory(newLocation.QuestHere.RewardItem); // Calling function to add experience points on completion of quest _player.AddExperiencePoints(newLocation.QuestHere.RewardExperiencePoints); // Calling function to add gold on completion of quest _player.Gold += newLocation.QuestHere.RewardGold; // Calling function to add quest reward item on completion of quest _player.AddItemToInventory(newLocation.QuestHere.RewardItem); // Calling function to mark quest as completed on completion of quest _player.MarkQuestCompleted(newLocation.QuestHere); // Calling function to remove quest items on completion of quest _player.RemoveQuestCompleteItems(newLocation.QuestHere); rtbMessages.Text += newLocation.QuestHere.RewardItem.Name.ToString() + Environment.NewLine; } } } else { rtbMessages.Text += "You receive the " + newLocation.QuestHere.Name + " quest." + Environment.NewLine; ScrollToBottomOfMessages(); rtbMessages.Text += newLocation.QuestHere.Description + Environment.NewLine; rtbMessages.Text += "To complete it, acquire:" + Environment.NewLine; ScrollToBottomOfMessages(); foreach (QuestCompleteItem qci in newLocation.QuestHere.QuestCompleteItems) { if (qci.Quantity == 1) { rtbMessages.Text += qci.Quantity.ToString() + " " + qci.Details.Name + Environment.NewLine; } else { rtbMessages.Text += qci.Quantity.ToString() + " " + qci.Details.NamePlural + Environment.NewLine; } } rtbMessages.Text += Environment.NewLine; _player.Quests.Add(newLocation.QuestHere); } } if (newLocation.NumberEnemy == 0) { newLocation.EnemyHere = null; } if (newLocation.EnemyHere != null) { rtbMessages.Text += "You see a " + newLocation.EnemyHere.Name + Environment.NewLine; ScrollToBottomOfMessages(); Enemy standardEnemy = World.EnemyByID(newLocation.EnemyHere.ID); _currentEnemy = new Enemy(standardEnemy.ID, standardEnemy.Name, standardEnemy.MaximumDamage, standardEnemy.RewardExperiencePoints, standardEnemy.RewardGold, standardEnemy.CurrentHitPoints, standardEnemy.MaximumHitPoints); foreach (Item lootItem in standardEnemy.LootTable) { _currentEnemy.LootTable.Add(lootItem); } cboWeapons.Visible = true; cboMeds.Visible = true; btnUseMed.Visible = true; btnUseWeapon.Visible = true; } else { _currentEnemy = null; cboWeapons.Visible = false; UpdateMedListInUI(); btnUseWeapon.Visible = false; } UpdateInventoryListInUI(); UpdateQuestListInUI(); UpdateMedListInUI(); UpdateWeaponListInUI(); }
public EnvironmentalObject(Lootable details, int quantity) { Details = details; Quantity = quantity; }
public static void DisplayInfo(Lootable lootable) { instance.DisplayTooltipInfo(lootable); }