AckCard.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using FSRole;
  5. using FSEvent;
  6. using FSBuff;
  7. using UnityEngine.UI;
  8. namespace FSCard {
  9. /*
  10. * 攻击卡片组件
  11. */
  12. public class AckCard : MonoBehaviour, Card {
  13. // 种类
  14. public CardType Type { get; set; }
  15. // 卡片的唯一标示
  16. public string ID { set; get; }
  17. // 花费的能量
  18. public int Cost { get; set; }
  19. // 韧性
  20. public int Tenacity { get; set; }
  21. // 数值
  22. public int Value { set; get; }
  23. // 目标
  24. public Role Target { set; get; }
  25. // 挂载的BUFF id
  26. public string BuffID { set; get; }
  27. // 发起者
  28. public Role Source { set; get; }
  29. // 卡面
  30. public Image Face { set; get; }
  31. // Use this for initialization
  32. void Start() {
  33. Face = transform.Find("Face").GetComponent<Image>();
  34. if (Face != null) {
  35. // 加载图片
  36. Image image = gameObject.GetComponent<Image>();
  37. if (Source.CurrentAttr.Camp == RoleCamp.ARMY) {
  38. if (Type == CardType.CARD_TYPE_ATTACK) {
  39. image.sprite = Resources.Load("Textures/Cards/BG/Army_Ack", typeof(Sprite)) as Sprite;
  40. } else if (Type == CardType.CARD_TYPE_DEFANCE) {
  41. image.sprite = Resources.Load("Textures/Cards/BG/Army_Def", typeof(Sprite)) as Sprite;
  42. } else {
  43. image.sprite = Resources.Load("Textures/Cards/BG/Army_Spec", typeof(Sprite)) as Sprite;
  44. }
  45. } else {
  46. if (Type == CardType.CARD_TYPE_ATTACK) {
  47. image.sprite = Resources.Load("Textures/Cards/BG/Enemy_Ack", typeof(Sprite)) as Sprite;
  48. } else if (Type == CardType.CARD_TYPE_DEFANCE) {
  49. image.sprite = Resources.Load("Textures/Cards/BG/Enemy_Def", typeof(Sprite)) as Sprite;
  50. } else {
  51. image.sprite = Resources.Load("Textures/Cards/BG/Enemy_Spec", typeof(Sprite)) as Sprite;
  52. }
  53. }
  54. Face.sprite = Resources.Load("Textures/Cards/Face/" + ID, typeof(Sprite)) as Sprite;
  55. }
  56. }
  57. /*
  58. * 卡片执行
  59. */
  60. public void OnExecute() {
  61. print("卡片 " + ID + " 启动," + Target.CurrentAttr.ID + " 受到攻击...");
  62. Target.GetDamage(-Value);
  63. // 判断BUFF是否存在,如果存在,则运行BUFF
  64. if (BuffID != null) {
  65. if (Target != null) {
  66. print("攻击附带BUFF " + BuffID);
  67. BuffManager.Instance.LoadBuff(Target.gameObject, BuffID);
  68. }
  69. }
  70. }
  71. }
  72. }