Exemplo n.º 1
0
    private void OnItemClickedInWriteMode(MessageItemScript messageItemScript)
    {
        var item = messages.Find((message => message.Item == messageItemScript));

        if (item != null)
        {
            m_GameplaUiController.RequestWritableMessageUi(item.m_MessageText, (newText) =>
            {
                if (string.IsNullOrEmpty(newText))
                {
                    RemoveItem(item);
                    messageItemScript.ResetToDefault();
                }
                else
                {
                    item.m_MessageText = newText;
                }
            });
        }
        else
        {
            m_GameplaUiController.RequestWritableMessageUi("", text =>
            {
                if (!string.IsNullOrEmpty(text))
                {
                    AddMessage(messageItemScript, text);
                    messageItemScript.MarkAsWritten();
                }
            });
        }
    }
Exemplo n.º 2
0
    public void AddMessage(MessageItemScript item, string messageText)
    {
        MessageScript m = new MessageScript(item, messageText, messages.Count);

        messages.Add(m);

        m_GameplaUiController.OnAmountOfMemoriesChange(messages.Count);
    }
Exemplo n.º 3
0
    public void RemoveMessage(MessageItemScript item)
    {
        // Find message by it's item name
        string itemName = item.name;

        foreach (MessageScript m in messages)
        {
            if (m.GetItemName() == itemName)
            {
                RemoveItem(m);
                Debug.Log("Message related to item " + itemName + " has been deleted.");
                break;
            }
        }
        Debug.LogWarning("There's no message attached to item " + itemName + ". No deletion is posssible.");
    }
Exemplo n.º 4
0
    private void OnItemClickedInReadMode(MessageItemScript messageItemScript)
    {
        var item = messages.Find(message => message.Item == messageItemScript);

        if (item != null)
        {
            m_GameplaUiController.RequestReadableMessageUi(item.m_MessageText, _ =>
            {
                MarkAsRead(item);
            });
        }
        else
        {
            messageItemScript.MarkAsRead(false);
        }
    }
Exemplo n.º 5
0
    public void OnItemClicked(MessageItemScript messageItemScript)
    {
        switch (Mode)
        {
        case GameManagerMode.Default:
            throw new NotImplementedException();
            break;

        case GameManagerMode.ReadMode:
            OnItemClickedInReadMode(messageItemScript);
            break;

        case GameManagerMode.WriteMode:
            OnItemClickedInWriteMode(messageItemScript);
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
Exemplo n.º 6
0
 public MessageScript(MessageItemScript item, string messageText, int creationOrder)
 {
     m_Item          = item;
     m_MessageText   = messageText;
     m_CreationOrder = creationOrder;
 }
Exemplo n.º 7
0
 public void Reset()
 {
     itemInCrosshair = null;
 }
Exemplo n.º 8
0
    void FixedUpdate()
    {
        if (FPSCamera == null)
        {
            Debug.LogWarning("FPSCamera has been removed, we can't do any raycasting without it. Reassign it!");
            return;
        }

        // Bit shift the index of the layer (8) to get a bit mask
        int layerMask = 1 << 8;

        // This would cast rays only against colliders in layer 8.
        // But instead we want to collide against everything except layer 8. The ~ operator does this, it inverts a bitmask.
        //layerMask = ~layerMask;

        RaycastHit hit;

        // Does the ray intersect any objects excluding the player layer
        if (Physics.Raycast(FPSCamera.transform.position, FPSCamera.transform.forward, out hit, RaycastDistance, layerMask))
        {
            MessageItemScript item = hit.transform.GetComponentInParent <MessageItemScript>();

            if (item == null)
            {
                Debug.LogWarning("Item " + hit.transform.parent + " is in the message item layer but it doesn't have a  MessageItemScript attached. Please, fix it!");
                return;
            }

            // If a new item is crosshairs, we remove the old one and tell it we are no longer looking at it
            if (item != itemInCrosshair)
            {
                if (itemInCrosshair != null)
                {
                    itemInCrosshair.OutCrosshair();
                }
                item.InCrosshair();
                itemInCrosshair = item;
            }

            Debug.DrawRay(FPSCamera.transform.position, FPSCamera.transform.forward * hit.distance, Color.green);
            //Debug.Log("Did Hit");
        }
        else
        {
            if (itemInCrosshair != null)
            {
                itemInCrosshair.OutCrosshair();
            }
            itemInCrosshair = null;

            Debug.DrawRay(FPSCamera.transform.position, FPSCamera.transform.forward * 1000, Color.red);
            //Debug.Log("Did not Hit");
        }

        // Clicked or pressed E
        if (Input.GetAxis("Fire1") > 0f)
        {
            if (itemInCrosshair != null)
            {
                itemInCrosshair.Selected();
            }
        }
    }