Compare commits

...

5 Commits

Author SHA1 Message Date
Branden J Brown d9bbef4b05 add example Effect and EnemyAttributes assets
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline was successful Details
2023-07-30 10:17:51 -05:00
Branden J Brown 61b7bbefc0 use fields instead of properties 2023-07-30 10:16:49 -05:00
Branden J Brown 3b1b4a90b7 make Attribute a struct again 2023-07-30 10:16:12 -05:00
Branden J Brown d8d3a69c36 add non-attribute XP and threat to enemy stats 2023-07-30 08:41:01 -05:00
Branden J Brown ee2d696cec add create asset to enemy attributes 2023-07-30 08:35:42 -05:00
9 changed files with 70 additions and 7 deletions

8
Assets/Scriptables.meta generated Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1d13d7aac40657841955febd4faabbfa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

19
Assets/Scriptables/EnemyAttributes.asset generated Normal file
View File

@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c5304ff6dfe84844887d751cee48606a, type: 3}
m_Name: EnemyAttributes
m_EditorClassIdentifier:
STR: {fileID: 0}
CON: {fileID: 0}
SPD: {fileID: 0}
RNG: {fileID: 0}
MND: {fileID: 0}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d5bf638cf02c5b94cb9874d4414c1b8a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

14
Assets/Scriptables/StatEffect.asset generated Normal file
View File

@ -0,0 +1,14 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 494a21c06960ec442a7a6806f8aefedb, type: 3}
m_Name: StatEffect
m_EditorClassIdentifier:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4c96040df8ebed746832db7857b25bed
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,10 +1,14 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Attribute : ScriptableObject
[Serializable]
public struct Attribute
{
public long Base { get; set; }
public long Base;
public Attribute(long stat) { Base = stat; }
/// <summary>
/// Calculates the stat value with accumulated buff and debuff modifiers.

View File

@ -6,16 +6,16 @@ public class EffectSO : ScriptableObject
/// <summary>
/// Additive change applied before multiplicative scaling.
/// </summary>
public long Base { get; private set; }
public long Base;
/// <summary>
/// Multiplicative scaling in units of hundredth of a percent.
/// E.g., 625 permyriad is 6.25%.
/// </summary>
public long Permyriad { get; private set; }
public long Permyriad;
/// <summary>
/// Additive change applied after multiplicative scaling.
/// </summary>
public long Flat { get; private set; }
public long Flat;
/// <summary>
/// Create a new attribute effect instance.

View File

@ -1,5 +1,6 @@
using UnityEngine;
[CreateAssetMenu(fileName = "EnemyAttributes", menuName = "Enemy Attributes")]
public class EnemyAttributesSO : ScriptableObject
{
[SerializeField] private Attribute STR;
@ -7,6 +8,8 @@ public class EnemyAttributesSO : ScriptableObject
[SerializeField] private Attribute SPD;
[SerializeField] private Attribute RNG;
[SerializeField] private Attribute MND;
public long XP { get; private set; }
public long Threat { get; private set; }
public static EnemyAttributesSO New()
{

View File

@ -17,8 +17,7 @@ public class AttributeTest
[TestCase(1000000, 0, -20000, 0, ExpectedResult = 0)]
public long Value(long startStat, long baseBonus, long permyriadBonus, long flatBonus)
{
var attr = ScriptableObject.CreateInstance<Attribute>();
attr.Base = startStat;
var attr = new Attribute(startStat);
var effect = EffectSO.New(baseBonus, permyriadBonus, flatBonus);
return attr.Calc(effect);
}