Esempio n. 1
0
 protected override void Reset()
 {
     if (effects == null)
     {
         effects = new List <Tapestry_Effect>();
     }
     inventoryUI = FindObjectOfType <Tapestry_Level>().inventoryUI;
     base.Reset();
 }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;
        inventoryUI      = FindObjectOfType <Tapestry_Level>().inventoryUI;
        if (ReferenceEquals(inventory, null))
        {
            inventory = (Tapestry_Inventory)ScriptableObject.CreateInstance("Tapestry_Inventory");
        }
        if (damageProfile == null)
        {
            damageProfile = new Tapestry_DamageProfile();
        }
        if (attributeProfile == null)
        {
            attributeProfile = new Tapestry_AttributeProfile();
        }
        if (skillProfile == null)
        {
            skillProfile = new Tapestry_SkillProfile();
        }
        if (keywords == null)
        {
            keywords = (Tapestry_KeywordRegistry)ScriptableObject.CreateInstance("Tapestry_KeywordRegistry");
        }
        if (effects == null)
        {
            effects = new List <Tapestry_Effect>();
        }

        for (int i = 0; i < transform.childCount; i++)
        {
            if (transform.GetChild(i).name == "T_Points")
            {
                GameObject pointContainer = transform.GetChild(i).gameObject;
                for (int j = 0; j < pointContainer.transform.childCount; j++)
                {
                    if (pointContainer.transform.GetChild(j).name == "P_Attach")
                    {
                        attachPoint = pointContainer.transform.GetChild(j).gameObject;
                    }
                }
            }
        }
        isRunning           = true;
        heldItemStartingPos = equippedItemContainer.transform.localPosition;
        heldItemStartingRot = equippedItemContainer.transform.localRotation;
    }
Esempio n. 3
0
    private void HandleInventory()
    {
        if (ReferenceEquals(inventoryUI, null))
        {
            inventoryUI = FindObjectOfType <Tapestry_UI_Inventory>();
        }
        if (ReferenceEquals(equipmentProfile, null))
        {
            equipmentProfile = (Tapestry_EquipmentProfile)ScriptableObject.CreateInstance("Tapestry_EquipmentProfile");
        }

        bool open = Input.GetKey(Tapestry_Config.KeyboardInput_Inventory);

        if (openLastFrame && !open)
        {
            if (inventoryUI.IsOpen)
            {
                inventoryUI.Close();
                Cursor.lockState = CursorLockMode.Locked;
                Cursor.visible   = false;
            }
            else
            {
                inventoryUI.Open(inventory, equipmentProfile);
                Cursor.lockState = CursorLockMode.None;
                Cursor.visible   = true;
            }
        }
        if (Input.GetKey(Tapestry_Config.KeyboardInput_Cancel))
        {
            if (inventoryUI.IsOpen)
            {
                inventoryUI.Close();
                Cursor.lockState = CursorLockMode.Locked;
                Cursor.visible   = false;
            }
        }

        //End of frame
        openLastFrame = open;
    }
Esempio n. 4
0
    private void HandleActivation()
    {
        bool activate = Input.GetKey(Tapestry_Config.KeyboardInput_Activate);
        bool push     = Input.GetKey(Tapestry_Config.KeyboardInput_Push);
        bool lift     = Input.GetKey(Tapestry_Config.KeyboardInput_Lift);

        objectInSights = null;

        RaycastHit hit;
        bool       rayHit = Physics.Raycast(
            Camera.main.transform.position,
            Camera.main.transform.forward,
            out hit,
            reach.Value,
            ~(LayerMask.GetMask("Ignore Raycast") | LayerMask.GetMask("Tapestry Held Items"))
            );

        if (rayHit)
        {
            objectInSights = hit.transform.gameObject.GetComponentInParent <Tapestry_Activatable>();

            if (objectInSights != null)
            {
                objectInSights.Hover();

                if (activateLastFrame && !activate && objectInSights.GetComponent <Tapestry_Activatable>().isInteractable)
                {
                    if ((typeof(Tapestry_Item).IsAssignableFrom(objectInSights.GetType())))
                    {
                        Tapestry_Item i = (Tapestry_Item)objectInSights;
                        if (ReferenceEquals(inventory, null))
                        {
                            inventory = (Tapestry_Inventory)ScriptableObject.CreateInstance("Tapestry_Inventory");
                        }

                        inventory.AddItem(i, 1);
                        objectInSights.Activate(this);
                    }
                    else if (objectInSights.GetType() == typeof(Tapestry_Door))
                    {
                        Tapestry_Door d = (Tapestry_Door)objectInSights;
                        if (d.security.isLocked)
                        {
                            if (ReferenceEquals(inventory, null))
                            {
                                inventory = (Tapestry_Inventory)ScriptableObject.CreateInstance("Tapestry_Inventory");
                            }

                            if (!d.GetIsOpen())
                            {
                                if (inventory.ContainsKeyID(d.security.keyID))
                                {
                                    d.security.isLocked = false;
                                    if (d.consumeKeyOnUnlock)
                                    {
                                        inventory.RemoveKeyWithID(d.security.keyID);
                                    }
                                }
                                objectInSights.Activate(this);
                            }
                        }
                        else
                        {
                            objectInSights.Activate(this);
                        }
                    }
                    else if (objectInSights.GetType() == typeof(Tapestry_Container))
                    {
                        Tapestry_Container c = (Tapestry_Container)objectInSights;
                        if (inventoryUI == null)
                        {
                            inventoryUI = FindObjectOfType <Tapestry_UI_Inventory>();
                        }

                        Debug.Log(c.inventory.items.Count + " in target container.");
                        inventoryUI.Open(inventory, null, c.inventory, "Inventory", c.displayName);
                    }
                    else
                    {
                        objectInSights.Activate(this);
                    }
                }
                if (pushLastFrame && !push && objectInSights.GetComponent <Tapestry_Activatable>().isPushable)
                {
                    objectInSights.Push(this);
                }
                if (liftLastFrame && !lift && objectInSights.GetComponent <Tapestry_Activatable>().isLiftable)
                {
                    objectInSights.Lift(this);
                }
            }
        }

        //End of frame
        activateLastFrame = activate;
        pushLastFrame     = push;
        liftLastFrame     = lift;
    }