Exemplo n.º 1
0
        private void DrawWeapon(RPGDatabaseManager database)
        {
            var weaponTypeIds   = database.FetchEntry <WeaponTypeDataList>().entries.Select(l => l.Id).ToArray();
            var weaponTypeNames = database.FetchEntry <WeaponTypeDataList>().entries.Select(l => l.name).ToArray();

            var entry = (WeaponData)entrySelected;

            EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(400));
            DrawTitle();

            entry.name        = EditorGUILayout.TextField("Name", entry.name);
            entry.description = EditorGUILayout.TextField("Description", entry.description);
            entry.typeId      = EditorGUILayout.IntPopup("Type", entry.typeId, weaponTypeNames, weaponTypeIds);
            entry.price       = EditorGUILayout.IntField("Price", entry.price);

            EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(350));
            EditorGUILayout.LabelField("Attribute Effects");
            entry.strIncrease = EditorGUILayout.IntField(Constants.Attributes.STR, entry.strIncrease);
            entry.intIncrease = EditorGUILayout.IntField(Constants.Attributes.INT, entry.intIncrease);

            entry.dexIncrease = EditorGUILayout.IntField(Constants.Attributes.DEX, entry.dexIncrease);
            entry.agiIncrease = EditorGUILayout.IntField(Constants.Attributes.AGI, entry.agiIncrease);

            entry.lckIncrease = EditorGUILayout.IntField(Constants.Attributes.LCK, entry.lckIncrease);

            entry.defIncrease = EditorGUILayout.IntField(Constants.Attributes.DEF, entry.defIncrease);
            entry.resIncrease = EditorGUILayout.IntField(Constants.Attributes.RES, entry.resIncrease);
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndVertical();
        }
Exemplo n.º 2
0
        void Start()
        {
            //Loading database
            _database = new RPGDatabaseManager();
            _database.Load();

            //Fetching data and injecting into runtime classes
            var actorList = _database.FetchEntry <ActorDataList>();

            _actors = new Actor[actorList.Count];

            for (int i = 0; i < actorList.Count; i++)
            {
                var actorData = actorList.entries[i];
                var classData = _database.FetchClassData(actorData.classId);
                _actors[i] = new Actor(actorData, classData);

                var hp = _database.FetchAmount(actorData.Id, actorData.initialLevel, ActorAttributeType.HP);
                var mp = _database.FetchAmount(actorData.Id, actorData.initialLevel, ActorAttributeType.MP);

                var str  = _database.FetchAmount(actorData.Id, actorData.initialLevel, ActorAttributeType.Strength);
                var intl = _database.FetchAmount(actorData.Id, actorData.initialLevel, ActorAttributeType.Intelligence);

                var dex = _database.FetchAmount(actorData.Id, actorData.initialLevel, ActorAttributeType.Dextery);
                var agi = _database.FetchAmount(actorData.Id, actorData.initialLevel, ActorAttributeType.Agility);

                var lck = _database.FetchAmount(actorData.Id, actorData.initialLevel, ActorAttributeType.Luck);

                var def = _database.FetchAmount(actorData.Id, actorData.initialLevel, ActorAttributeType.Defense);
                var res = _database.FetchAmount(actorData.Id, actorData.initialLevel, ActorAttributeType.Resistance);

                _actors[i].wpnName      = _database.FetchWeapon(actorData.initialWeapon).name;
                _actors[i].expNextLevel = _database.FetchExpForNextLevel(actorData.Id, actorData.initialLevel);

                _actors[i].SetAttributes(hp, mp, str, intl, dex, agi, lck, def, res);
            }

            //Displaying it on the UI
            for (int i = 0; i < actorList.Count; i++)
            {
                partyInfoWnd.UpdateDisplay(_actors[i], i);
            }

            TransitionTo(State.PartyInfo);
        }
