public void SetItemInventory(PickUpObjectScript pickUpObject, int currentIndex)
 {
     if (currentIndex < inventory.inventorySize)
     {
         itemsHUD[currentIndex].sprite = pickUpObject.PickUpGraphic;
     }
 }
Ejemplo n.º 2
0
 public override void PickUp(PickUpObjectScript pickUp)
 {
     if (InventoryData.InventoryCount < InventoryData.MAXINVENTORYCOUNT)
     {
         base.PickUp(pickUp);
         gameObject.SetActive(false);
     }
 }
Ejemplo n.º 3
0
    // Update is called once per frame
    void OnTriggerEnter2D(Collider2D collider)
    {
        // Est-ce un tir ?
        ShotScript         shot         = collider.gameObject.GetComponent <ShotScript>();
        PlayerScript       player       = collider.gameObject.GetComponent <PlayerScript>();
        EnemyScript        enemy        = collider.gameObject.GetComponent <EnemyScript>();
        PickUpObjectScript pickUpObject = collider.gameObject.GetComponent <PickUpObjectScript>();

        if (shot != null)
        {
            // Tir allié
            if (shot.isEnemyShot != isEnemy)
            {
                currentHealth -= shot.damage;
                TakeDamage(shot.damage);

                // Destruction du projectile
                // On détruit toujours le gameObject associé
                // sinon c'est le script qui serait détruit avec ""this""
                Destroy(shot.gameObject);

                if (currentHealth <= 0)
                {
                    // Destruction !
                    Destroy(gameObject);
                }
            }
        }
        // Si le joueur touche un ennemi il perd 2 hp
        if (enemy != null && this.isEnemy == false)
        {
            currentHealth -= 20;
            TakeDamage(20);

            if (currentHealth <= 0)
            {
                Destroy(gameObject);
            }
        }
        //Si le joueur prend lifeItem, il récupère de la vie
        if (pickUpObject != null && pickUpObject.isLife == true)
        {
            healPlayer(50);
        }

        if (pickUpObject != null && pickUpObject.isLaser == true)
        {
            powerLaser = true;
        }
    }
    public void AddItem(PickUpObjectScript pickUpObject)
    {
        int temp;

        if (emptyItems.Count > 0)
        {
            temp = emptyItems[0];
            emptyItems.Remove(0);
        }
        else
        {
            temp          = currentIndex;
            currentIndex += 1;
        }
        item.Add(temp, pickUpObject);
        InventoryData.InventoryCount += 1;
        InventoryUIManager.InventoryUI.SetItemInventory(pickUpObject, temp - 1);
    }
Ejemplo n.º 5
0
 /// <summary>
 /// Picks up item.
 /// </summary>
 /// <param name="pickUp">Pick up.</param>
 public virtual void PickUp(PickUpObjectScript pickUp)
 {
     InventoryUIManager.InventoryUI.inventory.AddItem(pickUp);
 }
Ejemplo n.º 6
0
 private void Start()
 {
     PickUpObject = new PickUpObjectScript();
     inventoryUI  = InventoryUIManager.InventoryUI;
 }