Exemplo n.º 1
0
    public void endDragging()
    {
        isDragging = false;
        if (isOverDropZone)
        {
            int currentEnergyValue = 0;
            UnityEngine.UI.Text currentEnergyValueComponent = null;
            GameObject          energy = GameObject.Find("Energy");

            foreach (var i in energy.GetComponentsInChildren <UnityEngine.UI.Text>())
            {
                if (i.name == "Current")
                {
                    currentEnergyValueComponent = i;
                    currentEnergyValue          = Convert.ToInt32(i.text);
                }
            }

            int CardCost = Convert.ToInt32(GetChildComponentByName <UnityEngine.UI.Text>("Cost").text);

            if (CardCost <= currentEnergyValue)
            {
                int temp = currentEnergyValue - CardCost;
                currentEnergyValueComponent.text = temp.ToString();
                GameObject endTurn = GameObject.Find("ButtonEndTurn");
                EndTurn    et      = (EndTurn)endTurn.GetComponent(typeof(EndTurn));
                et.discardCard(this.gameObject);

                BaseCard att = this.GetComponent <BaseCard>();
                att.DoAction(dropzone);
            }
            else
            {
                transform.position = startPos;
            }
        }
        else
        {
            transform.position = startPos;
        }
    }