//buy element and put it in inventory
    private void BuyElement(ElementTypes element, GameObject elementObject)
    {
        //check if player has enough currency
        if (currencyManager.CurrentCurrency >= elementCost && inventory.Count < 18)
        {
            //remove currency required from player and increase element cost
            currencyManager.CurrentCurrency -= elementCost;
            elementCost = new BigInteger((double)elementCost * elementCostModifier);
            UpdateCurrencyText(elementCost);

            //spawn element in the correct position in the inventory
            int invlen = inventory.Count;
            inventory.Add(Instantiate(elementObject, inventoryZero, UnityEngine.Quaternion.identity).transform);
            inventory[invlen].position = inventoryZero + new UnityEngine.Vector3(invlen * 1.094f, (invlen / 6) * -1.094f, 0);
            if (invlen >= 6)
            {
                inventory[invlen].position = new UnityEngine.Vector3(inventoryZero.x + (invlen % 6) * 1.094f, inventory[invlen].position.y, 0);
            }

            //Debug.Log(inventoryZero.x + "+ ((" + invlen + " - 1) % 6) * 1.094 = " + (inventoryZero.x + (invlen % 6) * 1.094f));
            //Debug.Log(invlen + " % 6 = " + invlen % 6);

            //change origin and element in ItemPickUp
            ItemPickUp elementItemPickUp = inventory[invlen].GetComponent <ItemPickUp>();
            elementItemPickUp.Origin      = inventory[invlen].position;
            elementItemPickUp.Element     = element;
            elementItemPickUp.Shop        = gameObject.GetComponent <ElementShop>();
            elementItemPickUp.gamemanager = gameManager;
        }
    }
Beispiel #2
0
    public void EquipArmor(ItemPickUp armorPickUp, CharacterInventory charInventory)
    {
        switch (armorPickUp.itemDefinition.itemArmorSubType)
        {
        case ItemArmorSubType.Head:
            headArmor          = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;

        case ItemArmorSubType.Chest:
            chestArmor         = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;

        case ItemArmorSubType.Hands:
            handArmor          = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;

        case ItemArmorSubType.Legs:
            legArmor           = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;

        case ItemArmorSubType.Boots:
            footArmor          = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;
        }
    }
 public void ChangeEquipableItem(ItemPickUp itemPickup)
 {
     if (!characterDefinition.UnEquipItem(itemPickup, charInv, characterItemSlot))
     {
         characterDefinition.Equip(itemPickup, charInv, characterItemSlot);
     }
 }
Beispiel #4
0
    public override void OnInspectorGUI()
    {
        ItemPickUp pickup = (ItemPickUp)target;

        string[]     options;
        ItemDatabase database = ItemDatabase.instance;

        options = new string[database.database.Count];
        for (int i = 0; i < options.Length; i++)
        {
            options[i] = database.database[i].Title;
        }

        selected = EditorGUILayout.Popup("Item Type", selected, options);

        if (!pickup.isPickupInstance)
        {
            if (selected != prev)
            {
                itemName    = selected;
                prev        = selected;
                pickup.item = new Item(database.FetchItemByID(selected));
            }
        }
        if (DrawDefaultInspector())
        {
        }
    }
 public void ChangeWeapon(ItemPickUp weaponPickUp)
 {
     if (!characterDefinition.UnEquipWeapon(weaponPickUp, charInv, characterWeaponSlot))
     {
         characterDefinition.EquipWeapon(weaponPickUp, charInv, characterWeaponSlot);
     }
 }
    void OnTriggerStay(Collider other)
    //void OnCollisionEnter(Collision other)
    {
        Debug.Log("touch");

        ItemPickUp item = other.GetComponentInParent <ItemPickUp>();

        if (item && triggerButtonDown)
        {
            Debug.Log("grabbed");
            //item.HeldBy(attachPoint, playerType);

            FixedJoint joint = GetComponent <FixedJoint>();
            if (joint)
            {
                Debug.Log("JointConnected");
                joint.connectedBody = other.attachedRigidbody;

                //if picking up mouse disable mouse controls
                var mouse = other.GetComponentInChildren <Mouse>();
                if (mouse)
                {
                    Debug.Log("Mouse Pickup");
                    mouse.GetComponentInChildren <Basic3DRBmovement>().enabled = false;
                }
            }

            itemHeld = item;
        }
    }
