Esempio n. 1
0
    public static void Battle(BattleEventData data)
    {
        playerPoints = data.player.ReturnBattlePoints();
        npcPoints    = data.npc.ReturnBattlePoints();

        if (playerPoints <= 0 || npcPoints <= 0)
        {
            Debug.LogWarning("Player or NPC battle points is 0, most likely the logic has not be setup for this yet");
        }

        // if the player wins then the battle outcome is 1
        // if the npc has won, then the battle outcome is -1
        // otherwise the outcome is 0 and its a draw;
        battleOutcome = 1;
        if (playerPoints > npcPoints)
        {
            Debug.Log("This is Ture")
        }
        else
        {
            // we probably want to do some sort of check here to see if the player has won...rather than assigning xp everytime.
            // if so set points.
            data.player.CalculateXP(battleOutcome);
        }
        battleOutcome = 1;
        // If we wanted to we could also work out if the npc has won or if there is a draw!

        var results = new BattleResultEventData(data.player, data.npc, battleOutcome);

        GameEvents.FinishedBattle(results);
    }
Esempio n. 2
0
 public static void FinishedBattle(BattleResultEventData data)
 {
     if (OnBattleConclude != null)
     {
         OnBattleConclude(data);
     }
 }
    public void GainXP(BattleResultEventData data)
    {
        //Checking outcome and the data for xp, and debug logging it
        Debug.Log(data.outcome);
        Debug.Log(data.Xp);
        Debug.Log(data.player.xp);
        Debug.Log(data.npc.xp);

        if (data.outcome == 1)
        {
            data.player.xp += data.Xp;
            Debug.Log("Player has gained " + data.player.xp + "Xp");
            //if outcome = 1 add xp to the player and debug how much you gained
        }

        if (data.player.xp >= 100 + (data.player.level * 50))
        {
            data.player.level += 1;
            //add 1 to the player level
            GameEvents.PlayerLevelUp(data.player.level);
            //broadcast level up message
            Debug.Log("Player has level is " + data.player.level);
            //debug which level the player is
            int numPoints = 5;
            StatsGenerator.AssignUnusedPoints(data.player, 5);
            // assign 5 points each time
            data.player.xp = 0;
            //set xp back to 0
        }
    }
    public static void Battle(BattleEventData data)
    {
        //This needs to be replaced with some actual battle logic, at present
        // we just award the maximum possible win to the player
        float outcome = 1;

        Debug.Log(data.player.style);
        Debug.Log(data.player.rhythm);
        Debug.Log(data.player.luck);

        int playerstats = (data.player.rhythm + data.player.style) + (Random.Range(1, data.player.luck));
        int npcstats    = (data.npc.rhythm + data.npc.style) + (Random.Range(1, data.player.luck));

        if (playerstats > npcstats)
        {
            outcome = 1;
        }

        else if (playerstats < npcstats)
        {
            outcome = 0;
        }


        var results = new BattleResultEventData(data.player, data.npc, outcome);

        GameEvents.FinishedBattle(results);
    }
Esempio n. 5
0
    public void GainXP(BattleResultEventData data)
    {
        Debug.Log(data.outcome);

        Debug.Log(data.player.level);
        Debug.Log(data.player.xp);

        //checking if player won and then assigning xp
        if (data.outcome == 1)
        {
            data.player.xp += 10;
        }

        else
        {
            data.player.xp += 2;
        }

        if (data.player.xp >= xpRequired)
        {
            data.player.level++;
            Debug.Log("Level is now: " + data.player.level);
            int pointsToAdd = 10;
            StatsGenerator.AssignUnusedPoints(data.player, pointsToAdd);
            GameEvents.PlayerLevelUp(data.player.level);
            xpRequired += (xpRequired * (data.player.level / 2));
            Debug.Log(xpRequired);
        }

        // if data.outcome is 1 then player won, otherwise player lost
    }
Esempio n. 6
0
 public void GainXP(BattleResultEventData data)
 {
     if (data.outcome > 0)
     {
         Debug.Log("You Gained 100 XP!");
     }
 }
Esempio n. 7
0
 public void BattleResult(BattleResultEventData data)
 {
     if (data.outcome >= 0)
     {
         source.PlayOneShot(playerWins);
     }
     else
     {
         source.PlayOneShot(playerLoses);
     }
 }
    public void BattleResult(BattleResultEventData data)
    {
        float won = data.player.gameObject == gameObject ? data.outcome : data.outcome * -1;

        if (won > 0)
        {
            anim.SetTrigger("Win");
        }
        else
        {
            anim.SetTrigger("Lose");
        }
    }
Esempio n. 9
0
    public static void Battle(BattleEventData data)
    {
        //This needs to be replaced with some actual battle logic, at present
        // we just award the maximum possible win to the player

        float outcome = data.player.luck + data.player.xp - data.player.style * data.player.rhythm + Random.Range(-2, 10) + Random.Range(5, 10);

        Debug.Log(outcome);



        var results = new BattleResultEventData(data.player, data.npc, outcome);

        GameEvents.FinishedBattle(results);
    }
