Example #1
0
    //Do this when the selectable UI object is selected.
    public void OnSelect(BaseEventData eventData)
    {
        int    cost = 0;
        Button btn  = GetComponent <Button>();

        msg = " ";

        if (btn == jab)
        {
            cost = moveSet.getMoveSetCost(1);
            msg  = "Jab (" + cost.ToString() + "SP)\n\n";
            msg += "A weak attack that has no SP cost, but recovers some SP.";
        }
        else if (btn == straight)
        {
            cost = moveSet.getMoveSetCost(2);
            msg  = "Straight (" + cost.ToString() + "SP)\n\n";
            msg += "A light attack that recovers a small amount of HP.";
        }
        else if (btn == hook)
        {
            cost = moveSet.getMoveSetCost(3);
            msg  = "Hook (" + cost.ToString() + "SP)\n\n";
            msg += "A heavy attack with a small chance to daze the opponent.";
        }
        else if (btn == sunday)
        {
            cost = moveSet.getMoveSetCost(4);
            msg  = "Sunday Punch (" + cost.ToString() + "SP)\n\n";
            msg += "A heavy attack with a larger chance to daze the opponent.";
        }
        else if (btn == counter)
        {
            cost = moveSet.getMoveSetCost(0);
            msg  = "Counter! (" + cost.ToString() + "SP)\n\n";
            msg += "A medium attack that recovers some SP and some HP.";
        }
        else if (btn == guard)
        {
            cost = moveSet.getMoveSetCost(6);
            msg  = "Guard (" + cost.ToString() + "SP)\n\n";
            msg += "A defensive move that recovers a large amount of SP and halves damaged recieved until next turn.";
        }
        else if (btn == recover)
        {
            cost = moveSet.getMoveSetCost(7);
            msg  = "Recover (" + cost.ToString() + "SP)\n\n";
            msg += "A defensive move that recovers some HP.";
        }
        else if (btn == butterbee)
        {
            cost = moveSet.getMoveSetCost(8);
            msg  = "ButterBee (" + cost.ToString() + "SP)\n\n";
            msg += "A light attack that has a medium chance to attack a second time with a Counter.";
        }

        // Update textbox with move information
        moveText.text = msg;
    }
Example #2
0
    public void playerSelect(int moveNum)
    {
        // Reset error text on make selection
        btext.updateErrorText(" ");

        // alter doMove() so also can recieve player and enemy objects
        // and react based on whose turn it is

        if (moveset.getMoveSetCost(moveNum) > player.SP)
        {
            Debug.Log("you cannot afford this move w/current SP!");
            btext.updateErrorText("NOT ENOUGH SP!");
        }
        else
        {
            // Disable player Buttons!!!!!!!!!!!

            moveset.doMove(moveNum);

            // DOES THE SELECTED ACTION WOO

            // do yield playerturn
            // after done all the stuff; set Playerturn to falso
        }
    }
    // ------------------------------------------------------------------------------------------------- //

    public void playerSelect(int moveNum)
    {
        bool PlayerMiss;
        int  attemptMove = moveNum;

        // Reset error text on make selection
        btext.updateErrorText(" ");

        // Get miss chance, can't miss on Counter
        if (enemy.prevMove == 9 && moveNum == 0)
        {
            PlayerMiss = false;
        }
        else if (moveNum == 1 || moveNum == 6 || moveNum == 7 || moveNum == 10 || moveNum == 11)
        {
            PlayerMiss = false;
        }
        else
        {
            // Get if player misses or not
            PlayerMiss = (Random.Range(0.0f, 1.0f) < enemy.EVA) ? true : false;
        }

        if (PlayerMiss)
        {
            moveNum = 9; // Change move to miss
        }

        // Stop selection if player does not have enough SP
        if (moveset.getMoveSetCost(moveNum) > player.SP)
        {
            Debug.Log("you cannot afford this move w/current SP!");
            btext.updateErrorText("NOT ENOUGH SP!");
        }
        else // continue with player selection
        {
            // Deselect button
            EventSystem.current.SetSelectedGameObject(null);

            // Disable player Buttons
            standardAbilButton.SetActive(false);
            counterButton.SetActive(false);
            sundayButton.SetActive(false);
            butterButton.SetActive(false);

            // DOES THE SELECTED ACTION WOO
            moveset.doMove(moveNum);

            // Hold the turn until the animations are over.
            StartCoroutine(RunPlayerTurnAnimations(attemptMove, moveNum));
        }
    }
