From 600ab2d59e488d37b9cef3da8319998c258fc7c3 Mon Sep 17 00:00:00 2001 From: james7132 Date: Thu, 4 Jun 2015 22:13:42 -0400 Subject: [PATCH] Added functions to fire from existing bullets 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 --- .../Core/Colliders/AccelerationCollider.cs | 2 +- .../Core/Colliders/AddControllerCollider.cs | 62 +++++++++++++-- .../Colliders/ClearControllersCollider.cs | 9 +++ .../Core/Colliders/ColorChangeCollider.cs | 37 +++++++-- .../Core/Colliders/ConstantForceCollider.cs | 7 +- .../Core/Colliders/DeactivationCollider.cs | 3 + .../Core/Colliders/PrefabChangeCollider.cs | 8 +- .../Core/Colliders/RedirectionCollider.cs | 5 ++ .../Core/Colliders/ReflectionCollider.cs | 16 +++- .../Controllers/AccelerationController.cs | 2 + .../Controllers/AutoDeactivateController.cs | 9 +++ .../Core/Controllers/ColorChangeController.cs | 8 ++ .../Core/Controllers/DelayedAngleChange.cs | 8 +- .../Core/Controllers/FireDanmakuController.cs | 31 -------- Assets/DanmakU/Core/Danmaku.cs | 50 +++++++++++- Assets/DanmakU/Core/DanmakuExtensions.cs | 79 +++++++++++++++---- Assets/DanmakU/Core/DanmakuGroup.cs | 4 +- Assets/DanmakU/Core/DanmakuPrefab.cs | 13 +++ Assets/DanmakU/Core/FireBuilder.cs | 39 +++++++-- Assets/{ => Test}/SourceTest.cs | 0 20 files changed, 314 insertions(+), 78 deletions(-) delete mode 100644 Assets/DanmakU/Core/Controllers/FireDanmakuController.cs rename Assets/{ => Test}/SourceTest.cs (100%) diff --git a/Assets/DanmakU/Core/Colliders/AccelerationCollider.cs b/Assets/DanmakU/Core/Colliders/AccelerationCollider.cs index bc7ebb78..d585ad17 100644 --- a/Assets/DanmakU/Core/Colliders/AccelerationCollider.cs +++ b/Assets/DanmakU/Core/Colliders/AccelerationCollider.cs @@ -20,7 +20,7 @@ public class AccelerationCollider : DanmakuCollider { private float acceleration; /// - /// Gets or sets the acceleration. + /// Gets or sets the acceleration applied to affected bullets. Measured in units per second per second. /// /// The acceleration applied to bullets, in absolute world units/second^2. public float Acceleration { diff --git a/Assets/DanmakU/Core/Colliders/AddControllerCollider.cs b/Assets/DanmakU/Core/Colliders/AddControllerCollider.cs index 6107b1e7..3deceb46 100644 --- a/Assets/DanmakU/Core/Colliders/AddControllerCollider.cs +++ b/Assets/DanmakU/Core/Colliders/AddControllerCollider.cs @@ -9,7 +9,10 @@ /// A set of pre-created Danmaku Colliders that can be used /// namespace DanmakU.Collider { - + + /// + /// A DanmakuCollider implementation that adds controllers to valid bullets that contact it. + /// [AddComponentMenu("DanmakU/Colliders/Add Controller Collider")] public class AddControllerCollider : DanmakuCollider { @@ -20,6 +23,9 @@ public class AddControllerCollider : DanmakuCollider { private DanmakuGroup affected; + /// + /// Called on Component instantiation + /// public override void Awake () { base.Awake (); affected = new DanmakuSet (); @@ -31,26 +37,66 @@ public override void Awake () { } /// - /// 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. /// - /// The IDanmakuController implementation of a danmaku controller. + /// + /// + /// 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. + /// + /// The controller to be added. public void AddController(IDanmakuController controller) { controllerAggregate += controller.Update; } - + + /// + /// Removes a controller. + /// + /// + /// + /// 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. + /// + /// The controller to be removed. public void RemoveController(IDanmakuController controller) { controllerAggregate -= controller.Update; } - + + /// + /// Adds a Danmaku Controller to the list. + /// + /// + /// + /// 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. + /// + /// The controller(s) to be added. public void AddController(DanmakuController controller) { controllerAggregate += controller; } - + + /// + /// Removes a controller. + /// + /// + /// + /// 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. + /// + /// Controller. public void RemoveController(DanmakuController controller) { controllerAggregate -= controller; } - + + /// + /// Clears the controllers. + /// All of the currently included contrrollers are removed. + /// public void ClearControllers() { controllerAggregate = null; } diff --git a/Assets/DanmakU/Core/Colliders/ClearControllersCollider.cs b/Assets/DanmakU/Core/Colliders/ClearControllersCollider.cs index f78836d6..a98d3c97 100644 --- a/Assets/DanmakU/Core/Colliders/ClearControllersCollider.cs +++ b/Assets/DanmakU/Core/Colliders/ClearControllersCollider.cs @@ -4,13 +4,22 @@ using UnityEngine; +/// +/// A set of pre-created Danmaku Colliders that can be used +/// namespace DanmakU.Collider { + /// + /// A DanmakuCollider implementation that removes all DanmakuControllers from the bullets that come into contact with it. + /// [AddComponentMenu("DanmakU/Colliders/Clear Controllers Collider")] public class ClearControllersCollider : DanmakuCollider { private DanmakuGroup affected; + /// + /// Called on Component instantiation + /// public override void Awake () { base.Awake (); affected = new DanmakuSet (); diff --git a/Assets/DanmakU/Core/Colliders/ColorChangeCollider.cs b/Assets/DanmakU/Core/Colliders/ColorChangeCollider.cs index 9c73e069..0fd4cd50 100644 --- a/Assets/DanmakU/Core/Colliders/ColorChangeCollider.cs +++ b/Assets/DanmakU/Core/Colliders/ColorChangeCollider.cs @@ -5,31 +5,49 @@ using UnityEngine; using Vexe.Runtime.Types; +/// +/// A set of pre-created Danmaku Colliders that can be used +/// 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; } } @@ -46,6 +64,9 @@ public Gradient Gradient { private DanmakuGroup affected; + /// + /// Called on Component instantiation + /// public override void Awake () { base.Awake (); affected = new DanmakuSet (); diff --git a/Assets/DanmakU/Core/Colliders/ConstantForceCollider.cs b/Assets/DanmakU/Core/Colliders/ConstantForceCollider.cs index 01b64e56..6c27e751 100644 --- a/Assets/DanmakU/Core/Colliders/ConstantForceCollider.cs +++ b/Assets/DanmakU/Core/Colliders/ConstantForceCollider.cs @@ -5,11 +5,16 @@ using UnityEngine; using Vexe.Runtime.Types; +/// +/// A set of pre-created Danmaku Colliders that can be used +/// namespace DanmakU.Collider { [AddComponentMenu("DanmakU/Colliders/Constant Force Collider")] public class ConstantForceCollider : DanmakuCollider { - + + //TODO Document + [SerializeField, Show] private Vector2 force; diff --git a/Assets/DanmakU/Core/Colliders/DeactivationCollider.cs b/Assets/DanmakU/Core/Colliders/DeactivationCollider.cs index 0d93c5e9..5a310069 100644 --- a/Assets/DanmakU/Core/Colliders/DeactivationCollider.cs +++ b/Assets/DanmakU/Core/Colliders/DeactivationCollider.cs @@ -3,6 +3,9 @@ // See the LISCENSE file for copying permission. using UnityEngine; +/// +/// A set of pre-created Danmaku Colliders that can be used +/// namespace DanmakU.Collider { /// diff --git a/Assets/DanmakU/Core/Colliders/PrefabChangeCollider.cs b/Assets/DanmakU/Core/Colliders/PrefabChangeCollider.cs index 8abd891c..197fd7d3 100644 --- a/Assets/DanmakU/Core/Colliders/PrefabChangeCollider.cs +++ b/Assets/DanmakU/Core/Colliders/PrefabChangeCollider.cs @@ -5,10 +5,15 @@ using UnityEngine; using Vexe.Runtime.Types; +/// +/// A set of pre-created Danmaku Colliders that can be used +/// namespace DanmakU.Collider { [AddComponentMenu("DanmakU/Colliders/Prefab Change Collider")] public class PrefabChangeCollider : DanmakuCollider { + + //TODO Document [SerializeField, Show] private DanmakuPrefab prefab; @@ -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); diff --git a/Assets/DanmakU/Core/Colliders/RedirectionCollider.cs b/Assets/DanmakU/Core/Colliders/RedirectionCollider.cs index 06b90da3..81c18fed 100644 --- a/Assets/DanmakU/Core/Colliders/RedirectionCollider.cs +++ b/Assets/DanmakU/Core/Colliders/RedirectionCollider.cs @@ -5,6 +5,9 @@ using UnityEngine; using Vexe.Runtime.Types; +/// +/// A set of pre-created Danmaku Colliders that can be used +/// namespace DanmakU.Collider { /// @@ -12,6 +15,8 @@ namespace DanmakU.Collider { /// [AddComponentMenu("DanmakU/Colliders/Redirection Collider")] public class RedirectionCollider : DanmakuCollider { + + //TODO Document [SerializeField] private RotationMode rotationMode; diff --git a/Assets/DanmakU/Core/Colliders/ReflectionCollider.cs b/Assets/DanmakU/Core/Colliders/ReflectionCollider.cs index 3b7daccc..8872b22a 100644 --- a/Assets/DanmakU/Core/Colliders/ReflectionCollider.cs +++ b/Assets/DanmakU/Core/Colliders/ReflectionCollider.cs @@ -4,13 +4,27 @@ using UnityEngine; +/// +/// A set of pre-created Danmaku Colliders that can be used +/// namespace DanmakU.Collider { - + + /// + /// A DanmakuCollider implementation that uses vector reflection to redirect bullets. + /// + /// + /// + /// 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. + /// [AddComponentMenu("DanmakU/Colliders/Reflection Collider")] public class ReflectionCollider : DanmakuCollider { private DanmakuGroup affected; + /// + /// Called on Component instantiation + /// public override void Awake () { base.Awake (); affected = new DanmakuSet (); diff --git a/Assets/DanmakU/Core/Controllers/AccelerationController.cs b/Assets/DanmakU/Core/Controllers/AccelerationController.cs index 1dbd2720..e3269714 100644 --- a/Assets/DanmakU/Core/Controllers/AccelerationController.cs +++ b/Assets/DanmakU/Core/Controllers/AccelerationController.cs @@ -14,6 +14,8 @@ namespace DanmakU.Controllers { /// A Danmaku Controller that makes Danmaku speed up or slow down over time. /// public class AccelerationController : IDanmakuController { + + //TODO Document [SerializeField, Show] private float acceleration; diff --git a/Assets/DanmakU/Core/Controllers/AutoDeactivateController.cs b/Assets/DanmakU/Core/Controllers/AutoDeactivateController.cs index 54eededd..0d9912c6 100644 --- a/Assets/DanmakU/Core/Controllers/AutoDeactivateController.cs +++ b/Assets/DanmakU/Core/Controllers/AutoDeactivateController.cs @@ -12,6 +12,8 @@ namespace DanmakU.Controllers { /// [System.Serializable] public class AutoDeactivateController : IDanmakuController { + + //TODO Document [SerializeField, Show] private int frames; @@ -42,11 +44,18 @@ public AutoDeactivateController(float time) { } #region IDanmakuController implementation + + /// + /// Updates the Danmaku controlled by the controller instance. + /// + /// the bullet to update. + /// the change in time since the last update public void Update (Danmaku danmaku, float dt) { if (danmaku.frames > frames) { danmaku.Deactivate(); } } + #endregion } diff --git a/Assets/DanmakU/Core/Controllers/ColorChangeController.cs b/Assets/DanmakU/Core/Controllers/ColorChangeController.cs index 35fa2122..f6ed4983 100644 --- a/Assets/DanmakU/Core/Controllers/ColorChangeController.cs +++ b/Assets/DanmakU/Core/Controllers/ColorChangeController.cs @@ -10,6 +10,8 @@ namespace DanmakU.Controllers { [System.Serializable] public class ColorChangeController : IDanmakuController { + //TODO Document + [SerializeField, Show] private Gradient colorGradient; public Gradient ColorGradient { @@ -45,6 +47,12 @@ public float EndTime { #region IDanmakuController implementation + /// + /// Updates the Danmaku controlled by the controller instance. + /// + /// the bullet to update. + /// the change in time since the last update + /// Projectile. public void Update (Danmaku projectile, float dt) { Gradient gradient = ColorGradient; if (gradient == null) diff --git a/Assets/DanmakU/Core/Controllers/DelayedAngleChange.cs b/Assets/DanmakU/Core/Controllers/DelayedAngleChange.cs index 1747207f..4f9c03aa 100644 --- a/Assets/DanmakU/Core/Controllers/DelayedAngleChange.cs +++ b/Assets/DanmakU/Core/Controllers/DelayedAngleChange.cs @@ -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] @@ -58,6 +59,11 @@ public Transform Target { #region implemented abstract members of IDanmakuController + /// + /// Updates the Danmaku controlled by the controller instance. + /// + /// the bullet to update. + /// the change in time since the last update public void Update (Danmaku danmaku, float dt) { float time = danmaku.Time; if(time >= Delay && time - dt <= Delay) { diff --git a/Assets/DanmakU/Core/Controllers/FireDanmakuController.cs b/Assets/DanmakU/Core/Controllers/FireDanmakuController.cs deleted file mode 100644 index b75a4f65..00000000 --- a/Assets/DanmakU/Core/Controllers/FireDanmakuController.cs +++ /dev/null @@ -1,31 +0,0 @@ -//// Copyright (c) 2015 James Liu -//// -//// See the LISCENSE file for copying permission. -// -//using UnityEngine; -// -//namespace DanmakU.DanmakuControllers { -// -// [System.Serializable] -// public class FireDanmakuController : IDanmakuController { -// -// [SerializeField] -// private float delay; -// -// [SerializeField] -// private bool repeat; -// -// [SerializeField] -// private bool deactivateAfterwards; -// -// [SerializeField] -// //private DanmakuEmitter emitter; -// -// #region IDanmakuController implementation -// public void UpdateDanmaku (Danmaku danmaku, float dt) { -// //TODO: IMPLEMENT -// } -// #endregion -// -// } -//} diff --git a/Assets/DanmakU/Core/Danmaku.cs b/Assets/DanmakU/Core/Danmaku.cs index 87157123..cdd6cd93 100644 --- a/Assets/DanmakU/Core/Danmaku.cs +++ b/Assets/DanmakU/Core/Danmaku.cs @@ -95,7 +95,6 @@ public enum ColliderType { /// The damage this projectile does. public int Damage; - public bool BoundsCheck; public bool CollisionCheck; public float Speed; @@ -496,7 +495,7 @@ internal void Update() { } } - if (!is_active || (BoundsCheck && Field != null && !Field.bounds.Contains (position))) { + if (!is_active || (Field != null && !Field.bounds.Contains (position))) { DeactivateImmediate(); return; } @@ -575,6 +574,52 @@ public bool IsActive { } } + public static implicit operator FireData(Danmaku danmaku) { + FireData data = new FireData(); + data.Position = danmaku.Position; + data.Rotation = danmaku.Rotation; + data.AngularSpeed = danmaku.AngularSpeed; + data.Speed = danmaku.Speed; + data.Prefab = danmaku.Prefab; + data.Controller = danmaku.ControllerUpdate; + data.Damage = danmaku.Damage; + data.Field = danmaku.Field; + return data; + } + + /// + /// Fires a single bullet from the bullet's current position. + /// + /// + /// + /// By default, firing using this method also uses the rotation of the bullet to fire the bullet. + /// Set useRotation to false to disable this. + /// + /// the data used to create the . + /// If set to true, the bullet will use the current rotation of the bullet to fire with. + public Danmaku Fire (FireData data, bool useRotation = true) { + Vector2 tempPos = data.Position; + DynamicFloat tempRot = data.Rotation; + data.Position = Position; + if(useRotation) + data.Rotation = Rotation; + Danmaku danmaku = data.Fire(); + data.Position = tempPos; + data.Rotation = tempRot; + return danmaku; + } + + public void Fire (FireBuilder builder, bool useRotation = true) { + Vector2 tempPos = builder.Position; + DynamicFloat tempRot = builder.Rotation; + builder.Position = Position; + if(useRotation) + builder.Rotation = Rotation; + builder.Fire(); + builder.Position = tempPos; + builder.Rotation = tempRot; + } + /// /// Activates this instance. /// Calling this on a already fired projectile does nothing. @@ -616,7 +661,6 @@ public void DeactivateImmediate() { controllerCheck = false; Damage = 0; runtime.Remove(this); - BoundsCheck = true; CollisionCheck = true; is_active = false; danmakuPool.Return (this); diff --git a/Assets/DanmakU/Core/DanmakuExtensions.cs b/Assets/DanmakU/Core/DanmakuExtensions.cs index 184d8cff..971c9838 100644 --- a/Assets/DanmakU/Core/DanmakuExtensions.cs +++ b/Assets/DanmakU/Core/DanmakuExtensions.cs @@ -417,7 +417,7 @@ public static T AngularSpeed (this T danmakus, DynamicFloat angularSpeed) whe danmaku.AngularSpeed = angularSpeed.Value; } } - return null; + return danmakus; } public static T AngularSpeed (this T danmakus, IList angularSpeeds) where T : class, IEnumerable { @@ -809,7 +809,7 @@ public static T Layer (this T danmakus, int layer) where T : class, IEnumerab return danmakus; } - public static T BoundsCheck (this T danmakus, bool boundsCheck) where T : class, IEnumerable { + public static T CollisionCheck (this T danmakus, bool collisionCheck) where T : class, IEnumerable { if (danmakus == null) return null; var arrayTest = danmakus as Danmaku[]; @@ -817,18 +817,18 @@ public static T BoundsCheck (this T danmakus, bool boundsCheck) where T : cla for(int i = 0; i < arrayTest.Length; i++) { Danmaku danmaku = arrayTest[i]; if(danmaku != null) - danmaku.BoundsCheck = boundsCheck; + danmaku.CollisionCheck = collisionCheck; } } else { foreach(var danmaku in danmakus) { if(danmaku != null) - danmaku.BoundsCheck = boundsCheck; + danmaku.CollisionCheck = collisionCheck; } } return danmakus; } - public static T CollisionCheck (this T danmakus, bool collisionCheck) where T : class, IEnumerable { + public static T MatchPrefab (this T danmakus, DanmakuPrefab prefab) where T : class, IEnumerable { if (danmakus == null) return null; var arrayTest = danmakus as Danmaku[]; @@ -836,38 +836,89 @@ public static T CollisionCheck (this T danmakus, bool collisionCheck) where T for(int i = 0; i < arrayTest.Length; i++) { Danmaku danmaku = arrayTest[i]; if(danmaku != null) - danmaku.CollisionCheck = collisionCheck; + danmaku.MatchPrefab(prefab); } } else { foreach(var danmaku in danmakus) { if(danmaku != null) - danmaku.CollisionCheck = collisionCheck; + danmaku.MatchPrefab(prefab); } } return danmakus; } - public static T MatchPrefab (this T danmakus, DanmakuPrefab prefab) where T : class, IEnumerable { + #endregion + + #region Fire Functions + + public static T Fire(this T danmakus, FireData data, bool useRotation = true) where T : IEnumerable { if (danmakus == null) return null; + if (data == null) + throw new System.ArgumentNullException("Fire Data cannot be null!"); var arrayTest = danmakus as Danmaku[]; + Vector2 tempPos = data.Position; + DynamicFloat tempRot = data.Rotation; if (arrayTest != null) { for(int i = 0; i < arrayTest.Length; i++) { Danmaku danmaku = arrayTest[i]; - if(danmaku != null) - danmaku.MatchPrefab(prefab); + if(danmaku != null) { + data.Position = danmaku.Position; + if(useRotation) + data.Rotation = danmaku.Rotation; + data.Fire(); + } } } else { foreach(var danmaku in danmakus) { - if(danmaku != null) - danmaku.MatchPrefab(prefab); + if(danmaku != null) { + data.Position = danmaku.Position; + if(useRotation) + data.Rotation = danmaku.Rotation; + data.Fire(); + } } } + data.Position = tempPos; + data.Rotation = tempRot; + return danmakus; + } + + public static T Fire(this T danmakus, FireBuilder builder, bool useRotation = true) where T : IEnumerable { + if (danmakus == null) + return null; + if (builder == null) + throw new System.ArgumentNullException("Fire Builder cannot be null!"); + var arrayTest = danmakus as Danmaku[]; + Vector2 tempPos = builder.Position; + DynamicFloat tempRot = builder.Rotation; + if (arrayTest != null) { + for(int i = 0; i < arrayTest.Length; i++) { + Danmaku danmaku = arrayTest[i]; + if(danmaku != null) { + builder.Position = danmaku.Position; + if(useRotation) + builder.Rotation = danmaku.Rotation; + builder.Fire(); + } + } + } else { + foreach(var danmaku in danmakus) { + if(danmaku != null) { + builder.Position = danmaku.Position; + if(useRotation) + builder.Rotation = danmaku.Rotation; + builder.Fire(); + } + } + } + builder.Position = tempPos; + builder.Rotation = tempRot; return danmakus; } - - #endregion + + #endregion } } diff --git a/Assets/DanmakU/Core/DanmakuGroup.cs b/Assets/DanmakU/Core/DanmakuGroup.cs index 2ba97703..42d547e0 100644 --- a/Assets/DanmakU/Core/DanmakuGroup.cs +++ b/Assets/DanmakU/Core/DanmakuGroup.cs @@ -325,8 +325,7 @@ public DanmakuGroup(IEnumerable danmakus) : base () { } public class DanmakuList : DanmakuGroup>, IList { - - //TODO Add additional list functions here + //TODO Document private List danmakuList; @@ -456,7 +455,6 @@ public Danmaku this [int index] { public class DanmakuSet : DanmakuGroup> { - //TODO Add additional HashSet functions here //TODO Document private HashSet danmakuSet; diff --git a/Assets/DanmakU/Core/DanmakuPrefab.cs b/Assets/DanmakU/Core/DanmakuPrefab.cs index f80e9abe..9c81867f 100644 --- a/Assets/DanmakU/Core/DanmakuPrefab.cs +++ b/Assets/DanmakU/Core/DanmakuPrefab.cs @@ -188,6 +188,8 @@ public int SortingOrder { } #endregion + //private MaterialPropertyBlock mpb; + internal DanmakuController ExtraControllers { get { return controllerAggregate; @@ -203,6 +205,10 @@ internal void Remove(Danmaku danmaku) { } void Update() { + //runtimeRenderer.GetPropertyBlock(mpb); + //mpb.SetTexture("_MainTexture", cachedSprite.texture); + //runtimeRenderer.SetPropertyBlock(mpb); + danmakuCount = currentDanmaku.Count; int count = runtimeSystem.particleCount; if (danmakuCount > count) { @@ -258,6 +264,8 @@ void Update() { } public void Awake() { + + //mpb = new MaterialPropertyBlock(); Vector3[] vertexes; Renderer singleRenderer = GetComponent (); @@ -316,6 +324,8 @@ public void Awake() { cachedSortingLayer = spriteRenderer.sortingLayerID; cachedSortingOrder = spriteRenderer.sortingOrder; + //renderMaterial = cachedMaterial; + renderMaterial = new Material(cachedMaterial); renderMaterial.mainTexture = Sprite.texture; @@ -413,6 +423,9 @@ public void Awake() { runtimeRenderer.receiveShadows = false; runtimeRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; runtimeRenderer.useLightProbes = false; + + gameObject.hideFlags = HideFlags.HideInHierarchy; + runtimeSystem.gameObject.hideFlags = HideFlags.HideInHierarchy; } #if UNITY_EDITOR diff --git a/Assets/DanmakU/Core/FireBuilder.cs b/Assets/DanmakU/Core/FireBuilder.cs index a48369a5..3da6aadc 100644 --- a/Assets/DanmakU/Core/FireBuilder.cs +++ b/Assets/DanmakU/Core/FireBuilder.cs @@ -188,9 +188,12 @@ internal FireBuilder(DanmakuPrefab prefab, DanmakuField field = null) { /// /// Sets the firing origin position to a fixed point in space. + /// + /// + /// /// To move the origin of firing after calling this requries additional calls to this method. /// This will also 'un-link' the instance from any GameObjects. - /// + /// /// the position in which public FireBuilder From (Vector2 position) { Position = position; @@ -199,7 +202,25 @@ public FireBuilder From (Vector2 position) { } /// - /// Links the firing origin position to automatically track a GameObject. + /// Sets the firing origin to the current position of a bullet. + /// + /// + /// + /// To move the origin of firing after calling this requries additional calls to this method. + /// This will also 'un-link' the instance from any GameObjects. + /// + /// Danmaku. + public FireBuilder From (Danmaku danmaku) { + Position = danmaku.Position; + positionSource = null; + return this; + } + + /// + /// Links the firing origin position to automatically track a Transform and its GameObject. + /// + /// + /// /// After calling this, all calls to Fire() will automatically be fired from the absolute world /// position of the specified. (i.e. as the GameObject moves over time. so does position the instance fires from). /// Only one call is necessary to link the object. @@ -208,7 +229,7 @@ public FireBuilder From (Vector2 position) { /// the previously specified absolute world position, which by default is (0,0). /// /// If the given Transform is already null, this method does nothing. - /// + /// /// the specified origin Transform to use. public FireBuilder From (Transform transform) { if(transform != null) @@ -218,6 +239,9 @@ public FireBuilder From (Transform transform) { /// /// Links the firing origin position to automatically track a GameObject. + /// + /// + /// /// After calling this, all calls to Fire() will automatically be fired from the absolute world /// position of the specified. (i.e. as the GameObject moves over time. so does position the instance fires from). /// Only one call is necessary to link the object. @@ -226,7 +250,7 @@ public FireBuilder From (Transform transform) { /// the previously specified absolute world position, which by default is (0,0). /// /// If the given GameObject is already null, this method does nothing. - /// + /// /// the specified origin GameObject to use. public FireBuilder From (GameObject gameObject) { if(gameObject != null) @@ -235,7 +259,10 @@ public FireBuilder From (GameObject gameObject) { } /// - /// Links the firing origin position to automatically track a GameObject. + /// Links the firing origin position to automatically track a Component and its GameObject. + /// + /// + /// /// After calling this, all calls to Fire() will automatically be fired from the absolute world /// position of the specified. (i.e. as the GameObject moves over time. so does position the instance fires from). /// Only one call is necessary to link the object. @@ -244,7 +271,7 @@ public FireBuilder From (GameObject gameObject) { /// the previously specified absolute world position, which by default is (0,0). /// /// If the given Transform is already null, this method does nothing. - /// + /// /// the specified origin Component to use. public FireBuilder From (Component component) { if(component == null) diff --git a/Assets/SourceTest.cs b/Assets/Test/SourceTest.cs similarity index 100% rename from Assets/SourceTest.cs rename to Assets/Test/SourceTest.cs