IEnumerator IOpenChest()
    {
        OpenChest();

        yield return(new WaitForSeconds(3));

        CloseChest();

        focusController.DeFocus();
    }
Example #2
0
    void PickUpCurrency()
    {
        // Add to balance
        Debug.Log("DEBUG - CURRENCY: Added " + currency.name + " to your balance");
        characterStats.Balance += currency.CurrencyValue;

        // Delete from game world
        Debug.Log("DEBUG - CURRENCY: Deleting " + gameObject.name);
        Destroy(gameObject);

        // Stop Focusing the deleted currency
        focusController.DeFocus();
    }
Example #3
0
    void PickUpItem()
    {
        // Add item to inventory
        Debug.Log("DEBUG - ITEM: Added " + itemBlueprint.name + " to inventory");
        bool successfulPickup = Inventory.InventoryInstance.AddToInventory(itemBlueprint);

        // Delete item from game world
        if (successfulPickup == true)
        {
            Destroy(gameObject);
        }

        // Stop Focusing the deleted item
        focusController.DeFocus();
    }
Example #4
0
    void AttackEnemy()
    {
        if (health <= playerManager.player.GetComponent <AllCharacterStats>().Damage)
        {
            // drop loot
            for (int i = 0; i < enemy.loot.Count; i++)
            {
                if (enemy.loot[i].item != null)
                {
                    float chance = Random.Range(0.1f, 99.9f);
                    if (chance < enemy.loot[i].dropChance)
                    {
                        Debug.Log("DEBUG - Ai: Dropping loot " + enemy.loot[i].item.ItemName);

                        GameObject loot = Instantiate(enemy.loot[i].item.itemPrefab, focusController.focus.interactionPoint.position, focusController.focus.interactionPoint.rotation);
                        loot.name = enemy.loot[i].item.ItemName;
                    }
                    else
                    {
                        Debug.Log("DEBUG - Ai: Lost chance of dropping " + enemy.loot[i].item.ItemName + " - " + chance.ToString());
                    }
                }
                else
                {
                    Debug.LogWarning("WARNING - Ai: Drop item with index " + i + " is not assigned!");
                }
            }

            // drop currency
            for (int i = 0; i < enemy.currency.Count; i++)
            {
                if (enemy.currency[i].currency != null)
                {
                    float chance = Random.Range(0.1f, 99.9f);
                    if (chance < enemy.currency[i].dropChance)
                    {
                        Debug.Log("DEBUG - Ai: Dropping currency " + enemy.currency[i].currency.CurrencyName);

                        GameObject currency = Instantiate(enemy.currency[i].currency.currencyPrefab, focusController.focus.interactionPoint.position, focusController.focus.interactionPoint.rotation);
                        currency.name = enemy.currency[i].currency.CurrencyName;
                    }
                    else
                    {
                        Debug.Log("DEBUG - Ai: Lost chance of dropping " + enemy.currency[i].currency.CurrencyName + " - " + chance.ToString());
                    }
                }
                else
                {
                    Debug.LogWarning("WARNING - Ai: Drop currency with index " + i + " is not assigned!");
                }
            }

            focusController.DeFocus();

            // kill enemy
            KillEnemy();
        }
        else
        {
            float playerEnemyDistance = Vector3.Distance(playerManager.player.transform.position, this.transform.position);
            if (playerEnemyDistance <= enemy.enemyAttackRadius)
            {
                // attacking the enemy
                Debug.Log("DEBUG - Ai: Player dealed " + characterStats.Damage + " to " + enemy.prefabName);
                health -= characterStats.Damage;
            }

            // defocusing enemy
            focusController.DeFocus();
        }
    }