コード例 #1
0
    // a script of type spell effect that will be attached to this card when it`s created
    //public SpellEffect effect;


    public override String ToString()
    {
        return("Card: " + ca.ToString() + "owned by " + owner + " ID: " + UniqueCardID);
    }
コード例 #2
0
    // method to create a new creature and add it to the table
    public void AddCardAtIndex(CardAsset ca, GameObject itemCard, int UniqueID, int index)
    {
        GameObject targetSlot;

        if (index == 0)
        {
            targetSlot = leftSlot;
        }
        else
        {
            targetSlot = rightSlot;
        }

        Debug.Log("Adding CardAtIndex: " + ca.ToString() + itemCard.ToString() + UniqueID.ToString() + index);
        // create a new creature from prefab
        // GameObject itemCard = GameObject.Instantiate(GlobalSettings.Instance.ItemCardPrefab, slots.Children[index].transform.position, Quaternion.identity) as GameObject;
        itemCard.transform.position = slots.Children[index].transform.position;

        // apply the look from CardAsset
        OneCardManager manager = itemCard.GetComponent <OneCardManager>();

        //manager.cardAsset = ca;
        //manager.ReadCardFromAsset();

        // add tag according to owner
        foreach (Transform t in itemCard.GetComponentsInChildren <Transform>())
        {
            t.tag = owner.ToString() + "Item";
        }

        // parent a new creature gameObject to table slots
        itemCard.transform.SetParent(targetSlot.transform);

        // add a new creature to the list
        if (index == 0)
        {
            leftCardOnTable = itemCard;
        }
        else
        {
            rightCardOnTable = itemCard;
        }

        // let this creature know about its position
        WhereIsTheCardOrCreature w = itemCard.GetComponent <WhereIsTheCardOrCreature>();

        w.Slot = index;
        if (owner == AreaPosition.Low)
        {
            w.VisualState = VisualStates.LowTable;
        }
        else
        {
            w.VisualState = VisualStates.TopTable;
        }

        // add our unique ID to this creature
        if (itemCard.GetComponent <IDHolder>() == null)
        {
            Debug.Log("Tried to play a card without an IDHolder in TableVisual.");
            IDHolder id = itemCard.AddComponent <IDHolder>();
            id.UniqueID = UniqueID;
        }

        // end command execution
        Command.CommandExecutionComplete();
    }