BurningTimesAi/공유/개발팀_백업/EerieVillage/PlayerController.cs.bak_202...

151 lines
4.6 KiB
C#
Raw Normal View History

feat(BT5-Dev·2단계 + BT6-Plan·Phase3B): 7 Agent 병렬 집행 + pm-auditor Critical·Major 정정 BT5-Dev 2단계 (개발팀 Agent · Unity MCP 미지원 환경에서 파일 직접 Edit ~90% 커버): - Unity 5종 편집 (PlayerAttack·AttackHitbox 신설, PlayerController·Health·PlayerEnemyCollision 개정) - InputSystem_Actions Attack 액션·SampleScene Alien→PlayerIdle GUID 교체 - i-frame 0.6s·마우스 좌 공격·밟기 판정 폐기 - 백업 5종 C6-1 표준 - 구현 보고 04_BT5-Dev_2단계_구현보고.md - PD 수동 4건 남음 (AttackHitbox·Enemy Health·Play 검증·Animator trigger) BT6-Plan Phase 3-B (기획팀 6개 전문 에이전트 병렬 · 14문서 2224 라인 · 기각 53건): - narrative 3종: 마을 안개골·보스 3종·해학 60/민속 30/공포 10 - system 2종: 카드 3티어·특성 A/B/C 3축·오행 태그 - content 3종: 카드 32·아이템 파츠 5종 21예시·특성 15종 - level 2종: 스테이지 5·보스 3 3페이즈 - balance 2종: 이동 6.0·i-frame 0.6s·XP 80+Lv×20 - ux 2종: 가상 스틱+버튼·HUD 3순위·Tier 2 편입 후보 PM 자진 정정: - feedback_pm_dev_task_delegation_failure.md 신설 (Unity MCP PD 전가 패턴 재발 방지) - pm-auditor Critical 6·Major 4 지적 반영: · 기각안 59→53건 실측 정정 (C5 정직성) · 라인수 2350→2224 정정 · BT6-Plan 진행중 복귀 (commit 후 아카이브 이동) · 개발팀 로그 BT5-Plan 오등록 제거 · 2026-04-22.md narrative-designer 일자 오판 정정 주석 · audit_pattern_analysis placeholder 정리 매니페스트: 2026-04-23_BT5BT6_일괄commit (27건) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 17:19:47 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Platformer.Gameplay;
using static Platformer.Core.Simulation;
using Platformer.Model;
using Platformer.Core;
using UnityEngine.InputSystem;
namespace Platformer.Mechanics
{
/// <summary>
/// This is the main class used to implement control of the player.
/// It is a superset of the AnimationController class, but is inlined to allow for any kind of customisation.
/// </summary>
public class PlayerController : KinematicObject
{
public AudioClip jumpAudio;
public AudioClip respawnAudio;
public AudioClip ouchAudio;
/// <summary>
/// Max horizontal speed of the player.
/// </summary>
public float maxSpeed = 7;
/// <summary>
/// Initial jump velocity at the start of a jump.
/// </summary>
public float jumpTakeOffSpeed = 7;
public JumpState jumpState = JumpState.Grounded;
private bool stopJump;
/*internal new*/ public Collider2D collider2d;
/*internal new*/ public AudioSource audioSource;
public Health health;
public bool controlEnabled = true;
bool jump;
Vector2 move;
SpriteRenderer spriteRenderer;
internal Animator animator;
readonly PlatformerModel model = Simulation.GetModel<PlatformerModel>();
private InputAction m_MoveAction;
private InputAction m_JumpAction;
public Bounds Bounds => collider2d.bounds;
void Awake()
{
health = GetComponent<Health>();
audioSource = GetComponent<AudioSource>();
collider2d = GetComponent<Collider2D>();
spriteRenderer = GetComponent<SpriteRenderer>();
animator = GetComponent<Animator>();
m_MoveAction = InputSystem.actions.FindAction("Player/Move");
m_JumpAction = InputSystem.actions.FindAction("Player/Jump");
m_MoveAction.Enable();
m_JumpAction.Enable();
}
protected override void Update()
{
if (controlEnabled)
{
move.x = m_MoveAction.ReadValue<Vector2>().x;
if (jumpState == JumpState.Grounded && m_JumpAction.WasPressedThisFrame())
jumpState = JumpState.PrepareToJump;
else if (m_JumpAction.WasReleasedThisFrame())
{
stopJump = true;
Schedule<PlayerStopJump>().player = this;
}
}
else
{
move.x = 0;
}
UpdateJumpState();
base.Update();
}
void UpdateJumpState()
{
jump = false;
switch (jumpState)
{
case JumpState.PrepareToJump:
jumpState = JumpState.Jumping;
jump = true;
stopJump = false;
break;
case JumpState.Jumping:
if (!IsGrounded)
{
Schedule<PlayerJumped>().player = this;
jumpState = JumpState.InFlight;
}
break;
case JumpState.InFlight:
if (IsGrounded)
{
Schedule<PlayerLanded>().player = this;
jumpState = JumpState.Landed;
}
break;
case JumpState.Landed:
jumpState = JumpState.Grounded;
break;
}
}
protected override void ComputeVelocity()
{
if (jump && IsGrounded)
{
velocity.y = jumpTakeOffSpeed * model.jumpModifier;
jump = false;
}
else if (stopJump)
{
stopJump = false;
if (velocity.y > 0)
{
velocity.y = velocity.y * model.jumpDeceleration;
}
}
if (move.x > 0.01f)
spriteRenderer.flipX = false;
else if (move.x < -0.01f)
spriteRenderer.flipX = true;
animator.SetBool("grounded", IsGrounded);
animator.SetFloat("velocityX", Mathf.Abs(velocity.x) / maxSpeed);
targetVelocity = move * maxSpeed;
}
public enum JumpState
{
Grounded,
PrepareToJump,
Jumping,
InFlight,
Landed
}
}
}