Exemplo n.º 1
0
 private void HandleIronGateInteraction(RaycastHit hit)
 {
     if (hit.transform.TryGetComponent <IronGateInteractable>(out var ironGate))
     {
         ironGate.HighlightGate();
         highlightedGate = ironGate;
     }
     else
     {
         if (highlightedGate)
         {
             highlightedGate.UnhighlightGate();
             highlightedGate = null;
         }
     }
 }
Exemplo n.º 2
0
        private void MovePlayer()
        {
            //if (!isTalking)
            //{
            if (!PauseManager.Instance.IsPaused)
            {
                if (EventSystem.current.IsPointerOverGameObject())
                {
                    return;
                }

                Ray ray = cam.ScreenPointToRay(Input.mousePosition);

                if (Physics.Raycast(ray, out var hitInteractable, 30, LayerMask.GetMask("Iron Gate", "Default", "NotWalkable", "NPC")))
                {
                    HandleNPCInteraction(hitInteractable);

                    HandleIronGateInteraction(hitInteractable);
                }

                if (Input.GetMouseButtonDown(0))
                {
                    if (Physics.Raycast(ray, out var hit, 1000, LayerMask.GetMask("Default", "NPC", "Iron Gate", "NotWalkable")))
                    {
                        if (hit.transform.TryGetComponent <IronGateInteractable>(out var gate))
                        {
                            if (!gate.isGateOpening)
                            {
                                focusedInteractable = gate;
                                focusedInteractable.EnableInteractionArea();
                            }
                        }
                        else
                        {
                            if (focusedInteractable)
                            {
                                focusedInteractable.DisbleInteractionArea();
                            }

                            focusedInteractable = null;
                        }

                        //if (hit.transform.TryGetComponent<NPCInteractable>(out var npc))
                        //{
                        //    focusedNPC = npc;
                        //}
                        //else
                        //{
                        //    focusedNPC = null;
                        if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Default") || hit.collider.gameObject.layer == LayerMask.NameToLayer("NPC") || hit.collider.gameObject.layer == LayerMask.NameToLayer("Iron Gate"))
                        {
                            navMeshAgent.SetDestination(hit.point);
                        }
                        else if (hit.collider.gameObject.layer == LayerMask.NameToLayer("NotWalkable"))
                        {
#if UNITY_EDITOR
                            Debug.Log("Yes, indeed, you can't walk to there");
#endif
                        }

                        //}
                    }
                }

                //if (focusedNPC)
                //{
                //     navMeshAgent.SetDestination(focusedNPC.transform.position);
                //}
                //}
                //else
                //{
                //    transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(focusedNPC.transform.position - transform.position), rotateTime * Time.deltaTime);
                //}

                anim.SetFloat("HorizontalSpeed", navMeshAgent.velocity.magnitude);
            }
        }