Пример #1
0
    public virtual void RecieveResource(int amount)
    {
        // if object is alive
        if (Alive)
        {
            int damage = resource;
            // check if life is greater then damage delt
            if (damage == amount)
            {
                // do damage
                currentAmount -= amount;
            }
            else
            {
                //sett player health to 0
                currentAmount = 0;
                //check if it is a monster


                lootTable.DropLoot(this.gameObject);
                this.gameObject.GetComponent <MeshCollider>().enabled = false;
                this.gameObject.GetComponent <Renderer>().enabled     = false;
                foreach (GameObject item in Child)
                {
                    item.SetActive(false);
                }
            }
        }
    }
Пример #2
0
    private void SpawnLoot()
    {
        LootTable lt = GetComponent <LootTable>();

        if (lt)
        {
            lt.DropLoot();
        }
    }
Пример #3
0
 private void GenerateLoot()
 {
     if (lootTable != null)
     {
         var loot = lootTable.DropLoot();
         if (loot != null)
         {
             Instantiate(loot, transform.position, Quaternion.identity);
         }
     }
 }
Пример #4
0
    public void DropLoot()
    {
        if (fromEnemy)
        {
            ////Debug.Log("From Enemy Loot");
            //randomDir = new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), 0);
            //ejectForce = Random.Range(100f, 200f);
            //direction = (gameObject.transform.position - player.transform.position).normalized * 2;
            foreach (GameObject loot in guaranteedLoot)
            {
                lootTable.currentLoot.Add(loot);
                Debug.Log("Adding guaranteed loot: " + loot);
            }
            lootTable.DropLoot(rank, ai.dt, gameObject.transform.position);
            return;
        }

        else //if not from an enemy, ie, a crate, spawn all items on list NOT away from the player
        {
            foreach (GameObject loot in guaranteedLoot)
            {
                //float rng = Random.Range(0f, 1f);
                //if (rng <= lootListProbability)
                //{
                //    playerPos = player.transform.position;

                //}
                //else
                //{
                //Debug.Log("From Crate Loot");
                randomDir  = new Vector3(Random.Range(-3f, 3f), Random.Range(-3f, 3f), 0);
                ejectForce = Random.Range(50f, 100f);
                direction  = new Vector3(0f, 0f, 0f);

                GameObject lootItem = Instantiate(loot, gameObject.transform.position, gameObject.transform.rotation);
                lootItem.GetComponentInChildren <Rigidbody2D>().AddForce((direction + randomDir) * ejectForce);
                Debug.Log("Add force -  Direction: " + direction + ", RandomDir: " + randomDir + ", Eject Force: " + ejectForce);
            }
        }
    }