//This function is called when a non-player dies, and is run on the server. //If the item has assigned drops, it will randomly generate one to show when destroyed. //Regardless, it will destroy the given object. void ItemSpawnDestroy() { /* * print("rpcitemspawn "+dropOnDeath.lootDropItems.Count); * for (int i = 0; i < dropOnDeath.lootDropItems.Count; i++) * { * if (dropOnDeath.lootDropItems[i].item != null) * print(dropOnDeath.lootDropItems[i].item.name); * } */ if (dropOnDeath.lootDropItems.Count > 0) { //GameObject powerUp = Instantiate(dropOnDeath[Random.Range(0, dropOnDeath.Length)], transform.position, Quaternion.identity); GenericLootDropItemGameObject powerUp = dropOnDeath.PickLootDropItem(); if (powerUp.item != null) { GameObject newPowerUp = Instantiate(powerUp.item, transform.position, Quaternion.identity); } } EnemyBaseEntity enemyScript = GetComponent <EnemyBaseEntity>(); if (enemyScript != null) { enemyScript.DeathAnimation(); } else { Destroy(gameObject); } }
/// <summary> Spawning weapon around the chest </summary> private void DropWeaponNearChest() { GenericLootDropItemGameObject selectedItem = WeaponDropTable.PickLootDropItem(); GameObject weaponObject = Instantiate(selectedItem.item); weaponObject.transform.position = new Vector2(transform.position.x, transform.position.y) + Random.insideUnitCircle / 2.8f; _lootDropped = true; }
public GameObject CheckLootNearChest() { GenericLootDropItemGameObject selectedItem = lootDropTable.PickLootDropItem(); GameObject selectedItem1 = selectedItem.item; Debug.Log("selectedItem1" + selectedItem1); return(selectedItem1); }
/// <summary> /// Spawning objects in horizontal line /// </summary> /// <param name="numItemsToDrop"></param> void DropLootNearChest(int numItemsToDrop) { for (int i = 0; i < numItemsToDrop; i++) { GenericLootDropItemGameObject selectedItem = lootDropTable.PickLootDropItem(); GameObject selectedItemGameObject = Instantiate(selectedItem.item); selectedItemGameObject.transform.position = new Vector2(i / 2f, 0f); } }
/// <summary> /// Spawning objects in horizontal line /// </summary> /// <param name="numItemsToDrop"></param> public void DropLootNearChest(int numItemsToDrop, float enemyLocationX, float enemyLocationY) { for (int i = 0; i < numItemsToDrop; i++) { GenericLootDropItemGameObject selectedItem = lootDropTable.PickLootDropItem(); GameObject selectedItem1 = selectedItem.item; Debug.Log("selectedItem1" + selectedItem1); GameObject selectedItemGameObject = Instantiate(selectedItem.item); selectedItemGameObject.transform.position = new Vector2(enemyLocationX, enemyLocationY); } }
////////////////////////////////////////////////////////////////////////////////////////// void DropLootNearChest(int numItemsToDrop) { for (int i = 0; i < numItemsToDrop; i++) { GenericLootDropItemGameObject selectedItem = lootDropTable.PickLootDropItem(); GameObject selectedItemGameObject = Instantiate(selectedItem.item); selectedItemGameObject.transform.position = new Vector3( this.transform.position.x + Random.Range(-xOff, xOff), this.transform.position.y + 0.5f, this.transform.position.z + Random.Range(-zOff, zOff)); } }
public void Drop() { for (int i = 0; i < numItemsToDrop; i++) { GenericLootDropItemGameObject selectedItem = lootDropTable.PickLootDropItem(); if (selectedItem == null) { return; } GameObject selectedItemGameObject = Instantiate(selectedItem.item); /*selectedItemGameObject.transform.position = new Vector2(i/2f, 0f);*/ } }
//This function is called when a non-player dies, and is run on the server. //If the item has assigned drops, it will randomly generate one to show when destroyed. //Regardless, it will destroy the given object. void ItemSpawnDestroy() { //print("rpcitemspawn "+dropOnDeath.Length); //if (dropOnDeath.) { //print("dropondeathlength is over 0: "+baseDropChance); //Determine if we want to spawn a powerup to begin with: if (Random.Range(0.0f, 1.0f) < baseDropChance) { //GameObject powerUp = Instantiate(dropOnDeath[Random.Range(0, dropOnDeath.Length)], transform.position, Quaternion.identity); GenericLootDropItemGameObject powerUp = dropOnDeath.PickLootDropItem(); GameObject newPowerUp = Instantiate(powerUp.item, transform.position, Quaternion.identity); NetworkServer.Spawn(newPowerUp); } } Destroy(gameObject); }
////////////////////////////////////////////////////////////////////////////////////////// public void DropLootNearCorpse() { for (int i = 0; i < numItemsToDrop; i++) { GenericLootDropItemGameObject selectedItem = lootDropTable.PickLootDropItem(); //TODO: implement better looting system! // Fow now, we check if we have an item (item gameobject) to account for loot percentages // (i.e. selectedItem[0] == no gameobject) to make it possible to now drop loot on death. if (selectedItem.item != null) { GameObject selectedItemGameObject = Instantiate(selectedItem.item); selectedItemGameObject.transform.position = new Vector3( this.transform.position.x + Random.Range(-xOff, xOff), this.transform.position.y, this.transform.position.z + Random.Range(-zOff, zOff)); } } }