How to Implement a Turn-Based Tactics Game Part 1, 2 -> Basic features, basic combat loop (framework) As it turns out, the assets I can utilize have increased and the content I want to update has grown, so you can think of this as creating a quick prototype. With the content from these two parts, you'll also be able to infer roughly how I plan to implement the updated/upcoming content. ---------------------------------------------------------- Updates -> Advanced development and enrichment based on what was created in parts 1 and 2 cf -> Content beneficial for developing games in this genre + extras
Finally, even advanced items are starting to appear.
Design and implementation for reactive states are starting. (We will also cover common common contents in between #Advanced# <- Only those that are attached to this)
It uses the IEnumerator event, which allows you to perform operations in a set order no matter when you subscribe to it.
(In fact, it's the same as what we did in previous classes) It's a method of using additional IEnumerators by grouping them by priority and category and sorting them in a Consecutive and Parallel manner.
However, it may take some time to get used to the event subscription cancellation pattern at first.
Don't you want to try those states? If they are implemented, you can add a lot of strategy to the tactics game you make.
Those + you will now be able to implement and add similar things enough,
System change? It's added after development (I think it's a consistent context).
+After following all of that, you can now apply the IEnumerator event to most other projects with great excitement.
I think it might be possible.
Part 1,2 also perfectly controls the timing of events by IEnumeratorizing the events (in the order of subscription) <- This is also really good. And it's easy.
But this is one level higher, not depending on the subscription order, but automatically proceeding in a predetermined order + same categories at the same time!
Existing: Subscription order dependent method
csharp
public event Func OnDamageEvent; // 구독하는 순서가 실행 순서를 결정 OnDamageEvent += ProcessDamage; // 1번째 실행 OnDamageEvent += PlayAnimation; // 2번째 실행 OnDamageEvent += CheckDeath; // 3번째 실행 // 실행 yield return this.ConsecutiveAll(OnDamageEvent.GetInvocationList() .Cast >() .Select(handler => handler()));
Problem:
Determine execution order based on subscription order
Depends on code location or initialization order
Difficulty controlling order in complex interactions
Unpredictable execution order in dynamic subscriptions
Innovation: Declarative Priority Management
csharp
public event Func OnDamageEvent; // 구독 순서와 무관하게 우선순위로 실행 [EventPriority(1, "Damage")] IEnumerator ProcessDamage() { } [EventPriority(3, "Death")] IEnumerator CheckDeath() { } [EventPriority(2, "Animation")] IEnumerator PlayAnimation() { } // 구독 순서가 바뀌어도 실행 순서는 항상 동일 OnDamageEvent += CheckDeath; // 늦게 구독해도 OnDamageEvent += ProcessDamage; // 1번째 실행 OnDamageEvent += PlayAnimation; // 2번째 실행 // 3번째 실행
🌟 The Real Value of This Innovation
Scenario: Combat with Chain Reaction
csharp
// 기존 방식: 구독 순서에 민감 OnAttackEvent += ProcessDamage; // 먼저 구독하면 먼저 실행 OnAttackEvent += TriggerCounter; // 반격이 피해보다 늦게 처리 OnAttackEvent += CheckDeath; // 죽음 체크 OnAttackEvent += PlayAnimation; // 애니메이션 // 문제: 초기화 순서나 동적 구독에 따라 실행 순서 변경 가능
Improved approach: Ensuring clear ordering with attributes
csharp
[EventPriority(1, "PreProcess")] IEnumerator CalculateDamage() { } [EventPriority(2, "Damage")] IEnumerator ApplyDamage() { } [EventPriority(2, "Counter")] // 피해와 동시에 반격 IEnumerator TriggerCounter() { } [EventPriority(3, "PostProcess")] IEnumerator CheckDeath() { } [EventPriority(4, "Visual")] IEnumerator PlayAnimation() { } // 언제 구독하든, 어떤 순서로 구독하든 실행 순서 동일
Same priority, different categories = parallel execution