Ejemplo n.º 1
0
    private void changeSelection(float direction)
    {
        if (keys.Count == 0)
        {
            activeKey = null;
            changeItemDisplayed();
            return;
        }

        int newIndex;

        if (direction < 0)
        {
            newIndex = (keys.FindIndex(data => data.Equals(activeKey)) - 1) % keys.Count;
            if (newIndex < 0)
            {
                newIndex = keys.Count - 1;
            }
        }
        else
        {
            newIndex = (keys.FindIndex(data => data.Equals(activeKey)) + 1) % keys.Count;
        }

        activeKey = keys[newIndex];
        changeItemDisplayed();
    }
Ejemplo n.º 2
0
    public void setupKey(scr_KeyData keyData)
    {
        this.keyData = keyData;

        TextMeshPro tmp = GetComponentInChildren <TextMeshPro>();

        tmp.text  = keyData.symbol;
        tmp.color = keyData.color;
    }
Ejemplo n.º 3
0
    public scr_KeyData addKey(scr_KeyData key)
    {
        if (keys.Count == 0)
        {
            activeKey = key;
            changeItemDisplayed();
        }
        keys.Add(key);

        return(key);
    }
Ejemplo n.º 4
0
    public void activatePortal(scr_KeyData keyData)
    {
        scr_PortGate destGateScript = keyData.transform.GetComponent <scr_PortGate>();

        //Change this gate's stuff
        setDestination(destGateScript);

        //Change destination gate stuff
        destGateScript.setDestination(this);

        destinationGateObject.GetComponentInChildren <Camera>().enabled = true; //Enable camera on destination gate when activated
    }
Ejemplo n.º 5
0
    public void deactivatePortal(scr_KeyData keyData)
    {
        scr_PortGate destGateScript = destinationGateObject.GetComponent <scr_PortGate>();

        //Change this gate's stuff
        unsetDestination(destGateScript);

        //Change destination gate stuff
        destGateScript.unsetDestination(this);

        destinationGateObject = null;
    }
Ejemplo n.º 6
0
    private void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            if (playerClick())
            {
                scr_Inventory playerInventory = other.GetComponent <scr_Inventory>();
                scr_KeyData   keyUsed         = playerInventory.activeKey; //Get active (used) key data from player inventory

                if (!active)                                               //put key on portal recepticle
                {
                    if (keyUsed != null)
                    {
                        if (keyUsed.transform.root != transform.root)
                        {
                            GameObject.FindGameObjectWithTag("UI").GetComponent <scr_UI>()
                            .displayMsg("Some force is pushing the key back...");
                            return;
                        }

                        active    = true;
                        keyPlaced = keyUsed.spawn(transform, false);
                        keyPlaced.GetComponent <BoxCollider>().isTrigger = false;

                        playerInventory.removeKey(keyUsed);

                        showUseText();

                        updateLift(-1);
                    }
                }

                else if (keyPlaced) //take key from portal recepticle
                {
                    scr_KeyData keyData = keyPlaced.GetComponent <scr_PortalKeyPickUp>().keyData;
                    playerInventory.addKey(keyData); //Add the data from the pickup back to player inventory
                    active = false;
                    Destroy(keyPlaced);

                    updateLift(1);
                }
            }
        }
    }
Ejemplo n.º 7
0
    private void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            if (playerClick())
            {
                scr_Inventory playerInventory = other.GetComponent <scr_Inventory>();
                if (!transform.parent.GetComponent <scr_PortGate>().active) //put key on portal recepticle
                {
                    scr_KeyData keyUsed = playerInventory.activeKey;        //Get active (used) key data from player inventory

                    if (keyUsed != null)
                    {
                        if (keyUsed.transform.GetComponentInParent <scr_PortGate>().active)
                        {
                            GameObject.FindGameObjectWithTag("UI").GetComponent <scr_UI>().displayMsg("Some force is pushing the key back...");
                            return;
                        }

                        transform.parent.GetComponent <scr_PortGate>().activatePortal(keyUsed);
                        keyPlaced = keyUsed.spawn(transform, true);
                        keyPlaced.transform.GetChild(0).localPosition = new Vector3(.1f, 0, 0); //Change symbol position

                        playerInventory.removeKey(keyUsed);

                        showUseText();
                    }
                }
                else if (keyPlaced) //take key from portal recepticle
                {
                    scr_KeyData keyData = keyPlaced.GetComponent <scr_PortalKeyPickUp>().keyData;
                    playerInventory.addKey(keyData); //Add the data from the pickup back to player inventory
                    transform.parent.GetComponent <scr_PortGate>().deactivatePortal(keyData);
                    Destroy(keyPlaced);
                    showUseText();
                }
            }
        }
    }
Ejemplo n.º 8
0
 public scr_KeyData removeKey(scr_KeyData key)
 {
     keys.Remove(key);
     changeSelection(-1);
     return(key);
 }