Advertisement
Guest User

Card and Effect classes

a guest
Jul 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.36 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public enum Faction { None, Lightbearers, Seaborn_Sharks, Farmers, Fanatics_of_Light, Volcanics, Eidetics, Patriots, Magi, Scavengers, The_Reluctant_Dead, Manakins, Watchers, Battleborns, Hexers, TechArtists, The_EndFairies };
  6. public enum CardType { None, Unit, Commander, Tactic };
  7. public enum UnitType { None, Soldier, Spellcaster};
  8. public enum SoldierType { None, Agent, Fighter};
  9. public enum SpellcasterType { None, Enhancer, Terraformer, Hexer, Caster, Channeller };
  10. public enum Location { Null, Deck, Reserves, Medbay, Graveyard, Field, FieldSoldier, FieldSpellcaster, Commander_Deck, Tactics, Hand, Target1}
  11.  
  12. public enum TargetingType { SimpleTargeting }
  13. public enum SimpleTargetingType { ZoneList }
  14. public enum CARDS { ThisCard }
  15. public enum TriggerType { OtherEffect, Moving, PositionChange, AtWill, Battle, EnterField}
  16. //location will also need player id, and in some cases ids for sublocations (e.g. top of deck, left soldierslot)
  17.  
  18.  
  19. [System.Serializable]
  20. public class Effect : MonoBehaviour
  21. {
  22. public GameManager gameManager;
  23.  
  24. public string description;
  25.  
  26. public string choiceTitle;
  27.  
  28. public Card attachedCard;
  29. public bool triggered;
  30. public bool atWill;
  31. public bool hasConditions;
  32.  
  33. public int playerID;
  34.  
  35.  
  36. #region Conditions
  37.  
  38. #endregion
  39.  
  40. #region Triggers
  41.  
  42.  
  43. public struct TriggerVars
  44. {
  45. public bool isPreemptive;
  46. public bool isChoice;
  47. public int numberOfTriggers;
  48. public TriggerType triggerType;
  49.  
  50. }
  51.  
  52. public TriggerVars[] triggers;
  53.  
  54. public bool TriggerCheck(TriggerVars trigger)
  55. {
  56. bool value = false;
  57. if (trigger.triggerType == TriggerType.EnterField)
  58. {
  59. CardTemplate attachedCardTmp = attachedCard.GetComponent<CardTemplate>();
  60. if (attachedCardTmp.justCreated == true & attachedCardTmp.inZone)
  61. {
  62. attachedCardTmp.justCreated = false;
  63. value = true;
  64. }
  65. }
  66.  
  67. return value;
  68. }
  69.  
  70.  
  71. public void Update()
  72. {
  73. foreach (TriggerVars t in triggers)
  74. {
  75. TriggerCheck(t);
  76. }
  77. }
  78.  
  79. #endregion
  80.  
  81. #region Effects
  82.  
  83.  
  84.  
  85. public CARDS[] cards1;
  86. public Location[] locations1;
  87. public Location[] locations2;
  88.  
  89.  
  90.  
  91. public List<Card> cards1cards = new List<Card>();
  92. public List<CardTemplate> cards1Tmps = new List<CardTemplate>();
  93.  
  94. #region Move [CARDS] in [LOCATION] to [LOCATION]
  95.  
  96.  
  97. IEnumerator Moving()
  98. {
  99. for (int i = 0; i < cards1.Length; i++)
  100. {
  101. if (cards1[i] == CARDS.ThisCard)
  102. {
  103.  
  104. if (locations2[i] == Location.Target1)
  105. {
  106. if (targetings[1].targetType == TargetingType.SimpleTargeting)
  107. {
  108. StartCoroutine(SimpleTargeting(targetings[1]));
  109. while (!doneTargeting)
  110. {
  111. yield return null;
  112. }
  113. if (targetings[1].simpleTType == SimpleTargetingType.ZoneList)
  114. {
  115. GameObject cardPlayed = gameManager.CardTemplateGenerator(attachedCard, simpleTargetingZoneResults[0].gameObject.transform.position, simpleTargetingZoneResults[0].gameObject.transform.rotation);
  116. cardPlayed.GetComponent<CardTemplate>().inZone = true;
  117. cardPlayed.GetComponent<CardTemplate>().zoneIn = simpleTargetingZoneResults[0];
  118. }
  119. }
  120.  
  121.  
  122. }
  123. CardTemplate cardTmp = attachedCard.GetComponent<CardTemplate>();
  124. if (cardTmp.inHand)
  125. {
  126. gameManager.players[cardTmp.inHandPlayerID].hand.RemoveAt(cardTmp.handID);
  127. gameManager.UpdateAllHands();
  128. }
  129.  
  130.  
  131.  
  132.  
  133. }
  134. }
  135.  
  136.  
  137. yield return null;
  138. }
  139.  
  140.  
  141. #endregion
  142.  
  143.  
  144. #region Change [CARDS] position to [POSITION]
  145.  
  146.  
  147.  
  148. #endregion
  149.  
  150. #endregion
  151.  
  152. #region Targeting
  153.  
  154. int numberTargetings = 1;
  155.  
  156. public struct TargetVars
  157. {
  158.  
  159. public TargetingType targetType;
  160.  
  161. public SimpleTargetingType simpleTType;
  162. public ZoneScript[] simpleTargetingZoneList;
  163. public int simpleTargetingMinChoices;
  164. public int simpleTargetingMaxChoices;
  165. public bool canBeOccupied;
  166.  
  167. }
  168. public List<ZoneScript> simpleTargetingZoneResults = new List<ZoneScript>();
  169.  
  170. public TargetVars[] targetings;
  171.  
  172. bool doneTargeting = true;
  173.  
  174. IEnumerator SimpleTargeting(TargetVars targeting)
  175. {
  176. doneTargeting = false;
  177. if (targeting.simpleTType == SimpleTargetingType.ZoneList)
  178. {
  179. List<ZoneScript> zoneChoices = new List<ZoneScript>();
  180. foreach (ZoneScript z in targeting.simpleTargetingZoneList)
  181. {
  182. if (targeting.canBeOccupied | !z.occupied)
  183. {
  184. z.MakeTarget(playerID, zoneChoices);
  185. }
  186. }
  187. if (targeting.simpleTargetingMinChoices == 1 && targeting.simpleTargetingMaxChoices == 1)
  188. {
  189. while (zoneChoices.Count != 1)
  190. {
  191. if (Input.GetMouseButtonDown(1))
  192. {
  193. foreach (ZoneScript z in targeting.simpleTargetingZoneList)
  194. {
  195. z.CancelTarget();
  196. }
  197. yield break;
  198. }
  199. yield return null;
  200. }
  201. }
  202.  
  203.  
  204. foreach (ZoneScript z in zoneChoices)
  205. {
  206.  
  207. simpleTargetingZoneResults.Add(z);
  208.  
  209. }
  210. foreach (ZoneScript z in targeting.simpleTargetingZoneList)
  211. {
  212. if (targeting.canBeOccupied | !z.occupied)
  213. {
  214. z.CancelTarget();
  215. }
  216. }
  217. }
  218.  
  219.  
  220. doneTargeting = true;
  221. yield return null;
  222.  
  223. }
  224.  
  225. #endregion
  226.  
  227. #region SecondaryChoices
  228. #endregion
  229.  
  230. #region Checks
  231.  
  232. #endregion
  233.  
  234. #region Placeholders
  235.  
  236. #region CARDS
  237. #endregion
  238.  
  239. #region LOCATION
  240. #endregion
  241.  
  242. #region ZONES
  243. #endregion
  244.  
  245. #endregion
  246.  
  247.  
  248. IEnumerator ActivateEffect()
  249. {
  250.  
  251. gameManager.globalTriggerCheck = true;
  252. yield return null;
  253. }
  254.  
  255. }
  256.  
  257.  
  258. public class Card : MonoBehaviour
  259. {
  260. //in-game variables
  261. public int ownerplayerID;
  262. public int controllerplayerID;
  263.  
  264. //card qualities
  265. public string cardName = "";
  266. public Sprite cardImage;
  267. public Faction faction;
  268. public CardType cardType;
  269. public UnitType unitType;
  270. public SoldierType soldierType;
  271. public SpellcasterType spellcasterType;
  272. public int offence;
  273. public int defence;
  274. public bool isOffenceVar;
  275. public bool isDefenceVar;
  276. public bool isQuick;
  277. public bool hasInLocationEffects;
  278. public int numbInLocationEffects;
  279. public Location[] inLocationEffectLocations;
  280. public string effectText;
  281.  
  282. //Construction variables
  283. private bool battlestats = false;
  284.  
  285.  
  286.  
  287. //effects
  288.  
  289. public bool triggerWhileInHand;
  290. public bool triggerWhileOnField;
  291. public bool triggerWhileInDeck;
  292. public bool triggerWhileInReserveDeck;
  293. public bool triggerWhileInGraveyard;
  294. public bool triggerWhileInMedBay;
  295. public bool triggerWhileInCommanderDeck;
  296.  
  297.  
  298. public int numberOfEffects;
  299. public List<Effect> effects = new List<Effect>();
  300.  
  301.  
  302. public void Assemble()
  303. {
  304. CardTemplate cardTemplate = GetComponent<CardTemplate>();
  305. cardTemplate.cardName.text = cardName;
  306. if (cardType == CardType.Commander)
  307. {
  308. cardTemplate.commanderBase.SetActive(true);
  309. cardTemplate.fighterBase.SetActive(false);
  310. cardTemplate.agentBase.SetActive(false);
  311. cardTemplate.spellcasterBase.SetActive(false);
  312. cardTemplate.tacticBase.SetActive(false);
  313. battlestats = true;
  314. }
  315. else if (cardType == CardType.Tactic)
  316. {
  317. cardTemplate.commanderBase.SetActive(false);
  318. cardTemplate.fighterBase.SetActive(false);
  319. cardTemplate.agentBase.SetActive(false);
  320. cardTemplate.spellcasterBase.SetActive(false);
  321. cardTemplate.tacticBase.SetActive(true);
  322. }
  323. else if (cardType == CardType.Unit)
  324. {
  325. if (unitType == UnitType.Soldier)
  326. {
  327. battlestats = true;
  328. if (soldierType == SoldierType.Fighter)
  329. {
  330. cardTemplate.commanderBase.SetActive(false);
  331. cardTemplate.fighterBase.SetActive(true);
  332. cardTemplate.agentBase.SetActive(false);
  333. cardTemplate.spellcasterBase.SetActive(false);
  334. cardTemplate.tacticBase.SetActive(false);
  335. }
  336. else if (soldierType == SoldierType.Agent)
  337. {
  338. cardTemplate.commanderBase.SetActive(false);
  339. cardTemplate.fighterBase.SetActive(false);
  340. cardTemplate.agentBase.SetActive(true);
  341. cardTemplate.spellcasterBase.SetActive(false);
  342. cardTemplate.tacticBase.SetActive(false);
  343. }
  344. }
  345. else if (unitType == UnitType.Spellcaster)
  346. {
  347. cardTemplate.commanderBase.SetActive(false);
  348. cardTemplate.fighterBase.SetActive(false);
  349. cardTemplate.agentBase.SetActive(false);
  350. cardTemplate.spellcasterBase.SetActive(true);
  351. cardTemplate.tacticBase.SetActive(false);
  352. }
  353. }
  354. if (battlestats)
  355. {
  356. cardTemplate.offenceText.gameObject.SetActive(true);
  357. cardTemplate.offenceNumber.gameObject.SetActive(true);
  358. cardTemplate.defenceText.gameObject.SetActive(true);
  359. cardTemplate.defenceNumber.gameObject.SetActive(true);
  360. cardTemplate.offenceNumber.text = offence.ToString();
  361. cardTemplate.defenceNumber.text = defence.ToString();
  362. }
  363. else
  364. {
  365. cardTemplate.offenceText.gameObject.SetActive(false);
  366. cardTemplate.offenceNumber.gameObject.SetActive(false);
  367. cardTemplate.defenceText.gameObject.SetActive(false);
  368. cardTemplate.defenceNumber.gameObject.SetActive(false);
  369. }
  370. cardTemplate.effectText.gameObject.SetActive(true);
  371. cardTemplate.effectText.text = effectText;
  372. }
  373.  
  374. public string TextGenerate()
  375. {
  376.  
  377. return "test";
  378. }
  379.  
  380.  
  381. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement