Пример #1
0
    //The Death method, drops a loot item, gives xp and then destorys the enemy will eventully play death animation
    public void EnemyDeath()
    {
        if (PersistantGameManager.Instance.currentEnemyKills.ContainsKey(enemyStats.enemyName))
        {
            PersistantGameManager.Instance.currentEnemyKills[enemyStats.enemyName]++;
        }
        else
        {
            PersistantGameManager.Instance.currentEnemyKills.Add(enemyStats.enemyName, 1);
        }

        if (questTarget == true && PersistantGameManager.Instance.activeQuests.Contains(questKey))
        {
            GameObject      questDrop        = Instantiate(Resources.Load(lootDropPreFabName), transform.position + new Vector3(0.6f, 0, 0), Quaternion.identity) as GameObject;
            LootDropMonitor questDropMonitor = questDrop.GetComponent <LootDropMonitor>();



            questDropMonitor.type = 2;
            //questDropMonitor.item = PersistantGameManager.Instance.questTargets[nPCMonitor.currentQuest.questKey];
            questDropMonitor.item = questReward;
            droppedQuestItem      = true;
        }

        // Sets most recent killed enemy's level to the enemy level for loot to level based on enemy stats rather than the player.
        PersistantGameManager.Instance.lastEnemyLevel = enemyStats.enemyLevel;


        //Gets the new weapon based off the drop chance and the value of weapon, if a weapon is not going to be droped it returns null
        LootItem newItem = LootManager.DropItem(itemChance, weaponValue);

        int chance = random.Next(0, 3);

        if (chance > 0 && enemyStats.enemyName != "Evil Door")
        {
            newItem = null;
        }

        //runs if there is a weapon stored in new weapon
        if (newItem != null)
        {
            //Instatiates the loot drop prefab at the poition of the enemy takes a local "Gameobject copy"
            GameObject lootDropInstance = Instantiate(Resources.Load(lootDropPreFabName), transform.position, Quaternion.identity) as GameObject;

            //gets the LootDropMonitor from the newly created Loot Drop
            LootDropMonitor lootDropInstanceMonitor = lootDropInstance.GetComponent <LootDropMonitor>();

            if (newItem.type == 0)
            {
                lootDropInstanceMonitor.type      = 0;
                lootDropInstanceMonitor.itemStats = newItem.newWeapon;
            }


            if (droppedQuestItem == true)
            {
                Vector2 lootPosition = lootDropInstance.transform.position;
                lootDropInstance.transform.position = new Vector2(lootDropInstance.transform.position.x - 1 / 2, lootPosition.y);
            }


            //Tells the Loot Drop what weapon it should store
        }

        //Gives the player XP
        GiveExp(enemyStats.enemyTier, enemyStats.enemyLevel);


        //Kills the enemy
        if (transform.parent != null)
        {
            Destroy(transform.parent.gameObject);
        }
        else
        {
            Destroy(transform.gameObject);
        }
    }
Пример #2
0
 public static void OnDropLoot(string entryName, Vector2 location)
 {
     LootManager.DropItem(location, 1, "Lizard.Mod_ExampleMod.ExampleItem");
     LootManager.DropSkill(location, 1, "Lizard.Mod_ExampleMod.ExampleSkill");
 }