Example #4
0
    public void OnSelect(BaseEventData eventData)
    {
        Button btn  = GetComponent <Button>();
        int    rank = PlayerPrefs.GetInt("PlayerRank");
        int    cost;
        int    moveCost = 0;

        if (rank > 1)
        {
            cost = 1000;
        }
        else
        {
            cost = 2000;
        }


        msg = " ";

        if (btn == exitmenu)
        {
            msg  = "\n\n";
            msg += "Exit the Training Menu and return to the Game Menu.";
        }
        else if (btn == upgrade)
        {
            msg  = "\n\n";
            msg += "There are stat UPGRADES available; spend EXP to buy upgrades and increase your stats to become more powerful in battle.";
        }
        else if (btn == ability)
        {
            msg  = "\n\n";
            msg += "There are NEW ABILITIES available; spend EXP to learn new abilities to use in battle.";
        }
        else if (btn == power)
        {
            msg  = "\n\n";
            msg += "Power (PWR)\nCost: " + cost.ToString() + "EXP\n";
            msg += "The PWR stat increases how much DAMAGE your attacks do, as well as increasing your maximum Stamina Points (SP).";
        }
        else if (btn == speed)
        {
            msg  = "\n\n";
            msg += "Speed (SPD)\nCost: " + cost.ToString() + "EXP\n";
            msg += "The SPD stat increases the % chance you will EVADE an enemy attack. ";
            msg += "Certain abilities have features such as a chance to Daze the enemy or perform a double attack, SPD stat increases your chance %.";
        }
        else if (btn == tough)
        {
            msg  = "\n\n";
            msg += "Toughness (TGH)\nCost: " + cost.ToString() + "EXP\n";
            msg += "The TGH stat increases how much you DEFENSE can mitigate opponents attack, as well as increas your maximum Hit Points (HP).";
        }
        else if (btn == exitupgrade)
        {
            msg  = "\n\n";
            msg += "Done with UPGRADES.";
        }
        else if (btn == sunday)
        {
            moveCost = moveSet.getMoveSetCost(4);
            msg      = "\n\n";
            msg     += "Sunday Punch\nCost: " + cost.ToString() + "EXP\n";
            msg     += "A powerful attack costing " + moveCost.ToString() + "SP, that has a small chance to inflict DAZED status on opponent, preventing opponent from attacking for 1 turn.";
        }
        else if (btn == butterbee)
        {
            moveCost = moveSet.getMoveSetCost(8);
            msg      = "\n\n";
            msg     += "ButterBee\nCost: " + cost.ToString() + "EXP\n";
            msg     += "\"Fly like a butterfly...\" you know the rest! A weaker attack costing " + moveCost.ToString() + "SP, that has a medium chance of also performing a second attack on the opponent.";
        }
        else if (btn == exitability)
        {
            msg  = "\n\n";
            msg += "Done with ABILITIES.";
        }

        // Update textbox with move information
        infoText.text = msg;
    }
    public int runEnemyAI(PlayerObject player, EnemyObject enemy, MatchTurn turn, MoveSetScript moveSet)
    {
        /*
         * LIST OF MOVES POSSIBLE:
         * 0 Counter
         * 1 Jab
         * 2 Straight / Light Attack
         * 3 Hook / Heavy Attack
         * 4 Sunday Punch / Crit chance
         * 5 Dynamite Blow / Dazes enemy
         * 6 Guard / Halves Damage 1 turn
         * 7 Recover / +% of HP & SP
         * 8 ButterBee / +1 EVA for X turns
         * 9 Miss / Missed Oponent
         * 10 Dazed / Dazed by enemy cannot attack
         * 11 FINISHER / Finishing Move; target critical condition
         */

        int answerAI    = -1; // Holds move number result; returns -1 if error
        int divNum      = 4;  // Number of turns between special attacks
        int lowSP       = 40; // Threshold for SP before attempt SP recovery
        int enemyLowHP  = 30; // Threshold for enemy HP
        int playerLowHP = 20; // Threshold for player HP

        bool EnemyMiss       = (Random.Range(0.0f, 1.0f) < player.EVA) ? true : false;
        bool PlayerDefense   = (player.prevMove == 6 || player.prevMove == 7) ? true : false;
        bool RandoHookChance = (Random.Range(0.0f, 1.0f) < 0.55f) ? true : false;

        /*
         * bool divis = ((enemy.turnCounter % divNum)==0 ? true : false);
         * Debug.Log("divNum = 3; turn num = " + enemy.turnCounter + "; divisible? = " + divis);
         */

        // LEAF NODES:
        Node Counter   = new ActionNode(0);
        Node Jab       = new ActionNode(1);
        Node Straight  = new ActionNode(2);
        Node Hook      = new ActionNode(3);
        Node Sunday    = new ActionNode(4);
        Node Dynamite  = new ActionNode(5);
        Node Guard     = new ActionNode(6);
        Node Recover   = new ActionNode(7);
        Node ButterBee = new ActionNode(8);
        Node Miss      = new ActionNode(9);
        Node Dazed     = new ActionNode(10);
        Node Finisher  = new ActionNode(11);

        // SPECIAL BRANCH:

        // Test if player rank == 2, if yes Special move is ButterBee, else Dynamite
        Node PlayerRank2 = new TestNode(ButterBee, Dynamite, player.PlayerRank, 2, 2);
        // Test if player rank == 3, if yes Special move is Sunday Punch, else PlayerRank2 node
        Node PlayerRank3 = new TestNode(Sunday, PlayerRank2, player.PlayerRank, 3, 3);
        // Test if match is training match, if yes return heavy, else PlayerRank3 node
        Node SpecialTraining = new BoolNode(Hook, PlayerRank3, player.Sparring);

        // LOW SP BRANCH:

        // Decide between Hook or Straight by Random number (see RandoHookChance above)
        Node RandomHook = new BoolNode(Hook, Straight, RandoHookChance);
        // If enemy Misses, return Miss, else RandomHook node
        Node MissRegular = new BoolNode(Miss, RandomHook, EnemyMiss);
        // If enemy HP is <= player HP, Recover else Jab
        Node FreeGetHP = new TestNode(Recover, Jab, enemy.HP, 0, player.HP);
        // If player last move was defensive FreeGetHP node, else RandomHook node
        Node PlayerDefensive = new BoolNode(FreeGetHP, MissRegular, PlayerDefense);
        // If miss true Jab, else SpecialTraining node
        Node MissSpecial = new BoolNode(Jab, SpecialTraining, EnemyMiss);
        // If enemy.turnCount is divisible by divNum, MissSpecial node, else PlayerDefensive node
        Node TurnDivisible = new TestNode(MissSpecial, PlayerDefensive, (enemy.turnCounter % divNum), 0, 0);
        // If enemy HP is <= player HP, Guard, else Jab
        Node LowStamGetSP = new TestNode(Guard, Jab, enemy.HP, 0, player.HP);
        // If enemy.sp < lowSP, LowStamGetSP, else TurnDivisible
        Node EnemyLowSP = new TestNode(LowStamGetSP, TurnDivisible, enemy.SP, 0, lowSP);

        // CRITICAL HEALTH BRANCH:

        // If enemy.SP < recover cost, Jab, else Recover
        Node RecoverCost = new TestNode(Jab, Recover, enemy.SP, 0, moveSet.getMoveSetCost(7));
        // If enemy HP is <= enemyLowHP, RecoverCost node, else EnemyLowSP node
        Node EnemyCritical = new TestNode(RecoverCost, EnemyLowSP, enemy.HP, 0, enemyLowHP);
        // If enemy Misses, return Miss, else return Finish
        Node MissFinisher = new BoolNode(Miss, Finisher, EnemyMiss);
        // If enemy.SP < recover cost, Jab, else Recover
        Node FinisherCost = new TestNode(RecoverCost, MissFinisher, enemy.SP, 0, moveSet.getMoveSetCost(11));
        // If enemy HP is <= enemyLowHP, RecoverCost node, else EnemyLowSP node
        Node PlayerCritical = new TestNode(FinisherCost, EnemyCritical, player.HP, 0, playerLowHP);

        // START / ROOT:

        // if enemy miss, return miss, else return counter
        Node MissCounter = new BoolNode(Miss, Counter, EnemyMiss);
        // if enemy.SP < Counter's SP cost, Jab, else MissCounter node
        Node CounterCost = new TestNode(Jab, MissCounter, enemy.SP, 0, moveSet.getMoveSetCost(0));
        // If player is dazed, RecoverCost node, else PlayerCritical node
        Node PlayerDazed = new BoolNode(RecoverCost, PlayerCritical, player.Dazed);
        // If enemy is dazed, return Dazed, else PlayerDazed node
        Node EnemyDazed = new BoolNode(Dazed, PlayerDazed, enemy.Dazed);
        // ROOT node, if player missed then CounterCost node, else EnemyDazed node
        Node RootPlayerMiss = new TestNode(CounterCost, EnemyDazed, player.prevMove, 9, 9);

        answerAI = RootPlayerMiss.RunNode();

        return(answerAI);
    }