Ejemplo n.º 1
0
    /// <summary>
    /// 每回合增加手牌
    /// </summary>
    /// <param name="cardlist"></param>
    private void addCard(List <CardDto> cardlist)
    {
        int index = myCardList.Count;

        foreach (var item in cardlist)
        {
            myCardList.Add(item);
        }
        //对手牌进行排序
        //CardWeight.SortCard(ref myCardList);

        //复用先前创建的牌
        for (int i = 0; i < index; i++)
        {
            CardCtrllist[i].gameObject.SetActive(true);
            CardCtrllist[i].Init(myCardList[i], true, i);
        }

        for (int i = index; i < myCardList.Count; i++)
        {
            GameObject card = GameObject.Instantiate(cardPrefab, cardTransformParent);
            card.transform.localPosition = new Vector3(0, index * 0.01f, index * -1f);
            //card.name = myCardList[i].Name;
            CardCtrl cardCtrl = card.GetComponent <CardCtrl>();

            cardCtrl.CardMouseDownEvent = IsCanSelece;
            cardCtrl.Init(myCardList[i], true, index);

            CardCtrllist.Add(cardCtrl);
            index++;
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 初始阶段创建手牌
    /// </summary>
    /// <param name="cardDto"></param>
    /// <param name="index"></param>
    private void createCard(CardDto cardDto, int index)
    {
        GameObject card = GameObject.Instantiate(cardPrefab, cardTransformParent);

        //card.transform.localPosition = new Vector2(index * 1f, 0);
        card.transform.localPosition = new Vector3(0, index * 0.01f, index * -1f);
        //card.name = cardDto.Name;
        CardCtrl cardCtrl = card.GetComponent <CardCtrl>();

        cardCtrl.CardMouseDownEvent = IsCanSelece;
        cardCtrl.Init(cardDto, true, index);

        myCardList.Add(cardDto);
        CardCtrllist.Add(cardCtrl);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 出所选中的牌
    /// </summary>

    /*private void dealSelectedCard()
     * {
     *  DealDto dealDto = new DealDto(GameModles.Instance.userDto.ID, getSelectedCard());
     *  if (dealDto.isRegular)
     *  {
     *      //socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_CREQ, dealDto);
     *      Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);
     *  }
     *  else
     *  {
     *      Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "出牌不合法");
     *  }
     * }*/

    /// <summary>
    /// 获取所选中的牌
    /// </summary>
    /// <returns></returns>

    /*private List<CardDto> getSelectedCard()
     * {
     *  List<CardDto> selectedCard = new List<CardDto>();
     *  foreach (var item in CardCtrllist)
     *  {
     *      if(item.IsSelected == true)
     *      {
     *          selectedCard.Add(item.cardDto);
     *      }
     *  }
     *  return selectedCard;
     * }*/

    /// <summary>
    /// 出牌成功时移除手牌
    /// </summary>
    private void removeSelectCard(CardDto removeCard)
    {
        //剩余手牌
        //List<CardDto> RestmyCardList = new List<CardDto>(myCardList);
        List <CardCtrl> RestCardCtrllist = new List <CardCtrl>(CardCtrllist);

        //int removeindex = -1;
        for (int i = 0; i < RestCardCtrllist.Count; i++)
        {
            if (RestCardCtrllist[i].cardDto == removeCard)
            {
                RestCardCtrllist.RemoveAt(i);
                //removeindex = i;
                break;
            }
        }
        myCardList.Remove(removeCard);

        int index = 0;

        foreach (var item in RestCardCtrllist)
        {
            CardCtrllist[index].Init(item.cardDto, true, index);

            index++;

            if (index == RestCardCtrllist.Count)
            {
                break;
            }
        }

        for (int i = index; i < CardCtrllist.Count; i++)
        {
            CardCtrllist[i].IsSelected = false;
            Destroy(CardCtrllist[i].gameObject);
            CardCtrllist.RemoveAt(i);
        }

        //CardCtrllist = RestCardCtrllist;


        LastSelectCard = null;
        Dispatch(AreoCode.MAP, MapEvent.CANCEL_SELECT_ARMYCARD, null);//清除上次选择的卡牌
    }