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
  1. Survivors Roguelike Kit

Adding a New Stage Configuration

Stage System Detailed Guide

The Stage System drives all enemy spawning in your game. It consists of two asset types—StageConfigSO (defining which groups spawn) and SpawnSet (defining how and when each group spawns)—plus the StageManager component that runs it at runtime.


1. Spawn Patterns (SpawnPatternType)

Spawn behavior is controlled by this enum in code:

public enum SpawnPatternType {
  Random,  // scattered just outside the camera view
  Circle,  // enemies form a ring around the player
  Dense    // enemies cluster tightly around a point
}

Use these patterns to vary your encounters.


2. Defining a SpawnSet

A SpawnSet asset describes one group of enemies and its spawn logic.

a. Create or Locate a SpawnSet

  1. In the Project window go to:

Assets/RGame/RoguelikeKit/ScriptableObjects/DataSO/Stage/StageSet
  1. To create a new one: Right-click → Create → RGame → RoguelikeKit → Stage → Spawn Set

  2. Name the asset (e.g., SpawnSet_GoblinRing).

b. Configure SpawnSet Properties

Open your SpawnSet in the Inspector and set these fields:

  • PoolKey: string matching your object-pool key (e.g., "Goblin").

  • Weight: relative chance when picking randomly.

  • Pattern (SpawnPatternType): choose Random, Circle, or Dense.

  • BaseRatePerSecond (Random only): enemies spawned per second (before scaling).

  • Count (Circle/Dense only): how many enemies spawn each tick.

  • CircleRadius (Circle only): distance from player for the ring.

  • StartTime & EndTime: when (in seconds) this set becomes active.

  • IntensityCurve: AnimationCurve (0–1) that multiplies BaseRatePerSecond over the segment.


3. Assembling a StageConfigSO

A StageConfigSO asset groups multiple SpawnSets into a timeline.

a. Locate or Create

  1. Navigate to:

    Assets/RGame/RoguelikeKit/ScriptableObjects/DataSO/Stage/StageConfigSO.asset
  2. To create new: Right-click → Create → RGame → RoguelikeKit → Stage → StageConfigSO

  3. Name it (e.g., StageConfig_ForestLevel).

b. Add SpawnSets

In the Inspector’s SpawnSets list:

  1. Click +.

  2. Drag each SpawnSet asset into its slot.

  3. The StageManager will sort them by StartTime at runtime.


4. StageManager Component

  1. Assign references:

    • PoolRuntimeSO: your pooling asset

    • GlobalConfigSO & CommonStatRuntimeSO: for curse scaling

    • EnemySystem: handles enemy registration

    • PlayerSpawnChannelSO, StartStageEventChannelSO, VoidEventChannelSO: hook up spawn and win events

    • minSpawnRadius / maxSpawnRadius: for Random pattern distances

  2. At gameplay start, fire the StartStageEvent with your StageConfigSO during initialization.

The StageManager will:

  • Sort SpawnSets by StartTime.

  • For each set when time ≥ StartTime, spawn according to its Pattern:

    • Random: continuous spawning using BaseRatePerSecond × IntensityCurve × Curse.

    • Circle: one-off ring of Count enemies at CircleRadius.

    • Dense: one-off cluster of Count enemies around a random point.

  • Stop after all sets finish and no enemies remain, then emit the gameWin event.


5. Tips & Best Practices

  • Tuning Difficulty: Adjust IntensityCurve shape to ramp up or ease difficulty.

  • Pattern Mix: Combine Random for filler, Circle for surround challenges, Dense for targeted ambushes.

  • Reusability: Duplicate SpawnSet assets to quickly create new stages.

  • Timing: Overlap StartTime/EndTime to layer multiple sets in parallel.

With these steps, even beginners can set up rich, varied stages fully through the Inspector—no coding required!

PreviousAdding a New EnemyNextAdding a New Map Configuration

Last updated 15 days ago