Beispiel #1
0
    int BattleCalculationPre(CardArea area1, CardArea area2)
    {
        int atk2 = 0;

        for (int i = 0; i < 9; i++)
        {
            int             atk        = 0;
            Card.HurtEffect hurteffect = Card.HurtEffect.Normal;
            BattleCube      cube       = area1.transform.GetChild(i).GetComponent <BattleCube>();
            if (cube != null && cube.transform.childCount > 0)
            {
                atk       += cube.transform.GetChild(0).GetComponent <Card>().m_CurrentATK;
                hurteffect = cube.transform.GetChild(0).GetComponent <Card>().m_HurtEffect;
                if (hurteffect == Card.HurtEffect.Backstab)
                {
                    for (int j = 8; j >= 0; j--)
                    {
                        BattleCube cube2 = area2.transform.GetChild(j).GetComponent <BattleCube>();
                        if (cube2 != null && cube2.m_Column == cube.m_Column && cube2.transform.childCount > 0)
                        {
                            atk = cube2.transform.GetChild(0).GetComponent <Card>().GetHurtPre(atk);
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < 9; j++)
                    {
                        BattleCube cube2 = area2.transform.GetChild(j).GetComponent <BattleCube>();
                        if (cube2 != null && cube2.m_Column == cube.m_Column && cube2.transform.childCount > 0)
                        {
                            if (hurteffect == Card.HurtEffect.Normal)
                            {
                                atk = cube2.transform.GetChild(0).GetComponent <Card>().GetHurtPre(atk);
                            }
                            //if (hurteffect == Card.HurtEffect.Puncture)
                            //{
                            //  atk = cube.transform.GetChild(0).GetComponent<Card>().GetHurtByPuncture(atk);
                            //}
                            if (hurteffect == Card.HurtEffect.Penetrate)
                            {
                                cube2.transform.GetChild(0).GetComponent <Card>().GetHurtPre(atk);
                            }
                        }
                    }
                    if (hurteffect == Card.HurtEffect.Penetrate)
                    {
                        atk = 0;
                    }
                }
                cube.transform.GetChild(0).GetComponent <Card>().GetHurtAPra(atk);
            }
            atk2 += atk;
        }
        return(atk2);
    }
Beispiel #2
0
    int BattleCalculation(CardArea atkarea, CardArea defarea, int row, int column, int currentcolumn, int currrentrow)
    {
        int atk = 0;

        Card.HurtEffect hurteffect = Card.HurtEffect.Normal;
        for (int i = 0; i < row * column; i++)
        {
            BattleCube cube = atkarea.transform.GetChild(i).GetComponent <BattleCube>();
            if (cube != null && cube.m_Column == currentcolumn && cube.m_Row == currrentrow && cube.transform.childCount > 0)
            {
                atk += cube.transform.GetChild(0).GetComponent <Card>().m_CurrentATK;
                if (cube.transform.GetChild(0).GetComponent <Card>().m_HurtEffect > hurteffect)
                {
                    hurteffect = cube.transform.GetChild(0).GetComponent <Card>().m_HurtEffect;
                }
            }
        }
        if (hurteffect == Card.HurtEffect.Backstab)
        {
            for (int i = row * column - 1; i >= 0; i--)
            {
                BattleCube cube = defarea.transform.GetChild(i).GetComponent <BattleCube>();
                if (cube != null && cube.m_Column == currentcolumn && cube.transform.childCount > 0)
                {
                    atk = cube.transform.GetChild(0).GetComponent <Card>().GetHurt(atk);
                }
            }
        }
        else
        {
            for (int i = 0; i < row * column; i++)
            {
                BattleCube cube = defarea.transform.GetChild(i).GetComponent <BattleCube>();
                if (cube != null && cube.m_Column == currentcolumn && cube.transform.childCount > 0)
                {
                    if (hurteffect == Card.HurtEffect.Normal)
                    {
                        atk = cube.transform.GetChild(0).GetComponent <Card>().GetHurt(atk);
                    }
                    if (hurteffect == Card.HurtEffect.Puncture)
                    {
                        atk = cube.transform.GetChild(0).GetComponent <Card>().GetHurtByPuncture(atk);
                    }
                    if (hurteffect == Card.HurtEffect.Penetrate)
                    {
                        cube.transform.GetChild(0).GetComponent <Card>().GetHurt(atk);
                    }
                }
            }
            if (hurteffect == Card.HurtEffect.Penetrate)
            {
                atk = 0;
            }
        }
        return(atk);
    }
Beispiel #3
0
    public void InitCard(bool isenemy, string name, string animname, int cost, int hp = 0, int atk = 0, Card.CardType cardtype = Card.CardType.Character, Card.HurtEffect hurteffect = Card.HurtEffect.Normal)
    {
        GameObject toInstantiate = (GameObject)Resources.Load("Prefabs/HandCard");
        Card       card          = Instantiate(toInstantiate, battlemanager.transform.Find("Recycle")).GetComponent <Card>();

        card.battleManager = battlemanager;
        card.m_IsEnemy     = isenemy;
        card.ChangeHPAndATKLine();
        card.m_CardName   = name;
        card.m_HurtEffect = hurteffect;
        card.ChangeHP(hp);
        card.ChangeATK(atk);
        card.m_Cost     = cost;
        card.m_CardType = cardtype;
        card.InitAnimation(animname);
        card.PrepareForBattle();
        this.m_AreaList.Add(card);
    }