public override bool update(TableManager table, THHCard.HealEventArg eventArg) { if (!_timer.isStarted) { foreach (var card in eventArg.cards) { if (table.tryGetServant(card, out Servant servant)) { servant.HealImage.display(); servant.HealText.text = "+" + eventArg.infoDic[card].healedValue.ToString(); table.setServant(table.getServant(card), card); } } _timer.start(); } foreach (var card in eventArg.cards) { if (table.tryGetServant(card, out Servant servant)) { servant.HealImage.setAlpha(_timer.progress); servant.HealText.setAlpha(_timer.progress); } } if (!_timer.isExpired()) { return(false); } foreach (var card in eventArg.cards) { if (table.tryGetServant(card, out Servant servant)) { servant.HealImage.hide(); } } return(true); }
public override bool update(TableManager table) { if (_animator == null) { return(true); } if (string.IsNullOrEmpty(_animName)) { return(true); } if (isFinished) { return(true); } if (!hasAnim(out var layer)) { Debug.LogError(_animator + "中不存在动画状态" + _animName, _animator); return(true); } if (!_isPlayed) { _isPlayed = true; _animator.Play(_animName, layer, 0); return(false); } for (int i = 0; i < _animator.layerCount; i++) { AnimatorStateInfo state = _animator.GetCurrentAnimatorStateInfo(i); if (state.IsName(_animName) && state.normalizedTime < 1) { return(false); } } isFinished = true; return(true); }
public override bool update(TableManager table, THHPlayer.InitReplaceEventArg eventArg) { table.ui.InitReplaceDialog.hide(); return(true); }
public override bool update(TableManager table, Pile.MoveCardEventArg eventArg) { if (eventArg.from == null) { if (eventArg.to.name == PileName.HAND) { //发现,印卡 if (!table.tryGetHand(eventArg.card, out var hand)) { hand = table.createHand(eventArg.card); } if (!SimpleAnimHelper.update(table, ref _anim, hand.onCreate, hand.animator)) { return(false); } } } else if (eventArg.from.name == PileName.INIT) { if (eventArg.to.name == PileName.HAND) { //初始手牌 table.createHand(eventArg.card); } } else if (eventArg.from.name == PileName.DECK) { if (eventArg.to.name == PileName.HAND) { //抽牌 if (!_timer.isStarted) { _item = table.createHand(eventArg.card); if (eventArg.from.owner == table.player) { _item.Card.rectTransform.position = table.ui.SelfDeck.rectTransform.position; _startPosition = table.ui.SelfDeck.rectTransform.position; } else { _item.Card.rectTransform.position = table.ui.EnemyDeck.rectTransform.position; _startPosition = table.ui.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); } } } else if (eventArg.from.name == PileName.HAND) { HandListItem hand = table.getHand(eventArg.card); if (eventArg.to.name == PileName.GRAVE) { //弃牌 if (!SimpleAnimHelper.update(table, ref _anim, hand.onDiscard, hand.animator, next => { if (next is MoveCardAnim moveCard && moveCard.tEventArg.card != eventArg.card) { return(true); } return(false); }))
public override bool update(TableManager table, Pile.MoveCardEventArg eventArg) { if (eventArg.from == null) { if (eventArg.to.name == PileName.HAND) { //发现,印卡 if (!table.tryGetHand(eventArg.card, out var hand)) { hand = table.createHand(eventArg.card); } if (!SimpleAnimHelper.update(table, ref _anim, hand.onCreate, hand.animator)) { return(false); } } } else if (eventArg.from.name == PileName.INIT) { if (eventArg.to.name == PileName.HAND) { //初始手牌 table.createHand(eventArg.card); } } else if (eventArg.from.name == PileName.DECK) { RectTransform deckTransform = eventArg.from == table.player.deck ? table.ui.SelfDeck.rectTransform : table.ui.EnemyDeck.rectTransform; if (eventArg.to.name == PileName.HAND) { //抽牌 if (!table.tryGetHand(eventArg.card, out var hand)) { hand = table.createHand(eventArg.card); hand.rectTransform.position = deckTransform.position; hand.GetComponentInChildren <PositionLerp>().setTarget(hand.rectTransform); } if (!SimpleAnimHelper.update(table, ref _anim, hand.onDraw, hand.animator)) { return(false); } //if (!_timer.isStarted) //{ // _item = table.createHand(eventArg.card); // if (eventArg.from.owner == table.player) // { // _item.Card.rectTransform.position = table.ui.SelfDeck.rectTransform.position; // _startPosition = table.ui.SelfDeck.rectTransform.position; // } // else // { // _item.Card.rectTransform.position = table.ui.EnemyDeck.rectTransform.position; // _startPosition = table.ui.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; } else if (eventArg.to.name == PileName.WARP) { if (!table.tryGetHand(eventArg.card, out var hand)) { hand = table.createHand(eventArg.card); hand.GetComponentInChildren <PositionLerp>().setTarget(deckTransform); } if (!SimpleAnimHelper.update(table, ref _anim, hand.onDraw, hand.animator)) { return(false); } if (!SimpleAnimHelper.update(table, ref _anim2, hand.onDiscard, hand.animator)) { return(false); } table.ui.SelfHandList.removeItem(hand); table.ui.EnemyHandList.removeItem(hand); } } else if (eventArg.from.name == PileName.HAND) { if (table.tryGetHand(eventArg.card, out var hand)) { if (eventArg.to.name == PileName.GRAVE) { //弃牌 if (!SimpleAnimHelper.update(table, ref _anim, hand.onDiscard, hand.animator, next => { if (next is MoveCardAnim moveCard && moveCard.tEventArg.card != eventArg.card) { return(true); } return(false); }))
public override bool update(TableManager table, THHPlayer.SetMaxGemEventArg eventArg) { return(true); }
public override bool update(TableManager table, THHPlayer.UseEventArg eventArg) { if (eventArg.card.define is ServantCardDefine) { if (eventArg.player == table.player) { if (!table.ui.ServantPlaceHolder.Servant.isDisplaying) { HandListItem item = table.getHand(eventArg.card); if (_handToField == null) { _handToField = new HandToFieldAnim(table, item, table.ui.SelfFieldList, eventArg.position); } if (!_handToField.update(table)) { return(false); } } if (tryTargetedAnim(table, eventArg)) { return(false); } table.ui.SelfHandList.removeItem(table.getHand(eventArg.card)); table.ui.addChild(table.ui.ServantPlaceHolder.rectTransform); table.ui.ServantPlaceHolder.hide(); } else { var hand = table.getHand(eventArg.card); if (hand == null) { throw new ActorNotFoundException(eventArg.card); } if (!table.ui.ServantPlaceHolder.Servant.isDisplaying) { //敌方使用随从 if (_handToField == null) { _handToField = new HandToFieldAnim(table, hand, table.ui.EnemyFieldList, eventArg.position); } if (!_handToField.update(table)) { return(false); } } if (tryTargetedAnim(table, eventArg)) { return(false); } table.ui.EnemyHandList.removeItem(hand); table.ui.addChild(table.ui.ServantPlaceHolder.rectTransform); table.ui.ServantPlaceHolder.hide(); } } else if (eventArg.card.define is SpellCardDefine) { if (eventArg.player == table.player) { table.ui.SelfHandList.removeItem(table.getHand(eventArg.card)); if (tryTargetedAnim(table, eventArg)) { return(false); } } else { HandListItem hand = table.getHand(eventArg.card); table.setCard(hand.Card, eventArg.card, true); hand.GetComponentInChildren <PositionLerp>().setTarget(table.ui.getChild("SpellDisplay")); if (!SimpleAnimHelper.update(table, ref _useAnim, hand.onEnemyUse, hand.animator)) { return(false); } table.ui.EnemyHandList.removeItem(table.getHand(eventArg.card)); if (tryTargetedAnim(table, eventArg)) { return(false); } } } else if (eventArg.card.isSkill()) { if (eventArg.player == table.player) { table.setSkill(table.ui.SelfSkill, eventArg.card); } else { table.setSkill(table.ui.EnemySkill, eventArg.card); } if (tryTargetedAnim(table, eventArg)) { return(false); } } else if (eventArg.card.isItem()) { if (eventArg.player == table.player) { table.setItem(table.ui.SelfItem, eventArg.card); if (!SimpleAnimHelper.update(table, ref _useAnim, table.ui.SelfItem.onEquip, table.ui.SelfItem.animator)) { return(false); } } else { table.setItem(table.ui.EnemyItem, eventArg.card); if (!SimpleAnimHelper.update(table, ref _useAnim, table.ui.EnemyItem.onEquip, table.ui.EnemyItem.animator)) { return(false); } } if (tryTargetedAnim(table, eventArg)) { return(false); } } return(true); }
public override bool update(TableManager table) { _action(); return(true); }
public override bool update(TableManager table, TouhouCardEngine.Card.AddModiEventArg eventArg) { SimpleAnim simpleAnim = null; Animator animator = null; if (table.tryGetServant(eventArg.card, out var servant)) { animator = servant.animator; if (eventArg.modifier is AttackModifier atkMod) { if (atkMod.value > 0) { simpleAnim = servant.onAttackUp; } else { simpleAnim = servant.onAttackDown; } servant.AttackTextPropNumber.asText.text = eventArg.card.getAttack(table.game).ToString(); } else if (eventArg.modifier is LifeModifier lifMod) { if (lifMod.value > 0) { simpleAnim = servant.onLifeUp; } else { simpleAnim = servant.onLifeDown; } servant.HpTextPropNumber.asText.text = eventArg.card.getCurrentLife(table.game).ToString(); } } else if (table.tryGetHand(eventArg.card, out var hand)) { animator = hand.animator; if (eventArg.modifier is AttackModifier atkMod) { if (atkMod.value > 0) { simpleAnim = hand.onAttackUp; } else { simpleAnim = hand.onAttackDown; } hand.Card.AttackPropNumber.asText.text = eventArg.card.getAttack(table.game).ToString(); } else if (eventArg.modifier is LifeModifier lifMod) { if (lifMod.value > 0) { simpleAnim = hand.onLifeUp; } else { simpleAnim = hand.onLifeDown; } hand.Card.LifePropNumber.asText.text = eventArg.card.getLife(table.game).ToString(); } else if (eventArg.modifier is CostModifier costMod) { if (costMod.value > 0) { simpleAnim = hand.onCostUp; } else { simpleAnim = hand.onCostDown; } hand.Card.CostPropNumber.asText.text = eventArg.card.getCost(table.game).ToString(); } } if (!SimpleAnimHelper.update(table, ref _anim, simpleAnim, animator)) { return(false); } return(true); }
public override void display(TableManager table, DiscoverRequest request) { table.displayDiscoverDialog(request.cardIdArray, request.title); }
public override bool update(TableManager table, THHPlayer.MoveEventArg eventArg) { table.createServant(eventArg.card, eventArg.position); return(true); }
public override bool update(TableManager table, THHCard.AttackEventArg eventArg) { if (table.tryGetMaster(eventArg.card, out var attackMaster)) { if (table.tryGetMaster(eventArg.target, out var targetMaster)) { attackMaster.GetComponentInChildren <PositionLerp>().setTarget(targetMaster.rectTransform, targetMaster.rectTransform.sizeDelta.x / 2); if (!SimpleAnimHelper.update(table, ref _attackAnim, attackMaster.onAttack, attackMaster.animator)) { return(false); } if (!SimpleAnimHelper.update(table, ref _attackedAnim, targetMaster.onAttacked, targetMaster.animator)) { return(false); } } else if (table.tryGetServant(eventArg.target, out var targetServant)) { attackMaster.GetComponentInChildren <PositionLerp>().setTarget(targetServant.rectTransform, targetServant.rectTransform.sizeDelta.x / 2); if (!SimpleAnimHelper.update(table, ref _attackAnim, attackMaster.onAttack, attackMaster.animator)) { return(false); } if (!SimpleAnimHelper.update(table, ref _attackedAnim, targetServant.onAttacked, targetServant.animator)) { return(false); } } table.setMaster(attackMaster, eventArg.card); } else if (table.getServant(eventArg.card) is Servant attackServant) { if (table.tryGetMaster(eventArg.target, out var targetMaster)) { attackServant.GetComponentInChildren <PositionLerp>().setTarget(targetMaster.rectTransform, targetMaster.rectTransform.sizeDelta.x / 2); if (!SimpleAnimHelper.update(table, ref _attackAnim, attackServant.onAttack, attackServant.animator)) { return(false); } if (!SimpleAnimHelper.update(table, ref _attackedAnim, targetMaster.onAttacked, targetMaster.animator)) { return(false); } } else if (table.tryGetServant(eventArg.target, out var targetServant)) { attackServant.GetComponentInChildren <PositionLerp>().setTarget(targetServant.rectTransform, targetServant.rectTransform.sizeDelta.x / 2); if (!SimpleAnimHelper.update(table, ref _attackAnim, attackServant.onAttack, attackServant.animator)) { return(false); } if (!SimpleAnimHelper.update(table, ref _attackedAnim, targetServant.onAttacked, targetServant.animator)) { return(false); } } //if (table.tryGetMaster(eventArg.target, out var targetMaster)) //{ // if (!_timer1.isStarted) // _timer1.start(); // attackServant.getChild("Root").position = // Vector3.Lerp(attackServant.rectTransform.position, targetMaster.rectTransform.position, // attackServant.attackAnimationCurve.Evaluate(_timer1.progress)); // if (!_timer1.isExpired()) // return false; // if (!_timer2.isStarted) // _timer2.start(); // attackServant.getChild("Root").position = // Vector3.Lerp(targetMaster.rectTransform.position, attackServant.rectTransform.position, // attackServant.attackAnimationCurve.Evaluate(_timer2.progress)); // if (!_timer2.isExpired()) // return false; //} //else if (table.getServant(eventArg.target) is Servant targetServant) //{ // if (!_timer1.isStarted) // _timer1.start(); // attackServant.getChild("Root").position = // Vector3.Lerp(attackServant.rectTransform.position, targetServant.rectTransform.position, // attackServant.attackAnimationCurve.Evaluate(_timer1.progress)); // if (!_timer1.isExpired()) // return false; // if (!_timer2.isStarted) // _timer2.start(); // attackServant.getChild("Root").position = // Vector3.Lerp(targetServant.rectTransform.position, attackServant.rectTransform.position, // attackServant.attackAnimationCurve.Evaluate(_timer2.progress)); // if (!_timer2.isExpired()) // return false; //} table.setServant(attackServant, eventArg.card); } return(true); }
public override bool update(TableManager table) { throw new NotImplementedException(); }
/// <summary> /// 每一帧调用 /// </summary> /// <param name="table">游戏桌面UI管理器</param> /// <param name="eventArg">死亡事件</param> /// <returns></returns> public override bool update(TableManager table, THHCard.DeathEventArg eventArg) { if (_animList == null) { _animList = new List <AnimAnim>(); foreach (var card in eventArg.infoDic.Keys) //列举所有死亡的信息 { if (table.tryGetServant(card, out var servant)) //尝试获取死亡的随从的随从UI { servant.onDeath.invokeBeforeAnim(); _animList.Add(new AnimAnim(servant.animator, servant.onDeath.animName)); //table.ui.SelfFieldList.removeItem(servant);//从自己的场上移除随从UI //table.ui.EnemyFieldList.removeItem(servant);//从敌人的场上移除随从UI } else if (table.tryGetServant(card, out var master)) { master.onDeath.invokeBeforeAnim(); _animList.Add(new AnimAnim(master.animator, master.onDeath.animName)); } else if (card.isItem()) { Item item = card.getOwner() == table.player ? table.ui.SelfItem : table.ui.EnemyItem; item.onDestroy.invokeBeforeAnim(); _animList.Add(new AnimAnim(item.animator, item.onDestroy.animName)); } } } bool isAllAnimDone = true; foreach (var anim in _animList) { if (!anim.update(table)) { isAllAnimDone = false; } } if (!isAllAnimDone) { return(false); } foreach (var card in eventArg.infoDic.Keys) //列举所有死亡的信息 { if (table.tryGetServant(card, out var servant)) //尝试获取死亡的随从的随从UI { servant.onDeath.afterAnim.Invoke(); table.ui.SelfFieldList.removeItem(servant); //从自己的场上移除随从UI table.ui.EnemyFieldList.removeItem(servant); //从敌人的场上移除随从UI } else if (table.tryGetMaster(card, out var master)) { master.onDeath.afterAnim.Invoke(); } else if (card.isItem()) { Item item = card.getOwner() == table.player ? table.ui.SelfItem : table.ui.EnemyItem; item.onDestroy.afterAnim.Invoke(); item.hide(); } } return(true); }