Пример #1
0
 public static void FightCompleted(FightResultData data)
 {
     if (OnFightComplete != null)
     {
         OnFightComplete(data);
     }
 }
Пример #2
0
    IEnumerator Attack(Character lhs, Character rhs)
    {
        lhs.isSelected = true;
        rhs.isSelected = true;
        lhs.GetComponent <AnimationController>().Dance();
        rhs.GetComponent <AnimationController>().Dance();

        yield return(new WaitForSeconds(fightAnimTime));

        float outcome = 0;
        //defaulting to draw
        Character winner = lhs, defeated = rhs;

        Debug.LogWarning("Attack called, needs to use character stats to determine winner with win strength from 1 to -1. This can most likely be ported from previous brief work.");


        Debug.LogWarning("Attack called, may want to use the BattleLog to report the dancers and the outcome of their dance off.");

        var results = new FightResultData(winner, defeated, outcome);

        lhs.isSelected = false;
        rhs.isSelected = false;
        GameEvents.FightCompleted(results);

        yield return(null);
    }
Пример #3
0
    public void HandleFightResult(SocketIOEvent ev)
    {
        //if death of player-- what do we do?
        //if enemy death, player.encounter = false;
        //else, update hpbars for both player and enemy
        //if the player has died, we won't get this message.  The player must explicitly call EndEncounter(true)
        // to clean up the encounter.
        FightResultData data          = FightResultData.FromJSONObject(ev.data);
        bool            enemyDamaged  = data.enemyHp < _currentHp;
        bool            playerDamaged = data.playerDamaged;
        bool            enemyDead     = data.enemyHp <= 0;
        bool            anyDamage     = enemyDamaged || playerDamaged;

        if (!enemyDead)
        {
            if (anyDamage)
            {
                AudioSource.PlayClipAtPoint(hit, Camera.main.transform.position, volume);
            }
            else
            {
                AudioSource.PlayClipAtPoint(miss, Camera.main.transform.position, volume);
            }
            SetCurrentHp(data.enemyHp);
        }
        else
        {
            EndEncounter(false);
            if (data.enemyHp <= 0)
            {
                AudioSource.PlayClipAtPoint(victory, Camera.main.transform.position, volume);
            }
        }
        waitingForServer = false;
    }
Пример #4
0
    void FightOver(FightResultData data)
    {
        Debug.LogWarning("FightOver called, may need to check for winners and/or notify teams of zero mojo dancers");

        //who won over all
        if (data.outcome >= 1)
        {
            TeamB.RemoveFromActive(RandTeamB);
        }
        else
        {
            TeamA.RemoveFromActive(RandTeamA);
        }

        Debug.Log(data.outcome);

        // play the win/lose effects
        data.winner.myTeam.EnableWinEffects();

        // remove the defeated character
        data.defeated.myTeam.RemoveFromActive(data.defeated);

        //defaulting to starting a new round to ease development
        //calling the coroutine so we can put waits in for anims to play
        StartCoroutine(HandleFightOver());
    }
Пример #5
0
    void FightOver(FightResultData data)
    {
        Debug.LogWarning("FightOver called, may need to check for winners and/or notify teams of zero mojo dancers");

        //defaulting to starting a new round to ease development
        //calling the coroutine so we can put waits in for anims to play
        StartCoroutine(HandleFightOver());
    }
Пример #6
0
    void FightOver(FightResultData data)
    {
        if (data.outcome != 0)
        {
            data.winner.myTeam.EnableWinEffects();

            data.defeated.myTeam.RemoveFromActive(data.defeated);
        }
        StartCoroutine(HandleFightOver());
    }
Пример #7
0
    IEnumerator Attack(Character lhs, Character rhs)
    {
        lhs.isSelected = true;
        rhs.isSelected = true;
        lhs.GetComponent <AnimationController>().Dance();
        rhs.GetComponent <AnimationController>().Dance();



        yield return(new WaitForSeconds(fightAnimTime));

        float outcome = 0;
        //defaulting to draw
        Character winner = lhs, defeated = rhs;


        float rhsoutcome = lhs.luck * lhs.rhythm - lhs.style / (lhs.xp + Random.Range(8, 19));

        float lhsoutcome = rhs.luck * rhs.rhythm - rhs.style / (rhs.xp + Random.Range(0, 12));

        if (lhsoutcome < rhsoutcome)
        {
            winner   = lhs;
            defeated = rhs;
            outcome  = -1;
        }
        else
        {
            winner   = rhs;
            defeated = lhs;
            outcome  = 1;
        }

        if (outcome != 0)
        {
            BattleLog.Log(new DefaultLogMessage(winner.charName.GetFullCharacterName() + "Wins", winner.myTeam.teamColor));
        }
        else
        {
            //draw
            BattleLog.Log(new DefaultLogMessage(lhs.charName.GetFullCharacterName() + "ties with" + rhs.charName.GetFullCharacterName(), drawCol));
        }
        // Debug.LogWarning("Attack called, needs to use character stats to determine winner with win strength from 1 to -1. This can most likely be ported from previous brief work.");


        //Debug.LogWarning("Attack called, may want to use the BattleLog to report the dancers and the outcome of their dance off.");

        var results = new FightResultData(winner, defeated, outcome);

        lhs.isSelected = false;
        rhs.isSelected = false;
        GameEvents.FightCompleted(results);

        yield return(null);
    }
