DefCard.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using FSRole;
  5. using FSEvent;
  6. using UnityEngine.UI;
  7. namespace FSCard {
  8. /*
  9. * 防守牌
  10. */
  11. public class DefCard : MonoBehaviour, Card {
  12. // 卡片总类
  13. public CardType Type { get; set; }
  14. // 卡片的唯一标示
  15. public string ID { set; get; }
  16. // 花费的能量
  17. public int Cost { get; set; }
  18. // 韧性
  19. public int Tenacity { get; set; }
  20. // 数值
  21. public int Value { set; get; }
  22. // 目标
  23. public Role Target { set; get; }
  24. // 挂载的BUFF id
  25. public string BuffID { set; get; }
  26. // 发起者
  27. public Role Source { set; get; }
  28. // 卡面
  29. public Image Face { set; get; }
  30. // Use this for initialization
  31. void Start() {
  32. Face = transform.Find("Face").GetComponent<Image>();
  33. if (Face != null) {
  34. // 加载图片
  35. Image image = gameObject.GetComponent<Image>();
  36. if (Source.CurrentAttr.Camp == RoleCamp.ARMY) {
  37. if (Type == CardType.CARD_TYPE_ATTACK) {
  38. image.sprite = Resources.Load("Textures/Cards/BG/Army_Ack", typeof(Sprite)) as Sprite;
  39. } else if (Type == CardType.CARD_TYPE_DEFANCE) {
  40. image.sprite = Resources.Load("Textures/Cards/BG/Army_Def", typeof(Sprite)) as Sprite;
  41. } else {
  42. image.sprite = Resources.Load("Textures/Cards/BG/Army_Spec", typeof(Sprite)) as Sprite;
  43. }
  44. } else {
  45. if (Type == CardType.CARD_TYPE_ATTACK) {
  46. image.sprite = Resources.Load("Textures/Cards/BG/Enemy_Ack", typeof(Sprite)) as Sprite;
  47. } else if (Type == CardType.CARD_TYPE_DEFANCE) {
  48. image.sprite = Resources.Load("Textures/Cards/BG/Enemy_Def", typeof(Sprite)) as Sprite;
  49. } else {
  50. image.sprite = Resources.Load("Textures/Cards/BG/Enemy_Spec", typeof(Sprite)) as Sprite;
  51. }
  52. }
  53. Face.sprite = Resources.Load("Textures/Cards/Face/" + ID, typeof(Sprite)) as Sprite;
  54. }
  55. }
  56. // Update is called once per frame
  57. void Update() {
  58. }
  59. /*
  60. * 卡片执行
  61. */
  62. public void OnExecute() {
  63. Dictionary<string, object> info = new Dictionary<string, object>();
  64. info.Add("card", this);
  65. EventListener.Instance.PostEvent(EventEnum.EVENT_DEFENSE_CARD_EXECUTE, info);
  66. }
  67. }
  68. }