+ 주인공 스킬(검의 왈츠)가 추가되었습니다. ㄴ 검의 왈츠 애니메이션이 추가되었습니다. ㄴ 스킬에 맞게 UI를 표시합니다. + 주인공이 더 이상 공격 중에 이동할 수 없습니다. + 새로운 스킬 시스템으로 변경하였습니다. + Combat씬에서 사용할 Camera, Ui를 추가하였습니다. + Input Action이 변경 되었습니다. (UseSkill => ActivateMainSkill) + Idamameable 인터페이스에 GetCurrentHp() 기능이 추가되었습니다. ㄴ 변경에 따라 기존 스크립트들에 추가되었습니다.
101 lines
3.0 KiB
C#
101 lines
3.0 KiB
C#
using System;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
[RequireComponent(typeof(PlayerInput))]
|
|
public class Player : BaseCharacter, IDamageable, IView
|
|
{
|
|
protected PlayerInput playerInput;
|
|
protected Vector2 movementInput;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
|
|
playerInput = GetComponent<PlayerInput>();
|
|
}
|
|
|
|
public virtual void TakeDamage(float attackerPower, Vector3? attackPos = null)
|
|
{
|
|
throw new System.NotImplementedException();
|
|
}
|
|
|
|
public virtual void Die()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public virtual float GetCurrentHp()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public virtual void OnMove(InputValue value) // WASD
|
|
{
|
|
movementInput = value.Get<Vector2>();
|
|
}
|
|
|
|
#region Interfaces
|
|
|
|
// IView
|
|
[field: Title("IView")]
|
|
[field: SerializeField] public float ViewRadius { get; set; } = 15f;
|
|
[field: SerializeField] public float AtkRange { get; set; } = 1.5f;
|
|
[field: SerializeField] public Collider[] Targets { get; set; } = new Collider[MAX_COLLIDERS];
|
|
[field: SerializeField] public Collider Target { get; set; }
|
|
[field: SerializeField] public LayerMask TargetLayer { get; set; }
|
|
|
|
protected const int MAX_COLLIDERS = 30;
|
|
|
|
public virtual void FindNearestTargetInRange(Vector3 centerPos, bool targetIsTrigger = true)
|
|
{
|
|
Array.Clear(Targets, 0, MAX_COLLIDERS);
|
|
|
|
var numResults = Physics.OverlapSphereNonAlloc(centerPos, ViewRadius, Targets, TargetLayer,
|
|
targetIsTrigger ? QueryTriggerInteraction.Collide : QueryTriggerInteraction.Ignore);
|
|
|
|
if (numResults <= 0)
|
|
{
|
|
SetTarget(null);
|
|
return;
|
|
}
|
|
|
|
var nearestDistance = ViewRadius * ViewRadius;
|
|
Collider nearestTargetCollider = null;
|
|
|
|
for (var i = 0; i < numResults; i++)
|
|
{
|
|
var distanceSqrToTarget = (centerPos - Targets[i].bounds.center).sqrMagnitude;
|
|
|
|
if (distanceSqrToTarget >= nearestDistance) continue;
|
|
|
|
nearestDistance = distanceSqrToTarget;
|
|
nearestTargetCollider = Targets[i];
|
|
}
|
|
|
|
SetTarget(nearestTargetCollider);
|
|
}
|
|
|
|
public virtual void SetTarget(Collider value)
|
|
{
|
|
Target = value;
|
|
}
|
|
|
|
public virtual bool IsTargetWithinRange(Vector3 centerPos, float range)
|
|
{
|
|
var inRange = Vector3.Distance(centerPos, Target.bounds.center) <= range;
|
|
return inRange;
|
|
}
|
|
|
|
public virtual void MoveTarget(Vector3 targetPos, float speed, float stopDistance = Single.MaxValue)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |