示例#1
0
    private IEnumerator EnemyTurn()
    {
        //draw card
        enemyHand.AddCardToHand();
        yield return(new WaitForSeconds(0.5f));

        if (turnManager.IsGameOver())
        {
            StopAllCoroutines();
        }
        //place card
        PlaceCardInfo placeCardInfo = enemyAI.GetCardPlaceInfo(enemyHand.GetCardList(), spots);

        if (placeCardInfo != null)
        {
            spots[placeCardInfo.spotIndex].GetComponent <FloorSpot>().SetCard(placeCardInfo.card);
            enemyHand.RemoveCardFromhand(placeCardInfo.card);
            yield return(new WaitForSeconds(0.5f));
        }
        yield return(EnemyTurnMoveOrders());
    }
示例#2
0
    public IEnumerator Turn7Event(GameObject materialSpot, GameObject pincherSpot)
    {
        //draw card
        Player player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();

        enemyHand.AddCardToHand();
        if (turnManager.IsGameOver())
        {
            StopAllCoroutines();
        }
        yield return(new WaitForSeconds(0.5f));

        //place Protest Cracker and kill Pincher
        enemyHand.RemoveCardFromhand(0);
        //put Protest Craker here
        materialSpot.GetComponent <FloorSpot>().SetCardWithData(protestCrack);
        yield return(new WaitForSeconds(1));

        dialogueManager.StartDialogue(pincherDyingDialogue);
        yield return(new WaitUntil(() => dialogueManager.HasFinish()));

        yield return(new WaitForSeconds(0.5f));

        //destroy pincher
        pincherSpot.GetComponent <FloorSpot>().SetCardWithData(battleManager.rockData);
        player.GetHurt(-2);
        yield return(new WaitForSeconds(1f));

        //decide move orders
        List <Lobster> lobsters = enemyAI.GetOrder(spots);

        //reset all enemies
        foreach (Lobster lob in lobsters)
        {
            if (lob.GetState() == LobsterState.Defence)
            {
                lob.ResetForNewTurn();
            }
        }
        //get and make movement for each lobster
        foreach (Lobster lob in lobsters)
        {
            EnemyMove move = enemyAI.GetTarget(lob, playerFloor);
            if (move == EnemyMove.Idle)           //do nothing
            {
                continue;
            }
            else if (move == EnemyMove.Defend)            //defend
            {
                lob.DefendButton();
                yield return(new WaitForSeconds(1));
            }
            else if (move == EnemyMove.AttackPlayer)             //attack player
            {
                player.GetHurt(lob.GetClaw());
                yield return(new WaitForSeconds(1));

                //if player died, stop coroutine here
                if (player.GetHealth() == 0)
                {
                    StopAllCoroutines();
                }
                //drop a stone
                yield return(battleManager.PlayerAddRock());

                yield return(new WaitForSeconds(0.5f));
            }
            else            //attack player's lobsters
            {
                int targetIndex = (int)move;
                //why it's so long, sorry Brian
                Lobster target             = playerFloor.GetComponent <Floor>().spots[targetIndex].GetComponent <FloorSpot>().GetCardInPlay().GetComponent <Lobster>();
                int     healthBeforeBattle = player.GetHealth();
                battleManager.Battle(lob, target);
                yield return(new WaitForSeconds(1));

                //if player died, stop coroutine here
                if (player.GetHealth() == 0)
                {
                    StopAllCoroutines();
                }
                //if there are damage overflow, wait for players to
                if (player.GetHealth() < healthBeforeBattle)
                {
                    yield return(battleManager.PlayerAddRock());

                    yield return(new WaitForSeconds(0.5f));
                }
            }
        }
        yield return(new WaitForSeconds(0.5f));

        //pincher died
        dialogueManager.StartDialogue(pincherDiedDialogue);
        yield return(new WaitUntil(() => dialogueManager.HasFinish()));

        playerHand.deck = newDeck;
        //end the turn
        turnManager.SwitchToPlayer();
    }