Created
October 2, 2020 00:36
-
-
Save Gillissie/2d0f997eb4afc2e0d2fac4929bf810ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
/* | |
Simple class to store some data about the analysis of playing a song at a gig. | |
*/ | |
namespace gilligames | |
{ | |
public class GigSongAnalysis | |
{ | |
public string text; | |
public float interestChange; | |
public Song song; | |
private float playingAdj; | |
private float lowEnergyAdj; | |
private float highEnergyAdj; | |
public static List<GigSongAnalysis> all = new List<GigSongAnalysis>(); | |
public GigSongAnalysis(Song song, float songQualityAdj, float playingAdj, float lowEnergyAdj, float highEnergyAdj, float interestChange) | |
{ | |
this.song = song; | |
this.playingAdj = playingAdj; | |
this.lowEnergyAdj = lowEnergyAdj; | |
this.highEnergyAdj = highEnergyAdj; | |
this.interestChange = interestChange; | |
// Debug.LogFormat("Song {0}, playingPopularityAdj: {1}, interestChange: {2}", song.title, playingPopularityAdj, interestChange); | |
var sb = new System.Text.StringBuilder(); | |
if (interestChange <= 0.0f) | |
{ | |
string theString = ", the"; | |
if (song.quality > 75) | |
{ | |
sb.Append("Despite this being a very high quality song"); | |
} | |
else if (song.quality > 50) | |
{ | |
sb.Append("Despite this being a high quality song"); | |
} | |
else if (song.quality > 25) | |
{ | |
sb.Append("Despite this being a decent quality song"); | |
} | |
else | |
{ | |
theString = "The"; | |
} | |
if (!appendNegative(sb, theString)) | |
{ | |
// This probably shouldn't ever happen, since this whole block only happens when the interest level was negative. | |
sb.Append(", the audience wasn't interested."); | |
} | |
} | |
else if (playingAdj >= 5.0f) | |
{ | |
sb.Append("The audience enjoyed this song very much"); | |
if (!appendNegative(sb, ", but the")) | |
{ | |
sb.Append("."); | |
} | |
} | |
else | |
{ | |
if (!appendNegative(sb, "The")) | |
{ | |
int iconCount = getIconCount(); | |
if (song.popularityGain > 2.0f) | |
{ | |
sb.Append("Most of the audience danced to this song. It has a lot of potential."); | |
} | |
else if (song.popularityGain > 1.0f) | |
{ | |
sb.Append("Several people were tapping their feet to this song. It has potential."); | |
} | |
else if (iconCount >= 4) | |
{ | |
sb.Append("The audience loved this performance."); | |
} | |
else if (iconCount >= 2) | |
{ | |
sb.Append("The audience enjoyed this performance."); | |
} | |
else if (playingAdj > 2.0f) | |
{ | |
sb.Append("The audience casually listened and enjoyed the song."); | |
} | |
else | |
{ | |
sb.Append("The audience was hardly paying attention."); | |
} | |
} | |
else if (interestChange > 0.0f) | |
{ | |
// There was negative feedback, even though the overall interest level was positive. | |
if (GigResultsMode.stagePresenceAdj > 0.0f && GigResultsMode.stagePresenceAdj > songQualityAdj) | |
{ | |
sb.Append(" Good stage presence"); | |
if (songQualityAdj >= GigResultsMode.stagePresenceAdj * 0.5f) | |
{ | |
// Song quality contributed significantly to the positive interest. | |
sb.Append(" and high song quality"); | |
} | |
sb.Append(" helped garner some applause."); | |
} | |
else if (songQualityAdj > 0.0f && songQualityAdj > GigResultsMode.stagePresenceAdj) | |
{ | |
sb.Append(" High song quality"); | |
if (GigResultsMode.stagePresenceAdj >= songQualityAdj * 0.5f) | |
{ | |
// Stage presence contributed significantly to the positive interest. | |
sb.Append(" and good stage presence"); | |
} | |
sb.Append(" helped garner some applause."); | |
} | |
} | |
} | |
text = sb.ToString(); | |
all.Add(this); | |
} | |
// Returns the number of happy or sad face icons earned for this song's performance. | |
// Positive value means happy, negative value means sad. For example, -5 means 5 sad faces. | |
public int getIconCount() | |
{ | |
int count = Mathf.Min(5, Mathf.CeilToInt(Mathf.Abs(interestChange / 3.0f))); | |
if (interestChange < 0.0f) | |
{ | |
count = -count; | |
} | |
return count; | |
} | |
// Adds the negative part about this song's performance. | |
// Returns false if nothing negative was added. | |
private bool appendNegative(System.Text.StringBuilder sb, string prefix) | |
{ | |
if (lowEnergyAdj < 0.0f) | |
{ | |
sb.Append(prefix); | |
sb.Append(" audience had a lot of energy to release when you played this low energy song, so they were bored."); | |
return true; | |
} | |
else if (highEnergyAdj < 0.0f) | |
{ | |
sb.Append(prefix); | |
if (interestChange < 0.0f) | |
{ | |
sb.Append(" audience had little or no energy left when you played this high energy song, so they were not into it."); | |
} | |
else | |
{ | |
sb.Append(" audience wanted to exert more energy on this song than they had, so it didn't live up to its potential."); | |
} | |
return true; | |
} | |
else if (playingAdj <= 0.0f) | |
{ | |
sb.Append(prefix); | |
sb.Append(" audience wasn't impressed with your low playing skill."); | |
return true; | |
} | |
return false; | |
} | |
public static void cleanupAll() | |
{ | |
all.Clear(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment