コード例 #1
0
        public void SetStatus(Status newstat, int len)
        {
            if (thequirk.quirk == QuirkType.statimmune && thequirk.givestatus == newstat)
            {
                //add switch for every status
                TheQueue.AddQueue(Name + " is immune to this status effect!");//,false);
                return;
            }

            if (status.Contains(newstat))
            {
                TheQueue.AddQueue(Name + " is already " + PrintStatus(newstat) + "!");
                return;
            }

            int randomboy;


            status.Add(newstat);

            switch (newstat)
            {
            case Status.annoyed:
                annoyed = len;
                TheQueue.AddQueue(Name + " is now annoyed!");    //,false);
                break;

            case Status.burn:
                burn = len;
                TheQueue.AddQueue(Name + " is now burned!");    //,false);
                break;

            case Status.cold:
                cold = len;
                TheQueue.AddQueue(Name + " is now cold!");    //,false);
                break;

            case Status.doubled:
                doubled = len;
                TheQueue.AddQueue(Name + " is now POWERED UP!");    //,false);
                break;

            case Status.frozen:
                frozen = len;
                TheQueue.AddQueue(Name + " is now frozen!");    //,false);
                break;

            case Status.halved:
                halved = len;
                TheQueue.AddQueue(Name + " is now dumbed down!");    //,false);
                break;

            case Status.high:
                high = len;
                TheQueue.AddQueue(Name + " is now high!");    //,false);
                break;

            case Status.paralyze:
                paralyze = len;
                TheQueue.AddQueue(Name + " is now paralyzed!");    //,false);
                break;

            case Status.poison:
                poison = len;
                TheQueue.AddQueue(Name + " is now poisoned!");    //,false);
                break;

            case Status.none:
                ClearStatus();
                TheQueue.AddQueue(Name + "'s status returned to normal!");    //,false);
                ClearStatus();
                break;

            case Status.random:
                randomboy = (int)UnityEngine.Random.Range((int)0, (int)11);
                if (randomboy == 0)
                {
                    SetStatus(Status.annoyed, len);
                }
                else if (randomboy == 1)
                {
                    SetStatus(Status.burn, len);
                }
                else if (randomboy == 2)
                {
                    SetStatus(Status.cold, len);
                }
                else if (randomboy == 3)
                {
                    SetStatus(Status.doubled, len);
                }
                else if (randomboy == 4)
                {
                    SetStatus(Status.frozen, len);
                }
                else if (randomboy == 5)
                {
                    SetStatus(Status.halved, len);
                }
                else if (randomboy == 6)
                {
                    SetStatus(Status.high, len);
                }
                else if (randomboy == 7)
                {
                    SetStatus(Status.paralyze, len);
                }
                else if (randomboy == 8)
                {
                    SetStatus(Status.poison, len);
                }
                else if (randomboy == 9)
                {
                    SetStatus(Status.evading, len);
                }
                else if (randomboy == 10)
                {
                    SetStatus(Status.asleep, len);
                }
                else
                {
                    SetStatus(Status.evading, len);      //to prevent setting status as "random" or "none"
                }
                break;

            case Status.evading:
                evading = len;
                TheQueue.AddQueue(Name + " is now evading!");    //,false);
                break;

            case Status.mixedup:
                mixedup = len;
                TheQueue.AddQueue(Name + " is now mIxEd uP!");    //,false);
                break;

            case Status.asleep:
                asleep = len;
                TheQueue.AddQueue(Name + " is now asleep!");    //,false);
                break;
            }
        }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        buttons.SetActive(BattleMain3.TurnGet());

        if (Input.GetKeyDown(KeyCode.Space))
        {
            UpMenu.SetMenu(UpMenu.curMenu.item);
        }


        if (BattleMain3.TurnGet() || UpMenu.upnow != UpMenu.curMenu.none)
        {
            if (Input.touchCount == 1 && onehit)
            {
                // touch on screen
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    Ray        ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                    RaycastHit hit = new RaycastHit();
                    moving = Physics.Raycast(ray, out hit);
                    if (moving)
                    {
                        go = hit.transform.gameObject;
                    }
                    else
                    {
                        onehit = false;
                    }
                }


                // release touch/dragging
                if ((Input.GetTouch(0).phase == TouchPhase.Ended || Input.GetTouch(0).phase == TouchPhase.Canceled || Input.touchCount != 1) && go != null && onehit)
                {
                    Ray        ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                    RaycastHit hit = new RaycastHit();
                    moving = Physics.Raycast(ray, out hit);
                    if (moving)
                    {
                        go2 = hit.transform.gameObject;
                    }
                    moving = false;
                    //Debug.Log("Touch Released from : " + go.name);
                    if (go == atk && go == go2)
                    {
                        //atk menu appears
                        UpMenu.SetMenu(UpMenu.curMenu.atk);
                    }
                    else if (go == chng && go == go2)
                    {
                        //active player1.moninvmenu appears
                        UpMenu.SetMenu(UpMenu.curMenu.mon);
                    }
                    else if (go == itm && go == go2)
                    {
                        //iteminvmenu appears
                        UpMenu.SetMenu(UpMenu.curMenu.item);
                    }
                    else if (go == esc && go == go2)
                    {
                        //50/50 shot at escaping
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        //StartCoroutine("CoDoTurn", TurnType.esc);
                        BattleMain3.InitTurn(BattleMain3.TurnType.esc);
                    }

                    if (go == movebuttons[0] && go2 == go)
                    {
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        BattleMain3.SetMove(BattleMain3.GetYou().moves[0]);
                        BattleMain3.InitTurn(BattleMain3.TurnType.attack);
                    }
                    else if (go == movebuttons[1] && go2 == go)
                    {
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        BattleMain3.SetMove(BattleMain3.GetYou().moves[1]);
                        BattleMain3.InitTurn(BattleMain3.TurnType.attack);
                    }
                    else if (go == movebuttons[2] && go2 == go)
                    {
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        BattleMain3.SetMove(BattleMain3.GetYou().moves[2]);
                        BattleMain3.InitTurn(BattleMain3.TurnType.attack);
                    }

                    if (go == monbuttons[0] && go2 == go)
                    {
                        BattleMain3.SetNewMon(monbuttons[0].GetComponent <InvSlot>().curMonster);
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        if (!TheQueue.deadselect)
                        {
                            BattleMain3.InitTurn(BattleMain3.TurnType.change);
                        }
                        else
                        {
                            BattleMain3.SetYou(monbuttons[0].GetComponent <InvSlot>().curMonster);
                            BattleMain3.SetNewMon(new Monster.SubMonster());
                            BattleMain3.UpHealth();
                            TheQueue.AddQueue("You've changed to " + BattleMain3.GetYou().Name + "!");
                            TheQueue.deadselect = false;
                            TheQueue.curdead    = false;
                        }
                    }
                    else if (go == monbuttons[1] && go2 == go)
                    {
                        BattleMain3.SetNewMon(monbuttons[1].GetComponent <InvSlot>().curMonster);
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        if (!TheQueue.deadselect)
                        {
                            BattleMain3.InitTurn(BattleMain3.TurnType.change);
                        }
                        else
                        {
                            BattleMain3.SetYou(monbuttons[1].GetComponent <InvSlot>().curMonster);
                            BattleMain3.SetNewMon(new Monster.SubMonster());
                            BattleMain3.UpHealth();
                            TheQueue.AddQueue("You've changed to " + BattleMain3.GetYou().Name + "!");
                            TheQueue.deadselect = false;
                            TheQueue.curdead    = false;
                        }
                    }
                    else if (go == monbuttons[2] && go2 == go)
                    {
                        BattleMain3.SetNewMon(monbuttons[2].GetComponent <InvSlot>().curMonster);
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        if (!TheQueue.deadselect)
                        {
                            BattleMain3.InitTurn(BattleMain3.TurnType.change);
                        }
                        else
                        {
                            BattleMain3.SetYou(monbuttons[2].GetComponent <InvSlot>().curMonster);
                            BattleMain3.SetNewMon(new Monster.SubMonster());
                            BattleMain3.UpHealth();
                            TheQueue.AddQueue("You've changed to " + BattleMain3.GetYou().Name + "!");
                            TheQueue.deadselect = false;
                            TheQueue.curdead    = false;
                        }
                    }


                    if (go == itembuttons[0] && go2 == go)
                    {
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        BattleMain3.SetItem(itembuttons[0].GetComponent <InvSlot>().curItem);
                        BattleMain3.Player1().iteminv.RemoveFromStack(itembuttons[0].GetComponent <InvSlot>().curItem);
                        BattleMain3.InitTurn(BattleMain3.TurnType.item);
                    }
                    else if (go == itembuttons[1] && go2 == go)
                    {
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        BattleMain3.SetItem(itembuttons[1].GetComponent <InvSlot>().curItem);
                        BattleMain3.Player1().iteminv.RemoveFromStack(itembuttons[1].GetComponent <InvSlot>().curItem);
                        BattleMain3.InitTurn(BattleMain3.TurnType.item);
                    }
                    else if (go == itembuttons[2] && go2 == go)
                    {
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        BattleMain3.SetItem(itembuttons[2].GetComponent <InvSlot>().curItem);
                        BattleMain3.Player1().iteminv.RemoveFromStack(itembuttons[2].GetComponent <InvSlot>().curItem);
                        BattleMain3.InitTurn(BattleMain3.TurnType.item);
                    }
                    else if (go == itembuttons[3] && go2 == go)
                    {
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        BattleMain3.SetItem(itembuttons[3].GetComponent <InvSlot>().curItem);
                        BattleMain3.Player1().iteminv.RemoveFromStack(itembuttons[3].GetComponent <InvSlot>().curItem);
                        BattleMain3.InitTurn(BattleMain3.TurnType.item);
                    }
                }
            }
            else
            {
                go     = null;
                go2    = null;
                onehit = true;
            }
        }
        else
        {
            go     = null;
            go2    = null;
            onehit = true;
        }
    }
