전체 글 607

무기 변경

UI Button을 눌렀을 때 무기가 바뀌는 원리 InputManager.cs CharacterInventory.cs protected override void HandleInput() { if (!AbilityAuthorized || (_condition.CurrentState != CharacterStates.CharacterConditions.Normal)) { return; } if (_inputManager.SwitchWeaponButton.State.CurrentState == MMInput.ButtonStates.ButtonDown) { SwitchWeapon (); } } InputManger클래스를 참조하고 있으면서 State에 따라 함수 호출 protected virtual void S..

Unity/TopdownEngine 2023.01.30

MMEvent 동작 원리

싱글톤 패턴에 Listener 등록하는 방식. 싱글톤 클래스에서는 누가 듣던가말던가 등록한 것들 Broadcast Android에서 EventBus처럼 쓰면 될듯함. Example (Achievement) Checkpoint.cs /// /// An event to trigger when a checkpoint is reached /// public struct CheckPointEvent { public int Order; public CheckPointEvent(int order) { Order = order; } static CheckPointEvent e; public static void Trigger(int order) { e.Order = order; MMEventManager.Trigger..

Unity/TopdownEngine 2023.01.29

특정 Ability On/Off 하기

PickableAbility.cs protected override void Pick(GameObject picker) { if (_character == null) { return; } bool newState = (Method == Methods.Permit); CharacterAbility ability = _character.FindAbilityByString(AbilityTypeAsString); if (ability != null) { ability.PermitAbility(newState); } } ability.PermitAbility(newState); AbilityPermitted 와 추가 조건들을 더해서 AbilityAuthorized 변수가 Ability의 발현 여부를 결정 Char..

Unity/TopdownEngine 2023.01.28

gameObject에 SendMessage 보내기

Java의 Reflection과 유사. String으로 매소드 이름과 매개변수를 보냄. MMPreventPassingThrough3D.cs (Sample) /// /// On fixedUpdate, checks the last movement and if needed casts a ray to detect obstacles /// protected virtual void FixedUpdate() { _lastMovement = this.transform.position - _positionLastFrame; _lastMovementSquared = _lastMovement.sqrMagnitude; // if we've moved further than our bounds, we may have misse..

(Weapon) 벽 튕기는 Projectile

https://topdown-engine-docs.moremountains.com/API/class_more_mountains_1_1_top_down_engine_1_1_projectile.html 대부분 Projectile에서 상속된 변수들이라 동일하고, Bounciness부분을 조절하면 튕긴다. · Amount Of Bounces : 몇번 튕기는지. 튕기다가 총알 자체가 Destroy될 수도 있으니, LifeTime, DamageOnToucch, Health등 연관된 기능들과 같이 체크해봐야 함. · Speed Modifier : 튕기고 속도가 어떻게 변하는지. 1.0이 기본값이고 비율로 변함. · Unity의 Raycast 설명: https://kukuta.tistory.com/391

Unity/TopdownEngine 2023.01.24