Пример #1
0
    /// <summary>
    /// This item is dropped.
    /// </summary>
    /// <param name="eventData"></param>
    public void OnEndDrag(PointerEventData eventData)
    {
        ResetConditions();
        // Check for cells under cursor
        bool             emptyDrop   = true;
        PointerEventData pointerData = new PointerEventData(EventSystem.current);

        pointerData.position = Input.mousePosition;
        List <RaycastResult> hits = new List <RaycastResult>();

        EventSystem.current.RaycastAll(pointerData, hits);
        if (hits.Count > 0)
        {
            foreach (RaycastResult hit in hits)
            {
                DadCell dadCell = hit.gameObject.GetComponent <DadCell>();
                if (dadCell != null)
                {
                    emptyDrop = false;
                    break;
                }
            }
        }
        if (emptyDrop == true)
        {
            DadCell.DadEventDescriptor desc = new DadCell.DadEventDescriptor();
            desc.sourceCell  = GetCell();
            desc.triggerType = DadCell.TriggerType.EmptyDrop;
            AccessUtility.SendMessageUpwards(transform, "OnDadGroupEvent", desc);
        }
    }
Пример #2
0
    /// <summary>
    /// Uses the item.
    /// </summary>
    public void UseItem()
    {
        bool res = true;

        CooldownItem cooldown = GetComponent <CooldownItem>();

        if (cooldown != null && cooldown.timeLeft > 0f)
        {
            res = false;
        }
        // Use item if there is no active cooldown
        if (res == true)
        {
            // Notify application about item use
            AccessUtility.SendMessageUpwards(transform, "OnItemUse", gameObject);
        }
    }
Пример #3
0
 /// <summary>
 /// Sends the stack event notification.
 /// </summary>
 /// <param name="desc">Event descriptor.</param>
 private void SendNotification(StackGroupEventDescriptor desc)
 {
     if (desc.sourceGroup != null)
     {
         // Send notification to source GO
         AccessUtility.SendMessageUpwards(desc.sourceGroup.transform, "OnStackGroupEvent", desc);
         foreach (GameObject receiver in desc.sourceGroup.eventAdditionalReceivers)
         {
             // Send notification to additionaly specified GOs
             AccessUtility.SendMessage(receiver.transform, "OnStackGroupEvent", desc);
         }
     }
     if (desc.destinationGroup != null && desc.sourceGroup != desc.destinationGroup && desc.destinationGroup.trashBinMode == false)
     {
         // Send notification to destination GO
         AccessUtility.SendMessageUpwards(desc.destinationGroup.transform, "OnStackGroupEvent", desc);
         foreach (GameObject receiver in desc.destinationGroup.eventAdditionalReceivers)
         {
             // Send notification to additionaly specified GOs
             AccessUtility.SendMessage(receiver.transform, "OnStackGroupEvent", desc);
         }
     }
 }