🔥 12월 30일 월요일 목표 🔥
🔍 팀 프로젝트 TurnPhase UI수정하고, 애니메이션 넣기
🔍 팀 프로젝트 PassiveCamera 만들기
📌 PassiveCamera 만들기
Passive Camera는 항상 실행하는 주체 유닛을 이벤트를 통해 받고,
그 이벤트 유닛중, Follow유닛의 Position의 위치값에 따라 달라진다.
여러 가지의 패시브들을 추후에 정리 후 수정 해주면 좋을 것 같다.
현재는 AttackTargetUnit에 Enemy와 PlayerUnit 둘 다 들어 갈 수 있다.
이유는 ? Passive를 본인 힐의 경우에는 본인을 중심으로 볼 수 있도록,
Enemy일 경우를 대비해 그 사이의 Position을 보도록 카메라를 설정해 두었기 때문이다.
👀 Event Script (이벤트버스패턴) : 패시브 이벤트를 위한 클래스 생성
public class ExecutePassiveAttackCommandEvent : EventBase
{
public readonly bool IsDone;
public readonly Unit PlayerUnit;
public readonly Unit PassiveTargetUnit;
public ExecutePassiveAttackCommandEvent(bool isDone, Unit playerUnit,Unit passiveTargetUnit)
{
PlayerUnit = playerUnit;
PassiveTargetUnit = passiveTargetUnit;
IsDone = isDone;
}
}
👀 SupportFire Script : 이벤트 발행 💚
public class SupportFire : PassiveSkill
{
public override IEnumerator Execute()
{
if(UnitType.EnemyUnit == OwnerUnit.type) yield break;
if(OwnerUnit == commandEvent.Command.GetUnit()) yield break;
Unit target = commandEvent.Command.GetContext().TargetUnit;
if(target == null) yield break;
if (5 < ((OwnerUnit.curCoord.y - target.curCoord.y).Abs()) +
(OwnerUnit.curCoord.x - target.curCoord.x).Abs()) yield break;
List<Unit> targets = new() {target};
DamageCalculator.CalculateDamage(OwnerUnit, 4, OwnerUnit.curCoord, ref targets, out List<int> damages);
targetList = new List<Unit>(targets);
damageList = new List<int>(damages);
Core.EventManager.Publish(new ExecutePassiveAttackCommandEvent(false,OwnerUnit,target));
yield return OwnerUnit.SkillSystem.ActivateSKill(0, targets, damages);
Core.EventManager.Publish(new ExecutePassiveAttackCommandEvent(true,OwnerUnit,target));
commandEvent = null;
yield return null;
}
}
👀 RemoldingSupply Script : 이벤트 발행
public class RemoldingSupply : PassiveSkill
{
public override IEnumerator Execute()
{
var damages = new List<int>();
var context = new EffectContext(EffectContext.StartPos, EffectContext.StartRot, EffectContext.TargetTransform,
EffectContext.MultiTargetTransforms, damages);
EffectHandler.Play(OwnerUnit, context);
OwnerUnit.GaugeSystem.Charge<ReMolding>(1);
Core.EventManager.Publish(new ExecutePassiveAttackCommandEvent(false,OwnerUnit,OwnerUnit));
yield return base.Execute();
Core.EventManager.Publish(new ExecutePassiveAttackCommandEvent(true,OwnerUnit,OwnerUnit));
}
}
👀 Recovery Script : 이벤트 발행
public class Recovery : PassiveSkill
{
public override IEnumerator Execute()
{
var damages = new List<int>();
var context = new EffectContext(OwnerUnit.transform.position, Quaternion.identity, EffectContext.TargetTransform, EffectContext.MultiTargetTransforms, damages);
EffectHandler.Play(OwnerUnit, context);
amount = (int)(OwnerUnit.StatsSystem.Stats.Health * Data.SkillPower);
amount = OwnerUnit.HealthSystem.RecoverHealth(amount);
Core.EventManager.Publish(new ExecutePassiveAttackCommandEvent(false,OwnerUnit,OwnerUnit));
yield return base.Execute();
Core.EventManager.Publish(new ExecutePassiveAttackCommandEvent(true,OwnerUnit,OwnerUnit));
}
👀 CameraController Script : 이벤트 구독⭐⭐⭐
private void OnEnable()
{
Core.EventManager.Subscribe<ExecutePassiveAttackCommandEvent>(PassiveSkillBindTarget);
}
public void PassiveSkillBindTarget(ExecutePassiveAttackCommandEvent commandEvent)
{
switch (commandEvent.IsDone)
{
case true:
passiveCamera.gameObject.SetActive(false);
break;
case false:
if (commandEvent.PlayerUnit.type == UnitType.EnemyUnit) return;
attackTargetUnit = commandEvent.PassiveTargetUnit.Requirement.cameraPoint;
attackTarget.position = attackTargetUnit.position;
if (followTarget == null || attackTargetUnit == null)
return;
passiveCamera.transform.position = followTarget.position + new Vector3(5f,5f,-5f);
Vector3 midPoint = (followTarget.position + attackTarget.position) / 2f;
passiveCamera.transform.LookAt(midPoint);
passiveCamera.gameObject.SetActive(true);
break;
}
}
🔥 12월 31일 화요일 목표 🔥
🔍 팀 프로젝트 AI 몬스터 로직 만들기
'Unity 내배캠 TIL' 카테고리의 다른 글
Unity 게임 개발 최종 팀 프로젝트(16주차 2일) (0) | 2025.01.07 |
---|---|
Unity 게임 개발 최종 팀 프로젝트(15주차 5일) (0) | 2025.01.03 |
Unity 게임 개발 최종 팀 프로젝트(14주차 5일) (0) | 2024.12.27 |
Unity 게임 개발 최종 팀 프로젝트(14주차 3일) (0) | 2024.12.27 |
Unity 게임 개발 최종 팀 프로젝트(14주차 4일) (0) | 2024.12.26 |