public void Initialize(JoystickLogic joystick) { var model = _modelContainer.GetChild(0); _animationLogic = model.GetComponent <CharacterAnimationLogic>(); // subscribe to joystick var movementData = new CharacterMovementData { Joystick = joystick, MovementMaxSpeed = _config.MovementMaxSpeed, OnCanMoveCheck = CheckCanMove, JoystickData = new JoystickEventData(), CharacterRigidbody = GetComponent <Rigidbody>(), AnimationLogic = _animationLogic }; _movementLogic.Initialize(this, movementData); var pod = _podContainer.GetChild(0); _podController = pod.GetComponent <PodController>(); var podData = new PodControllerData { Owner = transform }; _podController.Initialize(podData); var reachData = new CharacterReachData { OnMeeleTrigger = new CollisionTriggerData { TriggerEnterAction = OnMeleeRangeEnter, TriggerExitAction = OnMeleeRangeExit }, OnDodgeTrigger = new CollisionTriggerData { }, OnDistanceTrigger = new CollisionTriggerData { TriggerEnterAction = OnDistanceRangeEnter, TriggerExitAction = OnDistanceRangeExit } }; _reachLogic.Initialize(reachData); var attackData = new CharacterAttackData { AnimationLogic = _animationLogic }; _attackLogic.Initialize(attackData); }
public void FindDatas() { if (controlMechanism == null) { controlMechanism = this.gameObject.GetComponentInParent <ControlMechanism>(); } if (characterMovementData == null) { characterMovementData = this.gameObject.GetComponentInChildren <CharacterMovementData>(); } if (characterAnimationData == null) { characterAnimationData = this.gameObject.GetComponentInChildren <CharacterAnimationData>(); } if (characterAttackData == null) { characterAttackData = this.gameObject.GetComponentInChildren <CharacterAttackData>(); } if (hitRegister == null) { hitRegister = this.gameObject.GetComponentInChildren <HitRegister>(); } TouchDetector[] detectors = controlMechanism.gameObject.GetComponentsInChildren <TouchDetector>(); foreach (TouchDetector d in detectors) { if (!TouchDetectors.ContainsKey(d.touchDetectorType)) { TouchDetectors.Add(d.touchDetectorType, d); } } Touchable[] touchables = controlMechanism.gameObject.GetComponentsInChildren <Touchable>(); foreach (Touchable t in touchables) { if (!Touchables.Contains(t)) { Touchables.Add(t); } } }
public void Initialize(CharacterAttackData data) { _animationLogic = data.AnimationLogic; }