private void OnAttack(object sender, CardArgs attackArgs) { Debug.LogWarning($"[{this.GetType().Name}] OnAttack!"); var unit = sender as UnitManager; var dir = (attackArgs.Receiver.transform.position - attackArgs.Attacker.transform.position).normalized; var duration = 0.5f; var sequence = DOTween.Sequence(); switch (attackArgs.CardData.CardAnimation) { case CardAnimation.NormalAttack: default: soundManager.AudioSource.PlayOneShot(soundManager.HitTrack); sequence.Append(transform.DOLocalMoveX(transform.localPosition.x + 2 * dir.x, duration) .OnComplete(() => transform.DOLocalMoveX(transform.localPosition.x - 2 * dir.x, duration))); break; } attackArgs.Receiver.GetDamage(attackArgs.CardData.Amount); sequence.OnComplete(() => attackArgs.Callback()); }
private void OnGetHeal(object sender, CardArgs cardArgs) { var seq = DOTween.Sequence(); Debug.Log($"[{this.GetType().Name}] Getting Heal: {cardArgs.CardData.Amount}!"); seq.Append(Slider.DOValue((float)UnitManager.HP / (float)UnitManager.UnitData.HP, 1f)); HP.text = $"{UnitManager.HP} / {UnitManager.UnitData.HP}"; Debug.LogWarning($"[{this.GetType().Name}] OnAttack!"); var unit = sender as UnitManager; seq.OnComplete(() => cardArgs.Callback()); }
public void UseCard(Guid targetId, CardData card, Action callBack) { if (UnitState == UnitState.Exhausted) { UnitState = UnitState.Normal; OnExhausted?.Invoke(this, callBack); return; } // Temp if (card.Name == "Tail Attack") { Debug.LogWarning("Tail attack!!!!!"); UnitState = UnitState.Exhausted; } // var cf = new CardFactory(); // var act = cf.GetAction(card.CardClass); isInAction = true; var target = GameObject.Find(targetId.ToString()).GetComponent <UnitManager>(); var args = new CardArgs(this, target, card, callBack); switch (card.CardClass) { case CardClass.Damage: OnAttack?.Invoke(this, args); break; case CardClass.Heal: this.HP += card.Amount; if (this.HP >= UnitData.HP) { this.HP = UnitData.HP; } OnGetHeal?.Invoke(this, args); break; default: break; } }