Ejemplo n.º 1
0
 public void MoveCardToTomb(BattleCardMaid c)
 {
     RemoveCard(c);
     Tomb.Add(c);
     c.SetState(BattleMaid.CardState.Tomb);
     movingToTomb.Add(c);
 }
Ejemplo n.º 2
0
    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;
        }
        }
    }
Ejemplo n.º 3
0
    public BattleCardMaid GenerateCard(CardData data, RectTransform Container)
    {
        BattleCardMaid maid = Instantiate(BattleMaid.Summon.CardTemplate);

        maid.SetCard(data);
        maid.transform.SetParent(Container);
        return(maid);
    }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
 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);
     }
 }
Ejemplo n.º 6
0
 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();
 }
Ejemplo n.º 7
0
 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);
     }
 }
Ejemplo n.º 8
0
 public void SetDetailCard(BattleCardMaid maid)
 {
     if (maid == null)
     {
         if (selectedCard == null)
         {
             SetLeftPanelVisible(false);
             return;
         }
         maid = selectedCard;
     }
     CardDetail.SetCard(maid);
     SetCommand(maid);
     SetLeftPanelVisible(true);
 }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
    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);
        }
    }
Ejemplo n.º 11
0
 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();
     }
 }
Ejemplo n.º 12
0
 public void SetSelectedCard(BattleCardMaid maid)
 {
     selectedCard = maid;
     SetDetailCard(selectedCard);
 }
Ejemplo n.º 13
0
    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);
            }
        }
    }
Ejemplo n.º 14
0
 public bool IsCastPossible(Player p, BattleCardMaid c)
 {
     return(p.CurrentMana >= c.CostMana);
 }
Ejemplo n.º 15
0
 public bool IsAttackPossible(Player p, BattleCardMaid c)
 {
     return(!c.IsAttacked && !c.IsSleeping);
 }
Ejemplo n.º 16
0
    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("你的回合。");
    }