/// <summary> /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. /// </summary> /// <param name="danmaku">the danmaku that hit the collider.</param> /// <param name="info">additional information about the collision</param> protected override void DanmakuCollision(Danmaku danmaku, RaycastHit2D info) { if (affected.Contains(danmaku)) { return; } float baseAngle = angle.Value; switch (rotationMode) { case RotationMode.Relative: baseAngle += danmaku.Rotation; break; case RotationMode.Object: if (Target != null) { baseAngle += DanmakuUtil.AngleBetween2D(danmaku.Position, Target.position); } else { Debug.LogWarning("Trying to direct at an object but no Target object assinged"); } break; case RotationMode.Absolute: break; } danmaku.Rotation = baseAngle; affected.Add(danmaku); }
/// <summary> /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. /// </summary> /// <param name="danmaku">the danmaku that hit the collider.</param> /// <param name="info">additional information about the collision</param> protected override void DanmakuCollision(Danmaku danmaku, RaycastHit2D info) { if (affected.Contains(danmaku)) { return; } switch (type) { case ColorType.Constant: if (colors.Length > 0) { danmaku.Color = colors[0]; } break; case ColorType.Random: if (colors.Length > 0) { danmaku.Color = colors.Random(); } break; case ColorType.Gradient: if (gradient != null) { danmaku.Color = gradient.Evaluate(Random.value); } break; } affected.Add(danmaku); }
/// <summary> /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. /// </summary> /// <param name="danmaku">the danmaku that hit the collider.</param> /// <param name="info">additional information about the collision</param> protected override void DanmakuCollision(Danmaku danmaku, RaycastHit2D info) { if (affected.Contains(danmaku)) { return; } if (rotationMode == RotationType.Reflection) { Vector2 normal = info.normal; Vector2 direction = danmaku.direction; danmaku.Direction = direction - 2 * Vector2.Dot(normal, direction) * normal; affected.Add(danmaku); return; } float baseAngle = angle; switch (rotationMode) { case RotationType.Relative: baseAngle += danmaku.Rotation; break; case RotationType.Object: if (Target != null) { baseAngle += DanmakuUtil.AngleBetween2D( danmaku.Position, Target.position); } else { Debug.LogWarning( "Trying to direct at an object but no Target object assinged"); } break; case RotationType.Absolute: break; } danmaku.Rotation = baseAngle; affected.Add(danmaku); }
/// <summary> /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. /// </summary> /// <param name="danmaku">the danmaku that hit the collider.</param> /// <param name="info">additional information about the collision</param> protected override void DanmakuCollision(Danmaku danmaku, RaycastHit2D info) { if (affected.Contains(danmaku)) { return; } danmaku.ClearControllers(); affected.Add(danmaku); }
/// <summary> /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. /// </summary> /// <param name="danmaku">the danmaku that hit the collider.</param> /// <param name="info">additional information about the collision</param> protected override void DanmakuCollision(Danmaku danmaku, RaycastHit2D info) { if (affected.Contains(danmaku)) { return; } danmaku.ControllerUpdate += controllerAggregate; affected.Add(danmaku); }
/// <summary> /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. /// </summary> /// <param name="danmaku">the danmaku that hit the collider.</param> /// <param name="info">additional information about the collision</param> protected override void DanmakuCollision(Danmaku danmaku, RaycastHit2D info) { if (affected.Contains(danmaku)) { return; } Vector2 normal = info.normal; Vector2 direction = danmaku.direction; danmaku.Direction = direction - 2 * Vector2.Dot(normal, direction) * normal; danmaku.position = info.point; affected.Add(danmaku); }
/// <summary> /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. /// </summary> /// <param name="danmaku">the danmaku that hit the collider.</param> /// <param name="info">additional information about the collision</param> protected override void DanmakuCollision(Danmaku danmaku, RaycastHit2D info) { if (affected.Contains(danmaku)) { return; } if (prefab != null) { danmaku.MatchPrefab(prefab); } affected.Add(danmaku); }