コード例 #1
0
 public void HighlightTarget(ButtonHighlight highlight)
 {
     if (Error.TargetBlox != null && GameObjectHelper.HasComponent <HighlightableButton>(Error.TargetBlox.gameObject))
     {
         HighlightableButton hBtn = Error.TargetBlox.GetComponent <HighlightableButton>();
         hBtn.HighlightButton(highlight);
     }
 }
コード例 #2
0
    public void OnDrag(PointerEventData eventData)
    {
        IsBeingDragged         = true;
        bloxTransform.position = eventData.position;


        // If this blox has child bloxes and params, sets their positions in
        // order to drag them also
        RootBlox rootBlox = GetRootBlox();

        if (rootBlox != null)
        {
            float bloxVerticalSpacing = GetVerticalSpacing(rootBlox);
            float identSpacing        = GetIdentSpacing(rootBlox);
            float paramSpacing        = GetParamSpacing(rootBlox);
            // Sets the child blox and params position while dragging, for them to follow this blox
            // Those bloxes nesting is temporarily disabled
            SetChildBloxesPositionOnScreen(this, bloxVerticalSpacing, identSpacing, paramSpacing, false);
        }

        // Verifies if there are collided objects, and if
        // this object can be potentially nested to those
        if (collidedObjects.Count > 0)
        {
            // Although we are saving all the simultaneous collisions
            // We only want this object to nest with the highest ones
            float             maxY           = collidedObjects.Max(c => c.transform.position.y);
            List <GameObject> highestObjects = collidedObjects.Where(c => c.transform.position.y == maxY).Select(a => a.gameObject).ToList();
            ResetHightlight();
            foreach (GameObject collidedObject in highestObjects)
            {
                //If the collided object is a blox, checks if this is nestable to it, and hightlights if it is
                if (GameObjectHelper.HasComponent <ABlox>(collidedObject))
                {
                    NestingType nestingType = collidedObject.GetComponent <ABlox>().DetermineNestingType(this.gameObject);
                    if (nestingType != NestingType.NONE && GameObjectHelper.HasComponent <HighlightableButton>(collidedObject.gameObject))
                    {
                        HighlightableButton hB = collidedObject.gameObject.GetComponent <HighlightableButton>();
                        hB.HighlightButton(HighlightableButton.ButtonHighlight.Info);
                        hightlightableBloxes.Add(hB);
                    }
                }
            }
        }
    }