Ejemplo n.º 1
0
    public void RightMouseButton()
    {
        if (LookObject != null)
        {
            LoadedEntity lEnt = LookObject.GetComponent <LoadedEntity>();
            if (lEnt != null)
            {
                Entity ent = lEnt.Entity;
                if (ent is NPC)
                {
                    NPC npc = ent as NPC;

                    if (npc.HasDialog())
                    {
                        StartDialog(npc);
                    }
                }
            }
        }
        return;

        Ray  ray       = PlayerCamera.ScreenPointToRay(Input.mousePosition);
        bool entSelect = false;

        Debug.Log("hmmm");
        RaycastHit[] raycasthit = Physics.RaycastAll(ray);
        foreach (RaycastHit hit in raycasthit)
        {
            Debug.Log(hit);
            LoadedEntity hitEnt = hit.transform.gameObject.GetComponent <LoadedEntity>();
            if (hitEnt != null)
            {
                entSelect = true;
                //GameManager.DebugGUI.SetSelectedEntity(hitEnt);
                Entity hitEntity = hitEnt.Entity;
                if (hitEntity is NPC)
                {
                    NPC npc = hitEntity as NPC;
                    //If we have selected a different entities
                    if (npc != CurrentlySelected)
                    {
                        Debug.Log(hitEntity.Name + " has been clicked by the player");
                        GameManager.EventManager.InvokeNewEvent(new PlayerTalkToNPC(npc));
                        CurrentlySelected = npc;

                        if (npc.HasDialog())
                        {
                            Debug.Log("TRUE DIALOG");
                            GameManager.GUIManager.StartDialog(npc);
                            if (!Player.InConversation())
                            {
                                if (Player.CurrentDialogNPC() != npc)
                                {
                                    NPCDialog dial = npc.Dialog;
                                    dial.StartDialog();
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                CurrentlySelected = null;
            }
            Debug.Log(hit.collider.gameObject);
            if (hit.collider.gameObject.GetComponent <WorldObject>() != null)
            {
                WorldObject obj = hit.collider.gameObject.GetComponent <WorldObject>();
                Debug.Log(obj);
                Debug.Log(obj.Data);
                if (obj.Data is IOnEntityInteract)
                {
                    Debug.Log("here2");
                    (obj.Data as IOnEntityInteract).OnEntityInteract(Player);
                }
            }
        }

        if (!entSelect)
        {
            GameManager.DebugGUI.SetSelectedEntity(null);
        }
    }