Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Assets/Scenes/Main.unity

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Assets/Scripts/Game/DataCollection/DungeonData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using Game.LevelManager.DungeonLoader;
using Game.GameManager;
using Overlord.ProfileAnalyst;
using UnityEngine;
using Util;
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Game/DataCollection/PlayerData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public void Init(bool useFixedProfile)
{
SerializedData ??= new PlayerSerializedData
{
UseFixedProfile = useFixedProfile,
PreFormAnswers = new List<int>(),
PlayerId = RandomSingleton.GetInstance().Next(0, int.MaxValue) + (int)Time.realtimeSinceStartup,
PlayerProfile = new YeePlayerProfile(),
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Game/DataCollection/PlayerDataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void Start()
private void OnGameStart(object sender, EventArgs eventArgs)
{
CurrentPlayer = ScriptableObject.CreateInstance<PlayerData>();
CurrentPlayer.Init( ExperimentController.UseFixedProfile );
CurrentPlayer.Init( ExperimentController.UseRandomProfile );
}

private void OnMapStart(object sender, StartMapEventArgs eventArgs)
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Game/EnemyGenerator/TopdownFitness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
21 changes: 9 additions & 12 deletions Assets/Scripts/Game/GameManager/ExperimentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,17 +32,17 @@ public class ExperimentController : MonoBehaviour
private YeePlayerProfile selectedProfile;
private List<QuestLineList> _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;
}

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}";

Expand All @@ -41,6 +44,7 @@ public void Save(QuestLineList questLines, string profileName)

EditorUtility.SetDirty(_playerProfileToQuestLines);
AssetDatabase.SaveAssetIfDirty(_playerProfileToQuestLines);
#endif
}

private void SetQuestLineListForProfile(QuestLineList questLines)
Expand Down
24 changes: 23 additions & 1 deletion Assets/Scripts/Game/NarrativeGenerator/Quests/QuestLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using UnityEditor;
#endif
using UnityEngine;
using Game.GameManager;
using Util;
using static Util.Enums;
using Overlord.NarrativeGenerator.Quests;
Expand Down Expand Up @@ -199,12 +200,22 @@ public List<QuestSo> GetCompletedQuests()
}

public void PopulateQuestLine(in GeneratorSettings generatorSettings, NpcSo npcInCharge )
{
Dictionary<string, Func<int, float>> startSymbolWeights = YeeProfileCalculator.StartSymbolWeights;
if (ExperimentController.UseRandomProfile)
{
startSymbolWeights = GetRandomSymbolWeights();
}
PopulateQuestLineMarkov(generatorSettings, npcInCharge, startSymbolWeights);
}

private void PopulateQuestLineMarkov(in GeneratorSettings generatorSettings, NpcSo npcInCharge, Dictionary<string, Func<int, float>> 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();
Expand Down Expand Up @@ -247,5 +258,16 @@ public void ConvertDataForCurrentDungeon(List<DungeonRoomData> dungeonParts)
quest.CreateQuestString(_language);
}
}

private Dictionary<string, Func<int, float>> GetRandomSymbolWeights()
{
return new Dictionary<string, Func<int, float>>
{
{Constants.ImmersionQuest, _ => 25f},
{Constants.AchievementQuest, _ => 25f},
{Constants.MasteryQuest, _ => 25f},
{Constants.CreativityQuest, _ => 25f}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Util;
using System;
#if UNITY_EDITOR
using Codice.Client.Common;
#endif

namespace Overlord.RulesGenerator.EnemyGeneration
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using MyBox;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
using Overlord.UI;

Expand All @@ -19,15 +21,15 @@ public class SearchSpaceConfig : ScriptableObject
[DisplayInspector]
public EnemyWeaponsSOInterface WeaponSet;
}

#if UNITY_EDITOR
[CustomEditor(typeof(SearchSpaceConfig))]
public class SearchSpaceConfigEditor : Editor
{
public override void OnInspectorGUI()
{
serializedObject.Update();

// Cabeçalho
// Cabe�alho
EditorGUILayout.BeginHorizontal();
GUILayout.Label("Status", GUILayout.Width(75));
GUILayout.Label("Min", GUILayout.Width(40));
Expand All @@ -54,4 +56,5 @@ public override void OnInspectorGUI()

serializedObject.ApplyModifiedProperties();
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -91,5 +91,5 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent
return EditorGUIUtility.singleLineHeight + 2f;
}
}
}
#endif
}
Loading