コード例 #3
0
        public void StatLenUpdate()
        {
            //add the switch from SetStatus to actually do the effects
            if (status.Count == 0)
            {
                return;
            }
            if (isDead())
            {
                ClearStatus();
                return;
            }

            if (status.Contains(Status.annoyed) && annoyed > 0)
            {
                annoyed--;
                if (annoyed == 0)
                {
                    status.Remove(Status.annoyed);
                    TheQueue.AddQueue(Name + " is no longer annoyed!");
                }
            }
            if (status.Contains(Status.burn) && burn > 0)
            {
                burn--;
                TheQueue.AddQueue(Name + "'s burn caused 2 damage!");//,true);
                Damage(2);
                if (burn == 0)
                {
                    status.Remove(Status.burn);
                    TheQueue.AddQueue(Name + " is no longer burned!");
                }
            }
            if (status.Contains(Status.cold) && cold > 0)
            {
                cold--;
                if (cold == 0)
                {
                    status.Remove(Status.cold);
                    TheQueue.AddQueue(Name + " is no longer cold!");
                }
            }
            if (status.Contains(Status.doubled) && doubled > 0)
            {
                doubled--;
                if (doubled == 0)
                {
                    status.Remove(Status.doubled);
                    TheQueue.AddQueue(Name + " is no longer POWERED UP!");
                }
            }
            if (status.Contains(Status.frozen) && frozen > 0)
            {
                frozen--;
                if (frozen == 0)
                {
                    status.Remove(Status.frozen);
                    TheQueue.AddQueue(Name + " is no longer frozen!");
                }
            }
            if (status.Contains(Status.halved) && halved > 0)
            {
                halved--;
                if (halved == 0)
                {
                    status.Remove(Status.halved);
                    TheQueue.AddQueue(Name + " is no longer dumbed down!");
                }
            }
            if (status.Contains(Status.high) && high > 0)
            {
                high--;
                if (high == 0)
                {
                    status.Remove(Status.high);
                    TheQueue.AddQueue(Name + " is no longer high!");
                }
            }
            if (status.Contains(Status.paralyze) && paralyze > 0)
            {
                paralyze--;
                if (paralyze == 0)
                {
                    status.Remove(Status.paralyze);
                    TheQueue.AddQueue(Name + " is no longer paralyzed!");
                }
            }
            if (status.Contains(Status.poison) && poison > 0)
            {
                poison--;
                TheQueue.AddQueue(Name + "'s poison caused " + Math.Round(CurHealth() / 10, 2) + " damage!");
                Damage(Math.Round(CurHealth() / 10, 2));
                if (poison == 0)
                {
                    status.Remove(Status.poison);
                    TheQueue.AddQueue(Name + " is no longer poisoned!");
                }
            }
            if (status.Contains(Status.evading) && evading > 0)
            {
                evading--;
                if (evading == 0)
                {
                    status.Remove(Status.evading);
                    TheQueue.AddQueue(Name + " is no longer evading!");
                }
            }
            if (status.Contains(Status.mixedup) && mixedup > 0)
            {
                mixedup--;
                if (mixedup == 0)
                {
                    status.Remove(Status.mixedup);
                    TheQueue.AddQueue(Name + " is no longer mIxEd uP!");
                }
            }
            if (status.Contains(Status.asleep) && asleep > 0)
            {
                asleep--;
                if (asleep == 0)
                {
                    status.Remove(Status.asleep);
                    TheQueue.AddQueue(Name + " is no longer asleep!");
                }
            }


            if (isDead())
            {
                ClearStatus();
                TheQueue.AddQueue(Name + " died from its status effect!");
                return;
            }
        }
