Пример #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("InterObject") || other.CompareTag("Item"))
        {
            currentInterObj = other.gameObject;

            if (currentInterObj.name == "CraftingNPC")
            {
                interactableGUI.Show("Craft", currentInterObj.transform, new Vector2(0, 2f));
            }

            currentInterObjScript = currentInterObj.GetComponent <InteractionObject>();
            if (currentInterObjScript.openable)
            {
                interactableGUI.Show("Open", currentInterObj.transform, new Vector2(0, 2f));
            }

            if (currentInterObjScript.collectable)
            {
                Item item = currentInterObj.GetComponent <PickUp>().item;
                Item previousItem;
                if (equipment.Equip(item, out previousItem) && previousItem != null)
                {
                    hubChest.AddItemToHubChest(previousItem);
                }
                else if (item.type.ToString() == "Material")
                {
                    hubChest.AddItemToHubChest(item);
                }
                currentInterObj.SetActive(false);
            }
        }
    }
Пример #2
0
    private void playerEnteredBounds()
    {
        Level level = levelToLoad.GetComponent <Level>();

        portalGUI.SetOption(0, () => ActivateHubPortal(-1), level.title + " - Start");
        if (isInHub && level.checkPoints.Count > 0)
        {
            int index = 1;
            foreach (var Checkpoint in level.checkPoints)
            {
                if (player.Checkpoints.Contains(Checkpoint.portalId))
                {
                    portalGUI.SetOption(index, () => ActivateHubPortal(Checkpoint.portalId), level.title + " - " + index);
                    index++;
                }
            }
            //for (int i = 0; i < level.checkPoints.Count; i++)
            //{
            //    int index = i;
            //    portalGUI.SetOption(i+1, () => ActivateHubPortal(index), level.title + " - " + index);
            //}
            interactableGUI.Show(interactTextToDisplay, transform, guiOffset + Vector2.up * 2.1f);
            portalGUI.Show(transform, guiOffset);
        }
        else
        {
            interactableGUI.Show(interactTextToDisplay, transform, guiOffset);
            player.SetInteractAction(interactAction);
        }
    }
Пример #3
0
 private void Interact()
 {
     Debug.Log("coins: " + player.coins.ToString() + " price: " + upgradePrice.ToString() + " dmg: " + player.attack1Dam.ToString());
     if (player.coins >= upgradePrice)
     {
         player.attack1Dam        += 1f;
         player.attack2Dam        += 1.5f;
         player.attack3Dam        += 2f;
         player.downwardAttackDam += 1.5f;
         player.coins             -= upgradePrice;
         upgradePrice              = (upgradePrice + 5) * 2;
         player.SetCoinText();
         interactableGUI.Hide();
         interactableGUI.Show(interactTextToDisplay + " " + upgradePrice.ToString(), transform, new Vector2(0, 2f));
     }
 }
Пример #4
0
 private void AskToLevelUp()
 {
     interactableGUI.Show("Level up\n", transform, new Vector2(0, 2), player.priceToLevelUp.ToString(), "essence");
 }