Skip to content

Commit

Permalink
Added functions to fire from existing bullets
Browse files Browse the repository at this point in the history
Also removed BoundsCheck since it is useless now that it is not mandatory
to bind fired bullets to DanmakuFields

Also added a bit of dopcumentation
  • Loading branch information
james7132 committed Jun 5, 2015
1 parent a8239e9 commit 600ab2d
Show file tree
Hide file tree
Showing 20 changed files with 314 additions and 78 deletions.
2 changes: 1 addition & 1 deletion Assets/DanmakU/Core/Colliders/AccelerationCollider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class AccelerationCollider : DanmakuCollider {
private float acceleration;

/// <summary>
/// Gets or sets the acceleration.
/// Gets or sets the acceleration applied to affected bullets. Measured in units per second per second.
/// </summary>
/// <value>The acceleration applied to bullets, in absolute world units/second^2.</value>
public float Acceleration {
Expand Down
62 changes: 54 additions & 8 deletions Assets/DanmakU/Core/Colliders/AddControllerCollider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
/// A set of pre-created Danmaku Colliders that can be used
/// </summary>
namespace DanmakU.Collider {


/// <summary>
/// A DanmakuCollider implementation that adds controllers to valid bullets that contact it.
/// </summary>
[AddComponentMenu("DanmakU/Colliders/Add Controller Collider")]
public class AddControllerCollider : DanmakuCollider {

Expand All @@ -20,6 +23,9 @@ public class AddControllerCollider : DanmakuCollider {

private DanmakuGroup affected;

/// <summary>
/// Called on Component instantiation
/// </summary>
public override void Awake () {
base.Awake ();
affected = new DanmakuSet ();
Expand All @@ -31,26 +37,66 @@ public override void Awake () {
}

/// <summary>
/// Adds a Danmaku Controller to the list. This Danmaku Controller will be added to all bullets that touch
/// the collider until it is removed from the list.
/// Adds a Danmaku Controller to the list.
/// </summary>
/// <param name="controller">The IDanmakuController implementation of a danmaku controller.</param>
///
/// <remarks>
/// The Danmaku Controller will be added to all bullets that contact the collider until it is removed from the list.
/// If the controller is already on the list, it will still be added. More than one copy of the controller will be applied
/// to bullets.
/// </remarks>
/// <param name="controller">The controller to be added.</param>
public void AddController(IDanmakuController controller) {
controllerAggregate += controller.Update;
}


/// <summary>
/// Removes a controller.
/// </summary>
///
/// <remarks>
/// The controller is no longer added to bullets that contact this collider.
/// If the list does not contain the controller, this method does nothing.
/// If the list contains more than one copy of the controller, this method only removes one copy.
/// </remarks>
/// <param name="controller">The controller to be removed.</param>
public void RemoveController(IDanmakuController controller) {
controllerAggregate -= controller.Update;
}


/// <summary>
/// Adds a Danmaku Controller to the list.
/// </summary>
///
/// <remarks>
/// The Danmaku Controller will be added to all bullets that contact the collider until it is removed from the list.
/// If the controller is already on the list, it will still be added. More than one copy of the controller will be applied
/// to bullets.
/// </remarks>
/// <param name="controller">The controller(s) to be added.</param>
public void AddController(DanmakuController controller) {
controllerAggregate += controller;
}


/// <summary>
/// Removes a controller.
/// </summary>
///
/// <remarks>
/// The controller is no longer added to bullets that contact this collider.
/// If the list does not contain the controller, this method does nothing.
/// If the list contains more than one copy of the controller, this method only removes one copy.
/// If the supplied controller is multicast and contains multiple controllers, all of the contained controllers will be removed.
/// </remarks>
/// <param name="controller">Controller.</param>
public void RemoveController(DanmakuController controller) {
controllerAggregate -= controller;
}


/// <summary>
/// Clears the controllers.
/// All of the currently included contrrollers are removed.
/// </summary>
public void ClearControllers() {
controllerAggregate = null;
}
Expand Down
9 changes: 9 additions & 0 deletions Assets/DanmakU/Core/Colliders/ClearControllersCollider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@

using UnityEngine;

/// <summary>
/// A set of pre-created Danmaku Colliders that can be used
/// </summary>
namespace DanmakU.Collider {

/// <summary>
/// A DanmakuCollider implementation that removes all DanmakuControllers from the bullets that come into contact with it.
/// </summary>
[AddComponentMenu("DanmakU/Colliders/Clear Controllers Collider")]
public class ClearControllersCollider : DanmakuCollider {

private DanmakuGroup affected;

/// <summary>
/// Called on Component instantiation
/// </summary>
public override void Awake () {
base.Awake ();
affected = new DanmakuSet ();
Expand Down
37 changes: 29 additions & 8 deletions Assets/DanmakU/Core/Colliders/ColorChangeCollider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,49 @@
using UnityEngine;
using Vexe.Runtime.Types;

/// <summary>
/// A set of pre-created Danmaku Colliders that can be used
/// </summary>
namespace DanmakU.Collider {

public class ColorChangeCollider : DanmakuCollider {

//TODO Make a proper custom editor for this class
//TODO Document

public enum ColorType { Constant, Random, Gradient }

[SerializeField, Show]
private Color[] colors;
public Color[] Colors {
private ColorType type;
public ColorType Type {
get {
return colors;
return type;
}
set {
colors = value;
type = value;
}
}

[SerializeField, Show]
private ColorType type;
public ColorType Type {
private Color color;

public Color Color {
get {
return type;
return color;
}
set {
type = value;
color = value;
}
}

[SerializeField, Show]
private Color[] colors;
public Color[] Colors {
get {
return colors;
}
set {
colors = value;
}
}

Expand All @@ -46,6 +64,9 @@ public Gradient Gradient {

private DanmakuGroup affected;

/// <summary>
/// Called on Component instantiation
/// </summary>
public override void Awake () {
base.Awake ();
affected = new DanmakuSet ();
Expand Down
7 changes: 6 additions & 1 deletion Assets/DanmakU/Core/Colliders/ConstantForceCollider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
using UnityEngine;
using Vexe.Runtime.Types;

/// <summary>
/// A set of pre-created Danmaku Colliders that can be used
/// </summary>
namespace DanmakU.Collider {

[AddComponentMenu("DanmakU/Colliders/Constant Force Collider")]
public class ConstantForceCollider : DanmakuCollider {


//TODO Document

[SerializeField, Show]
private Vector2 force;

Expand Down
3 changes: 3 additions & 0 deletions Assets/DanmakU/Core/Colliders/DeactivationCollider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// See the LISCENSE file for copying permission.
using UnityEngine;

/// <summary>
/// A set of pre-created Danmaku Colliders that can be used
/// </summary>
namespace DanmakU.Collider {

/// <summary>
Expand Down
8 changes: 7 additions & 1 deletion Assets/DanmakU/Core/Colliders/PrefabChangeCollider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
using UnityEngine;
using Vexe.Runtime.Types;

/// <summary>
/// A set of pre-created Danmaku Colliders that can be used
/// </summary>
namespace DanmakU.Collider {

[AddComponentMenu("DanmakU/Colliders/Prefab Change Collider")]
public class PrefabChangeCollider : DanmakuCollider {

//TODO Document

[SerializeField, Show]
private DanmakuPrefab prefab;
Expand Down Expand Up @@ -39,7 +44,8 @@ protected override void DanmakuCollision (Danmaku danmaku, RaycastHit2D info) {
if (affected.Contains (danmaku))
return;

danmaku.MatchPrefab (prefab);
if(prefab != null)
danmaku.MatchPrefab (prefab);

affected.Add (danmaku);

Expand Down
5 changes: 5 additions & 0 deletions Assets/DanmakU/Core/Colliders/RedirectionCollider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
using UnityEngine;
using Vexe.Runtime.Types;

/// <summary>
/// A set of pre-created Danmaku Colliders that can be used
/// </summary>
namespace DanmakU.Collider {

/// <summary>
/// A DanmakuCollider that changes the direction of motion for all valid bullets that come into contact with it.
/// </summary>
[AddComponentMenu("DanmakU/Colliders/Redirection Collider")]
public class RedirectionCollider : DanmakuCollider {

//TODO Document

[SerializeField]
private RotationMode rotationMode;
Expand Down
16 changes: 15 additions & 1 deletion Assets/DanmakU/Core/Colliders/ReflectionCollider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@

using UnityEngine;

/// <summary>
/// A set of pre-created Danmaku Colliders that can be used
/// </summary>
namespace DanmakU.Collider {


/// <summary>
/// A DanmakuCollider implementation that uses vector reflection to redirect bullets.
/// </summary>
///
/// <remarks>
/// The resultant direction that valid bullets face after coming into contact with this collider is based
/// on the vector reflection calculated from the incoming direction of the bullet and the normal to the collider at the point of collision.
/// </remarks>
[AddComponentMenu("DanmakU/Colliders/Reflection Collider")]
public class ReflectionCollider : DanmakuCollider {

private DanmakuGroup affected;

/// <summary>
/// Called on Component instantiation
/// </summary>
public override void Awake () {
base.Awake ();
affected = new DanmakuSet ();
Expand Down
2 changes: 2 additions & 0 deletions Assets/DanmakU/Core/Controllers/AccelerationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace DanmakU.Controllers {
/// A Danmaku Controller that makes Danmaku speed up or slow down over time.
/// </summary>
public class AccelerationController : IDanmakuController {

//TODO Document

[SerializeField, Show]
private float acceleration;
Expand Down
9 changes: 9 additions & 0 deletions Assets/DanmakU/Core/Controllers/AutoDeactivateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace DanmakU.Controllers {
/// </summary>
[System.Serializable]
public class AutoDeactivateController : IDanmakuController {

//TODO Document

[SerializeField, Show]
private int frames;
Expand Down Expand Up @@ -42,11 +44,18 @@ public AutoDeactivateController(float time) {
}

#region IDanmakuController implementation

/// <summary>
/// Updates the Danmaku controlled by the controller instance.
/// </summary>
/// <param name="danmaku">the bullet to update.</param>
/// <param name="dt">the change in time since the last update</param>
public void Update (Danmaku danmaku, float dt) {
if (danmaku.frames > frames) {
danmaku.Deactivate();
}
}

#endregion

}
Expand Down
8 changes: 8 additions & 0 deletions Assets/DanmakU/Core/Controllers/ColorChangeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace DanmakU.Controllers {
[System.Serializable]
public class ColorChangeController : IDanmakuController {

//TODO Document

[SerializeField, Show]
private Gradient colorGradient;
public Gradient ColorGradient {
Expand Down Expand Up @@ -45,6 +47,12 @@ public float EndTime {

#region IDanmakuController implementation

/// <summary>
/// Updates the Danmaku controlled by the controller instance.
/// </summary>
/// <param name="danmaku">the bullet to update.</param>
/// <param name="dt">the change in time since the last update</param>
/// <param name="projectile">Projectile.</param>
public void Update (Danmaku projectile, float dt) {
Gradient gradient = ColorGradient;
if (gradient == null)
Expand Down
8 changes: 7 additions & 1 deletion Assets/DanmakU/Core/Controllers/DelayedAngleChange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace DanmakU.Controllers {

[System.Serializable]
public class DelayedAngleChange : IDanmakuController {


//TODO Document
//TODO Find a better solution to than this

[SerializeField, Show]
Expand Down Expand Up @@ -58,6 +59,11 @@ public Transform Target {

#region implemented abstract members of IDanmakuController

/// <summary>
/// Updates the Danmaku controlled by the controller instance.
/// </summary>
/// <param name="danmaku">the bullet to update.</param>
/// <param name="dt">the change in time since the last update</param>
public void Update (Danmaku danmaku, float dt) {
float time = danmaku.Time;
if(time >= Delay && time - dt <= Delay) {
Expand Down
Loading

0 comments on commit 600ab2d

Please sign in to comment.