Example #1
0
    int GetCardRank(Card_Field card, FieldUIType type)
    {
        switch (type)
        {
        case FieldUIType.monster:
            return(monsterArray.GetRank(card.gameObject));

        case FieldUIType.trap:
            return(trapArray.GetRank(card.gameObject));

        case FieldUIType.areaSpell:
            return(0);

        default:
            return(-1);
        }
    }
Example #2
0
    public bool DisSelectCard(Card_Field card)
    {
        switch (card.GetUIAreaType())
        {
        case FieldUIType.monster:
            return(selectCardMgr.DisSelectCard(ComVal.Area_Monster, GetCardRank(card, FieldUIType.monster), isMy));

        case FieldUIType.trap:
            return(selectCardMgr.DisSelectCard(ComVal.Area_NormalTrap, GetCardRank(card, FieldUIType.trap), isMy));

        case FieldUIType.areaSpell:
            return(selectCardMgr.DisSelectCard(ComVal.Area_FieldSpell, GetCardRank(card, FieldUIType.areaSpell), isMy));

        default:
            Debug.Log("error");
            return(false);
        }
    }
Example #3
0
 /// <summary>
 /// 结束卡片选择状态
 /// </summary>
 public void EndSelectCard()
 {
     foreach (var item in monsterArray.gameObjList)
     {
         if (item != null)
         {
             Card_Field card = item.GetComponent <Card_Field>();
             card.EndSelectState();
         }
     }
     foreach (var item in trapArray.gameObjList)
     {
         if (item != null)
         {
             Card_Field card = item.GetComponent <Card_Field>();
             card.EndSelectState();
         }
     }
 }
Example #4
0
 /// <summary>
 /// 进入选择卡片状态
 /// </summary>
 /// <param name="cardType"></param>
 /// <param name="num"></param>
 /// <param name="dele"></param>
 public void SelectFieldCard(Group cardGroup, bool isMySelect)
 {
     if (cardGroup.GroupNum == 0)
     {
         return;
     }
     for (int i = 0; i < cardGroup.GroupNum; i++)
     {
         Card       card = cardGroup.GetCard(i);
         GameObject obj  = GetCardObj(card);
         if (obj == null)
         {
             Debug.Log("error");
             return;
         }
         Card_Field cardField = obj.GetComponent <Card_Field>();
         cardField.EnterSelectState(isMySelect);
     }
 }
Example #5
0
 /// <summary>
 /// 更新场地上怪兽卡信息的显示
 /// </summary>
 /// <param name="monsterGroup"></param>
 public void UpdateCardMesShow(FieldCardGroup monsterGroup)
 {
     Card[] cardList = monsterGroup.cardList;
     for (int i = 0; i < cardList.Length; i++)
     {
         Card card = cardList[i];
         if (card != null)
         {
             Card_Field card_field = monsterArray.GetCard(i).GetComponent <Card_Field>();
             if (card.IsMonster() && card.curPlaseState != ComVal.CardPutType_layBack)
             {
                 card_field.UpdateCardMes(card.GetCurAfk(), card.GetCurDef(), card.GetCurLevel(), card.afk, card.def);
             }
             else if (card.curPlaseState == ComVal.CardPutType_layBack)
             {
                 card_field.HideCardMes();
             }
         }
     }
 }
Example #6
0
    /// <summary>
    /// 加入卡片到怪兽魔陷区
    /// <para>返回卡片的位置</para>
    /// <para>返回值为0到4</para>
    /// </summary>
    /// <param name="cardID"></param>
    /// <param name="putType"></param>
    /// <param name="gridID"></param>
    /// <param name="isInMonsterArea">真为放置在怪兽区域 否则为魔陷区域</param>
    public int AddCard(string cardID, int putType, FieldUIType fieldType)
    {
        int        val    = 5;//记录卡片的位置
        Card_Field prefeb = GameObject.Instantiate(cardPrefeb).GetComponent <Card_Field>();

        prefeb.Init(this, isMy);

        switch (fieldType)
        {
        case FieldUIType.monster:
            if (MonsterAreaIsFull())
            {
                Debug.Log("MonsterIsFull");
                return(0);
            }
            for (int i = 0; i < monsterGridList.Count; i++)
            {
                if (monsterGridList[i].transform.childCount == 0)
                {
                    prefeb.transform.SetParent(monsterGridList[i].transform);
                    monsterArray.AddCard(prefeb.gameObject, i);
                    val = i;
                    break;
                }
            }
            break;

        case FieldUIType.trap:
            if (TrapAreaIsFull())
            {
                Debug.Log("TrapIsFull");
                return(0);
            }
            for (int i = 0; i < trapGridList.Count; i++)
            {
                if (trapGridList[i].transform.childCount == 0)
                {
                    prefeb.transform.SetParent(trapGridList[i].transform);
                    trapArray.AddCard(prefeb.gameObject, i);

                    val = i;
                    break;
                }
            }
            break;

        case FieldUIType.areaSpell:
            prefeb.transform.SetParent(fieldSpellGrid.transform);
            fieldSpellCard = prefeb.gameObject;
            val            = 0;
            break;

        default:
            break;
        }
        prefeb.rectTransform.anchoredPosition3D = Vector3.zero;
        //  prefeb.rectTransform.sizeDelta = new Vector2(cardSizeX, cardSizeY);
        prefeb.rectTransform.localScale    = Vector3.one;
        prefeb.rectTransform.localRotation = new Quaternion(0, 0, 0, 1);
        prefeb.SetTexture(cardID, true);
        prefeb.SetPutType(putType, cardID);
        prefeb.SetArea((int)fieldType, val);
        return(val);
    }