Пример #8
0
    void FightOver(FightResultData data)
    {
        data.defeated.myTeam.RemoveFromActive(data.defeated);
        data.winner.myTeam.EnableWinEffects();

        //Debug.LogWarning("FightOver called, may need to check for winners and/or notify teams of zero mojo dancers");

        //defaulting to starting a new round to ease development
        //calling the coroutine so we can put waits in for anims to play
        StartCoroutine(HandleFightOver());
    }
Пример #9
0
    /// <summary>
    /// Passes in a winning character, and a defeated character, as well as the outcome between -1 and 1
    /// </summary>
    /// <param name="winner"></param>
    /// <param name="defeated"></param>
    /// <param name="outcome"></param>
    private void FightCompleted(Character winner, Character defeated, float outcome)
    {
        var results = new FightResultData(winner, defeated, outcome);

        winner.isSelected   = false;
        defeated.isSelected = false;

        battleSystem.FightOver(winner, defeated, outcome);
        winner.animController.BattleResult(winner, defeated, outcome);
        defeated.animController.BattleResult(winner, defeated, outcome);
    }
Пример #10
0
    void FightOver(FightResultData data)
    {
        if (data.outcome != 0)
        {
            data.winner.myTeam.EnableWinEffects();

            data.defeated.myTeam.RemoveFromActive(data.defeated);

            //this code is in charge of playing the effects of a victory when the battle is over, it also removes players from the defeated team.
        }
        StartCoroutine(HandleFightOver());
    }
Пример #11
0
    // In this script there is a dance off results between dancers.
    IEnumerator Attack(Character lhs, Character rhs)
    {
        lhs.isSelected = true;
        rhs.isSelected = true;
        lhs.GetComponent <AnimationController>().Dance();
        rhs.GetComponent <AnimationController>().Dance();

        float lhsresult;
        float rhsresult;
        float outcome;

        yield return(new WaitForSeconds(fightAnimTime));

        lhsresult = Random.Range(-1.0f, (lhs.luck * Random.Range(-1, lhs.luck)) + (1 / (lhs.rhythm * lhs.style + 1)) + 1);
        rhsresult = Random.Range(-1.0f, (rhs.luck * Random.Range(-1, rhs.luck)) + (1 / (rhs.rhythm * rhs.style + 1)) + 1);

        Character winner = lhs, defeated = rhs;

        if (lhsresult > rhsresult)
        {
            winner   = lhs;
            defeated = rhs;
            outcome  = lhsresult;
        }
        else
        {
            winner   = rhs;
            defeated = lhs;
            outcome  = rhsresult;
        }


        BattleLog.Log(new DefaultLogMessage("the winner character is " + winner.charName.GetFullCharacterName(), winner.myTeam.teamColor));
        BattleLog.Log(new DefaultLogMessage("the loser character is " + defeated.charName.GetFullCharacterName(), defeated.myTeam.teamColor));

        //defaulting to draw
        //Debug.LogWarning("Attack called, needs to use character stats to determine winner with win strength from 1 to -1. This can most likely be ported from previous brief work.");


        //Debug.LogWarning("Attack called, may want to use the BattleLog to report the dancers and the outcome of their dance off.");


        var results = new FightResultData(winner, defeated, outcome);

        lhs.isSelected = false;
        rhs.isSelected = false;
        GameEvents.FightCompleted(results);


        yield return(null);
    }
