Esempio n. 1
0
    private void UpdateDoorLock(DoorInteractable d, int ID, float amount)
    {
        Vector3 screenPos = mainCamera.WorldToScreenPoint(d.transform.position + interactOffset);

        doorLocks[ID].GetComponent <RectTransform>().position = screenPos;
        doorLocks[ID].transform.GetChild(0).GetComponent <Image>().fillAmount = amount;
    }
Esempio n. 2
0
    private void OnTriggerExit(Collider other)
    {
        if (other.CompareTag("Door"))
        {
            buttonPresses = 0;

            thisDoor = null;
            canSpam  = false;
            GetComponentInParent <PlayerController>().SetDoorPry(false);
            ActionReleaseSpamButton();
        }
    }
Esempio n. 3
0
    public void Lock()
    {
        RaycastHit2D[] hit             = Physics2D.CircleCastAll(transform.position, radiousOfAction, Vector2.up, 10, actionableLayerMask);
        float          dist            = Mathf.Infinity;
        GameObject     newInteractable = null;

        foreach (RaycastHit2D coll in hit)
        {
            if (coll.collider.gameObject.GetComponent <DoorInteractable>() != null)
            {
                if (Vector2.Distance(coll.collider.gameObject.transform.position, transform.position) < dist)
                {
                    dist            = Vector2.Distance(coll.collider.gameObject.transform.position, transform.position);
                    newInteractable = coll.collider.gameObject;
                }
            }
            if (newInteractable != null)
            {
                doorInteractable = newInteractable.GetComponent <DoorInteractable>();
            }
        }

        if (doorInteractable != null)
        {
            lockBtnText = GameObject.FindGameObjectWithTag("UI").transform.GetChild(5).transform.GetChild(0).gameObject.GetComponent <Text>();
            if (lockBtnText.text == "Lock")
            {
                if (doorInteractable.LockDoor(true))
                {
                    if (photonView.IsMine)
                    {
                        GetComponent <CollisionHandler>().HasLock--;
                    }
                    lockBtnText.text = "UnLock";
                    lockBtnText.transform.parent.gameObject.transform.GetChild(1).gameObject.SetActive(true);
                    lockBtnText.transform.parent.gameObject.transform.GetChild(2).gameObject.SetActive(false);
                }
            }
            else if (lockBtnText.text == "UnLock")
            {
                if (doorInteractable.LockDoor(false))
                {
                    lockBtnText.text = "Lock";
                    lockBtnText.transform.parent.gameObject.transform.GetChild(2).gameObject.SetActive(true);
                    lockBtnText.transform.parent.gameObject.transform.GetChild(1).gameObject.SetActive(false);
                }
            }

            doorInteractable = null;
        }
    }
Esempio n. 4
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Door"))
        {
            if (other.transform.parent.GetComponent <DoorInteractable>().state == InteractableState.negative)
            {
                thisDoor = other.transform.parent.GetComponent <DoorInteractable>();
                canSpam  = true;

                if (!thisDoor.cannotBeOpened)
                {
                    ActionAllocateSpamButton(thisDoor.gameObject);
                }
            }
        }
    }
Esempio n. 5
0
    private void SpawnWalls(bool[] doors, GameObject[] wallObjects)
    {
        for (int i = 0; i < doors.Length; i++)
        {
            int        type = doors[i] ? 0 : 1;
            GameObject wall = Instantiate(wallObjects[type], wallSpawnLocations[i].position, wallSpawnLocations[i].rotation);

            // If this wall segment has a space for a door
            // and this room "owns" that wall segment
            if (doors[i] && i < 2)
            {
                // Spawn door and initialize it
                Transform doorOpening = wall.transform.GetChild(0);

                DoorInteractable thisDoor = Instantiate(doorObject, doorOpening).GetComponent <DoorInteractable>();

                thisDoor.transform.SetParent(transform);

                InitAudienceInteractable(thisDoor);
            }
        }
    }
Esempio n. 6
0
    private void AllocateDoorLock(DoorInteractable d)
    {
        for (int i = 0; i < doorLockNum; i++)
        {
            if (!doorLocks[i].activeSelf)
            {
                // Set up health bar
                doorLocks[i].transform.GetChild(0).GetComponent <Image>().fillAmount = 1;

                // Position health bar correctly
                Vector3 screenPos = mainCamera.WorldToScreenPoint(d.transform.position + interactOffset);
                doorLocks[i].GetComponent <RectTransform>().position = screenPos;

                // Set health Bar Active
                doorLocks[i].SetActive(true);

                // Give ID to enemy
                d.referenceID = i;

                return;
            }
        }
    }
Esempio n. 7
0
    private void ReleaseDoorLock(DoorInteractable d, int ID)
    {
        doorLocks[ID].SetActive(false);

        d.referenceID = -1;
    }