public (Character attacker, Character defender) StartFight(int userId, int selectedCharId, int targetUserId, int selectedTargetCharId) { UserDbEntity u = _userRepository.GetAll().Include(x => x.Characters).FirstOrDefault(x => x.Id == userId); CharacterDbEntity uc = u.Characters.FirstOrDefault(x => x.Id == selectedCharId); UserDbEntity tu = _userRepository.GetAll().Include(x => x.Characters).FirstOrDefault(x => x.Id == targetUserId); CharacterDbEntity tuc = tu.Characters.FirstOrDefault(x => x.Id == selectedTargetCharId); FightResult result = _fightManager.Fight(uc, tuc); _userRepository.Update(result.TargetChar.User); Character attackerChar = uc.Build(); Character targetChar = tuc.Build(); return(attackerChar, targetChar); }
public float fightCompletedWaitTime = 2; // the amount of time we need to wait till a fight/round is completed. /// <summary> /// This occurs every round or every X number of seconds, is the core battle logic/game loop. /// </summary> /// <returns></returns> IEnumerator DoRound() { // waits for a float number of seconds.... yield return(new WaitForSeconds(battlePrepTime)); //checking for no dancers on either team if (teamA.allDancers.Count == 0 && teamB.allDancers.Count == 0) { Debug.LogWarning("DoRound called, but there are no dancers on either team. DanceTeamInit needs to be completed"); // This will be called if there are 0 dancers on both teams. } else if (teamA.activeDancers.Count > 0 && teamB.activeDancers.Count > 0) { Debug.LogWarning("DoRound called, it needs to select a dancer from each team to dance off and put in the FightEventData below"); //Randomly select two characters, one from each team Character characterA = teamA.activeDancers[Random.Range(0, teamA.activeDancers.Count)]; Character characterB = teamB.activeDancers[Random.Range(0, teamB.activeDancers.Count)]; //Make them fight fightManager.Fight(characterA, characterB); } else { DanceTeam winner; if (teamA.activeDancers.Count > 0) { winner = teamA; } else { winner = teamB; } //Enables the win effects, and logs it out to the console. winner.EnableWinEffects(); BattleLog.Log(winner.ToString(), winner.teamColor); Debug.Log("DoRound called, but we have a winner so Game Over"); } }
public float fightCompletedWaitTime = 2; // the amount of time we need to wait till a fight/round is completed. /// <summary> /// This occurs every round or every X number of seconds, is the core battle logic/game loop. /// </summary> /// <returns></returns> IEnumerator DoRound() { // waits for a float number of seconds.... yield return(new WaitForSeconds(battlePrepTime)); //checking for no dancers on either team if (teamA.allDancers.Count == 0 && teamB.allDancers.Count == 0) { Debug.LogWarning("DoRound called, but there are no dancers on either team. DanceTeamInit needs to be completed"); // This will be called if there are 0 dancers on both teams. } else if (teamA.activeDancers.Count > 0 && teamB.activeDancers.Count > 0) { Debug.LogWarning("DoRound called, it needs to select a dancer from each team to dance off and put in the FightEventData below"); //You need to select two random or engineered random characters to fight...so one from team a and one from team b.... //We then need to pass in the two selected dancers into fightManager.Fight(CharacterA,CharacterB); //fightManager.Fight(charA, charB); Character characterA = teamA.activeDancers[Random.Range(0, teamA.activeDancers.Count)]; Character characterB = teamB.activeDancers[Random.Range(0, teamB.activeDancers.Count)]; fightManager.Fight(characterA, characterB); } else { // IF we get to here...then we have a team has won...winner winner chicken dinner // We need to determine a winner...but how?...maybe look at the previous if statements for clues? if (teamA.activeDancers.Count > 0 && teamB.activeDancers.Count == 0) { teamA.EnableWinEffects(); BattleLog.Log(teamA.danceTeamName, teamA.teamColor); } else if (teamB.activeDancers.Count > 0 && teamA.activeDancers.Count == 0) { teamB.EnableWinEffects(); BattleLog.Log(teamB.danceTeamName, teamB.teamColor); } Debug.Log("DoRound called, but we have a winner so Game Over"); } }
public float fightCompletedWaitTime = 2; // the amount of time we need to wait till a fight/round is completed. /// <summary> /// This occurs every round or every X number of seconds, is the core battle logic/game loop. /// </summary> /// <returns></returns> IEnumerator DoRound() { // waits for a float number of seconds.... yield return(new WaitForSeconds(battlePrepTime)); //checking for no dancers on either team if (teamA.allDancers.Count == 0 && teamB.allDancers.Count == 0) { Debug.LogWarning("DoRound called, but there are no dancers on either team. DanceTeamInit needs to be completed"); // This will be called if there are 0 dancers on both teams. } else if (teamA.activeDancers.Count > 0 && teamB.activeDancers.Count > 0) { Debug.LogWarning("DoRound called, it needs to select a dancer from each team to dance off and put in the FightEventData below"); //Randomly chooses team members to compete against each other Character teamAChosenOne = teamA.activeDancers[Random.Range(0, teamA.activeDancers.Count)]; Character teamBChosenOne = teamB.activeDancers[Random.Range(0, teamB.activeDancers.Count)]; fightManager.Fight(teamAChosenOne, teamBChosenOne); } else { //Sets the winning team based off who still has dancers. DanceTeam winner = null; if (teamA.activeDancers.Count > 0) { winner = teamA; } else if (teamB.activeDancers.Count > 0) { winner = teamB; } //Enables the win effects, and logs it out to the console. winner.EnableWinEffects(); BattleLog.Log(winner.ToString(), winner.teamColor); Debug.Log("DoRound called, but we have a winner so Game Over"); } }