Пример #12
0
    IEnumerator Attack(Character lhs, Character rhs)
    {
        lhs.isSelected = true;
        rhs.isSelected = true;
        lhs.GetComponent <AnimationController>().Dance();
        rhs.GetComponent <AnimationController>().Dance();

        yield return(new WaitForSeconds(fightAnimTime));

        float outcome = 0;
        //defaulting to draw
        Character winner = lhs, defeated = rhs;

        //Debug.LogWarning("Attack called, needs to use character stats to determine winner with win strength from 1 to -1. This can most likely be ported from previous brief work.");
        outcome = (rhs.rhythm / rhs.style + rhs.luck) - (lhs.rhythm / lhs.style + lhs.luck);
        outcome = Mathf.Clamp(outcome, -1f, 1f);
        if (outcome > 0)
        {
            winner   = rhs;
            defeated = lhs;
        }
        else if (outcome < 0)
        {
            winner   = lhs;
            defeated = rhs;
        }
        else
        {
            Debug.Log("It's a draw");
        }

        if (outcome != 0)
        {
            BattleLog.Log(new DefaultLogMessage(winner.charName.GetFullCharacterName() + " is the Winnner!", winner.myTeam.teamColor));
        }
        else
        {
            BattleLog.Log(new DefaultLogMessage(lhs.charName.GetFullCharacterName() + " ties with " + rhs.charName.GetFullCharacterName(), drawCol));
        }

        var results = new FightResultData(winner, defeated, outcome);

        lhs.isSelected = false;
        rhs.isSelected = false;
        GameEvents.FightCompleted(results);

        yield return(null);
    }
Пример #13
0
 public void BattleResult(FightResultData data)
 {
     if (data.winner.gameObject == gameObject)
     {
         anim.SetTrigger("Win");
     }
     else if (data.defeated.gameObject == gameObject)
     {
         if (data.outcome == 0)
         {
             anim.SetTrigger("Win");
         }
         else
         {
             anim.SetTrigger("Lose");
         }
     }
 }
Пример #14
0
    void FightOver(FightResultData data)
    {
        Debug.LogWarning("FightOver called, may need to check for winners and/or notify teams of zero mojo dancers");

        // TODO - check if the battle is over
        // ONLY do the win effects and remove from active
        // if the outcome is valid (ie. not for a draw)
        Debug.Log(data.outcome);

        // play the win/lose effects
        data.winner.myTeam.EnableWinEffects();

        // remove the defeated character
        data.defeated.myTeam.RemoveFromActive(data.defeated);

        //defaulting to starting a new round to ease development
        //calling the coroutine so we can put waits in for anims to play
        StartCoroutine(HandleFightOver());
    }
    IEnumerator Attack(Character lhs, Character rhs)
    {
        lhs.isSelected = true;
        rhs.isSelected = true;
        lhs.GetComponent <AnimationController>().Dance();
        rhs.GetComponent <AnimationController>().Dance();

        yield return(new WaitForSeconds(fightAnimTime));

        //calulating the luck values for lhs and rhs
        int lhsLuck = Random.Range(0, lhs.luck + 1);
        int rhsLuck = Random.Range(0, rhs.luck + 1);

        //Debug.Log(lhsLuck);
        //Debug.Log(rhsLuck);

        //Calulating the lhs and rhs total battle number
        int lhsResult = lhs.rhythm + lhs.style * lhsLuck;
        int rhsResult = rhs.rhythm + rhs.style * rhsLuck;

        //Debug.Log(lhsResult);
        //Debug.Log(rhsResult);

        float     outcome = 1;
        Character winner = lhs, defeated = rhs;

        //Lhs wins
        if (lhsResult > rhsResult)
        {
            outcome  = 1;
            winner   = lhs;
            defeated = rhs;
            Debug.Log("lhs wins");
        }

        //Rhs wins
        else
        {
            outcome  = -1;
            winner   = rhs;
            defeated = lhs;
            Debug.Log("rhs wins");
        }

        Debug.Log(outcome);



        Debug.LogWarning("Attack called, needs to use character stats to determine winner with win strength from 1 to -1. This can most likely be ported from previous brief work.");


        Debug.LogWarning("Attack called, may want to use the BattleLog to report the dancers and the outcome of their dance off.");

        var results = new FightResultData(winner, defeated, outcome);

        lhs.isSelected = false;
        rhs.isSelected = false;
        GameEvents.FightCompleted(results);

        yield return(null);
    }
