Exemple #1
0
 partial void onAwake()
 {
     SelfHandList.asButton.onClick.AddListener(() =>
     {
         if (SelfHandList.isExpanded)
         {
             SelfHandList.shrink();
         }
         else
         {
             SelfHandList.expand();
         }
     });
 }
Exemple #2
0
 public void onReleaseHand(HandListItem item, PointerEventData pointer)
 {
     if (item.GetComponentInParent <HandList>() != SelfHandList)//你不能用别人的卡
     {
         return;
     }
     if (!canControl)//不是你的回合,不生效
     {
         resetUse(true, true);
         return;
     }
     usingHand = item;
     if (SelfHandList.rectTransform.rect.Contains(SelfHandList.rectTransform.InverseTransformPoint(pointer.position)))
     {
         //如果松开,取消使用
         resetUse(true, true);
     }
     else
     {
         if (!item.Card.card.isUsable(game, player, out string info))
         {
             //卡牌不可用
             showTip(info);
             resetUse(true, true);
         }
         else if (item.Card.card.define is ServantCardDefine)
         {
             //松开鼠标,确认使用随从牌
             var servants = SelfFieldList.getItems();
             int index    = 0;
             if (servants.Length > 0)
             {
                 //需要选择空位,计算空位
                 for (int i = 0; i < servants.Length; i++)
                 {
                     if (servants[i].rectTransform.position.x < pointer.position.x)
                     {
                         index = i + 1;
                     }
                 }
                 ServantPlaceHolder.rectTransform.SetSiblingIndex(index + 1);
             }
             if (item.Card.card.getAvaliableTargets(game) is TouhouCardEngine.Card[] targets && targets.Length > 0)
             {
                 _usingCard     = item.Card.card;
                 _usingPosition = index;
                 //进入选择目标状态,固定手牌到占位上,高亮可以选择的目标
                 item.Card.hide();
                 //显示占位随从
                 ServantPlaceHolder.Servant.display();
                 ServantPlaceHolder.Servant.update(item.Card.card.define, getSkin(item.Card.card));
                 isSelectingTarget = true;
                 selectableTargets = targets.Select(target =>
                 {
                     if (getMaster(target) is Master master)
                     {
                         return(master as UIObject);
                     }
                     else if (getServant(target) is Servant servant)
                     {
                         return(servant as UIObject);
                     }
                     throw new ActorNotFoundException(target);
                 }).ToArray();
                 SelfHandList.shrink();
             }
             else
             {
                 //使用无目标随从牌
                 player.cmdUse(game, item.Card.card, index);
                 resetUse(false, false);
             }
         }