コード例 #4
0
    IEnumerator UseMoveCo(AtkTurn theturn)
    {
        double dam         = 0;
        double origdam     = 0;
        int    paracheck   = 100;
        int    numhits     = 0;
        bool   multihit    = false;
        bool   mixedupfail = false;

        Monster.SubMonster atk     = theturn.atk;
        Monster.SubMonster def     = theturn.def;
        Move.SubMove       themove = theturn.atkmove;

        int  typecheck  = Types.CheckWeakness(themove.type, def.Type);
        bool statimmune = false;
        bool dodamage   = themove.dodamage;
        bool movefailed = false;

        if (themove.self)
        {
            statimmune = true;
        }
        if (themove.status == Monster.Status.none)
        {
            statimmune = true;
        }

        TheQueue.AddQueue(atk.Name + " used " + themove.Name + "!");

        //separate
        if (atk.status.Contains(Monster.Status.paralyze) || atk.status.Contains(Monster.Status.frozen))
        {
            paracheck = (int)UnityEngine.Random.Range((int)0, (int)3);
            if (paracheck != 0)
            {
                TheQueue.AddQueue(atk.Name + "'s status prevented it from moving!");
                usingmove = false;
                yield break;
            }
        }

        else if (atk.status.Contains(Monster.Status.asleep))
        {
            if ((int)UnityEngine.Random.Range((int)0, (int)5) == 0)
            {
                TheQueue.AddQueue(atk.Name + " is still sleeping!");
                TheQueue.AddQueue(atk.Name + " just woke up");
                atk.SetStatus(Monster.Status.none, 1);
                while (TheQueue.QCount() > 0)
                {
                    yield return(new WaitForEndOfFrame());
                }
                UpStats();
            }
            else
            {
                TheQueue.AddQueue(atk.Name + " is still sleeping!");
                usingmove = false;
                yield break;
            }
        }

        themove.Use();

        if (def.status.Contains(Monster.Status.evading))
        {
            if ((themove.dodamage || (!themove.self && themove.status != Monster.Status.none)))
            {
                if ((int)UnityEngine.Random.Range((int)0, (int)4) > 0)
                {
                    TheQueue.AddQueue(def.Name + " evaded the move!");
                    if (themove.hurtself)
                    {
                        TheQueue.AddQueue(atk.Name + " hurt itself!");
                        while (TheQueue.QCount() > 0)
                        {
                            yield return(new WaitForEndOfFrame());
                        }
                        TheQueue.AddQueue("It caused " + themove.hurtselfdam + " damage!");
                        UpHealth();
                        atk.Damage(themove.hurtselfdam);
                        if (atk.isDead())
                        {
                            TheQueue.AddQueue(atk.Name + " died!!!");
                        }
                    }
                    usingmove = false;
                    yield break;
                }
            }
        }

        dam  = themove.GiveDam();
        dam *= (1 + (atk.ATK / 200));
        dam  = System.Math.Round(dam, 2);
        //maybe move this switch statement within themove.hit()
        if (themove.dodamage || !statimmune)
        {
            switch (def.thequirk.quirk)
            {
            case Monster.QuirkType.none:
                break;

            case Monster.QuirkType.bouncer:
                if (themove.mt == def.thequirk.afmt && themove.dodamage)
                {
                    TheQueue.AddQueue(def.Name + "'s " + def.thequirk.Name + " caused the move to bounce back!");    //,false);

                    atk.Damage(dam / 2);
                    while (TheQueue.QCount() > 0)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                    UpHealth();
                    dodamage   = false;
                    movefailed = true;
                    while (TheQueue.QCount() > 0)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                    UpHealth();
                    TheQueue.AddQueue("It caused " + dam / 2 + " damage!");    //,true);
                    if (!themove.hurtself)
                    {
                        usingmove = false;
                        yield break;
                    }
                }
                break;

            case Monster.QuirkType.dodger:
                if (themove.mt == def.thequirk.afmt && themove.dodamage)
                {
                    if ((int)UnityEngine.Random.Range(0, 2) == 0)
                    {
                        break;
                    }
                    else
                    {
                        dodamage   = false;
                        movefailed = true;
                        TheQueue.AddQueue(def.Name + "'s " + def.thequirk.Name + " caused them to dodge!");    //,false);
                        if (!themove.hurtself)
                        {
                            usingmove = false;
                            yield break;
                        }
                    }
                }
                break;

            case Monster.QuirkType.givestatus:
                if (themove.mt == def.thequirk.afmt && themove.dodamage && !atk.status.Contains(def.thequirk.givestatus))
                {
                    if (atk.thequirk.quirk == Monster.QuirkType.statimmune)
                    {
                        if (atk.thequirk.givestatus == def.thequirk.givestatus)
                        {
                            break;
                        }
                        else
                        {
                            TheQueue.AddQueue("The move caused a status rebound!");
                            atk.SetStatus(def.thequirk.givestatus, def.thequirk.statlen);
                            while (TheQueue.QCount() > 0)
                            {
                                yield return(new WaitForEndOfFrame());
                            }
                            UpStats();
                        }
                    }
                    else
                    {
                        TheQueue.AddQueue("The move caused a status rebound!");
                        atk.SetStatus(def.thequirk.givestatus, def.thequirk.statlen);
                        //unless the attacker is immune to this status effect
                    }
                }

                break;

            case Monster.QuirkType.healer:
                if (def.thequirk.aftype == themove.type && themove.dodamage)
                {
                    dodamage   = false;
                    movefailed = true;
                    TheQueue.AddQueue("The moved caused " + def.Name + " to heal!");
                    def.Heal(def.thequirk.healhurt);
                    while (TheQueue.QCount() > 0)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                    UpHealth();
                    if (!themove.hurtself)
                    {
                        usingmove = false;
                        yield break;
                    }
                }
                break;

            case Monster.QuirkType.healerMT:
                if (def.thequirk.afmt == themove.mt && themove.dodamage)
                {
                    movefailed = true;
                    dodamage   = false;
                    //add quirk name
                    TheQueue.AddQueue("The moved caused " + def.Name + " to heal!");
                    def.Heal(def.thequirk.healhurt);
                    while (TheQueue.QCount() > 0)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                    UpHealth();
                    if (!themove.hurtself)
                    {
                        usingmove = false;
                        yield break;
                    }
                }
                break;

            case Monster.QuirkType.hurter:
                if (def.thequirk.afmt == themove.mt && themove.dodamage)
                {
                    //add quirk name
                    TheQueue.AddQueue("The moved caused " + atk.Name + " to take " + def.thequirk.healhurt + " damage!");
                    atk.Damage(def.thequirk.healhurt);
                    while (TheQueue.QCount() > 0)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                    UpHealth();
                    //if (atkr.isDead()) return;
                }
                break;

            case Monster.QuirkType.hurterT:
                if (def.thequirk.aftype == themove.type && themove.dodamage)
                {
                    //add quirk name
                    TheQueue.AddQueue("The moved caused " + atk.Name + " to take damage!");
                    atk.Damage(def.thequirk.healhurt);
                    while (TheQueue.QCount() > 0)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                    UpHealth();
                    //if (atkr.isDead()) return;
                }
                break;

            case Monster.QuirkType.mtimmune:
                if (themove.mt == def.thequirk.afmt && themove.dodamage)
                {
                    movefailed = true;
                    //add quirk name
                    dodamage = false;
                    TheQueue.AddQueue(def.Name + " is immune to this type of move!");
                    if (!themove.hurtself)
                    {
                        usingmove = false;
                        yield break;
                    }
                }
                break;

            case Monster.QuirkType.statimmune:
                if (themove.status == def.thequirk.givestatus && !themove.self)
                {
                    //add quirk name
                    statimmune = true;
                    TheQueue.AddQueue(def.Name + " is immune to " + themove.Name + "'s status effect!");
                }
                break;

            case Monster.QuirkType.typeimmune:
                if (themove.type == def.thequirk.aftype && themove.dodamage)
                {
                    //add quirk name
                    dodamage   = false;
                    movefailed = true;
                    TheQueue.AddQueue(def.Name + " is immune to this type!");
                    if (!themove.hurtself)
                    {
                        usingmove = false;
                        yield break;
                    }
                }
                break;
            }
        }


        if (themove.Hit())
        {
            if (dodamage)
            {
                dam  = themove.GiveDam();
                dam *= (1 + (atk.ATK / 200));
                //dam = System.Math.Round(dam, 2);
                if (atk.status.Contains(Monster.Status.doubled))
                {
                    dam *= 2;
                    TheQueue.AddQueue(atk.Name + "'s status caused double damage!");
                }
                if (atk.status.Contains(Monster.Status.halved))
                {
                    dam *= .5;
                    TheQueue.AddQueue(atk.Name + "'s status caused half damage!");
                }
                if (atk.status.Contains(Monster.Status.high))
                {
                    dam *= .7;
                    TheQueue.AddQueue(atk.Name + "'s status caused reduced damage!");
                }
                if (atk.status.Contains(Monster.Status.mixedup))
                {
                    if ((int)UnityEngine.Random.Range((int)0, (int)2) == 0)
                    {
                        TheQueue.AddQueue(atk.Name + " hurt itself instead!");
                        dam = System.Math.Round(dam, 2);
                        atk.Damage(dam / 2);
                        while (TheQueue.QCount() > 0)
                        {
                            yield return(new WaitForEndOfFrame());
                        }
                        UpHealth();
                        TheQueue.AddQueue("It did " + dam / 2 + " damage!");
                        mixedupfail = true;
                        dodamage    = false;
                        statimmune  = true;
                    }
                }

                if (def.status.Contains(Monster.Status.annoyed) && !mixedupfail)
                {
                    //print("poopoo");
                    dam *= 1.4;
                    TheQueue.AddQueue(def.Name + "'s status caused increased damage!");
                }
                if (def.status.Contains(Monster.Status.cold) && !mixedupfail)
                {
                    dam *= 1.4;
                    TheQueue.AddQueue(def.Name + "'s status caused increased damage!");
                }

                if (dodamage)
                {
                    if (typecheck == 2)
                    {
                        TheQueue.AddQueue("MEGA WEAKNESS! INSTAKILL!");
                        dam *= 3000;
                    }
                    else if (typecheck == 1)
                    {
                        TheQueue.AddQueue("Super effective!");
                        dam *= 2;

                        /*if (themove.Crit())
                         * {
                         *  dam *= 2;
                         *  TheQueue.AddQueue("Critical hit!");
                         * }*/
                        //def.Damage(dam);
                        //TheQueue.AddQueue("It did " + dam + " damage!");
                    }
                    else if (typecheck == 0)
                    {
                        /*if (themove.Crit())
                         * {
                         *  dam *= 1.5;
                         *  TheQueue.AddQueue("Critical hit!");
                         * }*/
                        //Damage(dam);
                        //TheQueue.AddQueue("It did " + dam + " damage!");
                    }
                    else if (typecheck == -1)
                    {
                        TheQueue.AddQueue("Not very effective");
                        dam /= 1.5;
                        //Damage(dam);
                        //TheQueue.AddQueue("It did " + dam + " damage!");
                    }
                    else if (typecheck == -2)
                    {
                        movefailed  = true;
                        statimmune  = true;
                        dodamage    = false;
                        mixedupfail = true;
                        TheQueue.AddQueue("The move had no effect!");
                    }
                    else if (typecheck == -3)
                    {
                        movefailed  = true;
                        dodamage    = false;
                        mixedupfail = true;
                        TheQueue.AddQueue("The move caused " + dam + " points of healing!");
                        def.Heal(dam);
                        statimmune = true;
                    }

                    if (!mixedupfail)
                    {
                        dam     = Math.Round(dam, 2);
                        origdam = dam;

                        if (themove.multihit && UnityEngine.Random.Range(0, 100f) < themove.MHP)
                        {
                            multihit = true;
                            TheQueue.AddQueue("Multi hit move!");
                        }

                        if (!multihit)
                        {
                            if (themove.Crit())
                            {
                                dam *= 1.5;
                                TheQueue.AddQueue("Critical hit!");
                            }
                            TheQueue.AddQueue("It did " + dam + " damage!");
                            def.Damage(dam);
                            while (TheQueue.QCount() > 0)
                            {
                                yield return(new WaitForEndOfFrame());
                            }
                            UnityEngine.Random.InitState((int)System.DateTime.Now.Ticks);

                            UpHealth();
                        }
                        else if (multihit)
                        {
                            if (themove.Crit())
                            {
                                dam *= 1.5;
                                TheQueue.AddQueue("Critical hit!");
                            }
                            TheQueue.AddQueue("First hit did " + dam + " damage!");
                            def.Damage(dam);
                            while (TheQueue.QCount() > 0)
                            {
                                yield return(new WaitForEndOfFrame());
                            }
                            UnityEngine.Random.InitState((int)System.DateTime.Now.Ticks);
                            UpHealth();

                            numhits = 2;
                            dam     = origdam * (double)UnityEngine.Random.Range(.9f, 1.1f);
                            dam     = Math.Round(dam, 2);
                            if (themove.Crit())
                            {
                                dam *= 1.5;
                                TheQueue.AddQueue("Critical hit!");
                            }
                            TheQueue.AddQueue("Second hit did " + dam + " damage!");
                            def.Damage(dam);
                            while (TheQueue.QCount() > 0)
                            {
                                yield return(new WaitForEndOfFrame());
                            }
                            UpHealth();
                            if (themove.maxhits > 2)
                            {
                                for (int i = 3; i <= themove.maxhits; i++)
                                {
                                    if (UnityEngine.Random.Range(0, 100f) < themove.MHP)
                                    {
                                        dam = origdam * (double)UnityEngine.Random.Range(.8f, 1.2f);
                                        dam = Math.Round(dam, 2);
                                        if (themove.Crit())
                                        {
                                            dam *= 1.5;
                                            TheQueue.AddQueue("Critical hit!");
                                        }
                                        def.Damage(dam);
                                        while (TheQueue.QCount() > 0)
                                        {
                                            yield return(new WaitForEndOfFrame());
                                        }
                                        UpHealth();
                                        UnityEngine.Random.InitState((int)System.DateTime.Now.Ticks);
                                        numhits = i;
                                        TheQueue.AddQueue("Hit " + i + " did " + dam + " damage!");
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }
                            TheQueue.AddQueue(numhits + " hits!");
                        }
                    }
                }
            }



            if (!def.isDead() && !statimmune && themove.status != Monster.Status.none)
            {
                def.SetStatus(themove.status, themove.statlen);
            }
            //else if (!def.isDead() && !statimmune && themove.status != Monster.Status.none && def.status != Monster.Status.none && themove.statoverride)
            //def.SetStatus(themove.status, themove.statlen);
            else if (!def.isDead() && themove.status != Monster.Status.none && !themove.self && statimmune)
            {
                TheQueue.AddQueue(themove.Name + "'s status effect failed!");
            }

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

            if (themove.hurtself)
            {
                TheQueue.AddQueue(atk.Name + " hurt itself!");
                TheQueue.AddQueue("It caused " + themove.hurtselfdam + " damage!");
                //health bar animation
                atk.Damage(themove.hurtselfdam);
                while (TheQueue.QCount() > 0)
                {
                    yield return(new WaitForEndOfFrame());
                }
                UpHealth();
            }

            else if (themove.healself && !movefailed)
            {
                TheQueue.AddQueue(themove.Name + " caused " + atk.Name + " to heal!");
                TheQueue.AddQueue(atk.Name + " healed " + themove.hurtselfdam + " health!");
                //health bar animation
                atk.Heal(themove.hurtselfdam);
            }

            if (themove.self && !atk.status.Contains(themove.status) && !atk.isDead())
            {
                TheQueue.AddQueue(themove.Name + " gave " + atk.Name + " a status effect!");
                atk.SetStatus(themove.status, themove.statlen);
                statimmune = true;
                while (TheQueue.QCount() > 0)
                {
                    yield return(new WaitForEndOfFrame());
                }
                //if(themove.healself)
                //return;
            }

            /*else if (themove.self && atk.status != Monster.Status.none && themove.statoverride && !atk.isDead())
             * {
             *  TheQueue.AddQueue(themove.Name + " gave " + atk.Name + " a status effect!");
             *  atk.SetStatus(themove.status, themove.statlen);
             *  statimmune = true;
             * }*/
            else if (themove.self && atk.status.Contains(themove.status) && !atk.isDead())
            {
                TheQueue.AddQueue(atk.Name + " failed to give itself a status effect!");
            }

            if (def.isDead())
            {
                TheQueue.AddQueue(def.Name + " died!!!");
            }
            if (atk.isDead())
            {
                TheQueue.AddQueue(atk.Name + " died!!!");
            }
        }
        else
        {
            TheQueue.AddQueue(atk.Name + "'s attack missed!");
        }


        //UpStats();

        usingmove = false;
    }
コード例 #5
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;
        }
    }