Exemplo n.º 3
0
        private void OnEnable()
        {
            _database = new RPGDatabaseManager();
            _database.Load();
            if (_database.TotalEntries == 0)
            {
                DatabaseFolderHandler.ValidateAllFolders();
                DatabaseFactory.CreateDatabase();
                _database.Load();
            }

            _actorDataList          = _database.FetchEntry <ActorDataList>();
            _classDataList          = _database.FetchEntry <ActorClassDataList>();
            _skillDataList          = _database.FetchEntry <SkillDataList>();
            _itemDataList           = _database.FetchEntry <ItemDataList>();
            _weaponDataList         = _database.FetchEntry <WeaponDataList>();
            _weaponTypeDataList     = _database.FetchEntry <WeaponTypeDataList>();
            _attributeSpectDataList = _database.FetchEntry <AttributeSpecDataList>();

            _actorListSection      = new ListSection <ActorData>(_actorDataList, "Actors");
            _classListSection      = new ListSection <ActorClassData>(_classDataList, "Classes");
            _skillListSection      = new ListSection <SkillData>(_skillDataList, "Skills");
            _itemListSection       = new ListSection <ItemData>(_itemDataList, "Items");
            _weaponListSection     = new ListSection <WeaponData>(_weaponDataList, "Weapons");
            _weaponTypeListSection = new ListSection <WeaponTypeData>(_weaponTypeDataList, "Weapon Types");
            var flags = ReorderableListFlags.ShowIndices | ReorderableListFlags.HideAddButton | ReorderableListFlags.DisableReordering | ReorderableListFlags.HideRemoveButtons;

            _attributeSpecListSection = new ListSection <AttributeSpecData>(_attributeSpectDataList, "Attribute Specs", flags);

            _infoSection    = new InfoSection();
            _effectsSection = new EffectsSection();

            _coreTabSelected   = (CoreTabId)DatabaseEditorPrefs.CoreTab;
            _mainTabSelected   = (MainTabId)DatabaseEditorPrefs.MainTab;
            _configTabSelected = (ConfigTabId)DatabaseEditorPrefs.ConfigTab;
        }
Exemplo n.º 4
0
        private void DrawActor(RPGDatabaseManager database)
        {
            var entry = (ActorData)entrySelected;

            var classNames = database.FetchEntry <ActorClassDataList>().entries.Select(l => l.name).ToArray();
            var classIds   = database.FetchEntry <ActorClassDataList>().entries.Select(l => l.Id).ToArray();

            var actorClass = database.FetchEntry <ActorClassDataList>().entries.FirstOrDefault(l => l.Id == entry.classId);

            if (actorClass == null)
            {
                actorClass = new ActorClassData(entry.classId);
            }

            var weaponNames = database.FetchEntry <WeaponDataList>().entries.Where(l => l.typeId == actorClass.weaponTypeId).Select(l => l.name).ToArray();
            var weaponIds   = database.FetchEntry <WeaponDataList>().entries.Where(l => l.typeId == actorClass.weaponTypeId).Select(l => l.Id).ToArray();

            var attrList = database.FetchEntry <AttributeSpecDataList>();
            var level    = attrList.entries.First(x => x.name == Constants.Attributes.LEVEL);

            EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(400));
            DrawTitle();

            entry.name         = EditorGUILayout.TextField("Name", entry.name);
            entry.classId      = EditorGUILayout.IntPopup("Class", entry.classId, classNames, classIds);
            entry.initialLevel = EditorGUILayout.IntSlider("Initial Level", entry.initialLevel, level.start, level.end);

            EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(350));
            BrightEditorGUILayout.LabelFieldBold("Graphics");
            entry.graphics.face = SpriteField("Face", entry.graphics.face);
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(350));
            BrightEditorGUILayout.LabelFieldBold("Initial Equipment");
            entry.initialWeapon = EditorGUILayout.IntPopup("Weapon", entry.initialWeapon, weaponNames, weaponIds);
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndVertical();
        }
