Esempio n. 1
0
    public void setMultiCard(CardMonster c, int dir)
    {
        Transform pairDropSlot = this.transform.parent.FindChild(string.Format("playerMonster{0}", SlotID + dir));

        //		foreach (SlotMonster sm in this.transform.parent.GetComponentsInChildren<SlotMonster>()) {
        //			if (sm.gameObject.name.Equals(string.Format("playerMonster{0}", SlotID + dir)))
        //				pairDropSlot = sm;
        //		}
        if (pairDropSlot == null)
        {
            return;
        }
        Slot pdsm = pairDropSlot.GetComponent <Slot> ();

        if (pdsm != null && pdsm.canDrop(c))
        {
            GameObject o = GameObject.Instantiate(multiCardPrefab);

            CardMultiPart mpc = o.GetComponent <CardMultiPart>();
            if (dir > 0)
            {
                mpc.changeCard((c.CardI as MonsterInfo) + c.getPair());
                mpc.createUID(c.PairCard.UID);
                pdsm.setCard(mpc);
                mpc.createUID(c.UID);
                this.setCard(mpc);
            }
            else
            {
                mpc.changeCard(c.getPair() + (c.CardI as MonsterInfo));
                mpc.createUID(c.UID);
                this.setCard(mpc);
                mpc.createUID(c.PairCard.UID);
                pdsm.setCard(mpc);
            }
            mpc.returnToParent();

            GameObject.Destroy(c.PairCard.gameObject);
            GameObject.Destroy(c.gameObject);
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Plays an enemy card of the specified unique ID in the specified slot.
    /// </summary>
    /// <param name="uid">The unique ID of the card to be played.</param>
    /// <param name="slotID">The slot to play the card in.</param>
    public void playEnemyCard(int uid, int slotID)
    {
        foreach (Slot slot in GameObject.FindObjectsOfType <Slot>())
        {
            if (slot.SlotID == slotID + 12)
            {
                Card c = getCard <Card>(uid);
                switch (c.CardI.Type)
                {
                case (CardInfo.CardType.Monster):
                    ECardMonster ecm = c as ECardMonster;
                    if (ecm.CardI.AssoCardInfo.ContainsKey(CardRelation.RPAIR))
                    {
                        Transform pairDropSlot = this.transform.parent.FindChild(string.Format("enemyMonster{0}", slotID + 1));
                        //		foreach (SlotMonster sm in this.transform.parent.GetComponentsInChildren<SlotMonster>()) {
                        //			if (sm.gameObject.name.Equals(string.Format("playerMonster{0}", SlotID + dir)))
                        //				pairDropSlot = sm;
                        //		}
                        if (pairDropSlot == null)
                        {
                            break;
                        }
                        Slot pdsm = pairDropSlot.GetComponent <Slot> ();
                        if (pdsm == null)
                        {
                            break;
                        }
//						SlotMonster pairDropSlot = null;
//						foreach (SlotMonster sm in slot.transform.parent.GetComponentsInChildren<SlotMonster>()) {
//							if (sm.gameObject.name.Equals(string.Format("enemyMonster{0}", slotID + 1)))
//								pairDropSlot = sm;
//						}
//						if (pairDropSlot == null)
//							break;
                        ECardMonster ecmPair = pdsm.GetComponentInChildren <ECardMonster>();
                        GameObject   o       = GameObject.Instantiate(eMultiCardPrefab);

                        CardMultiPart mpc = o.GetComponent <CardMultiPart>();
                        mpc.changeCard((c.CardI as MonsterInfo) + (ecmPair.CardI as MonsterInfo));
                        mpc.createUID(uid);
                        mpc.GetComponent <SpriteRenderer> ().sortingOrder = pdsm.GetComponent <SpriteRenderer> ().sortingOrder + 1;
                        mpc.State = Card.States.INPLAY;
                        mpc.changeReturnParent(pdsm.transform);
                        mpc.returnToParent();

                        GameObject.Destroy(c.gameObject);
                        GameObject.Destroy(ecmPair.gameObject);
                    }
                    break;
                }

                if (c != null)
                {
                    c.GetComponent <SpriteRenderer> ().sortingOrder = slot.GetComponent <SpriteRenderer> ().sortingOrder + 1;
                    c.State = Card.States.INPLAY;
                    c.changeReturnParent(slot.transform);
                    c.returnToParent();
                }
            }
        }
    }