Exemplo n.º 1
0
    public void Guard(bool wasVisable)
    {
        if (StandingGuard)
        {
            agent.destination = ParentWaypoint.transform.position;
            if (agent.velocity == Vector3.zero)
            {
                transform.rotation = Quaternion.Lerp(transform.rotation, ParentWaypoint.transform.rotation, Time.deltaTime * 2f);
            }
            return;
        }


        if (agent.isOnOffMeshLink)
        {
            DoorManager door = agent.currentOffMeshLinkData.offMeshLink.gameObject.GetComponent <DoorManager>();
            if (door != null)
            {
                if (!door.IsOpen())
                {
                    door.OpenDoor();
                }
                else
                {
                    agent.autoTraverseOffMeshLink = true;
                    door.CloseDoor();
                    return;
                }
            }
        }
        else
        {
            agent.autoTraverseOffMeshLink = false;
        }

        if (pathList.Count > 1)
        {
            if (wasVisable == true)
            {
                if ((transform.position - pathList[pathPosNumber]).sqrMagnitude > (transform.position - pathList[IncrementWrapVaule(pathPosNumber, pathList.Count)]).sqrMagnitude)
                {
                    pathPosNumber = IncrementWrapVaule(pathPosNumber, pathList.Count);
                }
            }

            agent.destination = pathList[pathPosNumber];
            //If in range to the target path pos, set goal to the next path pos
            if ((transform.position - pathList[pathPosNumber]).sqrMagnitude < distanceToActivePathPos * distanceToActivePathPos)
            {
                pathPosNumber = IncrementWrapVaule(pathPosNumber, pathList.Count);
            }
        }
    }
Exemplo n.º 2
0
        private void RightClick(RaycastHit hit)
        {
            GameObject colliderGameObject = hit.collider.gameObject;
            Transform  colliderTransform  = hit.collider.transform;

            if (colliderGameObject.layer == LayerConstants.Door)
            {
                DoorManager door = colliderTransform.parent.GetComponent <DoorManager>();
                if (door == null)
                {
                    Debug.Log("DoorManager Not Found for " + colliderTransform.name);
                }
                else
                {
                    int keyValue = -1;

                    Item item = m_Inventory.GetCurrentItem();

                    if (item != null && item.itemType == Item.ItemType.KEY && m_InventoryDisplay.IsInventoryOpen())
                    {
                        keyValue = item.Value;
                    }

                    if (!door.IsOpen())
                    {
                        door.OpenDoor(keyValue);
                    }
                    else if (door.IsOpen())
                    {
                        door.CloseDoor();
                    }
                }
            }
            else if (colliderGameObject.layer == LayerConstants.Switch)
            {
                Switch _switch = colliderTransform.GetComponent <Switch>();
                if (_switch != null)
                {
                    _switch.Toggle();
                }
            }
            else if (colliderGameObject.layer == LayerConstants.Dial)
            {
                Dial _dial = colliderTransform.GetComponent <Dial>();
                if (_dial != null)
                {
                    StartCoroutine(_dial.DialDown());
                }
            }
        }