Exemplo n.º 5
0
        private void DrawClass(RPGDatabaseManager database)
        {
            var weaponTypeIds   = database.FetchEntry <WeaponTypeDataList>().entries.Select(l => l.Id).ToArray();
            var weaponTypeNames = database.FetchEntry <WeaponTypeDataList>().entries.Select(l => l.name).ToArray();
            var skillIds        = database.FetchEntry <SkillDataList>().entries.Select(l => l.Id).ToArray();
            var skillNames      = database.FetchEntry <SkillDataList>().entries.Select(l => l.name).ToArray();

            var entry = (ActorClassData)entrySelected;

            EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(400));
            classAreaVect = EditorGUILayout.BeginScrollView(classAreaVect, GUILayout.Width(400));

            DrawTitle();
            entry.name = EditorGUILayout.TextField("Name", entry.name);


            #region Growth
            BrightEditorGUILayout.LabelFieldBold("Growth");
            entry.expCurve = EditorGUILayout.CurveField(Constants.Attributes.EXP, entry.expCurve, GUILayout.Height(25f));
            entry.hpCurve  = EditorGUILayout.CurveField(Constants.Attributes.HP, entry.hpCurve, GUILayout.Height(25f));
            entry.mpCurve  = EditorGUILayout.CurveField(Constants.Attributes.MP, entry.mpCurve, GUILayout.Height(25f));

            entry.strCurve = EditorGUILayout.CurveField(Constants.Attributes.STR, entry.strCurve, GUILayout.Height(25f));
            entry.intCurve = EditorGUILayout.CurveField(Constants.Attributes.INT, entry.intCurve, GUILayout.Height(25f));

            entry.dexCurve = EditorGUILayout.CurveField(Constants.Attributes.DEX, entry.dexCurve, GUILayout.Height(25f));
            entry.agiCurve = EditorGUILayout.CurveField(Constants.Attributes.AGI, entry.agiCurve, GUILayout.Height(25f));
            entry.lckCurve = EditorGUILayout.CurveField(Constants.Attributes.LCK, entry.lckCurve, GUILayout.Height(25f));

            entry.defCurve = EditorGUILayout.CurveField(Constants.Attributes.DEF, entry.defCurve, GUILayout.Height(25f));
            entry.resCurve = EditorGUILayout.CurveField(Constants.Attributes.RES, entry.resCurve, GUILayout.Height(25f));
            #endregion

            #region Preview
            EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(350));
            var list  = database.FetchEntry <AttributeSpecDataList>();
            var level = list.entries.First(x => x.name == Constants.Attributes.LEVEL);
            var exp   = list.entries.First(x => x.name == Constants.Attributes.EXP);

            var hp   = list.entries.First(x => x.name == Constants.Attributes.HP);
            var mp   = list.entries.First(x => x.name == Constants.Attributes.MP);
            var attr = list.entries.First(x => x.name == Constants.Attributes.COMMON);

            BrightEditorGUILayout.LabelFieldBold("Preview");
            previewLv = EditorGUILayout.IntSlider(Constants.Attributes.LEVEL_SHORT, previewLv, level.start, level.end);

            float normalizedValue  = Mathf.InverseLerp(level.start, level.end, previewLv);
            float targetCurveValue = 0f;

            targetCurveValue = entry.expCurve.Evaluate(normalizedValue);
            EditorGUILayout.LabelField($"{Constants.Attributes.EXP}:\t{exp.FetchAtCurvePoint(targetCurveValue)}");

            targetCurveValue = entry.hpCurve.Evaluate(normalizedValue);
            EditorGUILayout.LabelField($"{Constants.Attributes.HP}:\t{hp.FetchAtCurvePoint(targetCurveValue)}");
            targetCurveValue = entry.mpCurve.Evaluate(normalizedValue);
            EditorGUILayout.LabelField($"{Constants.Attributes.MP}:\t{mp.FetchAtCurvePoint(targetCurveValue)}");

            targetCurveValue = entry.strCurve.Evaluate(normalizedValue);
            EditorGUILayout.LabelField($"{Constants.Attributes.STR_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}");
            targetCurveValue = entry.intCurve.Evaluate(normalizedValue);
            EditorGUILayout.LabelField($"{Constants.Attributes.INT_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}");

            targetCurveValue = entry.dexCurve.Evaluate(normalizedValue);
            EditorGUILayout.LabelField($"{Constants.Attributes.DEX_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}");
            targetCurveValue = entry.agiCurve.Evaluate(normalizedValue);
            EditorGUILayout.LabelField($"{Constants.Attributes.AGI_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}");

            targetCurveValue = entry.lckCurve.Evaluate(normalizedValue);
            EditorGUILayout.LabelField($"{Constants.Attributes.LCK_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}");

            targetCurveValue = entry.defCurve.Evaluate(normalizedValue);
            EditorGUILayout.LabelField($"{Constants.Attributes.DEF_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}");
            targetCurveValue = entry.resCurve.Evaluate(normalizedValue);
            EditorGUILayout.LabelField($"{Constants.Attributes.RES_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}");

            EditorGUILayout.EndVertical();
            #endregion

            #region Weapons
            EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(350));
            BrightEditorGUILayout.LabelFieldBold("Weapon Type");
            entry.weaponTypeId = EditorGUILayout.IntPopup(entry.weaponTypeId, weaponTypeNames, weaponTypeIds);
            EditorGUILayout.EndVertical();
            #endregion

            #region Skills
            EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(350));
            skillUnlockVect = EditorGUILayout.BeginScrollView(skillUnlockVect, GUILayout.MinHeight(90));
            BrightEditorGUILayout.LabelFieldBold(Constants.SKILLS);
            if (entry.skills == null)
            {
                entry.skills = new System.Collections.Generic.List <SkillUnlockArgs>();
            }

            for (int i = 0; i < entry.skills.Count; i++)
            {
                var skillUnlockArgs = entry.skills[i];

                EditorGUI.indentLevel++;
                EditorGUILayout.BeginHorizontal();
                skillUnlockArgs.level   = EditorGUILayout.IntField(Constants.Attributes.LEVEL_SHORT, skillUnlockArgs.level);
                skillUnlockArgs.skillId = EditorGUILayout.IntPopup(skillUnlockArgs.skillId, skillNames, skillIds);
                if (GUILayout.Button("-", GUILayout.Width(20f)))
                {
                    entry.skills.RemoveAt(i);
                    break;
                }
                EditorGUILayout.EndHorizontal();
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+", GUILayout.Width(40f)))
            {
                entry.skills.Add(new SkillUnlockArgs());
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
            #endregion

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
        }