Exemplo n.º 1
0
    IEnumerator MonTurn()
    {
        int opmove;
        //bool died = false;

        List <Move.SubMove> potmoves = new List <Move.SubMove>();

        for (int i = 0; i < 3; i++)
        {
            if (opon.moves[i].curPP > 0)
            {
                potmoves.Add(opon.moves[i]);
            }
        }

        if (potmoves.Count > 0)
        {
            opmove = (int)UnityEngine.Random.Range((int)0, (int)potmoves.Count);

            atkturn.atk     = opon;
            atkturn.def     = you;
            atkturn.atkmove = potmoves[opmove];

            usingmove = true;
            StartCoroutine("UseMoveCo", atkturn);
            while (usingmove)
            {
                yield return(new WaitForEndOfFrame());
            }
            UpHealth();
        }
        else
        {
            TheQueue.AddQueue(instance.opon.Name + " can't use any moves!");
        }

        while (TheQueue.QCount() > 0)
        {
            yield return(new WaitForEndOfFrame());
        }

        if (instance.you.isDead() && instance.opon.isDead())
        {
            TheQueue.AddQueue("Both m0nst3rz have died!");
            player1.moninv.RemoveMonster(instance.you);
            you = new Monster.SubMonster();
            if (player1.moninv.HasAnActive())
            {
                TheQueue.goadventure = true;
            }
            else
            {
                TheQueue.gohome = true;
            }
            yield break;
        }
        else if (instance.you.isDead())
        {
            player1.moninv.RemoveMonster(instance.you);
            opon.GetKill();
            UpHealth();//check
            if (player1.moninv.HasAnActive())
            {
                //instance.deadoponturn = false;
                player1.moninv.RemoveMonster(you);
                you = new Monster.SubMonster();
                TheQueue.curdead = true;
                playerdied       = true;
                while (you.Name == "")
                {
                    yield return(new WaitForEndOfFrame());
                }
                //playerdied = false;
            }
            else
            {
                player1.moninv.RemoveMonster(you);
                you = new Monster.SubMonster();
                TheQueue.AddQueue("You're out of m0nst3rz!!!");
                TheQueue.gohome = true;
                yield break;
            }
        }

        while (TheQueue.QCount() > 0)
        {
            yield return(new WaitForEndOfFrame());
        }

        opon.StatLenUpdate();
        UpStats();
        while (TheQueue.QCount() > 0)
        {
            yield return(new WaitForEndOfFrame());
        }
        UpHealth();

        if (instance.opon.isDead())
        {
            you.GetKill();
            TheQueue.AddQueue("You killed the " + instance.opon.Name + "!!!");
            TheQueue.goadventure = true;
            //deadoponturn = false;
        }

        if (TheQueue.QCount() == 0)
        {
            monturn = false;
        }
    }
Exemplo n.º 2
0
    IEnumerator MonTurn(TurnType tt)
    {
        switch (tt)
        {
        case TurnType.none:
            break;

        case TurnType.attack:
            atkturn.atk     = p2mon;
            atkturn.def     = p1mon;
            atkturn.atkmove = turnmove2;
            usingmove       = true;
            StartCoroutine("UseMoveCo", atkturn);
            while (TheQueue.QCount() > 0)
            {
                yield return(new WaitForEndOfFrame());
            }
            UpHealth();
            break;

        case TurnType.change:
            p2mon     = changeto2;
            changeto2 = new Monster.SubMonster();
            UpHealth();
            TheQueue.AddQueue("P2 has changed m0nst3rz to " + p2mon.Name + "!");
            break;
        }

        while (TheQueue.QCount() > 0)
        {
            yield return(new WaitForEndOfFrame());
        }

        if (!p2mon.isDead())
        {
            p2mon.StatLenUpdate();
            while (TheQueue.QCount() > 0)
            {
                yield return(new WaitForEndOfFrame());
            }
            UpHealth();
        }

        if (p1mon.isDead() && p2mon.isDead())
        {
            TheQueue.AddQueue("Both m0nst3rz have died!");
            player1.moninv.RemoveMonster(p1mon);
            p1mon = new Monster.SubMonster();
            player2.moninv.RemoveMonster(p2mon);
            p2mon = new Monster.SubMonster();
            if (player1.moninv.HasAnActive() && player2.moninv.HasAnActive())
            {
                TheQueue.curdead = true;
                while (p1mon.Name == "" || p2mon.Name == "")
                {
                    yield return(new WaitForEndOfFrame());
                }
            }
            else if (!player1.moninv.HasAnActive() && !player2.moninv.HasAnActive())
            {
                TheQueue.AddQueue("It's a tie!!!");
            }
            else if (!player2.moninv.HasAnActive())
            {
                TheQueue.AddQueue("P1 out of m0nst3rz!");
                TheQueue.AddQueue("P2 wins!!!");
            }
            else if (!player1.moninv.HasAnActive())
            {
                TheQueue.AddQueue("P2 out of m0nst3rz!");
                TheQueue.AddQueue("P1 wins!!!");
            }
            yield break;
        }

        else if (p1mon.isDead())
        {
            player1.moninv.RemoveMonster(p1mon);
            if (player1.moninv.HasAnActive())
            {
                //player1.moninv.RemoveMonster(p1mon);
                p1mon            = new Monster.SubMonster();
                TheQueue.curdead = true;
                while (p1mon.Name == "")
                {
                    yield return(new WaitForEndOfFrame());
                }
            }
            else
            {
                //player1.moninv.RemoveMonster(p1mon);
                p1mon = new Monster.SubMonster();
                TheQueue.AddQueue("P1 is out of m0nst3rz!!!");
                TheQueue.AddQueue("P2 Wins!");
                //TheQueue.gohome = true; //DISCONNECT
                yield break;
            }
        }

        else if (p2mon.isDead())
        {
            player2.moninv.RemoveMonster(p2mon);
            if (player2.moninv.HasAnActive())
            {
                //player2.moninv.RemoveMonster(p2mon);
                p2mon            = new Monster.SubMonster();
                TheQueue.curdead = true;
                while (p2mon.Name == "")
                {
                    yield return(new WaitForEndOfFrame());
                }
            }
            else
            {
                //player1.moninv.RemoveMonster(p1mon);
                p2mon = new Monster.SubMonster();
                TheQueue.AddQueue("P2 is out of m0nst3rz!!!");
                TheQueue.AddQueue("P1 Wins!");
                //TheQueue.gohome = true; //DISCONNECT
                yield break;
            }
        }

        if (TheQueue.QCount() == 0)
        {
            turn2 = false;
        }
    }