Beispiel #7
0
 public bool StoreItem(ItemPickUp item_pickup, out ItemPickUp previousItem, List <BaseEquipmentSlot> baseEquipmentSlots)
 {
     for (int index = 0; index < baseEquipmentSlots.Count; index++)
     {
         if (baseEquipmentSlots[index].EquipmentType == item_pickup.itemDefinition.SubType)
         {
             if (container_item_entry[index] != null)
             {
                 previousItem = container_item_entry[index].item_pickup;
                 container_item_entry[index] = new ItemEntry(item_pickup, index);
                 NotificationEvents();
                 return(true);
             }
             else
             {
                 container_item_entry[index] = new ItemEntry(item_pickup, index);
                 NotificationEvents();
                 previousItem = null;
                 return(true);
             }
         }
     }
     previousItem = null;
     return(false);
 }
    // undos all changes up until the first checkpoint encountered which will have its transform returned
    public static Transform undoChanges()
    {
        while (log.Count > 0)
        {
            EventDetails temp = log.Pop();

            switch (temp.type)
            {
            case (EventType.ITEM_RETRIEVED):
                ItemPickUp tempItem = temp.obj.GetComponent <ItemPickUp>();
                tempItem.reactivate();
                ItemTracker.removeItem(tempItem.item);
                break;

            case (EventType.CHECKPOINT):
                if (triggeredCheckpoint != null)
                {
                    triggeredCheckpoint();
                }
                return(temp.obj.transform);
            }
        }

        return(null);
    }
 public void ChangeArmour(ItemPickUp armourPickup)
 {
     if (!characterDefinition.UnequipArmour(armourPickup, inventory))
     {
         characterDefinition.EquipArmour(armourPickup, inventory);
     }
 }
Beispiel #10
0
 public void ChangeWeapon(ItemPickUp weaponPickup)
 {
     if (!characterDefinition.UnequipWeapon(weaponPickup, inventory, characterWeaponSlot))
     {
         characterDefinition.EquipWeapon(weaponPickup, inventory, characterWeaponSlot);
     }
 }
    public void GetInput()
    {
        if (Input.GetMouseButtonUp(0))
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit, Mathf.Infinity))
            {
                //Check if is an NPC
                TigerNpcController tigerNpcController = hit.transform.GetComponent <TigerNpcController>();
                itemPickUp = hit.transform.GetComponent <ItemPickUp>();

                if (tigerNpcController != null && PlayerController.main.contactPlayer == true)
                {
                    tigerNpcController.ShowQuestInfo();

                    return;
                }
                if (itemPickUp != null && itemPickUp.contactPlayer)
                {
                    itemPickUp.PickUp();

                    return;
                }
            }
        }
    }
