public void AddCertainCardFromDeck(string cardId) { CardInZhibo toPick = null; for (int i = 0; i < state.CardDeck.Count; i++) { if (state.CardDeck[i].CardId == cardId) { toPick = state.CardDeck[i]; break; } } if (toPick == null) { return; } bool ret = mUICtrl.AddNewCard(toPick); if (!ret) { Debug.Log("add card Fail"); return; } state.CardDeck.Remove(toPick); state.Cards.Add(toPick); if (state.CardDeck.Count == 0) { RefreshUsedCards(); } mUICtrl.UpdateDeckLeft(); }
public CardInZhibo AddCardFromDeck() { if (state.CardDeck.Count == 0) { RefreshUsedCards(); } if (state.CardDeck.Count == 0) { return(null); } if (state.Cards.Count >= CardMax) { return(null); } CardInZhibo info = state.CardDeck[0]; bool ret = mUICtrl.AddNewCard(info); if (!ret) { Debug.Log("add card Fail"); return(null); } state.CardDeck.RemoveAt(0); state.Cards.Add(info); if (state.CardDeck.Count == 0) { RefreshUsedCards(); } mUICtrl.UpdateDeckLeft(); return(info); //mUICtrl.GetCardContainer().UpdateCard(state.Cards.Count-1,info); }
public void AddCertainTmpCardFromDeck(CardInZhibo toPick) { if (!state.CardDeck.Contains(toPick)) { return; } CardInZhibo info = toPick; info.isTmp = true; bool ret = mUICtrl.AddNewTmpCard(info); if (!ret) { Debug.Log("add card Fail"); return; } state.CardDeck.Remove(toPick); state.TmpCards.Add(toPick); if (state.CardDeck.Count == 0) { RefreshUsedCards(); } mUICtrl.UpdateDeckLeft(); }
private void RemoveCardToDiscarded(CardInZhibo cinfo) { int idx; if (cinfo.isTmp) { idx = state.TmpCards.IndexOf(cinfo); state.TmpCards.Remove(cinfo); } else { idx = state.Cards.IndexOf(cinfo); state.Cards.Remove(cinfo); } if (cinfo.UseLeft > 0) { state.CardUsed.Add(cinfo); } cinfo.TimeLeft = 0; cinfo.NeedDiscard = false; if (cinfo.isTmp) { mUICtrl.GetCardContainer().RemoveTmpCard(idx); } else { mUICtrl.GetCardContainer().RemoveCard(idx); } cinfo.isTmp = false; }
private void LoadCard() { List <CardInfo> infoList = mCardMdl.GetAllCards(); state.CardDeck.Clear(); foreach (CardInfo info in infoList) { string eid = info.CardId; CardAsset ca = mCardMdl.GetCardInfo(eid); CardInZhibo card = new CardInZhibo(eid, ca.UseTime); card.ca = ca; state.CardDeck.Add(card); } List <string> platformCards = pRoleMgr.GetNowPlatformInfo().PlatformCards; for (int i = 0; i < platformCards.Count; i++) { string eid = platformCards[i]; CardAsset ca = mCardMdl.GetCardInfo(eid); CardInZhibo card = new CardInZhibo(eid, ca.UseTime); card.ca = ca; state.CardDeck.Add(card); } shuffle <CardInZhibo>(state.CardDeck); }
public void UpdateCard(int CardIdx, CardInZhibo cinfo) { if (CardIdx < 0 || CardIdx >= cards.Count) { return; } cards[CardIdx].UpdateView(cinfo); }
private void AddCardToDeck(string cardId, int level) { string eid = cardId; CardAsset ca = mCardMdl.GetCardInfo(eid); CardInZhibo card = new CardInZhibo(eid, ca.UseTime); card.ca = ca; state.CardDeck.Add(card); }
public void ExcuteUseCard(CardChainNode cardNode) { CardInZhibo card = cardNode.TargetCard; CardAsset cardAsset = card.ca; if (cardAsset != null) { NowExecuteCard = card; IsNoEffect = false; if (cardAsset.CardType == eCardType.GENG) { mUICtrl.ShowGengEffect(); } //几率触发或条件触发的效果 将放入该列表中后处理 List <CardEffect> extraEffects = new List <CardEffect>(); ValidBuffs = mBuffManager.CheckValidBuff(NowExecuteCard); foreach (CardEffect ce in cardAsset.Effects) { HandleOneCardEffect(ce, extraEffects); } for (int i = 0; i < extraEffects.Count; i++) { HandleOneCardEffect(extraEffects[i], extraEffects); } NowExecuteCard = null; if (cardAsset.StatusBonusType != 0 || cardAsset.SkillBonusType != 0) { state.UsedCardsToGetBonus.Add(cardAsset.CardId); } for (int i = 0; i < ValidBuffs.Count; i++) { if (!ValidBuffs[i].isBasedOn(eBuffLastType.CARD_BASE)) { continue; } ValidBuffs[i].LeftCardNum -= 1; if (ValidBuffs[i].LeftCardNum <= 0) { mBuffManager.RemoveBuff(ValidBuffs[i]); mBuffManager.CalculateBuffExtras(); } } } if (card.UseLeft > 0) { card.UseLeft -= 1; } RemoveCardToDiscarded(card); }
public bool TryUseCard(int cardIdx) { if (cardIdx < 0 || cardIdx >= state.Cards.Count) { return(false); } CardInZhibo cinfo = state.Cards[cardIdx]; CardAsset ca = cinfo.ca; if (state.Tili < ca.cost) { mUIMgr.ShowHint("体力不足"); return(false); } for (int i = 0; i < ca.UseConditions.Count; i++) { string[] args = ca.UseConditions[i].effectString.Split(','); switch (ca.UseConditions[i].effectType) { case eEffectType.MaxCount: int maxCount = int.Parse(args[0]); if (state.CardUsedCount.ContainsKey(NowExecuteCard.CardId) && state.CardUsedCount[NowExecuteCard.CardId] >= maxCount) { return(false); } if (state.CardUsedCount.ContainsKey(NowExecuteCard.CardId)) { state.CardUsedCount[NowExecuteCard.CardId] += 1; } else { state.CardUsedCount[NowExecuteCard.CardId] = 1; } break; case eEffectType.HavaCost: if (state.Tili == 0) { return(false); } break; default: break; } } state.Tili -= ca.cost; mUICtrl.UpdateTili(); PutCardInChain(cinfo); return(true); }
public void UpdateView(CardInZhibo info) { //if (info.ca.WillOverdue) //{ // view.TimeLeft.text = ((int)(info.TimeLeft) + 1) + ""; // if (info.TimeLeft < 3) // { // view.TimeLeft.color = Color.red; // } //} }
public void Init(CardInZhibo cardInfo, CardContainerLayout container) { rt = (RectTransform)transform; anim = GetComponent <Animator>(); this.container = container; CardAsset ca = cardInfo.ca; this.isTmp = cardInfo.isTmp; BindView(); RegisterEvent(); view.TimeLeftComp.gameObject.SetActive(false); if (!cardInfo.ca.IsConsume) { view.TimeLeftComp.gameObject.SetActive(false); } else { view.TimeLeftComp.gameObject.SetActive(true); view.TimeLeft.text = (int)cardInfo.UseLeft + ""; view.TimeLeft.color = Color.black; } anim.ResetTrigger("Disappear"); anim.Play("Normal"); //初始化卡面 view.Name.text = ca.CardName; view.Desp.text = ca.CardEffectDesp; nowDegree = 20f; targetDegree = 20f; container.PutToInitPos(this); isBacking = false; isDragging = false; isDestroying = false; isHighlight = false; PosDirty = false; isInChain = false; view.CardCG.alpha = 1f; nowValue = 0; view.CardFace.anchoredPosition = Vector2.zero; view.CardFace.localScale = MinimizeScale; view.CardCG.blocksRaycasts = true; CancelHighLight(); }
private void DiscardCard(CardInZhibo cinfo, bool triggerEffect) { if (triggerEffect && cinfo.ca.UseOnDiscard) { PutCardInChain(cinfo); } else { RemoveCardToDiscarded(cinfo); } }
public bool WillAffectCard(CardInZhibo card) { if (!bInfo.AffectCard) { return(false); } if (!card.ca.ApplyFilter(filter)) { return(false); } return(false); }
public bool WillAffectCard(CardInZhibo card) { if (!ZhiboBuffManager.isCardAffectBuff(bInfo)) { return(false); } if (!card.ca.ApplyFilter(filter)) { return(false); } return(false); }
public List <ZhiboBuff> CheckValidBuff(CardInZhibo card) { List <ZhiboBuff> ret = new List <ZhiboBuff>(); for (int i = 0; i < CardCountedBuffs.Count; i++) { if (CardCountedBuffs[i].WillAffectCard(card)) { ret.Add(CardCountedBuffs[i]); } } return(ret); }
public Vector3 GetCardPosition(CardInZhibo card) { Vector3 ret = Vector3.zero; if (card.isTmp) { ret = TmpCards[gameMode.state.TmpCards.IndexOf(card)].transform.position; } else { ret = cards[gameMode.state.Cards.IndexOf(card)].transform.position; } return(ret); }
public void GainNewCard(string cardId) { CardAsset ca = mCardMdl.GetCardInfo(cardId); if (ca == null) { return; } CardInZhibo info = new CardInZhibo(ca); bool ret = mUICtrl.AddNewCard(info); state.Cards.Add(info); }
public void PutCardInChain(CardInZhibo card, float delay = 0f) { state.UseCardChain.Add(new CardChainNode(card, delay)); if (card.isTmp) { int idx = state.TmpCards.IndexOf(card); mUICtrl.GetCardContainer().TmpCards[idx].isInChain = true; } else { int idx = state.Cards.IndexOf(card); mUICtrl.GetCardContainer().cards[idx].isInChain = true; } //isInChain }
public bool AddCard(CardInZhibo cardInfo) { IResLoader loader = GameMain.GetInstance().GetModule <ResLoader>(); GameObject cardGo = loader.Instantiate("Zhibo/Card"); if (cardGo == null) { return(false); } MiniCard card = cardGo.GetComponent <MiniCard>(); card.Init(cardInfo, this); card.transform.SetParent(transform, false); cards.Add(card); Adjust(); return(true); }
public bool AddTmpCard(CardInZhibo cardInfo) { IResLoader loader = GameMain.GetInstance().GetModule <ResLoader>(); GameObject cardGo = loader.Instantiate("Zhibo/Card", FixedContainer); if (cardGo == null) { return(false); } MiniCard card = cardGo.GetComponent <MiniCard>(); card.Init(cardInfo, this); card.rt.anchoredPosition = Vector3.zero; card.rt.localEulerAngles = Vector3.zero; TmpCards.Add(card); AdjustTmp(); return(true); }
public void Init(CardInZhibo cardInfo, CardContainerLayout container) { rt = (RectTransform)transform; anim = GetComponent <Animator>(); this.container = container; CardAsset ca = cardInfo.ca; this.isTmp = cardInfo.isTmp; BindView(); RegisterEvent(); view.TimeLeftComp.gameObject.SetActive(false); if (!cardInfo.ca.IsConsume) { view.TimeLeftComp.gameObject.SetActive(false); } else { view.TimeLeftComp.gameObject.SetActive(true); view.TimeLeft.text = (int)cardInfo.UseLeft + ""; view.TimeLeft.color = Color.black; } anim.ResetTrigger("Disappear"); anim.Play("Normal"); //初始化卡面 view.Name.text = ca.CardName; view.BackName.text = view.Name.text; view.NamePicture.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardName/" + ca.CatdImageName); view.BackNamePicture.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardName/" + ca.CatdImageName); view.Desp.text = ca.CardEffectDesp; view.BackDesp.text = ca.CardBackDesp; if (ca.cost == -1) { view.Cost.text = "X"; view.BackCost.text = "1"; } else { view.Cost.text = ca.cost + ""; view.BackCost.text = ca.cost + ""; } if (ca.CatdImageName == null || ca.CatdImageName == string.Empty) { view.Picture.sprite = ca.Picture; view.BackPicture.sprite = ca.Picture; } else { view.Picture.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardImage/" + ca.CatdImageName); view.BackPicture.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardImage/" + ca.CatdImageName); } //调整card外壳 if (ca.CardType == eCardType.GENG) { view.PictureCover.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardCover/Geng"); view.BackPictureCover.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardCover/Geng"); view.Background.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardBackground/Geng"); view.BackBackground.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardBackground/Geng"); view.TypePicture.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardType/Geng"); view.BackTypePicture.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardType/Geng"); Color nowColor = Color.white; ColorUtility.TryParseHtmlString(CostColor[2], out nowColor); //color follow the type view.Cost.color = nowColor; view.BackCost.color = nowColor; } else if (ca.CardType == eCardType.ABILITY) { view.PictureCover.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardCover/Ability"); view.BackPictureCover.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardCover/Ability"); view.Background.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardBackground/Ability"); view.BackBackground.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardBackground/Ability"); view.TypePicture.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardType/Ability"); view.BackTypePicture.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardType/Ability"); Color nowColor = Color.white; ColorUtility.TryParseHtmlString(CostColor[1], out nowColor); //color follow the type view.Cost.color = nowColor; view.BackCost.color = nowColor; } else if (ca.CardType == eCardType.ITEM) { view.PictureCover.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardCover/Item"); view.BackPictureCover.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardCover/Item"); view.Background.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardBackground/Item"); view.BackBackground.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardBackground/Item"); view.TypePicture.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardType/Item"); view.BackTypePicture.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("CardType/Item"); Color nowColor = Color.white; ColorUtility.TryParseHtmlString(CostColor[0], out nowColor); //color follow the type view.Cost.color = nowColor; view.BackCost.color = nowColor; } foreach (Transform child in view.GemContainer) { container.mResLoader.ReleaseGO("Zhibo/CardGem", child.gameObject); } view.CardGemList.Clear(); for (int i = 0; i < cardInfo.OverrideGems.Length; i++) { if (cardInfo.OverrideGems[i] > 0) { GameObject go = container.mResLoader.Instantiate("Zhibo/CardGem", view.GemContainer); CardGemView vv = new CardGemView(); vv.BindView(go.transform); view.CardGemList.Add(vv); //vv.Icon.sprite = GameMain.GetInstance().GetModule<ResLoader>().LoadResource<Sprite>("Zhibo/Gems/" + i); vv.Icon.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("Zhibo/Gems_icon/" + "w_" + i); //icon skin vv.Num.text = cardInfo.OverrideGems[i] + ""; } } foreach (Transform child in view.GemBackContainer) { container.mResLoader.ReleaseGO("Zhibo/CardGemBack", child.gameObject); } view.CardGemBackList.Clear(); int types = 0; for (int i = 0; i < cardInfo.OverrideGems.Length; i++) { if (cardInfo.OverrideGems[i] > 0) { GameObject go = container.mResLoader.Instantiate("Zhibo/CardGemBack", view.GemBackContainer); CardGemBackView vv = new CardGemBackView(); vv.BindView(go.transform); view.CardGemBackList.Add(vv); //vv.Icon.sprite = GameMain.GetInstance().GetModule<ResLoader>().LoadResource<Sprite>("Zhibo/Gems/" + i); vv.Icon.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("Zhibo/Gems_icon/" + "w_" + i); //icon skin vv.Num.text = cardInfo.OverrideGems[i] + ""; types++; } } int offset = 0; if (types > 1) { offset = 100 / (types - 1); } for (int i = 0; i < view.CardGemBackList.Count; i++) { //view.CardGemBackList[i].Content.localPosition = new Vector3(i * offset, 0, 0); } foreach (Transform child in view.GemsIncludeContainer) { container.mResLoader.ReleaseGO("Zhibo/CardGemSingleIcon", child.gameObject); } view.CardGemSingleIconList.Clear(); for (int i = 0; i < cardInfo.OverrideGems.Length; i++) { if (cardInfo.OverrideGems[i] > 0) { GameObject go = container.mResLoader.Instantiate("Zhibo/CardGemSingleIcon", view.GemsIncludeContainer); CardGemSingleIconView vv = new CardGemSingleIconView(); vv.BindView(go.transform); view.CardGemSingleIconList.Add(vv); vv.Icon.sprite = GameMain.GetInstance().GetModule <ResLoader>().LoadResource <Sprite>("Zhibo/Gems_icon/" + "w_" + i); //icon skin types++; } } nowDegree = 20f; targetDegree = 20f; container.PutToInitPos(this); isBacking = false; isDragging = false; isDestroying = false; isHighlight = false; PosDirty = false; isInChain = false; view.CardCG.alpha = 1f; nowValue = 0; view.CardRoot.anchoredPosition = Vector2.zero; view.CardRoot.localScale = MinimizeScale; view.CardCG.blocksRaycasts = true; CancelHighLight(); transform.localEulerAngles = Vector3.zero; isFaceUp = false; IsFanmian = false; //TurnToFace(); Reset(); }
public bool AddNewTmpCard(CardInZhibo cardInfo) { return(view.CardContainer.AddTmpCard(cardInfo)); }
public CardChainNode(CardInZhibo TargetCard, float Delay = 0f) { this.TargetCard = TargetCard; this.Delay = Delay; }
private void HandleOneCardEffect(CardEffect ce, List <CardEffect> extraEffects) { if (IsNoEffect) { return; } if (ce.EMode == eCardEffectMode.SIMPLE) { int rate = (int)(ce.Possibility == 0?100: ce.Possibility * (1f + mBuffManager.ExtraChenggonglv)); if (rate < 100) { int rand = Random.Range(0, 100); if (rand >= rate) { return; } } if (ce.isAddBuff) { mBuffManager.GenBuff(ce.buffInfo); return; } string[] args = ce.effectString.Split(','); switch (ce.effectType) { case eEffectType.SpawnGift: GenSpecial(args[0], int.Parse(args[1])); break; case eEffectType.MaxCount: int maxCount = int.Parse(args[0]); if (state.CardUsedCount.ContainsKey(NowExecuteCard.CardId) && state.CardUsedCount[NowExecuteCard.CardId] >= maxCount) { IsNoEffect = true; break; } if (state.CardUsedCount.ContainsKey(NowExecuteCard.CardId)) { state.CardUsedCount[NowExecuteCard.CardId] += 1; } else { state.CardUsedCount[NowExecuteCard.CardId] = 1; } break; case eEffectType.SpeedUp: GenSpeedUp(float.Parse(args[0])); break; case eEffectType.GenGoodDanmu: AddDanmuGroup(args[0], int.Parse(args[1]), 0); break; case eEffectType.GenBadDanmu: Debug.Log("random gen"); AddDanmuGroup(args[0], int.Parse(args[1]), int.Parse(args[1])); break; case eEffectType.GenMixedDanmu: AddDanmuGroup(args[0], int.Parse(args[1]), int.Parse(args[2])); break; case eEffectType.PickAndUse: PickAndUse(); break; case eEffectType.GetScoreWithZengfu: { string[] newe = ce.effectString.Split(';'); float baseScore = GetScoreFromFormulation(newe[0]); string[] arg2 = newe[1].Split(','); int count = CountCardInDeck(arg2[0]); string perCardExtra = arg2[1]; float score = baseScore; if (perCardExtra[perCardExtra.Length - 1] == '%') { float perExtra = float.Parse(perCardExtra.Substring(0, perCardExtra.Length - 1)); score = score * (1 + count * perExtra * 0.01f); } else { float perExtra = float.Parse(perCardExtra); score = score + count * perExtra; } GainScore(score); mUICtrl.ShowNewAudience(); mUICtrl.ShowDanmuEffect(mUICtrl.GetCardContainer().cards[state.Cards.IndexOf(NowExecuteCard)].transform.position); } break; case eEffectType.GetScore: int add = 0; for (int i = 0; i < ValidBuffs.Count; i++) { if (ValidBuffs[i].bInfo.BuffType == eBuffType.Next_Card_Extra_Score) { add += ValidBuffs[i].bInfo.BuffLevel; } } GainScore(GetScoreFromFormulation(args[0]), add); mUICtrl.ShowNewAudience(); mUICtrl.ShowDanmuEffect(mUICtrl.GetCardContainer().GetCardPosition(NowExecuteCard)); break; case eEffectType.GetChouka: GetQifenValue(int.Parse(args[0])); break; case eEffectType.GetTili: GenTili(int.Parse(args[0])); break; case eEffectType.ClearDanmu: DestroyBadRandomly(int.Parse(args[0])); break; case eEffectType.AddCardToDeck: AddCardToDeck(args[0], int.Parse(args[1])); break; case eEffectType.CostAll: int x = state.Tili; if (x == 0) { break; } GenTili(-x); { //目前只支持调用一个函数的 string cmd = ce.effectString; string[] newArgs = cmd.Split(','); float rr = float.Parse(newArgs[1]); float v = rr * x; string newString = v.ToString("f2"); extraEffects.Add(new CardEffect(newArgs[0], newString)); } break; case eEffectType.Dual: AddCardsFromDeck((int)(float.Parse(args[0]))); break; case eEffectType.GetArmor: AddArmor(int.Parse(args[0])); break; case eEffectType.GainCardWithPossibility: GainNewCardWithPossiblity(args[0], int.Parse(args[1])); break; case eEffectType.DiscardCards: DiscardRandomCards(int.Parse(args[0])); break; case eEffectType.ExtraMoney: GetExtraMoney(int.Parse(args[0])); break; case eEffectType.ExtraLiuliang: GetExtraLiuliang(int.Parse(args[0])); break; case eEffectType.ScoreMultiple: ScorePercentChange(float.Parse(args[0])); break; case eEffectType.GetHot: //ScorePercentChange(float.Parse(args[0])); break; case eEffectType.GetCertainCard: AddCertainCardFromDeck(args[0]); break; case eEffectType.EndFollowingEffect: IsNoEffect = true; break; default: break; } } else if (ce.EMode == eCardEffectMode.BRANCHES) { int value; switch (ce.BranchType) { case "random": value = Random.Range(0, 100); for (int i = 0; i < ce.BranchEffectStrings.Count; i++) { if (value < ce.BranchEffectStrings[i].value) { extraEffects.Add(new CardEffect(ce.BranchEffectStrings[i].effect, ce.BranchEffectStrings[i].effectString)); break; } } break; case "NextCardCost": CardInZhibo newCard = AddCardFromDeck(); if (newCard == null) { break; } value = newCard.ca.cost; for (int i = 0; i < ce.BranchEffectStrings.Count; i++) { if (value < ce.BranchEffectStrings[i].value) { extraEffects.Add(new CardEffect(ce.BranchEffectStrings[i].effect, ce.BranchEffectStrings[i].effectString)); break; } } break; default: break; } } }