コード例 #6
0
    IEnumerator YouTurn(TurnType tt)
    {
        int esccheck;

        switch (tt)
        {
        case TurnType.none:
            break;

        case TurnType.item:
            if (instance.turnitem.IT == Item.ItemType.potion)
            {
                //do animation here
                //DoPotion function?
                instance.you.Heal(-1);
                TheQueue.AddQueue("You used a potion!");
                while (TheQueue.QCount() > 0)
                {
                    yield return(new WaitForEndOfFrame());
                }
                UpHealth();
                TheQueue.AddQueue(instance.you.Name + " is fully healed!");
                if (instance.you.status.Count == 0)
                {
                    instance.you.SetStatus(Monster.Status.none, 1);
                }
            }
            else if (instance.turnitem.IT == Item.ItemType.net)
            {
                //DoNet
                //animation
                //if types match, catch
                //else if net type is none, 50/50
                //else if types dont match, dont catch
                TheQueue.AddQueue("You launched a net!");
                if (instance.turnitem.nettype == Types.Type.none)
                {
                    if (!instance.CheckNet())
                    {
                        TheQueue.AddQueue("Your net missed!");
                    }
                    else
                    {
                        if (player1.moninv.IsFull())
                        {
                            TheQueue.AddQueue("You don't have room for this m0nst3r!");
                            TheQueue.goadventure = true;
                            yield break;
                        }
                        else
                        {
                            TheQueue.AddQueue("You've caught the " + instance.opon.Name + "!");
                            player1.moninv.AddMonster(instance.opon);
                            TheQueue.goadventure = true;
                            yield break;
                        }
                    }
                }
                else if (instance.turnitem.nettype == instance.opon.Type)
                {
                    if (player1.moninv.IsFull())
                    {
                        TheQueue.AddQueue("You don't have room for this m0nst3r!");
                        TheQueue.goadventure = true;
                        yield break;
                    }
                    else
                    {
                        TheQueue.AddQueue("You've caught the " + instance.opon.Name + "!");
                        player1.moninv.AddMonster(instance.opon);
                        TheQueue.goadventure = true;
                        yield break;
                    }
                }
                else
                {
                    TheQueue.AddQueue("Your net missed!");
                }
            }
            break;

        case TurnType.attack:

            atkturn.atk     = you;
            atkturn.def     = opon;
            atkturn.atkmove = turnmove;

            usingmove = true;
            StartCoroutine("UseMoveCo", atkturn);
            while (usingmove)
            {
                yield return(new WaitForEndOfFrame());
            }
            UpHealth();
            break;

        case TurnType.change:
            you      = changeto;
            changeto = new Monster.SubMonster();
            UpHealth();
            TheQueue.AddQueue("You've changed m0nst3rz to " + instance.you.Name + "!");
            break;

        case TurnType.esc:
            esccheck = UnityEngine.Random.Range((int)0, (int)3);
            if (esccheck == 0)
            {
                TheQueue.AddQueue("You've escaped!");
                TheQueue.goadventure = true;
                yield break;
            }
            else
            {
                TheQueue.AddQueue("Escape attempt failed!");
            }
            break;
        }

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

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

        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);
            if (player1.moninv.HasAnActive())
            {
                player1.moninv.RemoveMonster(you);
                you = new Monster.SubMonster();
                //instance.deadoponturn = true;
                TheQueue.curdead = true;
                while (you.Name == "")
                {
                    yield return(new WaitForEndOfFrame());
                }
            }
            else
            {
                player1.moninv.RemoveMonster(you);
                you = new Monster.SubMonster();
                TheQueue.AddQueue("You're out of m0nst3rz!!!");
                TheQueue.gohome = true;
                yield break;
            }
        }

        else if (instance.opon.isDead())
        {
            you.GetKill();
            TheQueue.AddQueue("You killed the " + instance.opon.Name + "!!!");
            TheQueue.goadventure = true;
            yield break;
            //SceneManager.LoadScene("Adventure");
        }

        if (TheQueue.QCount() == 0)
        {
            youturn = false;
        }
    }