Beispiel #12
0
 public void EquipArmor(ItemPickUp armorPickUp, CharacterInventory charInventory)
 {
     //    switch (armorPickUp.itemDefinition.itemArmorSubType)
     //    {
     //        case ItemArmorSubType.Head:
     //            charInventory.inventoryDisplaySlots[3].sprite = armorPickUp.itemDefinition.itemIcon;
     //            headArmor = armorPickUp;
     //            currentResistance += armorPickUp.itemDefinition.itemAmount;
     //            break;
     //        case ItemArmorSubType.Chest:
     //            charInventory.inventoryDisplaySlots[4].sprite = armorPickUp.itemDefinition.itemIcon;
     //            chestArmor = armorPickUp;
     //            currentResistance += armorPickUp.itemDefinition.itemAmount;
     //            break;
     //        case ItemArmorSubType.Hands:
     //            charInventory.inventoryDisplaySlots[5].sprite = armorPickUp.itemDefinition.itemIcon;
     //            handArmor = armorPickUp;
     //            currentResistance += armorPickUp.itemDefinition.itemAmount;
     //            break;
     //        case ItemArmorSubType.Legs:
     //            charInventory.inventoryDisplaySlots[6].sprite = armorPickUp.itemDefinition.itemIcon;
     //            legArmor = armorPickUp;
     //            currentResistance += armorPickUp.itemDefinition.itemAmount;
     //            break;
     //        case ItemArmorSubType.Boots:
     //            charInventory.inventoryDisplaySlots[7].sprite = armorPickUp.itemDefinition.itemIcon;
     //            footArmor = armorPickUp;
     //            currentResistance += armorPickUp.itemDefinition.itemAmount;
     //            break;
     //    }
 }
Beispiel #13
0
    void AddItem(ItemPickUp pickUp)
    {
        //check if item is an item that needs to be collected
        if (ItemsToCollect.Contains(pickUp.item))
        {
            //check if the item has already been collected
            if (CurrentItems.Contains(pickUp.item))
            {
                //Item alredy exists and therefor we can return
                EjectItem(pickUp);
                return;
            }

            //Item has not been added and therefor add new item to the collected List
            CurrentItems.Add(pickUp.item);
            //Destroy collected Item
            Destroy(pickUp.gameObject);
        }
        else
        {
            EjectItem(pickUp);
        }

        AllItemsCollected = AreItemsCollected();
    }
 public void ChangeArmor(ItemPickUp armorPickUp)
 {
     if (!characterDefinition.UnEquipArmor(armorPickUp, charInv))
     {
         characterDefinition.EquipArmor(armorPickUp, charInv);
     }
 }
    public void EquipArmor(ItemPickUp armorPickUp, CharacterInventory charInventory)
    {
        switch (armorPickUp.itemDefinition.itemArmorSubType)            // switch the index of the enum in the item defintion of the itemPickUp enter as parameter
        {
        case ItemArmorSubType.Head:                                     // if its a head armor
            headArmor          = armorPickUp;                           // the current head armor will be the armorPickUp
            currentResistance += armorPickUp.itemDefinition.itemAmount; // increase the resistance based on the item amount of the itemPickUp enter as parameter
            break;

        case ItemArmorSubType.Chest:        // the same thing for all the type of armor in the enum
            chestArmor         = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;

        case ItemArmorSubType.Hands:        // the same thing for all the type of armor in the enum
            handsArmor         = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;

        case ItemArmorSubType.Legs:        // the same thing for all the type of armor in the enum
            legsArmor          = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;

        case ItemArmorSubType.Boots:        // the same thing for all the type of armor in the enum
            footArmor          = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;
        }
    }
