# LBattleFrameWork **Repository Path**: lanzhipeng2011/lbattle-frame-work ## Basic Information - **Project Name**: LBattleFrameWork - **Description**: 回合制游戏战斗框架简版 - **Primary Language**: C# - **License**: BSD-3-Clause - **Default Branch**: master - **Homepage**: https://gitee.com/lanzhipeng2011 - **GVP Project**: No ## Statistics - **Stars**: 14 - **Forks**: 2 - **Created**: 2024-03-15 - **Last Updated**: 2025-10-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LBattle Framework This is a Unity-based battle framework designed for the implementation of turn-based combat systems. The framework adopts a modular design, making it easy to extend and maintain, and is suitable for developing combat modules in strategy or RPG games. ## Features - **Modular Design**: The framework is divided into multiple modules such as the battle system, character system, and round system, making it easy to manage and extend. - **State Machine Management**: A state machine is used to manage different states of the battle and rounds, resulting in clear logic and easy maintenance. - **Event Center**: Global event broadcasting is implemented through `MessageCenter`, facilitating communication between modules. - **Data-Driven**: Character data and battle configurations are managed through data classes, making them easy to adjust and extend. ## Main Modules - **Battle System (BattleSystem)**: Manages the overall flow of the battle, including state transitions and updates. - **Character System (CharacterSystem)**: Manages character data in battle, as well as the creation and destruction of character objects. - **Round System (RoundSystem)**: Manages the flow of rounds in battle, including state transitions and updates. - **Event Center (MessageCenter)**: Responsible for the registration, listening, and broadcasting of global events. ## Core Class Descriptions - `LBattleFacade`: The facade class of the battle system, providing a unified interface for external calls. - `BattleStateControl`: The battle state controller, managing different battle states. - `RoundStateController`: The round state controller, managing different round states. - `CharacterModel`: The character data model, managing character configuration data. - `CharacterObj`: The character object class, managing the behavior and state of characters in battle. ## Usage Instructions 1. **Initialize the Battle System**: ```csharp LBattleFacade.Instance.Initinal(); ``` 2. **Create a Character**: ```csharp LBattleFacade.Instance.CreatCharacter(); ``` 3. **Create a Round**: ```csharp LBattleFacade.Instance.CreatRound(); ``` 4. **Update the Battle System**: ```csharp void Update() { LBattleFacade.Instance.Update(); } ``` ## Event System Register and listen for events through `MessageCenter`, for example: ```csharp MessageCenter.Instance.OnAddListener(MsgID.BattleEnd, OnBattleEnd); private void OnBattleEnd(object obj) { // Handle battle end logic } ``` ## Extension Suggestions - **Add New Battle States**: Inherit from `BattleStateBase`, implement the `Init`, `Update`, and `Release` methods, and register through `BattleStateControl`. - **Add New Round States**: Inherit from `RoundStateBase`, implement the `Init`, `Update`, and `Release` methods, and register through `RoundStateController`. - **Extend Character Data**: Add new properties in `CharacterData` to support more character features. ## License This project uses the MIT License. For details, please refer to the LICENSE file.