예제 #1
0
 public override bool update(Table table)
 {
     if (!_timer.isStarted)
     {
         if (eventArg.player == table.player)
         {
             _item = table.SelfHandList.addItem();
             _item.Card.update(eventArg.card, table.getSkin(eventArg.card));
             _item.Card.rectTransform.position = table.SelfDeck.rectTransform.position;
             _startPosition = table.SelfDeck.rectTransform.position;
         }
         else
         {
             _item = table.EnemyHandList.addItem();
             _item.Card.update(eventArg.card, null);
             _item.Card.rectTransform.position = table.EnemyDeck.rectTransform.position;
             _startPosition = table.EnemyDeck.rectTransform.position;
         }
         _timer.start();
     }
     _item.Card.rectTransform.position = Vector3.Lerp(_startPosition, _item.rectTransform.position, _item.Card.drawCurve.Evaluate(_timer.progress));
     if (!_timer.isExpired())
     {
         return(false);
     }
     return(true);
 }
예제 #2
0
 public void onDragHand(HandListItem item, PointerEventData pointer)
 {
     if (item.GetComponentInParent <HandList>() != SelfHandList)//你不能用别人的卡
     {
         return;
     }
     usingHand = item;
     if (!canControl)//不是你的回合
     {
         resetUse(true, true);
         return;
     }
     //拖拽卡片
     item.Card.rectTransform.position = pointer.position;
     if (SelfHandList.rectTransform.rect.Contains(SelfHandList.rectTransform.InverseTransformPoint(pointer.position)))
     {
         //如果移动回手牌区域,恢复正常大小
         item.Card.rectTransform.localScale = Vector3.one;
         //移除随从占位
         hideServantPlaceHolder();
     }
     else
     {
         //移动到手牌区以外的地方视作打算使用
         if (!item.Card.card.isUsable(game, player, out string info))
         {
             //卡牌不可用,停止拖拽并提示
             showTip(info);
             resetUse(true, true);
         }
         else
         {
             //手牌在战场上大小和随从牌一致
             item.Card.rectTransform.localScale = Vector3.one * .4f / rectTransform.localScale.y;
             if (item.Card.card.define is ServantCardDefine)
             {
                 SelfFieldList.defaultItem.rectTransform.SetAsFirstSibling();
                 ServantPlaceHolder.rectTransform.sizeDelta = SelfFieldList.defaultItem.rectTransform.sizeDelta;
                 SelfFieldList.addChild(ServantPlaceHolder.rectTransform);
                 ServantPlaceHolder.display();
                 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);
                 }
             }
         }
     }
 }
예제 #3
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);
             }
         }