분류 전체보기 613

Scene 이동 간에 유지되는 GameObject

🧰 MMPersistentSingleton을 상속한 클래스의 Instace를 가져오면 자동으로 DontDestroy영역에 해당 클래스가 생성됨 🧰 그냥 MMSingleton 클래스는 DontDestroyOnLoad 없음 GameManager.cs public class GameManager : MMPersistentSingleton, void Awake() { GameManager.Instance.MaximumLives = 1; } MMPersistentSingleton.cs public class MMPersistentSingleton : MonoBehaviourwhere T : Component { protected virtual void Awake () { InitializeSingleton(); ..

Unity/TopdownEngine 2023.03.10

Weapon 능력치 동적 변경 계획

게임 진행 중 Weapon의 능력치 (공격속도, 데미지 등) 을 변경 계획 Static 능력치 1. Scriptable Object에 초깃값 및 레벨 별 능력치가 이미 기록되어 있음. 2. Level에 따라 무기의 능력치 초기화 Dynamic 능력치 1. 능력치를 컨트롤하는 Manager가 전역적으로 있음 2. Weapon과 Bullet에 Listener가 있음. 이 친구는 모든 Weapon과 Bullet에 붙어있음 3. Manager에서 BroadCast하면 각 Listenr에서 이를 Observer하여 반영

Unity/TopdownEngine 2023.02.15

무기 변경

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..