Example #1
0
    private void CheckInteractions()
    {
        RaycastHit hit;

        if (!Physics.Raycast(GetRay(), out hit, interactionDistance))
        {
            //turn UI off
            uiManager.UpdateInteractableText("");
            return;
        }
        Drink          drink      = hit.transform.GetComponent <Drink>();
        MysteryBox     mysteryBox = hit.transform.GetComponent <MysteryBox>();
        PackAPunch     packAPunch = hit.transform.GetComponent <PackAPunch>();
        BuyableWeapons buyable    = hit.transform.GetComponent <BuyableWeapons>();
        Obstacle       obstacle   = hit.transform.GetComponent <Obstacle>();

        if (buyable != null)
        {
            InteractWithBuyable(buyable);
        }
        else if (drink != null)
        {
            InteractWithDrink(drink);
        }
        else if (mysteryBox != null)
        {
            InteractWithMysteryBox(mysteryBox);
        }
        else if (packAPunch != null)
        {
            InteractWithPackAPunch(packAPunch);
        }
        else if (obstacle != null)
        {
            uiManager.UpdateInteractableText(obstacle.blockedArea + ": $" + obstacle.cost.ToString());
            if (CheckInteractionInput() == false)
            {
                return;
            }
            if (gameManager.points < obstacle.cost)
            {
                return;
            }
            obstacle.Buy();
            gameManager.ConsumePoints(obstacle.cost);
        }
    }
Example #2
0
 private void InteractWithPackAPunch(PackAPunch packAPunch)
 {
     if (weapons[currentWeaponIndex] != null)
     {
         uiManager.UpdateInteractableText(packAPunch.name + " " + weapons[currentWeaponIndex]._name);
     }
     if (CheckInteractionInput() == false)
     {
         return;
     }
     if (packAPunch.inUse == true)
     {
         return;
     }
     if (weapons[currentWeaponIndex] == null || weapons[currentWeaponIndex].packed == true)
     {
         return;
     }
     if (gameManager.points < packAPunch.cost)
     {
         return;
     }
     packAPunch.Buy(this, weapons[currentWeaponIndex]);
 }