Roofen-Game
  • Welcome to Roofen Game
  • Frameworks
    • Common Stat
      • Demo
      • 🚀 Quick Start Guide
      • Runtime
      • Action
      • Formula
      • Examples
      • Debugger
      • FAQ
      • Version Update
      • FutureDirection
    • RToDo
  • Survivors Roguelike Kit
    • Quick Start
    • Core Concepts Overview
      • Scene Concepts
      • Stat Concepts
      • Skill Concepts
    • Adding a New Playable Character
    • Adding a New Enemy
    • Adding a New Stage Configuration
    • Adding a New Map Configuration
    • Adding a New Level
    • Adding a New Attack Skill
    • Adding a New Buff
    • Configuring the Exp System
    • Damage Numbers Display Guide
    • Upcoming Features Preview
    • Release Notes
  • RSOFramework
Powered by GitBook
On this page
  • Add Buffs to Your Attack Skills
  • Adding a New Buff
  1. Survivors Roguelike Kit

Adding a New Buff

PreviousAdding a New Attack SkillNextConfiguring the Exp System

Last updated 24 days ago

Add Buffs to Your Attack Skills

First, you need to find your skill prefab. You'll see that two new properties have been added to the skill script: the "Add Buff Event" where you can select a only event, and the second one where you can add your own or preset three buffs.

Assets/RGame/RoguelikeKit/Prefabs/Skill/BothSideSkill.prefab

Adding a New Buff

This guide walks you through creating and configuring a new buff in the RGame RoguelikeKit, using BurnBuff as an example.

1. Inspect the Existing Buff Asset

  1. In Unity, navigate to:

    Assets/RGame/RoguelikeKit/ScriptableObjects/DataSO/Buff/BurnBuff.asset
  2. Select BurnBuff.asset to view its properties in the Inspector. You will see four key fields:

    • Duration: Total lifespan of the buff (in seconds).

    • TickInterval: How often TickEffect() is called. For BurnBuff, this is set to 1s (one damage tick per second).

    • OnRemove: choose a unique event.

    • Damage: Amount of damage dealt each tick.

The remaining two built‑in buff types (e.g. FreezeBuff, SlowBuff) use the same properties—just examine their asset files and you’ll see how Duration, Interval, and effect parameters differ.

2. Create a New Buff Script

  1. Right‑click in your project window and choose Create → RGame → RoguelikeKit → Buff → BaseBuff (or duplicate BurnBuff and rename).

  2. Name your new script: MyCustomBuff.cs.

3. Implement Core Methods

Each buff requires three overrides in your BaseBuff subclass:

  • Activate(): Called when the buff is applied.

  • TickEffect(): Called every TickInterval seconds while active.

  • DeActivate(): Called when the buff expires or is removed.

Below is the full BurnBuff implementation for reference:

using UnityEngine;

namespace RGame.RoguelikeKit
{
    [CreateAssetMenu(menuName = "RGame/RoguelikeKit/Buff/BurnBuff")]
    public class BurnBuff : BaseBuff
    {
        public int Damage;
        private EnemyHit _ownerHit;
        
        public override void Activate()
        {
            BuffName = "BurnBuff";
            
            // Visual: tint sprite red
            var mat = Owner.MySpriteRenderer.material;
            mat.SetColor("_FlameRedBlend", Color.red);

            // Cleanup on death
            Owner.OnDeath += OnOwnerDestroy;

            // Cache damage component
            _ownerHit = Owner.GetComponentInChildren<EnemyHit>();
        }

        public override void DeActivate()
        {
            // Reset visual
            var mat = Owner.MySpriteRenderer.material;
            mat.SetColor("_FlameRedBlend", Color.white);

            // Remove death listener
            Owner.OnDeath -= OnOwnerDestroy;
        }

        public override void TickEffect()
        {
            base.TickEffect();
            _ownerHit.Hit(Damage);
        }
        
        private void OnOwnerDestroy(Enemy owner)
        {
            // Raise event to clear buffs
            RemoveAllBuff.RaiseEvent(this);
        }
    }
}

4. Configure Your New Buff Asset

  1. In the Inspector, set Duration, TickInterval, and any custom parameters (e.g., damage, slow percentage).

  2. Wire up OnRemoveAllBuff to the appropriate event channel.

5. (Optional) Use Your AI Assistant

If you prefer, ask your AI assistant to scaffold a new buff class using this pattern:

Tell me to create a {BuffName} that {effect description} every {interval}s for {duration}s.

Your assistant can generate the C# boilerplate and even set up properties—no coding worries required.

You don't need to worry about the AI being unable to create the effect you want. As long as it's not particularly complex, the AI can handle it.


You’re all set! With this pattern, you can rapidly add new buff types—just follow the Activate(), TickEffect(), and DeActivate() lifecycle, then configure the asset parameters in the Inspector.