コード例 #7
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;
        }
    }
コード例 #8
0
ファイル: MBattlePlayer.cs プロジェクト: heugel/m0nst3rz
    /*public override void OnStartLocalPlayer()
     * {
     *  if (isClient) playernum = 2;
     *  else if (isServer) playernum = 1;
     *  print(playernum);
     *  BMMulti.PlayerSet(GetComponent<PlayerMain>(), playernum);
     * }*/

    void Update()
    {
        if (!doneyet)
        {
            player = GetComponent <PlayerMain>().GetPlayer();
            if (isLocalPlayer)
            {
                playernum = 1;
            }
            else
            {
                playernum = 2;
            }
            doneyet = true;
        }

        /*if (BMMulti.IsActive() && !doneyet)
         * {
         *
         *  if (isLocalPlayer) playernum = 1;
         *  else playernum = 2;
         *  //print(playernum);
         *  //print(isServer);
         *  BMMulti.PlayerSet(GetComponent<PlayerMain>(), playernum);
         *  doneyet = true;
         * }*/
        buttons.SetActive(BMMulti.TurnGet());

        if (BMMulti.TurnGet() || menumother.upnow != MUpMenu.curMenu.none)
        {
            if (Input.touchCount == 1 && onehit)
            {
                // touch on screen
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    Ray        ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                    RaycastHit hit = new RaycastHit();
                    moving = Physics.Raycast(ray, out hit);
                    if (moving)
                    {
                        go = hit.transform.gameObject;
                    }
                    else
                    {
                        onehit = false;
                    }
                }


                // release touch/dragging
                if ((Input.GetTouch(0).phase == TouchPhase.Ended || Input.GetTouch(0).phase == TouchPhase.Canceled || Input.touchCount != 1) && go != null && onehit)
                {
                    Ray        ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                    RaycastHit hit = new RaycastHit();
                    moving = Physics.Raycast(ray, out hit);
                    if (moving)
                    {
                        go2 = hit.transform.gameObject;
                    }
                    moving = false;
                    //Debug.Log("Touch Released from : " + go.name);
                    if (go == atk && go == go2)
                    {
                        //atk menu appears
                        menumother.SetMenu(MUpMenu.curMenu.atk);
                    }
                    else if (go == chng && go == go2)
                    {
                        //active player1.moninvmenu appears
                        menumother.SetMenu(MUpMenu.curMenu.mon);
                    }

                    else if (go == esc && go == go2)
                    {
                        //DISCONNECT
                    }

                    if (go == movebuttons[0] && go2 == go)
                    {
                        menumother.SetMenu(MUpMenu.curMenu.none);
                        BMMulti.SetMove(BMMulti.GetYou(playernum).moves[0], playernum);
                        BMMulti.InitTurn(BMMulti.TurnType.attack, playernum);
                    }
                    else if (go == movebuttons[1] && go2 == go)
                    {
                        menumother.SetMenu(MUpMenu.curMenu.none);
                        BMMulti.SetMove(BMMulti.GetYou(playernum).moves[1], playernum);
                        BMMulti.InitTurn(BMMulti.TurnType.attack, playernum);
                    }
                    else if (go == movebuttons[2] && go2 == go)
                    {
                        menumother.SetMenu(MUpMenu.curMenu.none);
                        BMMulti.SetMove(BMMulti.GetYou(playernum).moves[2], playernum);
                        BMMulti.InitTurn(BMMulti.TurnType.attack, playernum);
                    }

                    if (go == monbuttons[0] && go2 == go)
                    {
                        BMMulti.SetNewMon(monbuttons[0].GetComponent <InvSlot>().curMonster, playernum);
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        if (!TheQueue.deadselect)
                        {
                            BMMulti.InitTurn(BMMulti.TurnType.change, playernum);
                        }
                        else
                        {
                            BMMulti.SetYou(monbuttons[0].GetComponent <InvSlot>().curMonster, playernum);
                            BMMulti.SetNewMon(new Monster.SubMonster(), playernum);
                            BMMulti.UpHealth();
                            TheQueue.AddQueue("You've changed to " + BMMulti.GetYou(playernum).Name + "!");
                            TheQueue.deadselect = false;
                            TheQueue.curdead    = false;
                        }
                    }
                    else if (go == monbuttons[1] && go2 == go)
                    {
                        BMMulti.SetNewMon(monbuttons[1].GetComponent <InvSlot>().curMonster, playernum);
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        if (!TheQueue.deadselect)
                        {
                            BMMulti.InitTurn(BMMulti.TurnType.change, playernum);
                        }
                        else
                        {
                            BMMulti.SetYou(monbuttons[1].GetComponent <InvSlot>().curMonster, playernum);
                            BMMulti.SetNewMon(new Monster.SubMonster(), playernum);
                            BMMulti.UpHealth();
                            TheQueue.AddQueue("You've changed to " + BMMulti.GetYou(playernum).Name + "!");
                            TheQueue.deadselect = false;
                            TheQueue.curdead    = false;
                        }
                    }
                    else if (go == monbuttons[2] && go2 == go)
                    {
                        BMMulti.SetNewMon(monbuttons[2].GetComponent <InvSlot>().curMonster, playernum);
                        UpMenu.SetMenu(UpMenu.curMenu.none);
                        if (!TheQueue.deadselect)
                        {
                            BMMulti.InitTurn(BMMulti.TurnType.change, playernum);
                        }
                        else
                        {
                            BMMulti.SetYou(monbuttons[2].GetComponent <InvSlot>().curMonster, playernum);
                            BMMulti.SetNewMon(new Monster.SubMonster(), playernum);
                            BMMulti.UpHealth();
                            TheQueue.AddQueue("You've changed to " + BMMulti.GetYou(playernum).Name + "!");
                            TheQueue.deadselect = false;
                            TheQueue.curdead    = false;
                        }
                    }
                }
            }
            else
            {
                go     = null;
                go2    = null;
                onehit = true;
            }
        }
        else
        {
            go     = null;
            go2    = null;
            onehit = true;
        }
    }