public void CheckReset(int eventCode) { if (ComVal.isBind(ComVal.resetEvent_Phase, eventCode)) { if (resetCode <= eventCode) { int val = startRoundCount + resetRoundCount; if (val == duel.roundCount) { isDisable = true; } //else if (duel.roundCount > val) //{ // Debug.Log(ownerCard.cardID); // Debug.Log("error"); //} } } else { if (resetCode == eventCode) { int val = startRoundCount + resetRoundCount; if (val == duel.roundCount) { isDisable = true; } //else if (val > duel.roundCount) //{ // Debug.Log("error"); //} } } }
public bool isFit(Card card) { bool result = false; switch (attribute) { case ComVal.fiter_containName: result = card.ContainName((string)val); break; case ComVal.fiter_isAttribute: result = ComVal.isBind((int)val, card.GetCurAttribute()); break; case ComVal.fiter_isLevel: result = card.level == (int)val; break; case ComVal.fiter_isCardType: result = ComVal.isBind((int)val, card.cardType); break; case ComVal.fiter_isArea: result = ComVal.isBind((int)val, card.curArea); break; } return(result); }
/// <summary> /// 移除不确定卡片时,需要填写area参数 /// </summary> /// <param name="card"></param> /// <param name="player"></param> /// <param name="area"></param> /// <param name="duel"></param> /// <returns></returns> public static Card RemoveCardFromArea(Card card, Player player, int area) { int curArea = card.curArea; if (curArea.IsBind(ComVal.Area_Field))//场地 { RemoveCardFromField(card, player); return(card); } else if (ComVal.isBind(curArea, ComVal.Area_Hand))//手牌 { RemoveCardFromHand(card, player); return(card); } else { if (area != 0) { return(RemoveCardFromDeck(area, card, player)); } else { return(RemoveCardFromDeck(curArea, card, player)); } } }
public void OnFindButtonClick() { string keyWord = keyWordInputField.text; int cardType = StaticMethod.ChangeCardType(cardTypeDropdown.captionText.text); int cardRace = StaticMethod.ChangeCardRace(cardRaceDropdown.captionText.text); int cardAttr = StaticMethod.ChangeCardAttr(cardAttrDropdown.captionText.text); string str = cardLevelDropdown.captionText.text; int cardLevel = 0; if (str != "N/A") { str = str.Replace("星", ""); cardLevel = int.Parse(str); } if (!ComVal.isMonster(cardType)) { if (cardRace != 0 || cardAttr != 0 || cardLevel != 0) { return; } } editUI.FindCard(cardType, cardAttr, cardRace, cardLevel, keyWord); }
/// <summary> /// 是否可以发动效果 /// </summary> /// <param name="_code"></param> /// <returns></returns> public bool CanBeLaunch(Code _code) { if (!ownerCard.CanLauchEffect(this) || !ownerCard.controller.CanLauchEffect(this)) { return(false); } if (ownerCard.IsMonster() && ownerCard.IsInField()) { if (!ownerCard.IsFaceUp()) { return(false); } } if (lauchArea != 0) { if (!ComVal.isBind(ownerCard.curArea, lauchArea)) { return(false); } } if (!ComVal.isBind(_code.code, code)) { return(false); } if (lauchPhase != 0) { if (!ComVal.isBind(duel.currentPhase, lauchPhase)) { return(false); } } return(checkLauch(duel, ownerCard, this, _code)); }
/// <summary> /// 由外部调用 /// </summary> /// <param name="i"></param> public void ChangeToPhase(int i) { currentPhase = buttonList[ComVal.ChangePhaseToVal(i) - 1]; foreach (var item in buttonList) { item.ChangeToNormalColor(); } currentPhase.ChangeTextColor(); SetCanControl(); }
public bool isSpell() { if (ComVal.isBind(cardType, ComVal.cardType_Spell)) { return(true); } else { return(false); } }
public bool IsTrap() { if (ComVal.isBind(cardType, ComVal.cardType_Trap)) { return(true); } else { return(false); } }
public bool IsMonster() { if (ComVal.isBind(cardType, ComVal.cardType_Monster)) { return(true); } else { return(false); } }
/// <summary> /// 是否在手牌或场地上 /// </summary> /// <returns></returns> public bool IsHandAndField() { for (int i = 0; i < cardList.Count; i++) { if (!ComVal.isBind(cardList[i].curArea, ComVal.Area_Hand | ComVal.Area_Monster | ComVal.Area_Trap)) { return(false); } } return(true); }
/// <summary> /// 筛选出符合种族的怪兽卡片 /// </summary> /// <param name="ff"></param> public Group SiftingGroupInRace(int race) { Group a = new Group(); for (int i = 0; i < cardList.Count; i++) { if (ComVal.isBind(cardList[i].race, race)) { a.AddCard(cardList[i]); } } return(a); }
public Group SiftingGroupInArea(int area) { Group a = new Group(); foreach (var item in cardList) { if (ComVal.isBind(item.curArea, area)) { a.AddCard(item); } } return(a); }
/// <summary> /// 筛选出符合属性的怪兽卡片 /// </summary> /// <param name="attr"></param> /// <returns></returns> public Group SiftingGroupInAttr(int attr) { Group a = new Group(); foreach (var item in cardList) { if (ComVal.isBind(item.GetCurAttribute(), attr)) { a.AddCard(item); } } return(a); }
public Group GetAreaGroup(int area) { Group g = new Group(); for (int i = 0; i < cardList.Count; i++) { Card card = cardList[i]; if (ComVal.isBind(area, card.curArea)) { g.AddCard(card); } } return(g); }
public int GetAreaNum(int area) { int a = 0; for (int i = 0; i < cardList.Count; i++) { Card card = cardList[i]; if (ComVal.isBind(area, card.curArea)) { a++; } } return(a); }
public bool CanLauchTriggerEffect(Code code, Chain chain, bool isDelayode, bool isNotInChain = false) { int effectType; effectType = ComVal.cardEffectType_triggerEffect; if (IsHideInTrapArea()) { if (cardSetRound == 0) { return(false); } } if (isSpell() && curArea == ComVal.Area_Hand) { if (duel.curPlayer != ownerPlayer) { return(false); } } if (IsTrap() && curArea == ComVal.Area_Hand) { return(false); } foreach (var item in lauchEffectList) { if (isDelayode) { if ((ComVal.isBind(item.code, chain.codeVal) && item.IsBindCardEffectType(ComVal.cardEffectType_chooseLauch))) { continue; } } if (ComVal.isBind(code.code, item.code)) { if (item.cardEffectType.IsBind(ComVal.cardEffectType_notInChain)) { if (!isNotInChain) { return(false); } } if (item.CanBeLaunch(code) && !chain.ContainEffect(item.code, this, item) && item.IsBindCardEffectType(effectType)) { return(true); } } } return(false); }
/// <summary> /// 对墓地 除外 主卡组 额外卡组移除卡片 /// <para>如果card为空,则返回主卡组的第一张卡 用于抽卡</para> /// </summary> /// <param name="card"></param> static Card RemoveCardFromDeck(int area, Card card, Player player) { Card result = Card.Empty(); switch (area) { case ComVal.Area_MainDeck: if (!Card.IsEmpty(card)) { player.group_MainDeck.RemoveCard(card); } else { result = player.group_MainDeck.RemoveFirstCard(); } break; case ComVal.Area_Extra: player.group_ExtraDeck.RemoveCard(card); break; case ComVal.Area_Graveyard: player.group_Graveyard.RemoveCard(card.areaRank); break; case ComVal.Area_Remove: player.group_Remove.RemoveCard(card.areaRank); break; default: break; } if (ComVal.isBind(area, ComVal.Area_MainDeck) || ComVal.isBind(area, ComVal.Area_Extra)) { DuelUIManager.GetInstance().RemoveCardFromDeck(area, Card.Empty(), 1, player.isMy); } else { DuelUIManager.GetInstance().RemoveCardFromDeck(area, card, 1, player.isMy); } //if (area == ComVal.Area_MainDeck) //{ // Duel.GetInstance().ShuffleDeck(player); //} return(result); }
/// <summary> /// 获取可以发动的效果 /// <para>不存在于连锁之中</para> /// </summary> /// <returns></returns> public List <LauchEffect> GetCanLauchEffectList(Code code, Chain chain) { List <LauchEffect> list = new List <LauchEffect>(); foreach (var item in lauchEffectList) { if (chain.isDelayCode) { if ((ComVal.isBind(item.code, chain.codeVal) && item.IsBindCardEffectType(ComVal.cardEffectType_chooseLauch))) { continue; } } if (item.CanBeLaunch(code) && !chain.ContainEffect(item.code, this, item)) { list.Add(item); } } return(list); }
public static List <Card> GetCardListFromPlayer(int area, Player player) { List <Card> list = new List <Card>(); if (ComVal.isBind(ComVal.Area_Graveyard, area)) { list.AddRange(player.group_Graveyard.cardList); } if (ComVal.isBind(ComVal.Area_Extra, area)) { list.AddRange(player.group_ExtraDeck.cardList); } if (ComVal.isBind(ComVal.Area_Hand, area)) { list.AddRange(player.group_HandCard.cardList); } if (ComVal.isBind(ComVal.Area_Remove, area)) { list.AddRange(player.group_Remove.cardList); } if (ComVal.isBind(ComVal.Area_MainDeck, area)) { list.AddRange(player.group_MainDeck.cardList); } if (ComVal.isBind(ComVal.Area_Monster, area)) { list.AddRange(player.group_MonsterCard.GetCardList()); } if (ComVal.isBind(ComVal.Area_NormalTrap, area)) { list.AddRange(player.group_TrapCard.GetCardList()); } if (area.IsBind(ComVal.Area_FieldSpell)) { if (player.fieldSpell != null) { list.Add(player.fieldSpell); } } return(list); }
/// <summary> /// 生成卡片信息 /// </summary> public void Init(bool _isMy) { if (IsMonster()) { curAfk = afk; curDef = def; curLevel = level; curAttribute = attribute; cardAttackedTime = 0; } isMy = _isMy; duel = Duel.GetInstance(); if (ComVal.isInExtra(cardType)) { curArea = ComVal.Area_Extra; } else { curArea = ComVal.Area_MainDeck; } }
private Group GettargetGroup(IDuel duel, Card card) { Group g = duel.GetIncludeNameCardFromArea(ComStr.KeyWord_Hero, false, card.ownerPlayer, ComVal.cardType_Monster, ComVal.Area_Monster, filter, false, null, null); Group g1 = duel.GetIncludeNameCardFromArea(ComStr.KeyWord_MaskHERO, false, card.ownerPlayer, ComVal.CardType_Monster_Fusion, ComVal.Area_Extra); g1 = card.ownerPlayer.GetCanSpSummonGroup(g1); Group g2 = new Group(); int val = 0; foreach (var item in g1.cardList) { val = ComVal.Add(item.GetCurAttribute(), val); } foreach (var item in g.cardList) { if (ComVal.isBind(item.GetCurAttribute(), val)) { g2.AddCard(item); } } return(g2); }
public void RoundEndReset() { foreach (var item in effectLauchCountLimitList) { item.ResetLauchCount(); } stayturn++; if (ComVal.isBind(curArea, ComVal.Area_Field)) { cardSetRound++; } else { cardSetRound = 0; } if (IsMonster()) { cardChangeTypeTime = 1; cardChangeTypeedTime = 0; cardAttackedTime = 0; cardAttackedTime = 0; } }
/// <summary> /// 只要有一个效果可以发动 返回真 /// <para>且不存在于连锁当中</para> /// </summary> /// <param name="code"></param> /// <returns></returns> private bool MCanLauchEffect(Code code, Chain chain, int cardEffectType) { if (IsTrap()) { if (curArea == ComVal.Area_NormalTrap && curPlaseState == ComVal.CardPutType_UpRightBack) { if (cardSetRound == 0) { return(false); } } } else if (isSpell()) { if (curArea == ComVal.Area_NormalTrap && curPlaseState == ComVal.CardPutType_UpRightBack && cardType == ComVal.CardType_Spell_Quick) { if (cardSetRound == 0) { return(false); } } } int effectType = cardEffectType; foreach (var item in lauchEffectList) { if (ComVal.isBind(code.code, item.code)) { if (item.CanBeLaunch(code) && item.IsBindCardEffectType(effectType)) { return(true); } } } return(false); }
bool filter(Card card) { return(ComVal.isBind(ComVal.CardRace_Warrior, card.race)); }
/// <summary> /// 排序 /// </summary> /// <param name="list"></param> /// <returns></returns> public static List <Card> SortCardList(List <Card> list) { List <Card> normalMonsterList = new List <Card>(); List <Card> monsterList = new List <Card>(); List <Card> spellList = new List <Card>(); List <Card> trapList = new List <Card>(); List <Card> xyzMonsterList = new List <Card>(); List <Card> fusionMonsterList = new List <Card>(); List <Card> synchroMonsterList = new List <Card>(); List <Card> resultList = new List <Card>(); for (int i = 0; i < list.Count; i++) { Card card = list[i]; if (card.IsMonster()) { if (!ComVal.isInExtra(card.cardType) && card.cardType != ComVal.CardType_Monster_Normal) { bool isInsert = false; for (int j = 0; j < monsterList.Count; j++)//有同名则插入其后面 { if (card.cardID == monsterList[j].cardID) { monsterList.Insert(j, card); isInsert = true; break; } } if (!isInsert) { for (int x = 0; x < monsterList.Count; x++) { if (card.level < monsterList[x].level) { monsterList.Insert(x, card); isInsert = true; break; } } } if (!isInsert) { monsterList.Add(card); } } else if (card.cardType == ComVal.CardType_Monster_Normal) { bool isInsert = false; for (int j = 0; j < normalMonsterList.Count; j++)//有同名则插入其后面 { if (card.cardID == normalMonsterList[j].cardID) { normalMonsterList.Insert(j, card); isInsert = true; break; } } if (!isInsert) { for (int x = 0; x < normalMonsterList.Count; x++) { if (card.level < normalMonsterList[x].level) { normalMonsterList.Insert(x, card); isInsert = true; break; } } } if (!isInsert) { normalMonsterList.Add(card); } } else if (card.cardType == ComVal.CardType_Monster_Fusion) { bool isInsert = false; for (int j = 0; j < fusionMonsterList.Count; j++)//有同名则插入其后面 { if (card.cardID == fusionMonsterList[j].cardID) { fusionMonsterList.Insert(j, card); isInsert = true; break; } } if (!isInsert) { for (int x = 0; x < fusionMonsterList.Count; x++) { if (card.level < fusionMonsterList[x].level) { fusionMonsterList.Insert(x, card); isInsert = true; break; } } } if (!isInsert) { fusionMonsterList.Add(card); } } else if (card.cardType == ComVal.CardType_Monster_Synchro) { bool isInsert = false; for (int j = 0; j < synchroMonsterList.Count; j++)//有同名则插入其后面 { if (card.cardID == synchroMonsterList[j].cardID) { synchroMonsterList.Insert(j, card); isInsert = true; break; } } if (!isInsert) { for (int x = 0; x < synchroMonsterList.Count; x++) { if (card.level < synchroMonsterList[x].level) { synchroMonsterList.Insert(x, card); isInsert = true; break; } } } if (!isInsert) { synchroMonsterList.Add(card); } } else if (card.cardType == ComVal.CardType_Monster_XYZ) { bool isInsert = false; for (int j = 0; j < xyzMonsterList.Count; j++)//有同名则插入其后面 { if (card.cardID == xyzMonsterList[j].cardID) { xyzMonsterList.Insert(j, card); isInsert = true; break; } } if (!isInsert) { for (int x = 0; x < xyzMonsterList.Count; x++) { if (card.level < xyzMonsterList[x].level) { xyzMonsterList.Insert(x, card); isInsert = true; break; } } } if (!isInsert) { xyzMonsterList.Add(card); } } } else if (card.isSpell()) { bool isInsert = false; for (int j = 0; j < spellList.Count; j++)//有同名则插入其后面 { if (card.cardID == spellList[j].cardID) { spellList.Insert(j, card); isInsert = true; break; } } if (!isInsert) { spellList.Add(card); } } else if (card.IsTrap()) { bool isInsert = false; for (int j = 0; j < trapList.Count; j++)//有同名则插入其后面 { if (card.cardID == trapList[j].cardID) { trapList.Insert(j, card); isInsert = true; break; } } if (!isInsert) { trapList.Add(card); } } } resultList.AddRange(normalMonsterList); resultList.AddRange(monsterList); resultList.AddRange(fusionMonsterList); resultList.AddRange(synchroMonsterList); resultList.AddRange(xyzMonsterList); resultList.AddRange(spellList); resultList.AddRange(trapList); return(resultList); }
/// <summary> /// 增加卡片 /// </summary> /// <param name="isMain">是否为主卡组</param> /// <param name="id">卡片id</param> public void AddCardToDeck(string id) { Card card = LoadXml.GetCard(id); bool isMain = !ComVal.isInExtra(card.cardType); int cardNum = 0; if (isMain) { foreach (var item in curDeck.mainDeck.cardList) { if (item.cardID == card.cardID) { cardNum++; } } } else { foreach (var item in curDeck.extraDeck.cardList) { if (item.cardID == card.cardID) { cardNum++; } } } if (cardNum >= 3) { return; } if (isMain) { if (curCard != null) { int val = GetObjVal(curCard.gameObject, isMain); AddToDeckFromPool(card, mainDeckGroup.transform, true); curDeck.mainDeck.InsertCard(card, val); for (int i = val; i < curDeck.mainDeck.GroupNum; i++) { mainDeckList[i].GetComponent <Card_Edit>().SetTexture(curDeck.mainDeck.GetCard(i).cardID, true); } UpdateText(); return; } if (mainDeckList.Count > curDeck.mainDeck.cardList.Count) { Card_Edit theCard_edit = mainDeckList[curDeck.mainDeck.cardList.Count].GetComponent <Card_Edit>(); theCard_edit.SetTexture(card.cardID, true); theCard_edit.SetActive(true); } else if (mainDeckList.Count == curDeck.mainDeck.cardList.Count) { AddToDeckFromPool(card, mainDeckGroup.transform, true); } else { Debug.Log("error"); } curDeck.mainDeck.AddCard(card); } else { if (curCard != null) { int val = GetObjVal(curCard.gameObject, isMain); AddToDeckFromPool(card, extraDeckGroup.transform, false); curDeck.extraDeck.InsertCard(card, val); for (int i = val; i < curDeck.extraDeck.GroupNum; i++) { extraDeckList[i].GetComponent <Card_Edit>().SetTexture(curDeck.extraDeck.GetCard(i).cardID, true); } UpdateText(); return; } if (extraDeckList.Count > curDeck.extraDeck.cardList.Count) { Card_Edit theCard_edit = extraDeckList[curDeck.extraDeck.cardList.Count].GetComponent <Card_Edit>(); theCard_edit.SetTexture(card.cardID, true); theCard_edit.SetActive(true); } else if (extraDeckList.Count == curDeck.extraDeck.cardList.Count) { AddToDeckFromPool(card, extraDeckGroup.transform, false); } else { Debug.Log("error"); } curDeck.extraDeck.AddCard(card); } UpdateText(); }