一键导入
rpg
RPG game architecture — stat system (base + modifiers), level/XP, skill trees, quest system, NPC interaction, turn-based and real-time combat patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
RPG game architecture — stat system (base + modifiers), level/XP, skill trees, quest system, NPC interaction, turn-based and real-time combat patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
DOTween animation library — sequence composition, tween lifecycle, easing, kill strategies. CRITICAL: Always kill tweens in OnDestroy to prevent leaks and errors.
Dialogue tree patterns — ScriptableObject graph, node types (text, choice, condition, event), typewriter effect, localization-ready. Load when implementing NPC conversations.
Generic state machine patterns — IState interface, StateMachine<T>, game state management (menu/gameplay/pause), enemy AI states, hierarchical FSM. Load when implementing state-driven behavior.
2D platformer architecture — tight controls (coyote time, input buffer, variable jump), level design patterns, collectibles, checkpoints, hazards, boss patterns.
Unity physics — non-allocating queries, collision layers, FixedUpdate discipline, continuous collision detection, character controllers, joints.
How the atomic instinct learning system works — observations, distillation, confidence scoring, project vs global scope, and promotion/evolution workflows.
| name | rpg |
| description | RPG game architecture — stat system (base + modifiers), level/XP, skill trees, quest system, NPC interaction, turn-based and real-time combat patterns. |
| globs | ["**/RPG*.cs","**/Stat*.cs","**/Quest*.cs","**/Skill*.cs","**/Level*.cs"] |
public enum StatModifierType { Flat, PercentAdd, PercentMultiply }
[System.Serializable]
public sealed class StatModifier
{
public float Value;
public StatModifierType Type;
public int Order;
public object Source;
public StatModifier(float value, StatModifierType type, int order, object source)
{
Value = value;
Type = type;
Order = order;
Source = source;
}
}
[System.Serializable]
public sealed class CharacterStat
{
[SerializeField] private float _baseValue;
private readonly List<StatModifier> _modifiers = new();
private float _cachedValue;
private bool _isDirty = true;
public float Value
{
get
{
if (_isDirty)
{
_cachedValue = CalculateFinalValue();
_isDirty = false;
}
return _cachedValue;
}
}
public void AddModifier(StatModifier mod)
{
_modifiers.Add(mod);
_modifiers.Sort((a, b) => a.Order.CompareTo(b.Order));
_isDirty = true;
}
public void RemoveAllModifiersFromSource(object source)
{
for (int i = _modifiers.Count - 1; i >= 0; i--)
{
if (_modifiers[i].Source == source)
{
_modifiers.RemoveAt(i);
_isDirty = true;
}
}
}
private float CalculateFinalValue()
{
float finalValue = _baseValue;
float percentAddSum = 0f;
for (int i = 0; i < _modifiers.Count; i++)
{
StatModifier mod = _modifiers[i];
switch (mod.Type)
{
case StatModifierType.Flat:
finalValue += mod.Value;
break;
case StatModifierType.PercentAdd:
percentAddSum += mod.Value;
if (i + 1 >= _modifiers.Count || _modifiers[i + 1].Type != StatModifierType.PercentAdd)
{
finalValue *= 1f + percentAddSum;
percentAddSum = 0f;
}
break;
case StatModifierType.PercentMultiply:
finalValue *= 1f + mod.Value;
break;
}
}
return Mathf.Round(finalValue * 100f) / 100f;
}
}
Modifier ordering: Flat (+5) → PercentAdd (+10% stacks additively) → PercentMultiply (+20% stacks multiplicatively).
public sealed class LevelSystem
{
private int _currentLevel = 1;
private int _currentXP;
private int _maxLevel = 99;
public event System.Action<int> OnLevelUp;
public int CurrentLevel => _currentLevel;
public int CurrentXP => _currentXP;
public int XPToNextLevel => GetXPForLevel(_currentLevel + 1) - GetXPForLevel(_currentLevel);
public float XPProgress => (float)_currentXP / XPToNextLevel;
public void AddXP(int amount)
{
_currentXP += amount;
while (_currentXP >= XPToNextLevel && _currentLevel < _maxLevel)
{
_currentXP -= XPToNextLevel;
_currentLevel++;
OnLevelUp?.Invoke(_currentLevel);
}
}
// Exponential XP curve
private int GetXPForLevel(int level)
{
return Mathf.RoundToInt(100f * Mathf.Pow(level, 1.5f));
}
}
public enum ObjectiveType { Kill, Collect, Talk, Location, Custom }
[System.Serializable]
public sealed class QuestObjective
{
public string Description;
public ObjectiveType Type;
public string TargetId;
public int RequiredCount;
[NonSerialized] public int CurrentCount;
public bool IsComplete => CurrentCount >= RequiredCount;
}
[CreateAssetMenu(menuName = "RPG/Quest Definition")]
public sealed class QuestDefinition : ScriptableObject
{
[SerializeField] private string _questId;
[SerializeField] private string _title;
[TextArea] [SerializeField] private string _description;
[SerializeField] private List<QuestObjective> _objectives;
[SerializeField] private int _xpReward;
[SerializeField] private List<ItemDefinition> _itemRewards;
[SerializeField] private QuestDefinition[] _prerequisites;
public string QuestId => _questId;
public string Title => _title;
public IReadOnlyList<QuestObjective> Objectives => _objectives;
public int XPReward => _xpReward;
}
public sealed class QuestTracker
{
private readonly Dictionary<string, QuestDefinition> _activeQuests = new();
public event System.Action<QuestDefinition> OnQuestCompleted;
public void StartQuest(QuestDefinition quest)
{
_activeQuests[quest.QuestId] = quest;
}
public void ReportProgress(ObjectiveType type, string targetId, int count = 1)
{
foreach (KeyValuePair<string, QuestDefinition> kvp in _activeQuests)
{
QuestDefinition quest = kvp.Value;
bool allComplete = true;
for (int i = 0; i < quest.Objectives.Count; i++)
{
QuestObjective obj = quest.Objectives[i];
if (obj.Type == type && obj.TargetId == targetId)
{
obj.CurrentCount = Mathf.Min(obj.CurrentCount + count, obj.RequiredCount);
}
if (!obj.IsComplete) allComplete = false;
}
if (allComplete)
{
OnQuestCompleted?.Invoke(quest);
}
}
}
}