public void MoveCardToTomb(BattleCardMaid c) { RemoveCard(c); Tomb.Add(c); c.SetState(BattleMaid.CardState.Tomb); movingToTomb.Add(c); }
public void OnSelectCard(BattleCardMaid maid) { switch (currentCmd) { case CommandMaid.State.None: { if (CurrentSelectedCard != maid) { SetSelectedCard(maid); } else { SetSelectedCard(null); } break; } case CommandMaid.State.Attacking: case CommandMaid.State.Casting: { if (maid.Targetable) { currentSelector.SelectTarget(maid); } break; } } }
public BattleCardMaid GenerateCard(CardData data, RectTransform Container) { BattleCardMaid maid = Instantiate(BattleMaid.Summon.CardTemplate); maid.SetCard(data); maid.transform.SetParent(Container); return(maid); }
public void SummonCard(BattleCardMaid maid) { CurrentMana -= maid.CostMana; Hand.Remove(maid); maid.SetState(BattleMaid.CardState.Field); Monsters.Add(maid); maid.transform.SetParent(MonsterGroup.transform); maid.OnSummon(); }
public void DrawCard(int count = 1) { for (int i = 0; i < count; i++) { BattleCardMaid maid = CardPool[currentCardIdx]; CardPool.Remove(maid); maid.SetState(BattleMaid.CardState.Hand); maid.transform.SetParent(HandGroup.transform); Hand.Add(maid); } }
public void SetCard(BattleCardMaid maid) { Data = maid.Data; mana = maid.mana; atk = maid.atk; hp = maid.hp; casting = maid.casting; state = maid.state; attacked = maid.attacked; Refresh(); }
public void RemoveCard(BattleCardMaid c) { if (c.State == BattleMaid.CardState.CardPool) { CardPool.Remove(c); } else if (c.State == BattleMaid.CardState.Field) { Monsters.Remove(c); } else if (c.State == BattleMaid.CardState.Hand) { Hand.Remove(c); } }
public void SetDetailCard(BattleCardMaid maid) { if (maid == null) { if (selectedCard == null) { SetLeftPanelVisible(false); return; } maid = selectedCard; } CardDetail.SetCard(maid); SetCommand(maid); SetLeftPanelVisible(true); }
public bool IsCommandPossible(BattleCardMaid maid, CommandMaid.State cmd) { if (cmd == CommandMaid.State.TurnEnd) { return(currentTurn == Turn.Self); } if (maid == null || cmd == CommandMaid.State.None) { return(false); } if (cmd == CommandMaid.State.Cancel) { return(true); } return(events.Count == 0 && currentTurn == maid.Owner.Side); }
public void SetCommand(BattleCardMaid maid) { int idx = 0; SelfPlayer.SetManaCostEstimate(0); if ((currentCmd & (CommandMaid.State.Attacking | CommandMaid.State.Casting | CommandMaid.State.Summoning)) != 0) { SetCommand(idx++, CommandMaid.State.Cancel, true); if (currentCmd == CommandMaid.State.Casting) { SelfPlayer.SetManaCostEstimate(maid.CostMana); } } else if (maid.Owner == SelfPlayer) { if (maid.Data.Type == CardType.Monster) { if (maid.State == CardState.Hand) { SetCommand(idx++, CommandMaid.State.Summon, IsSummonPossible(SelfPlayer, maid)); if (IsSummonPossible(SelfPlayer, maid)) { SelfPlayer.SetManaCostEstimate(maid.CostMana); } } else if (maid.State == CardState.Field) { SetCommand(idx++, CommandMaid.State.Attack, IsAttackPossible(SelfPlayer, maid)); } } else if (maid.Data.Type == CardType.Spell) { SetCommand(idx++, CommandMaid.State.Cast, IsCastPossible(SelfPlayer, maid)); if (IsCastPossible(SelfPlayer, maid)) { SelfPlayer.SetManaCostEstimate(maid.CostMana); } } } while (idx < MaxCommand) { commands[idx++].SetCommand(CommandMaid.State.None); } }
private void Update() { if (movingToTomb.Count > 0) { for (int i = movingToTomb.Count - 1; i >= 0; i--) { BattleCardMaid maid = movingToTomb[i]; if (!maid.IsAnimating) { maid.transform.SetParent(TombGroup.transform); movingToTomb.RemoveAt(i); if (BattleMaid.Summon.CurrentSelectedCard == maid) { BattleMaid.Summon.SetSelectedCard(null); } } } } if (Side == BattleMaid.Turn.Opponent && BattleMaid.Summon.CurrentTurn == BattleMaid.Turn.Opponent) { BattleMaid.Summon.EndTurn(); } }
public void SetSelectedCard(BattleCardMaid maid) { selectedCard = maid; SetDetailCard(selectedCard); }
public void CommandExecute(BattleCardMaid maid, CommandMaid.State cmd) { if (maid == null) { maid = CurrentSelectedCard; } if (!IsCommandPossible(maid, cmd)) { return; } switch (cmd) { case CommandMaid.State.TurnEnd: AddBattleEvent(new TurnEndBattleEvent()); break; case CommandMaid.State.Cancel: { if (currentCmd == CommandMaid.State.Attacking) { Helper.SetText("攻擊取消。"); } else if (currentCmd == CommandMaid.State.Casting) { Helper.SetText("施法取消。"); } ClearCurrentCommand(); ClearSetTargetable(); break; } case CommandMaid.State.Attack: currentCmd = CommandMaid.State.Attacking; AddBattleEvent(new AttackBattleEvent(maid)); Helper.SetText("請選擇攻擊目標:"); break; case CommandMaid.State.Cast: currentCmd = CommandMaid.State.Casting; SpellCardData s = maid.Data as SpellCardData; AddBattleEvent(new CastSpellBattleEvent(s.CastEffect, maid)); Helper.SetText("請選擇施法目標:"); break; case CommandMaid.State.Summon: maid.Owner.SummonCard(maid); MonsterCardData m = maid.Data as MonsterCardData; if (m.Warcry != null) { AddBattleEvent(new AbilityBattleEvent(m.Warcry, maid)); } break; } if (maid != null) { maid.Owner.UpdateState(); if (maid == CurrentSelectedCard) { SetCommand(maid); } } }
public bool IsCastPossible(Player p, BattleCardMaid c) { return(p.CurrentMana >= c.CostMana); }
public bool IsAttackPossible(Player p, BattleCardMaid c) { return(!c.IsAttacked && !c.IsSleeping); }
private void Init() { currentTurn = Turn.Self; ClearCurrentCommand(); selectedCard = null; BGMPlayer.clip = BGM; BGMPlayer.Play(); SelfPlayer.HandGroup.ClearChildren(); SelfPlayer.MonsterGroup.ClearChildren(); OpponentPlayer.HandGroup.ClearChildren(); OpponentPlayer.MonsterGroup.ClearChildren(); LeftCommandPanel.Clear(); SelfPlayer.Init(); SelfPlayer.Side = Turn.Self; SelfPlayer.CardPool.Clear(); for (int i = 0; i < 30; i++) { CardData card = CardPool.Cards[i % CardPool.Cards.Count].Value; BattleCardMaid maid = GenerateCard(card, SelfPlayer.CardPoolGroup.transform as RectTransform); maid.SetState(CardState.CardPool); maid.Owner = SelfPlayer; SelfPlayer.CardPool.Add(maid); } SelfPlayer.DrawCard(5); SelfPlayer.UpdateState(); OpponentPlayer.Init(); OpponentPlayer.Side = Turn.Opponent; OpponentPlayer.CardPool.Clear(); for (int i = 0; i < 30; i++) { CardData card = CardPool.Cards[i % CardPool.Cards.Count].Value; BattleCardMaid maid = GenerateCard(card, OpponentPlayer.CardPoolGroup.transform as RectTransform); maid.SetState(CardState.CardPool); maid.Owner = OpponentPlayer; OpponentPlayer.CardPool.Add(maid); } OpponentPlayer.DrawCard(9); int c = 0; for (int i = 8; i >= 0 && c < 5; i--) { if (OpponentPlayer.Hand[i].Data.Type == CardType.Monster) { OpponentPlayer.SummonCard(OpponentPlayer.Hand[i]); ++c; } } OpponentPlayer.CurrentMana = 1; OpponentPlayer.UpdateState(); for (int i = 0; i < MaxCommand; i++) { commands[i] = Instantiate(CommandTemplate); commands[i].transform.SetParent(LeftCommandPanel); commands[i].SetVisible(false); } TurnEndCommand.SetCommand(CommandMaid.State.TurnEnd, true); Helper.SetText("你的回合。"); }