예제 #1
0
    private IEnumerator MoveBattleUnitsToMiddle()
    {
        List <Card> opponentUnit = Opponent.cardGroupSelectedForBattle.cards;

        Vector2[] positionsForOpponentUnits = CardLayoutHelper.GetCardLayout(
            new Vector2(0f, 1f),
            opponentUnit.Count,
            opponentUnit.First().CardWidth,
            0.1f
            );

        List <Card> playerUnit = Player.cardGroupSelectedForBattle.cards;

        Vector2[] positionsForPlayerUnits = CardLayoutHelper.GetCardLayout(
            new Vector2(0f, -1f),
            playerUnit.Count,
            playerUnit.First().CardWidth,
            0.1f
            );

        Opponent.cardGroupSelectedForBattle.Select(false);
        Player.cardGroupSelectedForBattle.Select(false);

        for (int i = 0; i < opponentUnit.Count; i++)
        {
            Vector2 startPos = opponentUnit[i].transform.localPosition;
            Vector2 endPos   = positionsForOpponentUnits[i];
            StartCoroutine(opponentUnit[i].MoveFromTo(startPos, endPos, 0.3f));
        }
        for (int i = 0; i < playerUnit.Count; i++)
        {
            Vector2 startPos = playerUnit[i].transform.localPosition;
            Vector2 endPos   = positionsForPlayerUnits[i];
            StartCoroutine(playerUnit[i].MoveFromTo(startPos, endPos, 0.3f));
        }

        yield return(new WaitForSeconds(0.5f));

        foreach (Card card in opponentUnit)
        {
            StartCoroutine(card.FlipCard(0.3f));
        }
        foreach (Card card in playerUnit)
        {
            StartCoroutine(card.FlipCard(0.3f));
        }

        StartCoroutine(ResolveBattle(opponentUnit, playerUnit, false));
    }
예제 #2
0
 public Vector2[] GetCardLayout(int numCards, float cardWidth, float padding)
 {
     return(CardLayoutHelper.GetCardLayout(Center, numCards, cardWidth, padding));
 }