Beispiel #16
0
    public void LayerFind(Layer layer, RaycastHit?hit)
    {
        switch (layer)
        {
        case Layer.Walkable:
            DetectPoint(hit.Value.point);
            break;

        case Layer.Enemy:
            distance = 0;
            GameObject target = hit.Value.collider.gameObject;
            EnemyNormalAttack(target);
            break;

        case Layer.Item:
            ItemPickUp pickUp = GetComponent <ItemPickUp>();
            if (Vector3.Distance(transform.position, hit.Value.collider.transform.position) < 2f)
            {
                pickUp.TakeItem(hit.Value.collider.transform);
            }
            else
            {
                distance = 0;
                DetectItem(hit.Value.collider.transform);
                pickUp.TakeItem(hit.Value.collider.transform);
            }

            break;

        default:
            print("Undefined layer");
            break;
        }
    }
    // We can only UnEquip a weapon that is currently equiped. Therefore to avoid any bugs we need to check if the weapon is currently attached.
    // We are going to have a MEthod that returns a bool. We are going to have code to determine weather that thing is true or false and then we will return it.
    // What is really great about this is that we can then take this Method and put it inside an if statement(condition) and the Method will run and the if statement will do
    // what it needs to do to act as if it is true or false if(MethodOfReturnTypeBool) ... genial!! The Method will run as soon as the condition is evaluated.
    // This is a really great way to setup equiping system because if the item is equipable there is some things we want to do (e.g. Put item in head change inventory etc.)
    // If we cant maybe it will just go back right into the inventory etc etc.

    // There is certain information we need to pass it. First which weapon should be unequiped.
    // We need to tell it which inventory this is coming from.
    // Also we need to tell it in which weaponSlot the weapon currently is.
    #endregion
    public bool UnEquipWeapon(ItemPickUp weaponToRemove, CharacterInventory charInventory, GameObject weaponSlot)
    {
        bool isWeaponEquiped = false;

        // weapon is the gameObject that stores our currently equiped weapon
        if (weapon == null)
        {
            // If the Function enters this if statement the funcion will end here and no additional code from the function will be run.
            return(isWeaponEquiped);
        }

        if (weapon == weaponToRemove)
        {
            charInventory.inventoryDisplaySlots[2].sprite = null;
            isWeaponEquiped = true;
            #region Destroy over DestroyObject, Inspector Setup Komment
            // DestroyObject is deprecated use Destroy instead!
            // We are going to destroy the Equipped gameObject. Which is the child of our weaponSlot!
            // Transform also holds information about child objects not only position, rotation and scale!!
            // GetChild(0) will give us the first child of this gameObject!

            // Since the weapon that is currently equipped, is destroyed using by desttoying the child of the WeaponSlot this need to be Setup accordingly in the Inspector.
            // The currently equpped weapon in our case the sword needs to be the child of the WeaponSlot and thw WeaponSlot needs to be paranted to where we want to spawn
            // The Weapon which is in the Hand of the Character therefore we parent it to the Characters Wrist. We also parent the CharInventory to our Hero to keep things
            // organized. We need this gameObj anyway cause we need to attach a Class to another Script which is only possible if it is attached to a gameObj.
            #endregion
            Destroy(weaponSlot.transform.GetChild(0).gameObject);
            weapon        = null;
            currentDamage = baseDamage;
        }

        return(isWeaponEquiped);
    }
Beispiel #18
0
    public void EquipArmor(ItemPickUp armorPickUp, CharacterInventory charInventory)
    {
        switch (armorPickUp.itemDefinition.itemArmorSubType)
        {
        case ItemArmorSubType.Head:
            charInventory.inventoryDisplaySlots[3].sprite = armorPickUp.itemDefinition.itemIcon;
            headArmor          = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;

        case ItemArmorSubType.Chest:
            charInventory.inventoryDisplaySlots[4].sprite = armorPickUp.itemDefinition.itemIcon;
            chestArmor         = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;

        case ItemArmorSubType.Hands:
            charInventory.inventoryDisplaySlots[5].sprite = armorPickUp.itemDefinition.itemIcon;
            handArmor          = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;

        case ItemArmorSubType.Legs:
            charInventory.inventoryDisplaySlots[6].sprite = armorPickUp.itemDefinition.itemIcon;
            legArmor           = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;

        case ItemArmorSubType.Boots:
            charInventory.inventoryDisplaySlots[7].sprite = armorPickUp.itemDefinition.itemIcon;
            footArmor          = armorPickUp;
            currentResistance += armorPickUp.itemDefinition.itemAmount;
            break;
        }
    }
