// Use this for initialization
 void Start()
 {
     sentences = new Queue <string>();
     player    = GameObject.Find("Player").GetComponent <Player>();
     inventory = GameObject.Find("InventoryManager").GetComponent <SwordInventory>();
     sword     = GameObject.FindGameObjectWithTag("Sword").GetComponent <Sword>();
 }
Esempio n. 2
0
    private IEnumerator HandleSwordPickup(GameObject swordGO, SpriteRenderer heldSwordSR)
    {
        yield return(new WaitForSeconds(2.0f)); // Will hold the pose for 2 seconds.

        // After this timer, add the new sword to the inventory
        SwordInventory si = GameObject.FindObjectOfType <SwordInventory>();

        if (si != null)
        {
            si.AddSlot(SwordId(swordGO));
            Destroy(swordGO);
        }
        // Stop the animation and make the player's original sword reappear in their hand
        if (heldSwordSR != null)
        {
            heldSwordSR.enabled = true;
        }
        pickingUpSword = false;
        getInventorySwords(); // Get the inventory of swords again to account for new one
        if (brickSwordHeld)   // if brick sword is held upon pickup
        {
            brickSword.SetActive(true);
        }
        inventory.switchSwords = true; // Able to switch swords once inventory is updated
    }
Esempio n. 3
0
    void Start()
    {
        rb             = GetComponent <Rigidbody2D>();
        playerAnimator = GetComponent <Animator>();
        playerCollider = GetComponent <Collider2D>();
        moving         = false;
        grounded       = false;
        falling        = false;
        hitpointBar    = GameObject.Find("HitpointBar").GetComponent <HitpointBar>();

        audioSource = GetComponent <AudioSource>();

        inventoryGO = GameObject.Find("InventoryManager");
        inventory   = inventoryGO.GetComponent <SwordInventory>();
        swordPossessions.Add(0);
        addSwords();
        getInventorySwords();
        activeSwordIndex = inventory.index;
        pauseMenu        = GameObject.Find("PauseMenu");
        playerHPBar      = GameObject.Find("HitpointBar").GetComponent <HitpointBar>();

        Scene currentScene = SceneManager.GetActiveScene(); // To know which level

        sceneName      = currentScene.name;
        brickSwordHeld = false; // for sword pickup only
    }
Esempio n. 4
0
 public virtual void Start()
 {
     damageDelay           = damageDuration * damageDealt;
     damaging              = false;
     swordAnimator         = GetComponent <Animator>();
     player                = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
     inventory             = GameObject.Find("InventoryManager").GetComponent <SwordInventory>();
     swordCollider         = player.GetComponentInChildren <BoxCollider2D>();
     swordCollider.enabled = false;
     audioSource           = GetComponent <AudioSource>();
     audioSource.volume    = 0.2f;
     pauseMenu             = GameObject.Find("PauseMenu");
 }