Esempio n. 10
0
    public static void Battle(BattleEventData data)
    {
        playerPoints = data.player.ReturnBattlePoints();
        npcPoints    = data.npc.ReturnBattlePoints();

        if (playerPoints <= 0 || npcPoints <= 0)
        {
            Debug.LogWarning("Player or NPC battle points is 0, most likely the logic has not be setup for this yet");
        }

        if (playerPoints > npcPoints)
        {
            Debug.Log("Player has won with" + playerPoints + "points!");
            battleOutcome = 1 - ((float)npcPoints / (float)playerPoints);
            data.player.CalculateXP(battleOutcome);
            battleOutcome = 1;
        }
        else if (npcPoints > playerPoints)
        {
            Debug.Log("NPC has won with" + npcPoints + "points!");
            battleOutcome = 1 - ((float)playerPoints / (float)npcPoints);
            data.npc.CalculateXP(battleOutcome);
            battleOutcome = -1;
        }
        else if (npcPoints == playerPoints)
        {
            Debug.Log("It's a draw!");
            battleOutcome = 0.1f;
            data.player.CalculateXP(battleOutcome);
            data.npc.CalculateXP(battleOutcome);
            battleOutcome = 0;
        }
        else
        {
            Debug.LogWarning("Player or NPC battle points is 0, most likely something has gone wrong with the logic");
        }

        // if the player wins then the battle outcome is 1
        // we probably want to do some sort of check here to see if the player has won...rather than assigning xp everytime.
        // if so set points.
        // If we wanted to we could also work out if the npc has won or if there is a draw!

        var results = new BattleResultEventData(data.player, data.npc, battleOutcome);

        GameEvents.FinishedBattle(results);
    }
Esempio n. 11
0
    public static void Battle(BattleEventData data)
    {
        //This needs to be replaced with some actual battle logic, at present
        // we just award the maximum possible win to the player
        float outcome = 1;


        //Luck is randomised every battle
        int roundsLuckStat = (Random.Range(1, 101));

        Debug.Log("luck to beat = " + roundsLuckStat);

        //checks level

        //battlescore assigned and compared
        int npcBattleScore = data.npc.rhythm + data.npc.style;
        int pcBattleScore  = data.player.rhythm + data.player.style;

        Debug.Log("pc = " + pcBattleScore);
        Debug.Log("npc = " + npcBattleScore);
        //check for luck
        if (data.npc.luck >= roundsLuckStat)
        {
            npcBattleScore = npcBattleScore * data.npc.luck;
        }
        if (data.player.luck >= roundsLuckStat)
        {
            pcBattleScore = pcBattleScore * data.player.luck;
        }

        //check for win
        if (pcBattleScore > npcBattleScore)
        {
            outcome = 1;
        }
        if (npcBattleScore > pcBattleScore)
        {
            outcome = 0;
        }
        var results = new BattleResultEventData(data.player, data.npc, outcome);

        GameEvents.FinishedBattle(results);
    }
Esempio n. 12
0
    public static void Battle(BattleEventData data)
    {
        //This needs to be replaced with some actual battle logic, at present
        // we just award the maximum possible win to the player

        float outcome = 0;

        if (data.player.totalstats > data.npc.totalstats)
        {
            outcome = Random.Range(0.1f, 1);
        }
        if (data.player.totalstats < data.npc.totalstats)
        {
            outcome = Random.Range(-1, -0.1f);
        }
        if (data.player.totalstats == data.npc.totalstats)
        {
            outcome = 0;
        }
        var results = new BattleResultEventData(data.player, data.npc, outcome);

        GameEvents.FinishedBattle(results);
    }
