/*
     * Chest Drops
     */
    IEnumerator DropTreasure()
    {
        isOpen = true;

        yield return(new WaitForSeconds(1f));

        print("Chest opened");
        table.DropItem();
    }
Exemple #2
0
 public override void Interact()
 {
     base.Interact();
     if (!opened)
     {
         table.DropItem();
         opened = true;
     }
     else
     {
         Debug.Log("Chest already looted");
     }
 }
    /*
     * Trigger death of enemy. Drops loot and destorys game object
     * Creator: Myles Hagen,Tianqi Xiao, Shane Weerasuriya
     */
    public void Die()
    {
        isDead        = true;
        con.enabled   = false;
        agent.enabled = false;
        col.enabled   = false;
        table.DropItem();

        //Play a randomization of clips in list if muiltple exist
        if (enemyDeathClips.Length > 0)
        {
            int x = (int)Random.Range(0.0f, enemyDeathClips.Length);
            AudioSource.PlayClipAtPoint(enemyDeathClips[x], transform.position, 1.0f);
        }

        TimeOfDeath();
        Destroy(gameObject, 10f);
    }
    /*
     * Trigger death of enemy. Drops loot and destorys game object
     * Creator: Myles Hangen
     */
    public virtual void Die()
    {
        //Debug.Log("die in enemy");
        //for village scene initial event
        int scenenum = SceneManager.GetActiveScene().buildIndex;

        if (scenenum == 0 && AllEventList.returnStatus("villageInitial", 0) == false)
        {
            Debug.Log("Increasing count.");
            ManageScene.instance.increaseCount();
        }
        //
        if (aiGroundSwarm.instance != null)
        {
            aiGroundSwarm.instance.deathCounter++;
        }
        isDead = true;
        if (con != null)
        {
            con.enabled = false;
        }
        agent.enabled = false;
        col.enabled   = false;
        if (table != null)
        {
            table.DropItem();
        }

        //Play a randomization of clips in list if muiltple exist
        if (enemyDeathClips.Length > 0)
        {
            int x = (int)Random.Range(0.0f, enemyDeathClips.Length);
            AudioSource.PlayClipAtPoint(enemyDeathClips[x], transform.position, 1.0f);
        }

        TimeOfDeath();
        Destroy(gameObject, 10f);
    }
    /*
     * Function: DelaySpawn
     * Parameters: delay
     * Description: coroutine to delay the instaniation of items
     * when chest is opened to keep drops in line with animation.
     */
    IEnumerator DelaySpawn(float delay)
    {
        yield return(new WaitForSeconds(delay));

        table.DropItem();
    }