Пример #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         eventlogs.AddEvent(item.name + " is on the floor.");
         isStepOn = true;
     }
 }
Пример #2
0
        void CalculateLoot()
        {
            int calculateDropChance = Random.Range(0, 101);

            if (calculateDropChance > dropChance)
            {
                Debug.Log("No loot");
                return;
            }
            if (calculateDropChance <= dropChance)
            {
                int itemWeight = 0;

                for (int i = 0; i < lootTable.items.Count; i++)
                {
                    itemWeight += lootTable.items[i].dropRate;
                }
                Debug.Log("Item Weight : " + itemWeight);

                int randomDropValue = Random.Range(0, itemWeight);

                for (int i = 0; i < lootTable.items.Count; i++)
                {
                    if (randomDropValue <= lootTable.items[i].dropRate)
                    {
                        Instantiate(lootTable.items[i].gameobject, transform.position, Quaternion.identity);
                        eventLogs.AddEvent(lootTable.items[i].name + " Dropped");
                        return;
                    }
                    randomDropValue -= lootTable.items[i].dropRate; //increased drop rate
                }
            }
        }
Пример #3
0
 public void DamageEntity(string beenDamaged, int damage)
 {
     damage         = Mathf.Clamp(damage, 0, int.MaxValue); //have room for improvements ,. ,balancing shits
     currentHealth -= damage;
     eventLogs.AddEvent(beenDamaged + " has been Hit for " + damage);
     if (currentHealth <= 0)
     {
         currentHealth = 0;
         Die();
     }
 }