Esempio n. 13
0
    public void GainXP(BattleResultEventData data)
    {
        //sets xp to zero (does not effect previous file)
        data.player.xp = 0;
        //tries to read the xp from text file
        try
        {
            data.player.xp = System.Convert.ToInt32(System.IO.File.ReadAllText("xp.txt"));
        }
        catch
        {
        }

        //adds xp based on win
        if (data.outcome == 1)
        {
            data.player.xp += 20;
            Debug.Log("win");
            Debug.Log(data.player.xp);
        }
        if (data.outcome == 0)
        {
            data.player.xp += 10;
            Debug.Log("lose");
            Debug.Log(data.player.xp);
        }

        //checks level based on total xp
        if (data.player.xp >= 100 && data.player.level < 2)
        {
            data.player.level += 1;
            GameEvents.PlayerLevelUp(data.player.level);
            StatsGenerator.AssignUnusedPoints(data.player, 10);
            Debug.Log("Level Up");
        }
        if (data.player.xp >= 200 && data.player.level < 3)
        {
            data.player.level += 1;
            GameEvents.PlayerLevelUp(data.player.level);
            StatsGenerator.AssignUnusedPoints(data.player, 10);
            Debug.Log("Level Up");
        }
        if (data.player.xp >= 300 && data.player.level < 4)
        {
            data.player.level += 1;
            GameEvents.PlayerLevelUp(data.player.level);
            StatsGenerator.AssignUnusedPoints(data.player, 10);
            Debug.Log("Level Up");
        }
        if (data.player.xp >= 500 && data.player.level < 5)
        {
            data.player.level += 1;
            GameEvents.PlayerLevelUp(data.player.level);
            StatsGenerator.AssignUnusedPoints(data.player, 10);
            Debug.Log("Level Up");
        }
        if (data.player.xp >= 800 && data.player.level < 6)
        {
            data.player.level += 1;
            GameEvents.PlayerLevelUp(data.player.level);
            StatsGenerator.AssignUnusedPoints(data.player, 10);
            Debug.Log("Level Up");
        }
        if (data.player.xp >= 1300 && data.player.level < 7)
        {
            data.player.level += 1;
            GameEvents.PlayerLevelUp(data.player.level);
            StatsGenerator.AssignUnusedPoints(data.player, 10);
            Debug.Log("Level Up");
        }
        if (data.player.xp >= 2100 && data.player.level < 8)
        {
            data.player.level += 1;
            GameEvents.PlayerLevelUp(data.player.level);
            StatsGenerator.AssignUnusedPoints(data.player, 10);
            Debug.Log("Level Up");
        }
        if (data.player.xp >= 3400 && data.player.level < 9)
        {
            data.player.level += 1;
            GameEvents.PlayerLevelUp(data.player.level);
            StatsGenerator.AssignUnusedPoints(data.player, 10);
            Debug.Log("Level Up");
        }
        if (data.player.xp >= 5500 && data.player.level < 10)
        {
            data.player.level += 1;
            GameEvents.PlayerLevelUp(data.player.level);
            StatsGenerator.AssignUnusedPoints(data.player, 10);
            Debug.Log("Level Up");
        }
        System.IO.File.WriteAllText("xp.txt", System.Convert.ToString(data.player.xp));
        System.IO.File.WriteAllText("level.txt", System.Convert.ToString(data.player.level));
    }
Esempio n. 14
0
 public void GainXP(BattleResultEventData data)
 {
     data.player.xp = data.player.xp + (int)((data.outcome * 100) / data.player.level);
 }
Esempio n. 15
0
 private void GameEvents_OnBattleConclude(BattleResultEventData data)
 {
     GainXP(data);
 }
    public static void Battle(BattleEventData data)
    {
        //This needs to be replaced with some actual battle logic, at present
        // we just award the maximum possible win to the player
        float outcome = 1;

        data.player.luck = Random.Range(1, 7);
        data.npc.luck    = Random.Range(1, 7);
        //Randomise the luck every time battle begins
        float playerBoogie = data.player.rhythm + data.player.style * 2 + data.player.luck * 2;
        float npcBoogie    = data.npc.rhythm + data.npc.style * 2 + data.npc.luck * 2;
        //Find boogie power by using formula (rhythm + style *2 + luck * 2)
        int XpOutcome = Mathf.RoundToInt(playerBoogie - npcBoogie);
        //round xp to a int not float
        int Xp = 0;

        // your code between here
        data.player.luck = Random.Range(1, 7);
        data.npc.luck    = Random.Range(1, 7);
        //Randomise the luck every time battle begins

        Debug.Log("Enemy Rhythm = " + data.npc.rhythm);
        Debug.Log("Enemy Style = " + data.npc.style);
        Debug.Log("Enemy Luck = " + data.npc.luck);
        Debug.Log("Enemy Boogie Power = " + npcBoogie);
        //Debug npc's stats

        Debug.Log("Player Rhythm = " + data.player.rhythm);
        Debug.Log("Player Style = " + data.player.style);
        Debug.Log("Player Luck = " + data.player.luck);
        Debug.Log("Player Boogie Power = " + playerBoogie);
        //Debug Player's Stats



        if (playerBoogie > npcBoogie)
        {
            outcome = 1;
            Debug.Log("Player wins the dance battle");
        }
        else if (playerBoogie < npcBoogie)
        {
            outcome = 0;
            Debug.Log("Player loses the dance battle");
        }
        else if (playerBoogie == npcBoogie)
        {
            Debug.Log("Player has drawn with the npc");
        }
        //figure out if player has won, lose, or drawn

        if (XpOutcome == 0 || XpOutcome == 1 || XpOutcome == 2)
        {
            Xp = Random.Range(10, 21);
        }
        else if (XpOutcome == 3 || XpOutcome == 4 || XpOutcome == 5)
        {
            Xp = Random.Range(20, 26);
        }
        else if (XpOutcome == 6 || XpOutcome == 7 || XpOutcome == 8 || XpOutcome == 9)
        {
            Xp = Random.Range(25, 36);
        }
        else if (XpOutcome == 10)
        {
            Xp = Random.Range(35, 51);
        }
        //assign xp based on how well the player performed

        var results = new BattleResultEventData(data.player, data.npc, outcome, Xp);

        Debug.Log("Player has attained " + Xp + " Xp");
        Debug.Log("Xp Outcome = " + XpOutcome);
        GameEvents.FinishedBattle(results);
        //Debug log and round up the code
    }