示例#1
0
    void Start()
    {
        acceptingNewCommand = false;

        emptySlot   = null;
        spacing     = -50;
        offset      = (int)transform.position.y; // !!! Set Pivot Anchor (x,y) = (0,1)
        maxCommands = 6;
    }
示例#2
0
    void AdjustEmptySpace(TopCommandSlot moveSlot, TopCommand movingCommand)
    {
        //Dynamically adjust the position of emptySpace
        int emptySpaceIndex = (((int)movingCommand.transform.position.y) - offset) / spacing;

        if (emptySpaceIndex < 0)
        {
            moveSlot.transform.SetAsFirstSibling();
        }
        else if (emptySpaceIndex >= GetComponentsInChildren <TopCommandSlot>().Length)
        {
            moveSlot.transform.SetSiblingIndex(GetComponentsInChildren <TopCommandSlot>().Length - 1);
        }
        else
        {
            moveSlot.transform.SetSiblingIndex(emptySpaceIndex);
        }
    }
示例#3
0
    void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData)
    {
        if (DragHandler.commandBeingDragged)
        {
            outsidePanel = false;
        }

        if (SpawnCMDHandler.commandBeingSpawned)
        {
            if (GetComponentsInChildren <TopCommandSlot>().Length == maxCommands)
            {
                return;
            }
            acceptingNewCommand = true;
            emptySlot           = Instantiate(Resources.Load("CSlotPrefab", typeof(TopCommandSlot))) as TopCommandSlot;
            emptySlot.transform.SetParent(transform);
            ExecuteEvents.Execute <IUpdateNumbers>(targetPanel.gameObject, null, (x, y) => x.UpdateNumbers(true));
        }
    }
示例#4
0
    void IHasFinalised.HasFinalised()
    {
        int hasDestroied = 0;

        if (DragHandler.commandBeingDragged)
        {
            if (outsidePanel)
            {
                TopCommandSlot tobeDiscarded = DragHandler.commandBeingDragged.GetComponentInParent <TopCommandSlot>();
                tobeDiscarded.destructCommand();
                Destroy(tobeDiscarded.gameObject);
                hasDestroied = 1;
                outsidePanel = false;
            }
            else
            {
                DragHandler.commandBeingDragged.transform.localPosition = Vector2.zero;
            }
        }

        if (SpawnCMDHandler.commandBeingSpawned)
        {
            emptySlot.AcceptCommand(SpawnCMDHandler.commandBeingSpawned);
            acceptingNewCommand = false;
            emptySlot           = null;
        }

        //Only shows debugging tool when there are commands in the panel
        if (GetLength() == hasDestroied)
        {
            debugPanel.gameObject.SetActive(false);
        }
        else
        {
            debugPanel.gameObject.SetActive(true);
        }
    }