arena/context/fighter.md

6.7 KiB

Update: Field HUD Text Removal

  • fighterFactory.js no longer creates pooled battlefield name labels. Zoom-visible and selected fighters can still show pooled health bars, while team identity comes from the team-colored sprite shadow.
  • HUD cleanup now owns only health-bar display objects.

Update: Elite Representative Fighter

  • fighterFactory.js accepts isElite and stackCount on a spawn plan. Elite attack damage is tuned by FIGHTER.ELITE.ATTACK_DAMAGE_BONUS_MULTIPLIER and ATTACK_DAMAGE_STACK_EXPONENT; HP, scale, and range use the other nested elite settings.
  • fighterSelection.js assigns elite plans only skins whose derived type matches FIGHTER.ELITE.TYPE (currently melee and magic); normal plans still draw from the complete manifest.
  • Elite scale becomes its baseScaleX/baseScaleY; kill-growth is currently disabled by COMBAT.KILL_REWARD_ENABLED = false, but this baseline remains correct if a separate mode enables it later.
  • Elite magic attack effects are scaled in combat.js through FIGHTER.ELITE.ATTACK_EFFECT_SCALE_MULTIPLIER, so spell visuals can be tuned independently from body scale.
  • Elite representatives cannot use splitOnDeath. Elite attack-speed and movement-speed bonuses are configurable independently under FIGHTER.ELITE.

Update: HUD Pooling

  • fighterFactory.js no longer creates permanent health bars for every fighter, and battlefield name labels are not created at all.
  • Health-bar HUD display objects are pooled on the scene and assigned only to selected fighters or zoom-visible nearby fighters chosen by ArenaScene.
  • syncFighterHud() acquires a slot lazily and releaseFighterHud() returns it to the pool when the fighter leaves the HUD candidate set, dies, or is destroyed.
  • Tune pool size and visible candidate limits in PERFORMANCE.FIGHTER_HUD_POOL_SIZE and PERFORMANCE.FIGHTER_HUD_VISIBLE_LIMIT.

Update: Team Shadow Sprite Optimization

  • Team identity is no longer rendered with a duplicated teamMarker sprite. fighterFactory.js now creates only the main Phaser sprite for each fighter.
  • fighterAssets.js lazily creates team-colored spritesheets for the actual skin + action + teamColor combinations used in a match. The derived texture keeps the original character art and replaces only the floor shadow color (#534545) in the lower frame band (y=55..59) with the team color.
  • Combat animation playback calls ensureFighterTeamAnimation() before switching actions, so idle, walk, attack, hurt, and death states keep the same team shadow treatment.
  • This reduces display-list cost from fighter sprite + teamMarker sprite to a single fighter sprite. The tradeoff is extra texture memory for team-colored derivatives, so derived textures must stay lazy and should not be pre-generated for the whole manifest.
  • Frost stun still uses the fighter body's setTint(WORLD_EFFECT.FROST_STUN_TINT). Do not reuse tint for team identity; team color is baked into the shadow pixels instead.

Context: Fighter & Assets

1. 모듈별 상세 역할 (src/game/fighter/)

  • fighterAssets.js: 캐릭터 스프라이트 로드 및 애니메이션/실루엣 생성을 담당합니다. 원본 이미지로부터 팀 색상 마커용 실루엣을 동적으로 생성합니다.
  • fighterFactory.js: 캐릭터 인스턴스화 및 HUD(이름표, 체력바) 관리를 담당합니다. Phaser Sprite와 DOM UI 사이의 가교 역할을 합니다.
  • fighterManifest.js: 모든 캐릭터 종족 및 스탯 데이터를 정의합니다. 20여 종의 캐릭터 설정이 포함되어 있습니다.
  • fighterStats.js: 공격 방식으로 melee, ranged, magic 역할을 판별하고 역할별 기본 스탯과 스킨별 오버라이드를 병합합니다.
  • fighterSelection.js: 매치 참여 캐릭터를 무작위로 선택하거나 섞는 로직을 담당합니다.

2. 주요 로직 구현 세부 사항

동적 팀 실루엣 생성

팀 색상 표시는 캐릭터 모양을 정교하게 따라가는 별도 spritesheet입니다.

  1. fighterAssets.js가 로드된 원본 스프라이트의 alpha 데이터를 캔버스에서 읽습니다.
  2. 원본 alpha 픽셀 주변 SELECTED_FIGHTER_OUTLINE_GAP은 비우고, 그 바깥 SELECTED_FIGHTER_OUTLINE_WIDTH에만 흰색 outline을 칠합니다.
  3. fighterFactory.js에서 생성된 캐릭터 뒤에 배치하고 팀 색상으로 tint 처리합니다.
  4. 캐릭터가 성장하여 커져도 같은 배율로 실루엣이 유지됩니다.

캐릭터 HUD 및 상태 동기화

  • 이름표 고정: 스프라이트 중심이 아닌 실제 히트박스 하단에 고정되어 시각적 일관성을 유지합니다.
  • 사망자 처리: 사망 시 HUD와 팀 마커를 숨겨 화면 가독성을 높입니다. 본체 sprite만 낮은 depth와 반투명 상태로 남깁니다.
  • 월드 감속 상태: 생성 시 worldEffectSpeedMultiplier1로 초기화하며, 냉각지대 안에서는 worldEffects.js가 해당 배율을 낮춰 공격속도와 이동속도 계산에 반영합니다.
  • 냉기 동결 상태: isFrostStunned와 동결 타이머를 캐릭터별로 관리합니다. 냉기 메테오 착탄에 생존하면 캐릭터 본체와 팀 실루엣 마커가 함께 얼음색으로 바뀌고, 동결 종료 시 본체 원본 색상과 저장된 팀 색상으로 복구됩니다.

캐릭터별 특성 (예: Slime)

  • spawnMultiplier: 배정된 슬롯 1개를 지정된 수만큼 확장하여 스폰합니다.
  • splitOnDeath: 사망 시 확률적으로 지정된 수만큼 분열체를 생성합니다.
  • 처치 보너스 비활성화: elite 압축 전투에서는 처치 회복/성장 보너스가 적용되지 않습니다. 따라서 Slime을 포함한 모든 fighter는 처치로 HP 또는 크기/속도 배율을 얻지 않습니다.

역할별 전투 스탯

  • combat.typeprojectile이면 ranged, instant-spell이면 magic, 그 외에는 melee 기본 프로필을 사용합니다.
  • 새로운 공격 구현이 기본 판별과 다른 역할을 사용해야 할 때는 combat.fighterTypemelee, ranged, magic 중 하나를 명시합니다.
  • 개별 스킨의 기존 stats.maxHp, combat.range, combat.cooldown, combat.criticalChance, combat.projectile.speed, combat.attackEffect.hitDelay 설정은 역할별 기본값보다 우선합니다.

3. 유지보수 규칙

  • 신규 캐릭터: 에셋 배치 후 fighterManifest.js에 정의를 추가합니다.
  • 종족값: 사망 통계를 위해 지정된 6개 종족 중 하나를 반드시 선택해야 합니다.
  • 캐릭터 특성: 전투 중 새 유닛을 생성하는 특성은 ArenaScene.js의 생성 헬퍼를 통해 this.fightersteam.size를 함께 갱신해야 합니다.