diff --git a/Assets/Resources/ScriptableObjectsData/Form/Realtime Generation With Quests/PreTestEN/RealtimePreTestQuestionnaireEN.asset b/Assets/Resources/ScriptableObjectsData/Form/Realtime Generation With Quests/PreTestEN/RealtimePreTestQuestionnaireEN.asset index 89285dd8..dd85c5f9 100644 --- a/Assets/Resources/ScriptableObjectsData/Form/Realtime Generation With Quests/PreTestEN/RealtimePreTestQuestionnaireEN.asset +++ b/Assets/Resources/ScriptableObjectsData/Form/Realtime Generation With Quests/PreTestEN/RealtimePreTestQuestionnaireEN.asset @@ -17,3 +17,14 @@ MonoBehaviour: - {fileID: 11400000, guid: b4f789a6f0c9c3341b386f997bf397e8, type: 2} - {fileID: 11400000, guid: 93c7f812d092b4f4ead10ddbbedabccc, type: 2} - {fileID: 11400000, guid: ef917d202211f524584c568f5d00663f, type: 2} + - {fileID: 11400000, guid: acd367862a546914980ef80ff61cb659, type: 2} + - {fileID: 11400000, guid: cb51c738830e4d44eb861eb666fc4630, type: 2} + - {fileID: 11400000, guid: 0d363b077e63be44c8c9b3732db59f2d, type: 2} + - {fileID: 11400000, guid: 69e1d13fe097e4048ac16ade13f571b0, type: 2} + - {fileID: 11400000, guid: b5bc0f9642e703845a7c8a8586ae5f39, type: 2} + - {fileID: 11400000, guid: 6119feedac4d2504cb12c543f3548d3a, type: 2} + - {fileID: 11400000, guid: 05366e436dfc0a440a1796626c52abc2, type: 2} + - {fileID: 11400000, guid: 2e5e3b699f4b9b54ab135d06070c612a, type: 2} + - {fileID: 11400000, guid: 781bbc2d141deea44b56dadda3001054, type: 2} + - {fileID: 11400000, guid: 28fe42cb4108f1246862bd32e8f676ed, type: 2} + - {fileID: 11400000, guid: 7278803a23487b24083fa3f36872008d, type: 2} diff --git a/Assets/Resources/ScriptableObjectsData/GeneratorSettings.asset b/Assets/Resources/ScriptableObjectsData/GeneratorSettings.asset index 6743e431..24d09fcf 100644 --- a/Assets/Resources/ScriptableObjectsData/GeneratorSettings.asset +++ b/Assets/Resources/ScriptableObjectsData/GeneratorSettings.asset @@ -17,7 +17,7 @@ MonoBehaviour: k__BackingField: {x: 20, y: 20} k__BackingField: 1 k__BackingField: 1 - k__BackingField: 0 + k__BackingField: 1 k__BackingField: 50 k__BackingField: 1 k__BackingField: diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index dc3a6f4f..cbe99a2b 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -960,7 +960,7 @@ PrefabInstance: - target: {fileID: 3829912036086566212, guid: c1496f6ed7dad834a8f8428a619dfdd6, type: 3} propertyPath: IsInPortuguese - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 3829912036086566212, guid: c1496f6ed7dad834a8f8428a619dfdd6, type: 3} @@ -993,6 +993,12 @@ PrefabInstance: propertyPath: m_Enabled value: 1 objectReference: {fileID: 0} + - target: {fileID: 3829912036086566238, guid: c1496f6ed7dad834a8f8428a619dfdd6, + type: 3} + propertyPath: generatorSettings + value: + objectReference: {fileID: 11400000, guid: 500aa46dd0ecb4f4e9a7a73772c2a4ad, + type: 2} - target: {fileID: 3829912036086566238, guid: c1496f6ed7dad834a8f8428a619dfdd6, type: 3} propertyPath: dungeonEntrances.Array.size diff --git a/Assets/Scripts/Game/DataCollection/DungeonData.cs b/Assets/Scripts/Game/DataCollection/DungeonData.cs index de8cfd1c..fa92134b 100644 --- a/Assets/Scripts/Game/DataCollection/DungeonData.cs +++ b/Assets/Scripts/Game/DataCollection/DungeonData.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using Game.LevelManager.DungeonLoader; +using Game.GameManager; using Overlord.ProfileAnalyst; using UnityEngine; using Util; @@ -18,6 +19,11 @@ namespace Game.DataCollection [Serializable] public class DungeonData : ScriptableObject { + +#if !UNITY_WEBGL || UNITY_EDITOR + [FirestoreProperty] +#endif + [field: SerializeField] public bool PlayerHadFixedProfile { get; set; } #if !UNITY_WEBGL || UNITY_EDITOR [FirestoreProperty] #endif @@ -287,6 +293,7 @@ public void Init(Map map, string mapName, string jsonPath, int playerId) TotalReadableItems += map.TotalReadableItems; HeatMap = CreateHeatMap(map); TotalAttempts++; + PlayerHadFixedProfile = ExperimentController.UseRandomProfile; _startTime = Time.realtimeSinceStartup; _jsonPath = jsonPath; PlayerId = playerId; diff --git a/Assets/Scripts/Game/DataCollection/PlayerData.cs b/Assets/Scripts/Game/DataCollection/PlayerData.cs index c5a571ff..f453bebc 100644 --- a/Assets/Scripts/Game/DataCollection/PlayerData.cs +++ b/Assets/Scripts/Game/DataCollection/PlayerData.cs @@ -25,6 +25,7 @@ public void Init(bool useFixedProfile) { SerializedData ??= new PlayerSerializedData { + UseFixedProfile = useFixedProfile, PreFormAnswers = new List(), PlayerId = RandomSingleton.GetInstance().Next(0, int.MaxValue) + (int)Time.realtimeSinceStartup, PlayerProfile = new YeePlayerProfile(), diff --git a/Assets/Scripts/Game/DataCollection/PlayerDataController.cs b/Assets/Scripts/Game/DataCollection/PlayerDataController.cs index 771f4251..5b25e2bf 100644 --- a/Assets/Scripts/Game/DataCollection/PlayerDataController.cs +++ b/Assets/Scripts/Game/DataCollection/PlayerDataController.cs @@ -100,7 +100,7 @@ private void Start() private void OnGameStart(object sender, EventArgs eventArgs) { CurrentPlayer = ScriptableObject.CreateInstance(); - CurrentPlayer.Init( ExperimentController.UseFixedProfile ); + CurrentPlayer.Init( ExperimentController.UseRandomProfile ); } private void OnMapStart(object sender, StartMapEventArgs eventArgs) diff --git a/Assets/Scripts/Game/EnemyGenerator/TopdownFitness.cs b/Assets/Scripts/Game/EnemyGenerator/TopdownFitness.cs index a62bed71..a7a55cfd 100644 --- a/Assets/Scripts/Game/EnemyGenerator/TopdownFitness.cs +++ b/Assets/Scripts/Game/EnemyGenerator/TopdownFitness.cs @@ -3,7 +3,9 @@ using System; using System.Linq; using UnityEngine; +#if UNITY_EDITOR using static Codice.Client.Common.Connection.AskCredentialsToUser; +#endif namespace TopdownGame.Overlord.Inheritance.RulesGenerator { diff --git a/Assets/Scripts/Game/GameManager/ExperimentController.cs b/Assets/Scripts/Game/GameManager/ExperimentController.cs index e91e4042..a07d8ac5 100644 --- a/Assets/Scripts/Game/GameManager/ExperimentController.cs +++ b/Assets/Scripts/Game/GameManager/ExperimentController.cs @@ -16,15 +16,11 @@ using Game.GameManager.Player; using Game.LevelManager.DungeonManager; using Topdown.Overlord.NarrativeGenerator; +using Game.ExperimentControllers; namespace Game.GameManager { - // TODO: Pula tela de level selection e carrega o nível gerado -> ao inves de carregar tela de level select, - - // TODO: - // Questão do loop -> Testar - public class ExperimentController : MonoBehaviour { public static event EventHandler StartExperimentGeneratorEventHandler; @@ -36,17 +32,17 @@ public class ExperimentController : MonoBehaviour private YeePlayerProfile selectedProfile; private List _questLinesListForProfile; - public static bool UseFixedProfile => _useFixedProfile; - private static bool _useFixedProfile; + public static bool UseRandomProfile => _useRandomProfile; + private static bool _useRandomProfile; private static bool _updatedProfile = false; private static bool _firstRunCompleted = false; - [SerializeField] - private DungeonSceneLoader[] dungeonEntrances; + [SerializeField] private DungeonSceneLoader[] dungeonEntrances; + [SerializeField] private GeneratorSettings generatorSettings; private void Awake() { - SetUseFixedProfile(); + SetUseRandomProfile(); _questLinesListForProfile = null; } @@ -126,9 +122,10 @@ private void LoadDataForExperiment(object sender, ProfileSelectedEventArgs profi ProfileSelectedEventHandler?.Invoke(null, new ProfileSelectedEventArgs(selectedProfile)); } - private static void SetUseFixedProfile() + private void SetUseRandomProfile() { - _useFixedProfile = RandomSingleton.GetInstance().Random.Next(0, 100) < 50; + _useRandomProfile = generatorSettings.EnableRandomProfileToPlayer && RandomSingleton.GetInstance().Random.Next(0, 100) > generatorSettings.ProbabilityToGetTrueProfile; + Debug.Log("Set Use Random Profile to "+_useRandomProfile); } private void OnRunComplete(object sender, EventArgs eventArgs) diff --git a/Assets/Scripts/Game/NarrativeGenerator/NarrativeExperimentRepository.cs b/Assets/Scripts/Game/NarrativeGenerator/NarrativeExperimentRepository.cs index e9a5cc9b..cf1028a1 100644 --- a/Assets/Scripts/Game/NarrativeGenerator/NarrativeExperimentRepository.cs +++ b/Assets/Scripts/Game/NarrativeGenerator/NarrativeExperimentRepository.cs @@ -4,7 +4,9 @@ using Game.NarrativeGenerator.Quests; using Overlord.ProfileAnalyst; using System.Collections.Generic; +#if UNITY_EDITOR using UnityEditor; +#endif using Util; namespace Overlord.NarrativeGenerator @@ -31,6 +33,7 @@ public void Save(QuestLineList questLines, string profileName) { SetQuestLineListForProfile(questLines); +#if UNITY_EDITOR string target = "Assets/Resources/Experiment"; string questLineFile = $"{target}/{profileName}"; @@ -41,6 +44,7 @@ public void Save(QuestLineList questLines, string profileName) EditorUtility.SetDirty(_playerProfileToQuestLines); AssetDatabase.SaveAssetIfDirty(_playerProfileToQuestLines); +#endif } private void SetQuestLineListForProfile(QuestLineList questLines) diff --git a/Assets/Scripts/Game/NarrativeGenerator/Quests/QuestLine.cs b/Assets/Scripts/Game/NarrativeGenerator/Quests/QuestLine.cs index 1628c324..101f33f6 100644 --- a/Assets/Scripts/Game/NarrativeGenerator/Quests/QuestLine.cs +++ b/Assets/Scripts/Game/NarrativeGenerator/Quests/QuestLine.cs @@ -10,6 +10,7 @@ using UnityEditor; #endif using UnityEngine; +using Game.GameManager; using Util; using static Util.Enums; using Overlord.NarrativeGenerator.Quests; @@ -199,12 +200,22 @@ public List GetCompletedQuests() } public void PopulateQuestLine(in GeneratorSettings generatorSettings, NpcSo npcInCharge ) + { + Dictionary> startSymbolWeights = YeeProfileCalculator.StartSymbolWeights; + if (ExperimentController.UseRandomProfile) + { + startSymbolWeights = GetRandomSymbolWeights(); + } + PopulateQuestLineMarkov(generatorSettings, npcInCharge, startSymbolWeights); + } + + private void PopulateQuestLineMarkov(in GeneratorSettings generatorSettings, NpcSo npcInCharge, Dictionary> startSymbolWeights ) { var questChain = new MarkovChain(); while (questChain.GetLastSymbol().CanDrawNext) { var lastSelectedQuest = questChain.GetLastSymbol(); - lastSelectedQuest.NextSymbolChances = YeeProfileCalculator.StartSymbolWeights; + lastSelectedQuest.NextSymbolChances = startSymbolWeights; lastSelectedQuest.SetNextSymbol(questChain); var nonTerminalSymbol = questChain.GetLastSymbol(); @@ -247,5 +258,16 @@ public void ConvertDataForCurrentDungeon(List dungeonParts) quest.CreateQuestString(_language); } } + + private Dictionary> GetRandomSymbolWeights() + { + return new Dictionary> + { + {Constants.ImmersionQuest, _ => 25f}, + {Constants.AchievementQuest, _ => 25f}, + {Constants.MasteryQuest, _ => 25f}, + {Constants.CreativityQuest, _ => 25f} + }; + } } } \ No newline at end of file diff --git a/Assets/Scripts/Game/ProfileAnalyst/TopdownPlayerProfileManager.cs b/Assets/Scripts/Game/ProfileAnalyst/TopdownPlayerProfileManager.cs index 552bb0dc..847cd89b 100644 --- a/Assets/Scripts/Game/ProfileAnalyst/TopdownPlayerProfileManager.cs +++ b/Assets/Scripts/Game/ProfileAnalyst/TopdownPlayerProfileManager.cs @@ -102,7 +102,7 @@ private void SelectPlayerProfile(object sender, EventArgs eventArgs) if (_profileCalculator is TopdownYeeProfileCalculator yeeProfileCalculator) { YeePlayerProfile playerProfile = _playerDataController.CurrentPlayer.SerializedData.PlayerProfile; - if (!ExperimentController.UseFixedProfile) + if (!ExperimentController.UseRandomProfile) { playerProfile = (YeePlayerProfile)yeeProfileCalculator.CreateProfileFromGameplay(_playerDataController.CurrentPlayer, _playerDataController.CurrentPlayer.CurrentDungeon); } diff --git a/Assets/Scripts/Overlord/RulesGenerator/GeneticAlgorithm/Crossover.cs b/Assets/Scripts/Overlord/RulesGenerator/GeneticAlgorithm/Crossover.cs index 9a88afef..e12a3a82 100644 --- a/Assets/Scripts/Overlord/RulesGenerator/GeneticAlgorithm/Crossover.cs +++ b/Assets/Scripts/Overlord/RulesGenerator/GeneticAlgorithm/Crossover.cs @@ -1,7 +1,9 @@ using System; using UnityEngine; using Util; +#if UNITY_EDITOR using static Codice.Client.Common.Connection.AskCredentialsToUser; +#endif namespace Overlord.RulesGenerator.EnemyGeneration { diff --git a/Assets/Scripts/Overlord/RulesGenerator/GeneticAlgorithm/Mutation.cs b/Assets/Scripts/Overlord/RulesGenerator/GeneticAlgorithm/Mutation.cs index d2ed89ba..e7526d93 100644 --- a/Assets/Scripts/Overlord/RulesGenerator/GeneticAlgorithm/Mutation.cs +++ b/Assets/Scripts/Overlord/RulesGenerator/GeneticAlgorithm/Mutation.cs @@ -1,6 +1,8 @@ using Util; using System; +#if UNITY_EDITOR using Codice.Client.Common; +#endif namespace Overlord.RulesGenerator.EnemyGeneration { diff --git a/Assets/Scripts/OverlordData/RulesGenerator/SearchSpaceConfig.cs b/Assets/Scripts/OverlordData/RulesGenerator/SearchSpaceConfig.cs index cec11a94..1ee642d4 100644 --- a/Assets/Scripts/OverlordData/RulesGenerator/SearchSpaceConfig.cs +++ b/Assets/Scripts/OverlordData/RulesGenerator/SearchSpaceConfig.cs @@ -1,5 +1,7 @@ using MyBox; +#if UNITY_EDITOR using UnityEditor; +#endif using UnityEngine; using Overlord.UI; @@ -19,7 +21,7 @@ public class SearchSpaceConfig : ScriptableObject [DisplayInspector] public EnemyWeaponsSOInterface WeaponSet; } - +#if UNITY_EDITOR [CustomEditor(typeof(SearchSpaceConfig))] public class SearchSpaceConfigEditor : Editor { @@ -27,7 +29,7 @@ public override void OnInspectorGUI() { serializedObject.Update(); - // Cabeçalho + // Cabe�alho EditorGUILayout.BeginHorizontal(); GUILayout.Label("Status", GUILayout.Width(75)); GUILayout.Label("Min", GUILayout.Width(40)); @@ -54,4 +56,5 @@ public override void OnInspectorGUI() serializedObject.ApplyModifiedProperties(); } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/Scripts/OverlordData/RulesGenerator/UI/RangeSliderUI.cs b/Assets/Scripts/OverlordData/RulesGenerator/UI/RangeSliderUI.cs index 539113b0..1c8fb0c7 100644 --- a/Assets/Scripts/OverlordData/RulesGenerator/UI/RangeSliderUI.cs +++ b/Assets/Scripts/OverlordData/RulesGenerator/UI/RangeSliderUI.cs @@ -27,7 +27,7 @@ public MinMaxSliderRange(float minLimit, float maxLimit, float minValue, float m [CustomPropertyDrawer(typeof(MinMaxSliderRange))] public class RangeSliderUI : PropertyDrawer { - const float NumberWidth = 40f; // menor para dar mais espaço ao slider + const float NumberWidth = 40f; // menor para dar mais espa�o ao slider const float NameWidth = 75f; const float InnerSpacing = 4f; @@ -91,5 +91,5 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent return EditorGUIUtility.singleLineHeight + 2f; } } -} #endif +}