Beispiel #19
0
    // itemToStore will be the Item the Character passed through
    public void StoreItem(ItemPickUp itemToStore)
    {
        // Use Dictionary Collection to store item

        // This will make sure that we are not adding multiple items as the character picks up "one" item.
        addedItem = false;

        // Wenn dein Character das tragen kann, dann kann er es storen. (Emcumbrance)
        if ((charStats.charDefinition.currentEncumbrance +
             itemToStore.itemDefinition.itemWeight) <= charStats.charDefinition.maxEncumbrance)
        {
            // The new itemEntry will be set to our item
            itemEntry.invEntry  = itemToStore;
            itemEntry.stackSize = 1;
            itemEntry.hbSprite  = itemToStore.itemDefinition.itemIcon;

            // The item we picked up will disapprear from the Environment!
            // addedItem is not used yet because when we set the Item inactive once we pick it up it cannot happend that we pick it up
            // multiple times!
            itemToStore.gameObject.SetActive(false);
        }
        else
        {
            Debug.Log("The Item is to heavy!");
        }
    }
    // Will tell us what armour out character has attached.
    public ItemPickUp GetCurrentArmor(ItemArmorSubType armorType)
    {
        // A local variable has to be initialized
        ItemPickUp currentItemPickUp = null;

        switch (armorType)
        {
        case ItemArmorSubType.NONE:
            currentItemPickUp = null;
            break;

        case ItemArmorSubType.HEAD:
            currentItemPickUp = charDefinition.headArmour;
            break;

        case ItemArmorSubType.CHEST:
            currentItemPickUp = charDefinition.chestArmour;
            break;

        case ItemArmorSubType.HANDS:
            currentItemPickUp = charDefinition.handArmour;
            break;

        case ItemArmorSubType.LEGS:
            currentItemPickUp = charDefinition.legArmour;
            break;

        case ItemArmorSubType.FEET:
            currentItemPickUp = charDefinition.footArmour;
            break;
        }

        return(currentItemPickUp);
    }
 public InventoryEntry(int stackSize,ItemPickUp invEntry,Sprite hbSprite)
 {
     this.invEntry = invEntry;
     this.stackSize = stackSize;
     this.hotBarSlot = 0;
     this.inventorySlot = 0;
     this.hbSprite = hbSprite;
 }
Beispiel #22
0
    public void EquipWeapon(ItemPickUp weaponPickUp, GameObject weaponSlot)
    {
        Rigidbody newWeapon;

        Weapon        = weaponPickUp;
        newWeapon     = Instantiate(weaponPickUp.ItemDefinition.weaponSlotObject, weaponSlot.transform);
        CurrentDamage = BaseDamage + Weapon.ItemDefinition.itemAmount;
    }
Beispiel #23
0
 public void ChangeWeapon(ItemPickUp weaponPickUp)
 {
     if (!CharacterDefinition.UnEquipWeapon(weaponPickUp, CharacterWeaponSlot))
     {
         CharacterDefinition.EquipWeapon(weaponPickUp, CharacterWeaponSlot);
         weaponPickUp.gameObject.SetActive(false); //Want to destroy it, but somehow it bugs destroy of the weapon in character hand
     }
 }
Beispiel #24
0
    void EjectItem(ItemPickUp pickUp)
    {
        //Eject the item in the opposite direction
        Rigidbody rb        = pickUp.GetComponent <Rigidbody>();
        Vector3   direction = -rb.velocity.normalized;

        rb.AddForce(direction * EjectForce, ForceMode.Impulse);
    }
Beispiel #25
0
    private void GetItem(BaseItemShopSlot baseItemShopSlot)
    {
        GameObject item_copy = Instantiate(_itemTemp);
        ItemPickUp item      = item_copy.GetComponent <ItemPickUp>();

        item.itemDefinition = _itemTemplateController.ItemTemplateDic[baseItemShopSlot.ITEMSHOP.ItemId];
        item.PurchaseItem();
    }
    // We are making use of the previously wrote Method UnEquipWeapon in CharacterStats_SO which is very smart

    // We need to check if the Current item we want to add is allready equiped and if it is we need to remove it.
    // To make room for a new GameObject.
    // We now have defined the characters Inventors and weaponSlot in the field region. And are to use them now!!!!!!!!!!!!
    // We dont need to pass them because this class has direct access to them wtf am i doing????

    // ChangeWeapon needs to be able to Equip and UnEquip weapons.
    #endregion
    public void ChangeWeapon(ItemPickUp weaponPickUp)
    {
        // Logic statement here!
        if (!charDefinition.UnEquipWeapon(weaponPickUp, charInv, charWeaponSlot))
        {
            charDefinition.EquipWeapon(weaponPickUp, charInv, charWeaponSlot);
        }
    }
Beispiel #27
0
    private void CheckItem()
    {
        if (Physics.SphereCast(P_target.transform.position, range, Vector3.up, out hitInfo, length, layerMask))
        //                 레이저 발사 위치            , 구의 반경, 발사 방향,      충돌 결과,     최대거리, 레이어마스크
        //if(checkRange_Script.checkItem())
        {
            //hitInfo = checkRange_Script.Get_hitInfo();

            if (hitInfo.transform.CompareTag("ObjAni") == false)
            {
                // = 외곽선 =
                ItemPickUp pieceItem_script = hitInfo.transform.GetComponent <ItemPickUp>();

                if (CheckAllSectorform(hitInfo)) //hitInfo가 범위 안에 있으면 true
                {
                    // - info 띄우기
                    ItemInfoAppear(pieceItem_script.item);

                    // - 외곽선
                    int temp_index = pieceItem_script.outlineIndex;
                    OutlineController.set_enabled(pieceItem_script.outlineIndex, true);

                    if (temp_index != pre_ol_index)
                    {
                        OutlineController.set_enabled(pre_ol_index, false);
                        pre_ol_index = pieceItem_script.outlineIndex;
                    }
                }
                else
                {
                    // - info 사라지게
                    InfoDisappear();

                    // - 외곽선 사라짐
                    OutlineController.set_enabled(pre_ol_index, false);

                    isCollision = false;
                }
            }
            else
            {
                if (CheckAllSectorform(hitInfo)) //hitInfo가 범위 안에 있으면 true
                {
                    // - info 띄우기
                    //ItemInfoAppear(pieceItem_script.item);

                    pickupActivated = true;
                    actionImage.gameObject.SetActive(true);
                }
            }
        }
        else
        {
            InfoDisappear();
            isCollision = false;
            OutlineController.set_enabled(pre_ol_index, false);
        }
    }
Beispiel #28
0
    public InventoryEntry(int stackSize, ItemPickUp item, Sprite hbSprite)
    {
        this.item = item;

        this.stackSize          = stackSize;
        this.hotBarSlot         = -1;
        this.inventorySlotIndex = 0;
        this.hbSprite           = hbSprite;
    }
Beispiel #29
0
    public void EquipWeapon(ItemPickUp weaponPickUp, CharacterInventory charInventory, GameObject weaponSlot)
    {
        Rigidbody newWeapon;

        weapon = weaponPickUp;
        charInventory.inventoryDisplaySlots[2].sprite = weaponPickUp.itemDefinition.itemIcon;
        newWeapon     = Instantiate(weaponPickUp.itemDefinition.weaponSlotObject, weaponSlot.transform);
        currentDamage = baseDamage + weapon.itemDefinition.itemAmount;
    }
Beispiel #30
0
    void Start()
    {
        thinkerbell = this.gameObject.GetComponent <Collider>();
        //thinkerbell.isTrigger = true;
        CanPick = this.gameObject.GetComponent <ItemPickUp>();

        //CanPick.enabled = false; //사용불가

        actionCtrler2_script = GameObject.FindObjectOfType <ActionController_02_VER2>();
    }
Beispiel #31
0
 public SpItemPickupMsg(ItemPickUp t, Item item)
 {
     type = t;
     Item = item;
 }