예제 #1
0
    // Sorts the objects
    public void Drop(PointerEventData data, GameObject draggingCardObject, Transform pointerObjectName)
    {
        GameObject pointerObject      = pointerObjectName.gameObject;
        Card       draggingCardScript = draggingCardObject.GetComponent <Card>();

        D = data.pointerDrag.GetComponent <isDraggable>();

        //Debug.Log("Dragging card is a " + draggingCardObject.GetComponent<Card>().Type);

        // Placing creature card
        if (pointerObject.CompareTag("Field") && !draggingCardScript.HasBeenPlaced && draggingCardScript.Type.Equals("Creature"))
        {
            // Run the logic for a card over a field
            //Debug.Log("Creature and Field conditions met.");
            TryPlace(draggingCardObject, draggingCardScript, pointerObject);
        }
        // Attacking creature card
        else if (pointerObject.CompareTag("Card") &&
                 draggingCardScript.Type.Equals("Creature") &&
                 !draggingCardScript.IsExhausted &&
                 draggingCardScript.HasBeenPlaced &&
                 !draggingCardScript.OwnerTag.Equals(pointerObject.GetComponent <Card>().OwnerTag)
                 )
        {
            //Debug.Log("Placed Card and Enemy Card conditions met.");
            TryAttack(draggingCardObject, draggingCardScript, pointerObject);
        }
        // Single target spell card
        else if (pointerObject.CompareTag("Card") && pointerObject.GetComponent <Card>().Type.Equals("Creature") && draggingCardScript.Type.Equals("Spell") && draggingCardScript.Target.Equals(Effect.Single))
        {
            //Debug.Log("Single target spell conditions met.");
            TrySpell(draggingCardObject, draggingCardScript, pointerObject);
        }
        // Non-targeted spell card
        else if (draggingCardScript.Type.Equals("Spell") && draggingCardScript.Target.Equals(Effect.All))
        {
            //Debug.Log("Non-targeted spell conditions met.");
            TrySpell(draggingCardObject, draggingCardScript, pointerObject);
        }
        // Zone spell card
        else if (draggingCardScript.Target.Equals(Effect.Zone) && pointerObject.CompareTag("Card") && pointerObject.GetComponent <Card>().Type.Equals("Creature") && draggingCardScript.Type.Equals("Spell"))
        {
            //Debug.Log("Zone spell conditions met.");
            TrySpell(draggingCardObject, draggingCardScript, pointerObject);
        }
        // Turn card back to card if action conditions are met
        else
        {
            Debug.Log("No conditions met!");
            draggingCardObject.tag = "Card";
        }
    }
    // Sorts the objects
    public void Drop(PointerEventData data, GameObject draggingCardObject, Transform pointerObjectName)
    {
        GameObject pointerObject = pointerObjectName.gameObject;
        Card draggingCardScript = draggingCardObject.GetComponent<Card>();

        D = data.pointerDrag.GetComponent<isDraggable>();

        //Debug.Log("Dragging card is a " + draggingCardObject.GetComponent<Card>().Type);

        // Placing creature card
        if (pointerObject.CompareTag("Field") && !draggingCardScript.HasBeenPlaced && draggingCardScript.Type.Equals("Creature"))
        {
            // Run the logic for a card over a field
            //Debug.Log("Creature and Field conditions met.");
            TryPlace(draggingCardObject, draggingCardScript, pointerObject);
        }
        // Attacking creature card
        else if (pointerObject.CompareTag("Card")
            && draggingCardScript.Type.Equals("Creature")
            && !draggingCardScript.IsExhausted
            && draggingCardScript.HasBeenPlaced
            && !draggingCardScript.OwnerTag.Equals(pointerObject.GetComponent<Card>().OwnerTag)
            )
        {
            //Debug.Log("Placed Card and Enemy Card conditions met.");
            TryAttack(draggingCardObject, draggingCardScript, pointerObject);
        }
        // Single target spell card
        else if (pointerObject.CompareTag("Card") && pointerObject.GetComponent<Card>().Type.Equals("Creature") && draggingCardScript.Type.Equals("Spell") && draggingCardScript.Target.Equals(Effect.Single))
        {
            //Debug.Log("Single target spell conditions met.");
            TrySpell(draggingCardObject, draggingCardScript, pointerObject);
        }
        // Non-targeted spell card
        else if (draggingCardScript.Type.Equals("Spell") && draggingCardScript.Target.Equals(Effect.All))
        {
            //Debug.Log("Non-targeted spell conditions met.");
            TrySpell(draggingCardObject, draggingCardScript, pointerObject);
        }
        // Zone spell card
        else if (draggingCardScript.Target.Equals(Effect.Zone) && pointerObject.CompareTag("Card") && pointerObject.GetComponent<Card>().Type.Equals("Creature") && draggingCardScript.Type.Equals("Spell"))
        {
            //Debug.Log("Zone spell conditions met.");
            TrySpell(draggingCardObject, draggingCardScript, pointerObject);
        }
        // Turn card back to card if action conditions are met
        else
        {
            Debug.Log("No conditions met!");
            draggingCardObject.tag = "Card";
        }
    }