public static void FolkvarMeleeAttack()
    {
        // Folkvar uses his first melee attack
        if (FolkvarCombatScript.folkvarCondition1[0] && FolkvarCombatScript.folkvarCondition1[1])
        {
            print("Folkvar uses his first attack");

            // Make Folkvar attack in game
            if (firstAttack != 0)
            {
                hasRunSimulation = false;

                if (secondAttack == 0)
                {
                    if (firstAttack != 4)
                    {
                        secondAttack = 4;
                    }
                    else
                    {
                        print("Can't choose the same move twice");
                    }
                }
            }
            else
            {
                firstAttack = 4;
            }


            FolkvarCombatScript.ResetFolkvarVariables();
        }

        // Folkvar uses his second melee attack
        if (FolkvarCombatScript.folkvarCondition2[0] && FolkvarCombatScript.folkvarCondition2[1] && FolkvarCombatScript.folkvarCondition2[2])
        {
            print("Folkvar uses his second attack");

            // Make Folkvar attack in game
            if (firstAttack != 0)
            {
                hasRunSimulation = false;

                if (secondAttack == 0)
                {
                    if (firstAttack != 5)
                    {
                        secondAttack = 5;
                    }
                    else
                    {
                        print("Can't choose the same move twice");
                    }
                }
            }
            else
            {
                firstAttack = 5;
            }


            FolkvarCombatScript.ResetFolkvarVariables();
        }

        // Folkvar uses his third melee attack
        if (FolkvarCombatScript.folkvarCondition3[0] && FolkvarCombatScript.folkvarCondition3[1] && FolkvarCombatScript.folkvarCondition3[2])
        {
            print("Folkvar uses his third attack");

            // Make Folkvar attack in game
            if (firstAttack != 0)
            {
                hasRunSimulation = false;

                if (secondAttack == 0)
                {
                    if (firstAttack != 6)
                    {
                        secondAttack = 6;
                    }
                    else
                    {
                        print("Can't choose the same move twice");
                    }
                }
            }
            else
            {
                firstAttack = 6;
            }


            FolkvarCombatScript.ResetFolkvarVariables();
        }


        // Folkvar moves
        if (FolkvarCombatScript.folkvarCondition4[0])
        {
            // If Folkvar moves to the left
            if (FolkvarCombatScript.folkvarCondition4[1])
            {
                print("Folkvar moves to the left");

                // Make Folkvar move in game
                if (firstAttack != 0)
                {
                    hasRunSimulation = false;

                    if (secondAttack == 0)
                    {
                        secondAttack = 12;
                    }
                }
                else
                {
                    firstAttack = 12;
                }

                FolkvarCombatScript.ResetFolkvarVariables();
            }

            // If Folkvar moves to the right
            if (FolkvarCombatScript.folkvarCondition4[2])
            {
                print("Folkvar moves to the right");

                // Make Folkvar move in game
                if (firstAttack != 0)
                {
                    hasRunSimulation = false;

                    if (secondAttack == 0)
                    {
                        secondAttack = 13;
                    }
                }
                else
                {
                    firstAttack = 13;
                }

                FolkvarCombatScript.ResetFolkvarVariables();
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        CharactersAlive();
        EndOfCombat();

        if (hasWon)
        {
            win = false;
        }
        if (hasLost)
        {
            lose = false;
        }

        if (win)
        {
            hasWon = true;
        }
        if (lose)
        {
            hasLost = true;
        }


        if (win)
        {
            // TODO: Play won-battle animation
            GameManagerScript.NextScene(false);
            print("You won!...that battle");
            win = false;
        }
        else
        {
            if (lose)
            {
                // TODO: Play lost-battle animation
                GameManagerScript.NextScene(false);
                print("You Lose");
                lose = false;
            }
        }

        // If the Netrixi marker is visible
        if (MarkerManagerScript.netrixiMarker)
        {
            if (isNetrixi)
            {
                if (netrixiAlive)
                {
                    netrixiAttacks = true;
                    folkvarAttacks = false;
                    ivAttacks      = false;

                    isNetrixi = false;

                    print("Netrixi will attack with a spell");
                }
            }
        }
        else
        {
            isNetrixi = true;
        }

        // If the Folkvar marker is visible
        if (MarkerManagerScript.folkvarMarker)
        {
            if (isFolkvar)
            {
                if (folkvarAlive)
                {
                    folkvarAttacks = true;
                    netrixiAttacks = false;
                    ivAttacks      = false;

                    isFolkvar = false;

                    print("Folkvar will attack with his mighty weapons");
                }
            }
        }
        else
        {
            isFolkvar = true;
        }

        // If the Iv marker is visible
        if (MarkerManagerScript.ivMarker)
        {
            if (isIv)
            {
                if (ivAlive)
                {
                    ivAttacks      = true;
                    netrixiAttacks = false;
                    folkvarAttacks = false;

                    isIv = false;

                    print("Iv will block with her force powers");
                }
            }
        }
        else
        {
            isIv = true;
        }


        // Reset player attacks and move onto next round if player locks in their choices
        if (secondAttack != 0)
        {
            if (MarkerManagerScript.goMarker)
            {
                if (Input.GetKeyDown(KeyCode.V))
                {
                    if (!NetrixiCombatScript.netrixiCondition4[0] || !FolkvarCombatScript.folkvarCondition4[0] || !IvCombatScript.ivCondition4[0])
                    {
                        if (!hasRunSimulation)
                        {
                            // Run combat simulation
                            var go     = new GameObject("runner");
                            var runner = go.AddComponent <CombatSimulationScript>();
                            runner.StartCoroutine(runner.RunSimulation(firstAttack, secondAttack, EnemyManagerScript.firstAttack, EnemyManagerScript.secondAttack, go));
                            hasRunSimulation = true;
                        }
                    }
                }
            }
        }



        // Determine whether the player has chosen a combat move
        if (netrixiAttacks)
        {
            if (CombatManagerScript.netrixiAlive)
            {
                NetrixiCombatScript.NetrixiAttack();
            }
        }
        if (folkvarAttacks)
        {
            if (CombatManagerScript.folkvarAlive)
            {
                FolkvarCombatScript.FolkvarAttack();
            }
        }
        if (ivAttacks)
        {
            if (CombatManagerScript.ivAlive)
            {
                IvCombatScript.IvAction();
            }
        }



        // Undo a chosen move or attack
        if (MarkerManagerScript.undoMarker)
        {
            if (Input.GetKeyDown(KeyCode.U))
            {
                // Determine what the player's first attack is
                if (firstAttack != 0)
                {
                    // Determine what the player's second attack is
                    if (secondAttack == 0)
                    {
                        // Reset attack
                        CharacterManagerScript.UndoMove();
                        firstAttack = 0;
                    }
                    else
                    {
                        // Reset attack
                        CharacterManagerScript.UndoMove();
                        secondAttack = 0;
                    }
                }
            }
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        MarkerManagerScript.S.Reset();
        CharacterManagerScript.StartCombat();

        firstAttack  = 0;
        secondAttack = 0;

        netrixiAttacks = false;
        folkvarAttacks = false;
        ivAttacks      = false;

        NetrixiCombatScript.ResetNetrixiVariables();
        FolkvarCombatScript.ResetFolkvarVariables();
        IvCombatScript.ResetIvVariables();

        isNetrixi = true;
        isFolkvar = true;
        isIv      = true;

        roundNumber = 1;


        // Determine which characters are in the scene
        netrixiAlive = true;
        if (GameManagerScript.folkvarInParty)
        {
            folkvarAlive = true;
        }
        else
        {
            folkvarAlive = false;
        }
        if (GameManagerScript.ivInParty)
        {
            ivAlive = true;
        }
        else
        {
            ivAlive = false;
        }

        // Determine which enemies are in the scene
        enemy1Alive = true;
        if (EnemyManagerScript.enemy2 == "null")
        {
            enemy2Alive     = false;
            canEnemy2Attack = false;
        }
        else
        {
            enemy2Alive = true;
        }

        if (EnemyManagerScript.enemy3 == "null")
        {
            enemy3Alive     = false;
            canEnemy3Attack = false;
        }
        else
        {
            enemy3Alive = true;
        }


        playerAttacking1 = false;
        playerAttacking2 = false;
        enemyAttacking1  = false;
        enemyAttacking2  = false;


        // Reset any transformed enemies
        if (!canEnemy1Attack)
        {
            NetrixiAttackScript.enemy1Transformed = false;
        }
        if (!canEnemy2Attack)
        {
            NetrixiAttackScript.enemy2Transformed = false;
        }
        if (!canEnemy3Attack)
        {
            NetrixiAttackScript.enemy3Transformed = false;
        }

        canEnemy1Attack = true;
        canEnemy2Attack = true;
        canEnemy3Attack = true;


        // If only Netrixi is present in the scene
        //if (netrixiAlive && !folkvarAlive && !ivAlive) netrixiAttacks = true;


        win  = false;
        lose = false;

        hasWon  = false;
        hasLost = false;

        enemy1StartingHP = enemy1HP;
        enemy2StartingHP = enemy2HP;
        enemy3StartingHP = enemy3HP;
    }
Esempio n. 4
0
    public IEnumerator RunSimulation(int playerFirstAttack, int playerSecondAttack, string enemyFirstAttack, string enemySecondAttack, GameObject runner)
    {
        CombatManagerScript.netrixiAttacks = false;
        CombatManagerScript.folkvarAttacks = false;
        CombatManagerScript.ivAttacks      = false;


        // FIRST ATTACK
        yield return(new WaitForSecondsRealtime(moveDelay));

        // Check to see if any Main Characters move for their first attack
        CheckForPlayerMovement(playerFirstAttack, 1);
        // If any Main Characters did move for their first attack
        if (didPlayerMove1)
        {
            yield return(new WaitForSecondsRealtime(moveDelay));
        }

        // Check to see if any Enemy Characters move for their first attack
        CheckForEnemyMovement(enemyFirstAttack, 1);
        // If any Enemy Characters did move for their first attack
        if (didEnemyMove1)
        {
            yield return(new WaitForSecondsRealtime(moveDelay));
        }



        // Check to see what the player's first attack is
        if (!didPlayerMove1)
        {
            AttackScript.PlayerAttack(playerFirstAttack, 1);
            CombatManagerScript.playerAttacking1 = true;

            AttackScript.enemyAttack = !AttackScript.enemyAttack;

            // Wait for attack animation to play
            yield return(new WaitForSecondsRealtime(attack1Delay));
        }

        // Check to see what the enemy's first attack is
        if (!didEnemyMove1)
        {
            AttackScript.EnemyAttack(enemyFirstAttack, 1, enemyAttacker1);
            CombatManagerScript.enemyAttacking1 = true;

            AttackScript.playerAttack = !AttackScript.playerAttack;

            // Wait for attack animation to play
            yield return(new WaitForSecondsRealtime(attack1Delay));
        }



        // SECOND ATTACK

        // Check to see if any Main Characters move for their second attack
        CheckForPlayerMovement(playerSecondAttack, 2);
        // If any Main Characters did move for their second attack
        if (didPlayerMove2)
        {
            yield return(new WaitForSecondsRealtime(moveDelay));
        }

        // Check to see if any Enemy Characters move for their second attack
        CheckForEnemyMovement(enemySecondAttack, 2);
        // If any Enemy Characters did move for their second attack
        if (didEnemyMove2)
        {
            yield return(new WaitForSecondsRealtime(moveDelay));
        }



        // Check to see what the player's second attack is
        if (!didPlayerMove2)
        {
            AttackScript.PlayerAttack(playerSecondAttack, 2);
            CombatManagerScript.playerAttacking2 = true;

            AttackScript.enemyAttack = !AttackScript.enemyAttack;

            // Wait for attack animation to play
            yield return(new WaitForSecondsRealtime(attack2Delay));
        }

        // Check to see what the enemy's second attack is
        if (!didEnemyMove2)
        {
            AttackScript.EnemyAttack(enemySecondAttack, 2, enemyAttacker2);
            CombatManagerScript.enemyAttacking2 = true;

            AttackScript.playerAttack = !AttackScript.playerAttack;

            // Wait for attack animation to play
            yield return(new WaitForSecondsRealtime(attack2Delay));
        }



        // Reset variables once simulation is finished
        CombatManagerScript.firstAttack  = 0;
        CombatManagerScript.secondAttack = 0;

        NetrixiCombatScript.ResetNetrixiVariables();
        FolkvarCombatScript.ResetFolkvarVariables();
        IvCombatScript.ResetIvVariables();

        CombatManagerScript.roundNumber += 1;

        CombatManagerScript.playerAttacking1 = false;
        CombatManagerScript.playerAttacking2 = false;
        CombatManagerScript.enemyAttacking1  = false;
        CombatManagerScript.enemyAttacking2  = false;

        CombatManagerScript.target1Location = 0;
        CombatManagerScript.target2Location = 0;

        CharacterManagerScript.ResetVariables();
        EnemyManagerScript.ClearMoves();

        didPlayerMove1 = false;
        didPlayerMove2 = false;
        didEnemyMove1  = false;
        didEnemyMove2  = false;


        // If only one character is alive
        //if (CombatManagerScript.netrixiAlive && !CombatManagerScript.folkvarAlive && !CombatManagerScript.ivAlive) CombatManagerScript.netrixiAttacks = true;
        //if (!CombatManagerScript.netrixiAlive && CombatManagerScript.folkvarAlive && !CombatManagerScript.ivAlive) CombatManagerScript.folkvarAttacks = true;
        //if (!CombatManagerScript.netrixiAlive && !CombatManagerScript.folkvarAlive && CombatManagerScript.ivAlive) CombatManagerScript.ivAttacks = true;


        Destroy(runner);
    }