/// <summary> /// Unregisters a saber in the Sira obstacle effect manager. /// </summary> /// <param name="saber"></param> public void UnregisterSaber(Saber saber) { ObstacleSparkleDatum osd = _obstacleSparkleData.FirstOrDefault(o => o.saber == saber); if (osd != null) { _obstacleSparkleData.Remove(osd); } }
/// <summary> /// Registers a saber into the Sira obstacle effect manager. /// </summary> /// <param name="saber"></param> public void RegisterSaber(Saber saber) { var osd = new ObstacleSparkleDatum { saber = saber, sparkleEffect = Instantiate(_obstacleSaberSparkleEffectPrefab) }; osd.sparkleEffect.color = _colorManager.GetObstacleEffectColor(); osd.effectTransform = osd.sparkleEffect.transform; _obstacleSparkleData.Add(osd); }
public override void Start() { for (int i = 0; i < _sabers.Length; i++) { ObstacleSparkleDatum obstacleSparkle = new ObstacleSparkleDatum { saber = _sabers[i], sparkleEffect = _effects[i], effectTransform = _effectsTransforms[i] }; _obstacleSparkleData.Add(obstacleSparkle); } }
private void Run() { if (!_initted) { base.Start(); for (int i = 0; i < _sabers.Length; i++) { var obstacleSparkle = new ObstacleSparkleDatum { saber = _sabers[i], sparkleEffect = _effects[i], effectTransform = _effectsTransforms[i] }; _obstacleSparkleData.Add(obstacleSparkle); } _initted = true; } }
public override void Update() { for (int i = 0; i < _obstacleSparkleData.Count; i++) { _obstacleSparkleData[i].wasSystemActive = _obstacleSparkleData[i].isSystemActive; _obstacleSparkleData[i].isSystemActive = false; } foreach (ObstacleController obstacleController in _obstaclePool.activeItems) { Bounds bounds = obstacleController.bounds; for (int i = 0; i < _obstacleSparkleData.Count; i++) { ObstacleSparkleDatum osd = _obstacleSparkleData[i]; if (osd.saber.isActiveAndEnabled && GetBurnMarkPos(bounds, obstacleController.transform, osd.saber.saberBladeBottomPos, osd.saber.saberBladeTopPos, out Vector3 pos)) { osd.isSystemActive = true; osd.burnMarkPosition = pos; osd.sparkleEffect.SetPositionAndRotation(pos, GetEffectRotation(pos, obstacleController.transform, bounds)); XRNode node = osd.saber.saberType == SaberType.SaberA ? XRNode.LeftHand : XRNode.RightHand; _hapticFeedbackController.ContinuousRumble(node); if (!osd.wasSystemActive) { osd.sparkleEffect.StartEmission(); //this.FireEvent("sparkleEffectDidStartEvent", osd.saber.saberType); _sparkleStartEvent?.Invoke(osd.saber.saberType); } } } } for (int i = 0; i < _obstacleSparkleData.Count; i++) { ObstacleSparkleDatum osd = _obstacleSparkleData[i]; if (!osd.isSystemActive && osd.wasSystemActive) { osd.sparkleEffect.StopEmission(); //this.FireEvent("sparkleEffectDidEndEvent", osd.saber.saberType); _sparkleEndEvent?.Invoke(osd.saber.saberType); } } }
/// <summary> /// The Unity Update method. /// </summary> public override void Update() { for (int i = 0; i < _obstacleSparkleData.Count; i++) { _obstacleSparkleData[i].wasSystemActive = _obstacleSparkleData[i].isSystemActive; _obstacleSparkleData[i].isSystemActive = false; } foreach (ObstacleController obstacleController in _beatmapObjectManager.activeObstacleControllers) { Bounds bounds = obstacleController.bounds; for (int i = 0; i < _obstacleSparkleData.Count; i++) { ObstacleSparkleDatum osd = _obstacleSparkleData[i]; if (osd.saber != null && osd.saber.isActiveAndEnabled && GetBurnMarkPos(bounds, obstacleController.transform, osd.saber.saberBladeBottomPos, osd.saber.saberBladeTopPos, out Vector3 pos)) { osd.isSystemActive = true; osd.burnMarkPosition = pos; osd.sparkleEffect.SetPositionAndRotation(pos, GetEffectRotation(pos, obstacleController.transform, bounds)); _hapticFeedbackController.PlayHapticFeedback(osd.saber.saberType.Node(), _rumblePreset); if (!osd.wasSystemActive) { osd.sparkleEffect.StartEmission(); Extensions.GetEventHandlers <ObstacleSaberSparkleEffectManager, Action <SaberType> >(this, "sparkleEffectDidStartEvent")?.Invoke(osd.saber.saberType); } } } } for (int i = 0; i < _obstacleSparkleData.Count; i++) { ObstacleSparkleDatum osd = _obstacleSparkleData[i]; if (!osd.isSystemActive && osd.wasSystemActive) { osd.sparkleEffect.StopEmission(); Extensions.GetEventHandlers <ObstacleSaberSparkleEffectManager, Action <SaberType> >(this, "sparkleEffectDidEndEvent")?.Invoke(osd.saber.saberType); } } }