···11-// Copyright (c) 2015 James Liu
22-//
33-// See the LISCENSE file for copying permission.
44-55-using UnityEngine;
66-77-namespace Hourai.DanmakU.Collider {
88-99- /// <summary>
1010- /// A DanmakuCollider implementation that uses vector reflection to redirect bullets.
1111- /// </summary>
1212- ///
1313- /// <remarks>
1414- /// The resultant direction that valid bullets face after coming into contact with this collider is based
1515- /// on the vector reflection calculated from the incoming direction of the bullet and the normal to the collider at the point of collision.
1616- /// </remarks>
1717- [AddComponentMenu("Hourai.DanmakU/Colliders/Reflection Collider")]
1818- public class ReflectionCollider : DanmakuCollider {
1919-2020- private DanmakuGroup affected;
2121-2222- /// <summary>
2323- /// Called on Component instantiation
2424- /// </summary>
2525- protected override void Awake() {
2626- base.Awake();
2727- affected = DanmakuGroup.Set();
2828- }
2929-3030- #region implemented abstract members of DanmakuCollider
3131-3232- /// <summary>
3333- /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter.
3434- /// </summary>
3535- /// <param name="danmaku">the danmaku that hit the collider.</param>
3636- /// <param name="info">additional information about the collision</param>
3737- protected override void DanmakuCollision(Danmaku danmaku,
3838- RaycastHit2D info) {
3939- if (affected.Contains(danmaku))
4040- return;
4141- Vector2 normal = info.normal;
4242- Vector2 direction = danmaku.direction;
4343- danmaku.Direction = direction -
4444- 2*Vector2.Dot(normal, direction)*normal;
4545- danmaku.position = info.point;
4646- affected.Add(danmaku);
4747- }
4848-4949- #endregion
5050- }
5151-5252-}