Пример #16
0
    IEnumerator Attack(Character lhs, Character rhs)
    {
        lhs.isSelected = true;
        rhs.isSelected = true;
        lhs.GetComponent <AnimationController>().Dance();
        rhs.GetComponent <AnimationController>().Dance();

        yield return(new WaitForSeconds(fightAnimTime));

        int       outcome = 0;
        Character winner = lhs, defeated = rhs;

        // Roll a random 6 sided die.
        int d6 = Random.Range(1, 7);
        //Debug.Log(d6 + " d6");

        // Get a temporary variable to store the rhythm and style for the player and NPC.
        int tempPlayerRhythm = lhs.rhythm;
        int tempPlayerStyle  = lhs.style;
        int tempNpcRhytm     = rhs.rhythm;
        int tempNpcStyle     = rhs.style;

        // If the dice roll is less than 3...
        if (d6 < 3)
        {
            // ...Increase the players temporary rhythm and style by one, resulting in the player winning.
            tempPlayerRhythm += 1;
            tempPlayerStyle  += 1;

            /*Debug.Log(tempPlayerRhythm + " tpr");
             * Debug.Log(tempPlayerStyle + " tps");*/
        }
        // else if the dice roll is greater than 3...
        else if (d6 > 3)
        {
            // Increase the NPC's temporary rhythm and style by one, resulting in the NPC winning.
            tempNpcRhytm += 1;
            tempNpcStyle += 1;

            /*Debug.Log(tempNpcRhytm + " tnr");
            *  Debug.Log(tempNpcStyle + " tns");*/
        }
        else
        {
            // It's a draw :)
            tempPlayerRhythm += Random.Range(0, 2);
            tempPlayerStyle  += Random.Range(0, 2);
            tempNpcRhytm     += Random.Range(0, 2);
            tempNpcStyle     += Random.Range(0, 2);

            /*Debug.Log(tempPlayerRhythm + " tpr");
             * Debug.Log(tempPlayerStyle + " tps");
             * Debug.Log(tempNpcRhytm + " tnr");
             * Debug.Log(tempNpcStyle + " tns ");*/
        }

        // Your code between here

        // Set outcome to 1 if the player won
        if (tempPlayerRhythm > tempNpcRhytm || tempPlayerStyle > tempNpcStyle && lhs.luck > rhs.luck)
        {
            outcome  = 1;
            winner   = lhs;
            defeated = rhs;
            Debug.Log("lhs");
        }
        // Set outcome to -1 if the player lost
        else if (tempPlayerRhythm < tempNpcRhytm && tempPlayerStyle < tempNpcStyle && rhs.luck > lhs.luck)
        {
            outcome  = 0;
            winner   = rhs;
            defeated = lhs;
            Debug.Log("rhs");
        }

        //else if (tempPlayerRhythm == tempNpcRhytm && lhs.luck == rhs.luck && tempPlayerStyle == tempNpcStyle)
        //outcome = 0;


        // I do not like this setup and I want to change how I determine a winner.

        //defaulting to draw
        Debug.LogWarning("Attack called, needs to use character stats to determine winner with win strength from 1 to -1. This can most likely be ported from previous brief work.");

        Debug.LogWarning("Attack called, may want to use the BattleLog to report the dancers and the outcome of their dance off.");

        var results = new FightResultData(winner, defeated, outcome);

        lhs.isSelected = false;
        rhs.isSelected = false;
        GameEvents.FightCompleted(results);

        yield return(null);
    }
Пример #17
0
    IEnumerator Attack(Character lhs, Character rhs)
    {
        lhs.isSelected = true;
        rhs.isSelected = true;
        lhs.GetComponent <AnimationController>().Dance();
        rhs.GetComponent <AnimationController>().Dance();

        yield return(new WaitForSeconds(fightAnimTime));

        float     outcome = 0;
        Character winner = lhs, defeated = rhs;

        // Do this one second!
        // Can re-use code from Battle in BattleHandler

        //Left Win
        if ((lhs.rhythm + (lhs.style) * lhs.luck) > (rhs.rhythm + (rhs.style) * rhs.luck))
        {
            outcome = 1;
            Debug.Log("Left Wins");
        }
        //Right Win
        else if ((rhs.rhythm + (rhs.style) * rhs.luck) < (lhs.rhythm + (lhs.style) * lhs.luck))
        {
            outcome = 2;
            Debug.Log("Right Wins");
        }
        //Tie
        else
        {
            outcome = 3;
            Debug.Log("Tie");
        }

        // debug the left hand side character stats
        Debug.Log(lhs.rhythm);
        Debug.Log(lhs.style);
        Debug.Log(lhs.luck);

        if (outcome == 1)
        {
            lhs = winner;
            rhs = defeated;
        }
        else if (outcome == 2)
        {
            rhs = winner;
            lhs = defeated;
        }
        // else
        //  {
        //     rhs = winner;
        //    lhs = winner;
        // }
        //defaulting to draw
        Debug.LogWarning("Attack called, needs to use character stats to determine winner with win strength from 1 to -1. This can most likely be ported from previous brief work.");


        Debug.LogWarning("Attack called, may want to use the BattleLog to report the dancers and the outcome of their dance off.");

        var results = new FightResultData(winner, defeated, outcome);

        lhs.isSelected = false;
        rhs.isSelected = false;
        GameEvents.FightCompleted(results);

        yield return(null);
    }