An open source Danmaku development kit for Unity3D.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Reorganization of Methods

The trigonometry information did not belong in the Danmaku class. It has
instead been moved to Hourai.FastTrig instead inside HouraiLib.

The Controller and Modifier classes were in very large files. They have
been split into multiple files and kept together as a single class via
partial classes.

james713 cfe7d0fe 66f4c438

+3462 -1114
-5
Assets/Dependencies/DanmakU/.gitignore
··· 1 - #Ignore all subdirectories except Core 2 - */* 3 - !Core/ 4 - !Core/* 5 - *.cs.meta
+43
Assets/Dependencies/DanmakU/Colliders/AccelerationCollider.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + using Vexe.Runtime.Types; 7 + 8 + namespace Hourai.DanmakU.Collider { 9 + 10 + /// <summary> 11 + /// A Danmaku Controller that speeds up or slows down danmaku so long as bullets are contacting it. 12 + /// </summary> 13 + [AddComponentMenu("Hourai.DanmakU/Colliders/Acceleration Collider")] 14 + public class AccelerationCollider : DanmakuCollider { 15 + 16 + [SerializeField, Show] 17 + private float _acceleration; 18 + 19 + /// <summary> 20 + /// Gets or sets the acceleration applied to affected bullets. Measured in units per second per second. 21 + /// </summary> 22 + /// <value>The acceleration applied to bullets, in absolute world units/second^2.</value> 23 + public float Acceleration { 24 + get { return _acceleration; } 25 + set { _acceleration = value; } 26 + } 27 + 28 + #region implemented abstract members of DanmakuCollider 29 + 30 + /// <summary> 31 + /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. 32 + /// </summary> 33 + /// <param name="danmaku">the danmaku that hit the collider.</param> 34 + /// <param name="info">additional information about the collision</param> 35 + protected override void DanmakuCollision(Danmaku danmaku, 36 + RaycastHit2D info) { 37 + danmaku.Speed += _acceleration*Dt; 38 + } 39 + 40 + #endregion 41 + } 42 + 43 + }
+12
Assets/Dependencies/DanmakU/Colliders/AccelerationCollider.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 677ca41367b711e48a1eca7431c56abb 3 + timeCreated: 1441237560 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+84
Assets/Dependencies/DanmakU/Colliders/AddControllerCollider.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + using System; 7 + using Vexe.Runtime.Types; 8 + 9 + namespace Hourai.DanmakU.Collider { 10 + 11 + /// <summary> 12 + /// A DanmakuCollider implementation that adds controllers to valid bullets that contact it. 13 + /// </summary> 14 + public abstract class AddControllerCollider : DanmakuCollider { 15 + 16 + private DanmakuGroup affected; 17 + private Action<Danmaku> controllerAggregate; 18 + 19 + /// <summary> 20 + /// Called on Component instantiation. 21 + /// </summary> 22 + protected override void Awake() { 23 + base.Awake(); 24 + affected = DanmakuGroup.Set(); 25 + } 26 + 27 + /// <summary> 28 + /// Adds a Danmaku Controller to the list. 29 + /// </summary> 30 + /// 31 + /// <remarks> 32 + /// The Danmaku Controller will be added to all bullets that contact the collider until it is removed from the list. 33 + /// If the controller is already on the list, it will still be added. More than one copy of the controller will be applied 34 + /// to bullets. 35 + /// </remarks> 36 + /// <param name="controller">The controller(s) to be added.</param> 37 + public void AddController(Action<Danmaku> controller) { 38 + controllerAggregate += controller; 39 + } 40 + 41 + /// <summary> 42 + /// Removes a controller. 43 + /// </summary> 44 + /// 45 + /// <remarks> 46 + /// The controller is no longer added to bullets that contact this collider. 47 + /// If the list does not contain the controller, this method does nothing. 48 + /// If the list contains more than one copy of the controller, this method only removes one copy. 49 + /// If the supplied controller is multicast and contains multiple controllers, all of the contained controllers will be removed. 50 + /// </remarks> 51 + /// <param name="controller">Controller.</param> 52 + public void RemoveController(Action<Danmaku> controller) { 53 + controllerAggregate = controllerAggregate.Remove(controller); 54 + } 55 + 56 + /// <summary> 57 + /// Clears the controllers. 58 + /// All of the currently included contrrollers are removed. 59 + /// </summary> 60 + public void ClearControllers() { 61 + controllerAggregate = null; 62 + } 63 + 64 + #region implemented abstract members of DanmakuCollider 65 + 66 + /// <summary> 67 + /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. 68 + /// </summary> 69 + /// <param name="danmaku">the danmaku that hit the collider.</param> 70 + /// <param name="info">additional information about the collision</param> 71 + protected override void DanmakuCollision(Danmaku danmaku, 72 + RaycastHit2D info) { 73 + if (affected.Contains(danmaku)) 74 + return; 75 + 76 + danmaku.Controller += controllerAggregate; 77 + 78 + affected.Add(danmaku); 79 + } 80 + 81 + #endregion 82 + } 83 + 84 + }
+12
Assets/Dependencies/DanmakU/Colliders/AddControllerCollider.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: a798cfc5d63981946af3f26512d446a2 3 + timeCreated: 1441237561 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+45
Assets/Dependencies/DanmakU/Colliders/ClearControllersCollider.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + 7 + namespace Hourai.DanmakU.Collider { 8 + 9 + /// <summary> 10 + /// A DanmakuCollider implementation that removes all DanmakuControllers from the bullets that come into contact with it. 11 + /// </summary> 12 + [AddComponentMenu("Hourai.DanmakU/Colliders/Clear Controllers Collider")] 13 + public class ClearControllersCollider : DanmakuCollider { 14 + 15 + private DanmakuGroup affected; 16 + 17 + /// <summary> 18 + /// Called on Component instantiation 19 + /// </summary> 20 + protected override void Awake() { 21 + base.Awake(); 22 + affected = DanmakuGroup.Set(); 23 + } 24 + 25 + #region implemented abstract members of DanmakuCollider 26 + 27 + /// <summary> 28 + /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. 29 + /// </summary> 30 + /// <param name="danmaku">the danmaku that hit the collider.</param> 31 + /// <param name="info">additional information about the collision</param> 32 + protected override void DanmakuCollision(Danmaku danmaku, 33 + RaycastHit2D info) { 34 + if (affected.Contains(danmaku)) 35 + return; 36 + 37 + danmaku.ClearControllers(); 38 + 39 + affected.Add(danmaku); 40 + } 41 + 42 + #endregion 43 + } 44 + 45 + }
+12
Assets/Dependencies/DanmakU/Colliders/ClearControllersCollider.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 8a19b594620b57e4f9ad6d6edf34fd99 3 + timeCreated: 1441237560 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+99
Assets/Dependencies/DanmakU/Colliders/ColorChangeCollider.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + using Vexe.Runtime.Types; 7 + 8 + namespace Hourai.DanmakU.Collider { 9 + 10 + [AddComponentMenu("Hourai.DanmakU/Colliders/Color Change Collider")] 11 + public class ColorChangeCollider : DanmakuCollider { 12 + 13 + //TODO Make a proper custom editor for this class 14 + //TODO Document 15 + 16 + public enum ColorType { 17 + 18 + Constant, 19 + Random, 20 + Gradient 21 + 22 + } 23 + 24 + private DanmakuGroup affected; 25 + 26 + [SerializeField, Show] 27 + private Color color; 28 + 29 + [SerializeField, Show] 30 + private Color[] colors; 31 + 32 + [SerializeField, Show] 33 + private Gradient gradient; 34 + 35 + [SerializeField, Show] 36 + private ColorType type; 37 + 38 + public ColorType Type { 39 + get { return type; } 40 + set { type = value; } 41 + } 42 + 43 + public Color Color { 44 + get { return color; } 45 + set { color = value; } 46 + } 47 + 48 + public Color[] Colors { 49 + get { return colors; } 50 + set { colors = value; } 51 + } 52 + 53 + public Gradient Gradient { 54 + get { return gradient; } 55 + set { gradient = value; } 56 + } 57 + 58 + /// <summary> 59 + /// Called on Component instantiation 60 + /// </summary> 61 + protected override void Awake() { 62 + base.Awake(); 63 + affected = DanmakuGroup.Set(); 64 + } 65 + 66 + #region implemented abstract members of DanmakuCollider 67 + 68 + /// <summary> 69 + /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. 70 + /// </summary> 71 + /// <param name="danmaku">the danmaku that hit the collider.</param> 72 + /// <param name="info">additional information about the collision</param> 73 + protected override void DanmakuCollision(Danmaku danmaku, 74 + RaycastHit2D info) { 75 + if (affected.Contains(danmaku)) 76 + return; 77 + 78 + switch (type) { 79 + case ColorType.Constant: 80 + if (colors.Length > 0) 81 + danmaku.Color = colors[0]; 82 + break; 83 + case ColorType.Random: 84 + if (colors.Length > 0) 85 + danmaku.Color = colors.Random(); 86 + break; 87 + case ColorType.Gradient: 88 + if (gradient != null) 89 + danmaku.Color = gradient.Evaluate(Random.value); 90 + break; 91 + } 92 + 93 + affected.Add(danmaku); 94 + } 95 + 96 + #endregion 97 + } 98 + 99 + }
+12
Assets/Dependencies/DanmakU/Colliders/ColorChangeCollider.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: ea36137d6d757084794d6747bca47c2d 3 + timeCreated: 1441237562 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+45
Assets/Dependencies/DanmakU/Colliders/ConstantForceCollider.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + using Vexe.Runtime.Types; 7 + 8 + namespace Hourai.DanmakU.Collider { 9 + 10 + [AddComponentMenu("Hourai.DanmakU/Colliders/Constant Force Collider")] 11 + public class ConstantForceCollider : DanmakuCollider { 12 + 13 + //TODO Document 14 + 15 + [SerializeField, Show] 16 + private Vector2 force; 17 + 18 + /// <summary> 19 + /// Gets or sets the force applied to contacting Danmaku. 20 + /// </summary> 21 + /// <remarks> 22 + /// Since Danmaku have no mass. The force applied in in terms of a constant displacement (units per second). 23 + /// </remarks> 24 + /// <value>The force applied.</value> 25 + public Vector2 Force { 26 + get { return force; } 27 + set { force = value; } 28 + } 29 + 30 + #region implemented abstract members of DanmakuCollider 31 + 32 + /// <summary> 33 + /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. 34 + /// </summary> 35 + /// <param name="danmaku">the danmaku that hit the collider.</param> 36 + /// <param name="info">additional information about the collision</param> 37 + protected override void DanmakuCollision(Danmaku danmaku, 38 + RaycastHit2D info) { 39 + danmaku.Position += force*Dt; 40 + } 41 + 42 + #endregion 43 + } 44 + 45 + }
+12
Assets/Dependencies/DanmakU/Colliders/ConstantForceCollider.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 1d8c5975bb697cf4ab3517cf7c148abe 3 + timeCreated: 1441237558 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+29
Assets/Dependencies/DanmakU/Colliders/DeactivationCollider.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + 7 + namespace Hourai.DanmakU.Collider { 8 + 9 + /// <summary> 10 + /// A DanmakuCollider that deactivates all valid danmaku that come in contact with it. 11 + /// </summary> 12 + [AddComponentMenu("Hourai.DanmakU/Colliders/Deactivation Collider")] 13 + public class DeactivationCollider : DanmakuCollider { 14 + #region implemented abstract members of DanmakuCollider 15 + 16 + /// <summary> 17 + /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. 18 + /// </summary> 19 + /// <param name="danmaku">the danmaku that hit the collider.</param> 20 + /// <param name="info">additional information about the collision</param> 21 + protected override void DanmakuCollision(Danmaku danmaku, 22 + RaycastHit2D info) { 23 + danmaku.Deactivate(); 24 + } 25 + 26 + #endregion 27 + } 28 + 29 + }
+12
Assets/Dependencies/DanmakU/Colliders/DeactivationCollider.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: b203cbb6109c5a545b1a7ab53de5e998 3 + timeCreated: 1441237561 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+51
Assets/Dependencies/DanmakU/Colliders/PrefabChangeCollider.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + using Vexe.Runtime.Types; 7 + 8 + namespace Hourai.DanmakU.Collider { 9 + 10 + [AddComponentMenu("Hourai.DanmakU/Colliders/Prefab Change Collider")] 11 + public class PrefabChangeCollider : DanmakuCollider { 12 + 13 + private DanmakuGroup affected; 14 + 15 + //TODO Document 16 + 17 + [SerializeField, Show] 18 + private DanmakuPrefab prefab; 19 + 20 + public DanmakuPrefab Prefab { 21 + get { return prefab; } 22 + set { prefab = value; } 23 + } 24 + 25 + protected override void Awake() { 26 + base.Awake(); 27 + affected = DanmakuGroup.Set(); 28 + } 29 + 30 + #region implemented abstract members of DanmakuCollider 31 + 32 + /// <summary> 33 + /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. 34 + /// </summary> 35 + /// <param name="danmaku">the danmaku that hit the collider.</param> 36 + /// <param name="info">additional information about the collision</param> 37 + protected override void DanmakuCollision(Danmaku danmaku, 38 + RaycastHit2D info) { 39 + if (affected.Contains(danmaku)) 40 + return; 41 + 42 + if (prefab != null) 43 + danmaku.MatchPrefab(prefab); 44 + 45 + affected.Add(danmaku); 46 + } 47 + 48 + #endregion 49 + } 50 + 51 + }
+12
Assets/Dependencies/DanmakU/Colliders/PrefabChangeCollider.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 67f19bffe73a45a4cb87faad63dc8497 3 + timeCreated: 1441237560 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+7
Assets/Dependencies/DanmakU/Colliders/README.md
··· 1 + #Colliders 2 + 3 + This folder contains a number of classes that derive from `DanmakuCollider` (and in turn `IDanmakuCollider`). 4 + 5 + `IDanmakuCollider` is the only way to add collision event handling with fired bullets in DanmakU. This Colliders folder provides a few pre-created ones that may be very useful. 6 + 7 + See the [wiki page](https://github.com/Rhythmia/DanmakU/wiki/Danmaku-Colliders) on Danmaku Colliders for more information.
+8
Assets/Dependencies/DanmakU/Colliders/README.md.meta
··· 1 + fileFormatVersion: 2 2 + guid: a5ac467579cb3104f877260052670d72 3 + timeCreated: 1431171964 4 + licenseType: Free 5 + DefaultImporter: 6 + userData: 7 + assetBundleName: 8 + assetBundleVariant:
+83
Assets/Dependencies/DanmakU/Colliders/RedirectionCollider.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + using Vexe.Runtime.Types; 7 + 8 + namespace Hourai.DanmakU.Collider { 9 + 10 + /// <summary> 11 + /// A DanmakuCollider that changes the direction of motion for all valid bullets that come into contact with it. 12 + /// </summary> 13 + [AddComponentMenu("Hourai.DanmakU/Colliders/Redirection Collider")] 14 + public class RedirectionCollider : DanmakuCollider { 15 + 16 + private DanmakuGroup affected; 17 + 18 + [SerializeField] 19 + private float angle; 20 + 21 + //TODO Document 22 + 23 + [SerializeField] 24 + private RotationMode rotationMode; 25 + 26 + [Serialize] 27 + public Transform Target { get; set; } 28 + 29 + public RotationMode RotationMode { 30 + get { return rotationMode; } 31 + set { rotationMode = value; } 32 + } 33 + 34 + public float Angle { 35 + get { return angle; } 36 + set { angle = value; } 37 + } 38 + 39 + /// <summary> 40 + /// Called on Component instantiation 41 + /// </summary> 42 + protected override void Awake() { 43 + base.Awake(); 44 + affected = DanmakuGroup.Set(); 45 + } 46 + 47 + #region implemented abstract members of DanmakuCollider 48 + 49 + /// <summary> 50 + /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. 51 + /// </summary> 52 + /// <param name="danmaku">the danmaku that hit the collider.</param> 53 + /// <param name="info">additional information about the collision</param> 54 + protected override void DanmakuCollision(Danmaku danmaku, 55 + RaycastHit2D info) { 56 + if (affected.Contains(danmaku)) 57 + return; 58 + float baseAngle = angle; 59 + switch (rotationMode) { 60 + case RotationMode.Relative: 61 + baseAngle += danmaku.Rotation; 62 + break; 63 + case RotationMode.Object: 64 + if (Target != null) { 65 + baseAngle += DanmakuUtil.AngleBetween2D( 66 + danmaku.Position, 67 + Target.position); 68 + } else { 69 + Debug.LogWarning( 70 + "Trying to direct at an object but no Target object assinged"); 71 + } 72 + break; 73 + case RotationMode.Absolute: 74 + break; 75 + } 76 + danmaku.Rotation = baseAngle; 77 + affected.Add(danmaku); 78 + } 79 + 80 + #endregion 81 + } 82 + 83 + }
+12
Assets/Dependencies/DanmakU/Colliders/RedirectionCollider.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 5daf15082e36992419d595977a7d7a79 3 + timeCreated: 1441237559 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+52
Assets/Dependencies/DanmakU/Colliders/ReflectionCollider.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + 7 + namespace Hourai.DanmakU.Collider { 8 + 9 + /// <summary> 10 + /// A DanmakuCollider implementation that uses vector reflection to redirect bullets. 11 + /// </summary> 12 + /// 13 + /// <remarks> 14 + /// The resultant direction that valid bullets face after coming into contact with this collider is based 15 + /// on the vector reflection calculated from the incoming direction of the bullet and the normal to the collider at the point of collision. 16 + /// </remarks> 17 + [AddComponentMenu("Hourai.DanmakU/Colliders/Reflection Collider")] 18 + public class ReflectionCollider : DanmakuCollider { 19 + 20 + private DanmakuGroup affected; 21 + 22 + /// <summary> 23 + /// Called on Component instantiation 24 + /// </summary> 25 + protected override void Awake() { 26 + base.Awake(); 27 + affected = DanmakuGroup.Set(); 28 + } 29 + 30 + #region implemented abstract members of DanmakuCollider 31 + 32 + /// <summary> 33 + /// Handles a Danmaku collision. Only ever called with Danmaku that pass the filter. 34 + /// </summary> 35 + /// <param name="danmaku">the danmaku that hit the collider.</param> 36 + /// <param name="info">additional information about the collision</param> 37 + protected override void DanmakuCollision(Danmaku danmaku, 38 + RaycastHit2D info) { 39 + if (affected.Contains(danmaku)) 40 + return; 41 + Vector2 normal = info.normal; 42 + Vector2 direction = danmaku.direction; 43 + danmaku.Direction = direction - 44 + 2*Vector2.Dot(normal, direction)*normal; 45 + danmaku.position = info.point; 46 + affected.Add(danmaku); 47 + } 48 + 49 + #endregion 50 + } 51 + 52 + }
+12
Assets/Dependencies/DanmakU/Colliders/ReflectionCollider.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 5a1200496191ca74c8184189f4da76f6 3 + timeCreated: 1441237559 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+9
Assets/Dependencies/DanmakU/_Core_/Controllers.meta
··· 1 + fileFormatVersion: 2 2 + guid: 0b46dd09dbe1e014d9a18e2c83e13e3a 3 + folderAsset: yes 4 + timeCreated: 1441315913 5 + licenseType: Free 6 + DefaultImporter: 7 + userData: 8 + assetBundleName: 9 + assetBundleVariant:
+21
Assets/Dependencies/DanmakU/_Core_/Controllers/ColorControllers.cs
··· 1 + using UnityEngine; 2 + using System; 3 + using System.Collections; 4 + 5 + namespace Hourai.DanmakU 6 + { 7 + public static partial class Controller 8 + { 9 + public static Action<Danmaku> ColorChange(Func<Danmaku, Color> colorChange) 10 + { 11 + if (colorChange == null) 12 + throw new ArgumentNullException("colorChange"); 13 + return delegate(Danmaku danmaku) 14 + { 15 + danmaku.Color = colorChange(danmaku); 16 + }; 17 + } 18 + } 19 + 20 + } 21 +
+12
Assets/Dependencies/DanmakU/_Core_/Controllers/ColorControllers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 7ea11f2a2561da341a056061956a8d5f 3 + timeCreated: 1441317023 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+21
Assets/Dependencies/DanmakU/_Core_/Controllers/DeactivationControllers.cs
··· 1 + using System; 2 + 3 + namespace Hourai.DanmakU 4 + { 5 + 6 + public static partial class Controller 7 + { 8 + public static Action<Danmaku> Deactivation(Func<Danmaku, bool> deactivation) 9 + { 10 + if (deactivation == null) 11 + throw new ArgumentNullException("deactivation"); 12 + return delegate(Danmaku danmaku) 13 + { 14 + if (deactivation(danmaku)) 15 + danmaku.Deactivate(); 16 + }; 17 + } 18 + } 19 + 20 + } 21 +
+12
Assets/Dependencies/DanmakU/_Core_/Controllers/DeactivationControllers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 9544f09e1fb5d8f4cbc34011afe03b55 3 + timeCreated: 1441322783 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+42
Assets/Dependencies/DanmakU/_Core_/Controllers/RotationContrrollers.cs
··· 1 + using UnityEngine; 2 + using System; 3 + using System.Collections; 4 + 5 + namespace Hourai.DanmakU 6 + { 7 + public static partial class Controller 8 + { 9 + public static Action<Danmaku> Homing(GameObject target) 10 + { 11 + if (target == null) 12 + throw new ArgumentNullException("target"); 13 + Transform trans = target.transform; 14 + return delegate(Danmaku danmaku) 15 + { 16 + if (trans) 17 + danmaku.Rotation = DanmakuUtil.AngleBetween2D(danmaku.position, 18 + trans.position); 19 + }; 20 + } 21 + 22 + public static Action<Danmaku> Homing(Component target) 23 + { 24 + if (target == null) 25 + throw new ArgumentNullException("target"); 26 + return Homing(target.gameObject); 27 + } 28 + 29 + public static Action<Danmaku> Homing(Func<Danmaku, Transform> target) 30 + { 31 + if (target == null) 32 + throw new ArgumentNullException("target"); 33 + return delegate(Danmaku danmaku) 34 + { 35 + Transform trans = target(danmaku); 36 + if (trans) 37 + danmaku.Rotation = DanmakuUtil.AngleBetween2D(danmaku.position, 38 + trans.position); 39 + }; 40 + } 41 + } 42 + }
+12
Assets/Dependencies/DanmakU/_Core_/Controllers/RotationContrrollers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 93f08a0a8251bde4faafaa80cad5ed20 3 + timeCreated: 1441316946 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+63
Assets/Dependencies/DanmakU/_Core_/Controllers/SpeedControllers.cs
··· 1 + using UnityEngine; 2 + using System; 3 + using System.Collections; 4 + 5 + namespace Hourai.DanmakU 6 + { 7 + public static partial class Controller 8 + { 9 + public static Action<Danmaku> Acceleration(Func<Danmaku, float> acceleration) { 10 + if(acceleration == null) 11 + throw new ArgumentNullException("acceleration"); 12 + return delegate(Danmaku danmaku) { 13 + danmaku.Speed += acceleration(danmaku) * Danmaku.dt; 14 + }; 15 + } 16 + 17 + public static Action<Danmaku> Acceleration(float acceleration) { 18 + return delegate(Danmaku danmaku) 19 + { 20 + danmaku.Speed += acceleration * Danmaku.dt; 21 + }; 22 + } 23 + 24 + public static Action<Danmaku> MaxSpeedLimit(Func<Danmaku, float> speedLimit) { 25 + if(speedLimit == null) 26 + throw new ArgumentNullException("speedLimit"); 27 + return delegate(Danmaku danmaku) { 28 + float limit = speedLimit(danmaku); 29 + if (danmaku.Speed > limit) 30 + danmaku.Speed = limit; 31 + }; 32 + } 33 + 34 + public static Action<Danmaku> MaxSpeedLimit(float speedLimit) 35 + { 36 + return delegate(Danmaku danmaku) { 37 + if (danmaku.Speed > speedLimit) 38 + danmaku.Speed = speedLimit; 39 + }; 40 + } 41 + 42 + public static Action<Danmaku> MinSpeedLimit(Func<Danmaku, float> speedLimit) 43 + { 44 + if (speedLimit == null) 45 + throw new ArgumentNullException("speedLimit"); 46 + return delegate(Danmaku danmaku) 47 + { 48 + float limit = speedLimit(danmaku); 49 + if (danmaku.Speed < limit) 50 + danmaku.Speed = limit; 51 + }; 52 + } 53 + 54 + public static Action<Danmaku> MinSpeedLimit(float speedLimit) 55 + { 56 + return delegate(Danmaku danmaku) 57 + { 58 + if (danmaku.Speed < speedLimit) 59 + danmaku.Speed = speedLimit; 60 + }; 61 + } 62 + } 63 + }
+12
Assets/Dependencies/DanmakU/_Core_/Controllers/SpeedControllers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: f5cb57f83f479704888d8e911d33853c 3 + timeCreated: 1441315936 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+7 -31
Assets/Dependencies/DanmakU/_Core_/Danmaku.cs
··· 14 14 /// The base object that represents a single bullet in a bullet hell game. 15 15 /// </summary> 16 16 public sealed partial class Danmaku { 17 - 17 + 18 18 /// <summary> 19 19 /// The supported collider shapes used by danmaku. 20 20 /// </summary> ··· 28 28 } 29 29 30 30 private bool _isActive; 31 - private DanmakuController _onUpdate; 31 + private Action<Danmaku> _onUpdate; 32 32 33 33 /// <summary> 34 34 /// Initializes a new instance of the <see cref="Hourai.DanmakU.Danmaku"/> class. ··· 69 69 /// </summary> 70 70 public event Action<Danmaku> OnDeactivate; 71 71 72 - public event DanmakuController Controller { 72 + public event Action<Danmaku> Controller { 73 73 add { 74 74 _onUpdate += value; 75 75 _controllerCheck = _onUpdate != null; ··· 85 85 _onUpdate = null; 86 86 } 87 87 88 - #region Rotation Functions 89 - 90 - public void Rotate(float deltaTheta) { 91 - Rotation += deltaTheta; 92 - } 93 - 94 - #endregion 95 - 96 - #region Speed Functions 97 - 98 - public void Accelerate(float dv) { 99 - Speed += dv; 100 - } 101 - 102 - #endregion 103 - 104 - #region Angular Speed Functions 105 - 106 - public void AngularAcclerate(float dav) { 107 - AngularSpeed += dav; 108 - } 109 - 110 - #endregion 111 - 112 88 internal void Update() 113 89 { 114 90 _originalPosition.x = position.x; ··· 116 92 Vector2 movementVector; 117 93 118 94 if (_controllerCheck) 119 - _onUpdate(this, dt); 95 + _onUpdate(this); 120 96 121 97 if (AngularSpeed != 0f) { 122 98 float rotationChange = AngularSpeed * dt; 123 99 rotation += rotationChange; 124 - direction = UnitCircle(rotation); 100 + direction = FastTrig.UnitCircle(rotation); 125 101 } 126 102 127 103 if (Speed != 0) { ··· 478 454 get { return rotation; } 479 455 set { 480 456 rotation = value; 481 - direction = UnitCircle(value); 457 + direction = FastTrig.UnitCircle(value); 482 458 } 483 459 } 484 460 ··· 510 486 } 511 487 512 488 /// <summary> 513 - /// The number of framesfieldBoundshave passed since this bullet has been fired. 489 + /// The number of frames passed since this bullet has been fired. 514 490 /// </summary> 515 491 /// <value>The number of frames that have passed since this bullet has been fired.</value> 516 492 public int Frames {
+12
Assets/Dependencies/DanmakU/_Core_/Danmaku.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 4dfa565c11a8b764aacf91b3e48d5c3b 3 + timeCreated: 1441237559 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+43 -43
Assets/Dependencies/DanmakU/_Core_/DanmakuBehavior.cs
··· 1 - // Copyright (c) 2015 James Liu 2 - // 3 - // See the LISCENSE file for copying permission. 4 - 5 - using System.Collections; 6 - using UnityEngine; 7 - using Vexe.Runtime.Types; 8 - 9 - namespace Hourai.DanmakU { 10 - 11 - public abstract class DanmakuBehaviour : BetterBehaviour { 12 - 13 - /// <summary> 14 - /// Shorthand for <c>TimeUtil.DeltaTime</c>. 15 - /// </summary> 16 - protected static float Dt { 17 - get { return TimeUtil.DeltaTime; } 18 - } 19 - 20 - /// <summary> 21 - /// Calculates the cosine of the 22 - /// </summary> 23 - /// <remarks> 24 - /// This function has much better performance than Mathf.Cos; however it can have much lower accuracy. 25 - /// </remarks> 26 - /// <param name="degree">Degree.</param> 27 - protected static float Cos(float degree) { 28 - return Danmaku.Cos(degree); 29 - } 30 - 31 - protected static float Sin(float degree) { 32 - return Danmaku.Sin(degree); 33 - } 34 - 35 - protected static float Tan(float degree) { 36 - return Danmaku.Tan(degree); 37 - } 38 - 39 - protected static Vector2 UnitCircle(float degree) { 40 - return Danmaku.UnitCircle(degree); 41 - } 42 - } 43 - 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using System.Collections; 6 + using UnityEngine; 7 + using Vexe.Runtime.Types; 8 + 9 + namespace Hourai.DanmakU { 10 + 11 + public abstract class DanmakuBehaviour : HouraiBehaviour { 12 + 13 + /// <summary> 14 + /// Shorthand for <c>TimeUtil.DeltaTime</c>. 15 + /// </summary> 16 + protected static float Dt { 17 + get { return TimeUtil.DeltaTime; } 18 + } 19 + 20 + /// <summary> 21 + /// Calculates the cosine of the 22 + /// </summary> 23 + /// <remarks> 24 + /// This function has much better performance than Mathf.Cos; however it can have much lower accuracy. 25 + /// </remarks> 26 + /// <param name="degree">Degree.</param> 27 + protected static float Cos(float degree) { 28 + return FastTrig.Cos(degree); 29 + } 30 + 31 + protected static float Sin(float degree) { 32 + return FastTrig.Sin(degree); 33 + } 34 + 35 + protected static float Tan(float degree) { 36 + return FastTrig.Tan(degree); 37 + } 38 + 39 + protected static Vector2 UnitCircle(float degree) { 40 + return FastTrig.UnitCircle(degree); 41 + } 42 + } 43 + 44 44 }
+12
Assets/Dependencies/DanmakU/_Core_/DanmakuBehavior.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 8edb2a68eb15ef74199d5e78daf18117 3 + timeCreated: 1441237560 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+16
Assets/Dependencies/DanmakU/_Core_/DanmakuCollider.cs
··· 8 8 9 9 namespace Hourai.DanmakU { 10 10 11 + /// <summary> 12 + /// An interface for any behaviour that would like to recieve messages of when danmaku collides 13 + /// with an attached collider. 14 + /// </summary> 15 + public interface IDanmakuCollider 16 + { 17 + 18 + /// <summary> 19 + /// Raises a danmaku collision event. 20 + /// </summary> 21 + /// <param name="danmaku">The danmaku collided with.</param> 22 + /// <param name="info">The relevant information about collision.</param> 23 + void OnDanmakuCollision(Danmaku danmaku, RaycastHit2D info); 24 + 25 + } 26 + 11 27 [RequireComponent(typeof (Collider2D))] 12 28 public abstract class DanmakuCollider : DanmakuBehaviour, IDanmakuCollider { 13 29
+12
Assets/Dependencies/DanmakU/_Core_/DanmakuCollider.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: b4ec9fdd8f8bc1a4b8944a9fd9c494e5 3 + timeCreated: 1441237561 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
-137
Assets/Dependencies/DanmakU/_Core_/DanmakuController.cs
··· 1 - // Copyright (c) 2015 James Liu 2 - // 3 - // See the LISCENSE file for copying permission. 4 - 5 - using System; 6 - using UnityEngine; 7 - 8 - namespace Hourai.DanmakU { 9 - 10 - /// <summary> 11 - /// Delegate form of IDanmakuController 12 - /// </summary> 13 - public delegate void DanmakuController(Danmaku danmaku, float dt); 14 - 15 - public static class Controller 16 - { 17 - #region Acceleration Controllers 18 - public static DanmakuController Acceleration(Func<Danmaku, float> acceleration) { 19 - if(acceleration == null) 20 - throw new ArgumentNullException("acceleration"); 21 - return delegate(Danmaku danmaku, float dt) { 22 - danmaku.Speed += acceleration(danmaku) * dt; 23 - }; 24 - } 25 - 26 - public static DanmakuController Acceleration(float acceleration) { 27 - return delegate(Danmaku danmaku, float dt) 28 - { 29 - danmaku.Speed += acceleration * dt; 30 - }; 31 - } 32 - #endregion 33 - 34 - #region Deactivation Controllers 35 - 36 - public static DanmakuController Deactivation(Func<Danmaku, bool> deactivation) { 37 - if(deactivation == null) 38 - throw new ArgumentNullException("deactivation"); 39 - return delegate(Danmaku danmaku, float dt) 40 - { 41 - if(deactivation(danmaku)) 42 - danmaku.Deactivate(); 43 - }; 44 - } 45 - 46 - #endregion 47 - 48 - #region Speed Limiters 49 - 50 - public static DanmakuController MaxSpeedLimit(Func<Danmaku, float> speedLimit) { 51 - if(speedLimit == null) 52 - throw new ArgumentNullException("speedLimit"); 53 - return delegate(Danmaku danmaku, float dt) { 54 - float limit = speedLimit(danmaku); 55 - if (danmaku.Speed > limit) 56 - danmaku.Speed = limit; 57 - }; 58 - } 59 - 60 - public static DanmakuController MaxSpeedLimit(float speedLimit) 61 - { 62 - return delegate(Danmaku danmaku, float dt) { 63 - if (danmaku.Speed > speedLimit) 64 - danmaku.Speed = speedLimit; 65 - }; 66 - } 67 - 68 - public static DanmakuController MinSpeedLimit(Func<Danmaku, float> speedLimit) 69 - { 70 - if (speedLimit == null) 71 - throw new ArgumentNullException("speedLimit"); 72 - return delegate(Danmaku danmaku, float dt) 73 - { 74 - float limit = speedLimit(danmaku); 75 - if (danmaku.Speed < limit) 76 - danmaku.Speed = limit; 77 - }; 78 - } 79 - 80 - public static DanmakuController MinSpeedLimit(float speedLimit) 81 - { 82 - return delegate(Danmaku danmaku, float dt) 83 - { 84 - if (danmaku.Speed < speedLimit) 85 - danmaku.Speed = speedLimit; 86 - }; 87 - } 88 - #endregion 89 - 90 - #region Color Controllers 91 - 92 - public static DanmakuController ColorChange(Func<Danmaku, Color> colorChange) { 93 - if(colorChange == null) 94 - throw new ArgumentNullException("colorChange"); 95 - return delegate(Danmaku danmaku, float dt) { 96 - danmaku.Color = colorChange(danmaku); 97 - }; 98 - } 99 - 100 - #endregion 101 - 102 - #region Homing Controllers 103 - 104 - public static DanmakuController Homing(GameObject target) { 105 - if(target == null) 106 - throw new ArgumentNullException("target"); 107 - Transform trans = target.transform; 108 - return delegate(Danmaku danmaku, float dt) { 109 - if (trans) 110 - danmaku.Rotation = DanmakuUtil.AngleBetween2D(danmaku.position, 111 - trans.position); 112 - }; 113 - } 114 - 115 - public static DanmakuController Homing(Component target) { 116 - if (target == null) 117 - throw new ArgumentNullException("target"); 118 - return Homing(target.gameObject); 119 - } 120 - 121 - public static DanmakuController Homing(Func<Danmaku, Transform> target) 122 - { 123 - if (target == null) 124 - throw new ArgumentNullException("target"); 125 - return delegate(Danmaku danmaku, float dt) 126 - { 127 - Transform trans = target(danmaku); 128 - if (trans) 129 - danmaku.Rotation = DanmakuUtil.AngleBetween2D(danmaku.position, 130 - trans.position); 131 - }; 132 - } 133 - 134 - #endregion 135 - } 136 - 137 - }
+12
Assets/Dependencies/DanmakU/_Core_/DanmakuField.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 8700f30fe9e49ad4fb2ed407eba26a75 3 + timeCreated: 1441237560 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+12
Assets/Dependencies/DanmakU/_Core_/DanmakuGame.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: abc5854c68616b4438f7892b026c5b76 3 + timeCreated: 1441237561 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
Assets/Dependencies/DanmakU/_Core_/DanmakuGameController.cs Assets/Dependencies/DanmakU/_Core_/DanmakuGame.cs
+12
Assets/Dependencies/DanmakU/_Core_/DanmakuGroup.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: c77ff69eeefe09549bc8ce54eba4d2e6 3 + timeCreated: 1441237562 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
-593
Assets/Dependencies/DanmakU/_Core_/DanmakuModifier.cs
··· 1 - // Copyright (c) 2015 James Liu 2 - // 3 - // See the LISCENSE file for copying permission. 4 - 5 - using System; 6 - using System.Collections; 7 - using System.Collections.Generic; 8 - using System.Linq; 9 - using System.Runtime.CompilerServices; 10 - using UnityEngine; 11 - using Vexe.Runtime.Extensions; 12 - 13 - namespace Hourai.DanmakU { 14 - 15 - [System.Serializable] 16 - public static class FireModifier { 17 - 18 - private static readonly Action<FireData, Vector2> setPos = (fd, pos) => fd.Position = pos; 19 - 20 - #region General Utilty Functions 21 - /// <summary> 22 - /// Replaces enumerated enumeration with their elements. 23 - /// This is a shallow replacement, only works on the initial enumeration. 24 - /// For a deep replacement (a recursive replacement of all enumerated enumerations), use FullyFlatten() instead. 25 - /// </summary> 26 - /// <param name="enumeration">the target enumeration of enumerations</param> 27 - /// <returns>an flattened enumeration. Returns an empty enumeration if <paramref name="enumeration"/> is null.</returns> 28 - public static IEnumerable Flatten(this IEnumerable enumeration) 29 - { 30 - if (enumeration == null) 31 - yield break; 32 - foreach (object data in enumeration) 33 - { 34 - var fd = data as FireData; 35 - var asEnumerator = data as IEnumerator; 36 - var asEnumerable = data as IEnumerable; 37 - if (fd != null) 38 - yield return fd; 39 - else if (asEnumerable != null) 40 - foreach (var subData in asEnumerable) 41 - yield return subData; 42 - else if (asEnumerator != null) 43 - while (asEnumerator.MoveNext()) 44 - yield return asEnumerator.Current; 45 - else 46 - yield return data; 47 - } 48 - } 49 - 50 - /// <summary> 51 - /// Recursively replaces all enumerated enumerations with their elements. 52 - /// This is a deep replacement. To only flatten the initial enumeration, use Flatten() instead. 53 - /// </summary> 54 - /// <param name="enumeration">the target enumeration of enumerations</param> 55 - /// <returns>an flattened enumeration. Returns an empty enumeration if <paramref name="enumeration"/> is null.</returns> 56 - public static IEnumerable FullyFlatten(this IEnumerable enumeration) 57 - { 58 - if (enumeration == null) 59 - yield break; 60 - Stack<IEnumerator> enumerationStack = new Stack<IEnumerator>(); 61 - enumerationStack.Push(enumeration.GetEnumerator()); 62 - while (enumerationStack.Count > 0) 63 - { 64 - IEnumerator iterator = enumerationStack.Peek(); 65 - while (iterator.MoveNext()) 66 - { 67 - object current = iterator.Current; 68 - var fd = current as FireData; 69 - if (fd != null) 70 - { 71 - yield return fd; 72 - continue; 73 - } 74 - var asIterator = current as IEnumerator; 75 - var asEnumerable = current as IEnumerable; 76 - if (asEnumerable != null) 77 - asIterator = asEnumerable.GetEnumerator(); 78 - if (asIterator != null) 79 - { 80 - enumerationStack.Push(asIterator); 81 - iterator = asIterator; 82 - } 83 - else 84 - { 85 - yield return current; 86 - } 87 - } 88 - enumerationStack.Pop(); 89 - } 90 - } 91 - 92 - /// <summary> 93 - /// Replaces all elements of type <typeparamref name="TIn"/> with generated values of type <typeparamref name="TOut"/>. 94 - /// This removes all replaced elements from the resultant enumeration and maintains the size of the enumeration. 95 - /// To keep the elements in, use Inject instead. 96 - /// </summary> 97 - /// <typeparam name="TIn">the target type to replace elements of</typeparam> 98 - /// <typeparam name="TOut">the type of object to replace with</typeparam> 99 - /// <param name="enumeration">the enumeration to replace the elements of</param> 100 - /// <param name="replacement">a mapping function that maps elements to be replace to their replacement</param> 101 - /// <param name="filter">a selection function. Returns true if a element is to be replaced. If null, all elements that can be replaced will be.</param> 102 - /// <returns>the enumeration with replaced elements</returns> 103 - public static IEnumerable Replace<TIn, TOut>(this IEnumerable enumeration, 104 - Func<TIn, TOut> replacement, 105 - Predicate<TIn> filter = null) 106 - { 107 - if (replacement == null) 108 - throw new ArgumentNullException("replacement"); 109 - if (enumeration == null) 110 - yield break; 111 - foreach (object data in enumeration) 112 - { 113 - if (data is TIn && (filter == null || filter((TIn)data))) 114 - yield return replacement((TIn)data); 115 - else 116 - yield return data; 117 - } 118 - } 119 - 120 - /// <summary> 121 - /// Injects a new elements of type <typeparamref name="TOut"/> before or after elements of type <typeparamref name="TIn"/>. 122 - /// This keeps all matched elements in the enumeration. This also expands the 123 - /// </summary> 124 - /// <typeparam name="TIn"></typeparam> 125 - /// <typeparam name="TOut"></typeparam> 126 - /// <param name="coroutine"></param> 127 - /// <param name="injection"></param> 128 - /// <param name="after"></param> 129 - /// <param name="filter"></param> 130 - /// <returns></returns> 131 - public static IEnumerable Inject<TIn, TOut>(this IEnumerable coroutine, 132 - Func<TIn, TOut> injection, 133 - Func<TIn, bool> after = null, 134 - Func<TIn, bool> filter = null) where TIn : class 135 - { 136 - if (injection == null) 137 - throw new ArgumentNullException("injection"); 138 - if (coroutine == null) 139 - yield break; 140 - foreach (object data in coroutine) 141 - { 142 - var typeChecked = data as TIn; 143 - if (typeChecked != null && (filter == null || filter(typeChecked))) 144 - { 145 - if (after == null || !after((TIn)data)) 146 - { 147 - yield return data; 148 - yield return injection(typeChecked); 149 - } 150 - else 151 - { 152 - yield return injection(typeChecked); 153 - yield return data; 154 - } 155 - } 156 - else 157 - yield return data; 158 - } 159 - } 160 - 161 - public static IEnumerable Duplicate<T>(this IEnumerable coroutine, 162 - Func<FireData, IEnumerable<T>> duplicationFunc, 163 - Action<FireData, T> editFunc = null, 164 - bool includeOriginal = true, 165 - Func<FireData, bool> filter = null) { 166 - if(duplicationFunc == null) 167 - throw new ArgumentNullException("duplicationFunc"); 168 - if (coroutine == null) 169 - yield break; 170 - 171 - var alterDummy = new FireData(); 172 - foreach (var obj in coroutine) { 173 - var fd = obj as FireData; 174 - if (fd == null || (filter != null && filter(fd))) { 175 - yield return obj; 176 - continue; 177 - } 178 - if (includeOriginal) 179 - yield return fd; 180 - IEnumerable<T> alterations = duplicationFunc(fd); 181 - if (alterations == null) 182 - continue; 183 - foreach (T alteration in duplicationFunc(fd)) { 184 - alterDummy.Copy(fd); 185 - editFunc.SafeInvoke(alterDummy, alteration); 186 - yield return alterDummy; 187 - } 188 - } 189 - } 190 - #endregion 191 - 192 - public static Task Execute(this MonoBehaviour behaviour, IEnumerable coroutine) 193 - { 194 - return coroutine.Execute(behaviour); 195 - } 196 - 197 - public static Task Execute(this IEnumerable data, MonoBehaviour context = null) 198 - { 199 - if (data == null) 200 - throw new ArgumentNullException("data"); 201 - 202 - var fd = data as FireData; 203 - var dp = data as DanmakuPrefab; 204 - if (fd != null) 205 - fd.Fire(); 206 - else if (dp != null) 207 - ((FireData) dp).Fire(); 208 - else { 209 - var fireTask = new Task(context ?? DanmakuGame.Instance, 210 - FireRoutine(data)); 211 - fireTask.Start(); 212 - return fireTask; 213 - } 214 - return null; 215 - } 216 - 217 - /// The actual coroutine that is executed in Fire() calls 218 - private static IEnumerator FireRoutine(IEnumerable dataSource) { 219 - foreach (object data in dataSource.FullyFlatten()) 220 - { 221 - var yi = data as YieldInstruction; 222 - var fd = data as FireData; 223 - if (data == null || yi != null) 224 - yield return data; 225 - else if (fd != null) 226 - fd.Fire(); 227 - else if (data is int) { 228 - int frames = (int) data; 229 - if (frames <= 0) 230 - yield return null; 231 - else 232 - for (var i = 0; i < frames; i++) 233 - yield return null; 234 - } else if (data is float) { 235 - float seconds = (float) data; 236 - if (seconds < TimeUtil.DeltaTime) 237 - yield return null; 238 - else 239 - for (var t = 0f; t < seconds; t += TimeUtil.DeltaTime) 240 - yield return null; 241 - } else { 242 - yield return data; 243 - } 244 - } 245 - } 246 - 247 - public static IEnumerable ForEachFireData(this IEnumerable coroutine, 248 - Action<FireData> action, 249 - Func<FireData, bool> filter = null) { 250 - if (coroutine == null) 251 - yield break; 252 - if (action == null) 253 - throw new ArgumentNullException("action"); 254 - 255 - var copy = new FireData(); 256 - foreach (object data in coroutine) { 257 - var fd = data as FireData; 258 - if (fd == null || (filter != null && !filter(fd))) { 259 - yield return data; 260 - continue; 261 - } 262 - copy.Copy(fd); 263 - action(copy); 264 - yield return copy; 265 - } 266 - } 267 - 268 - public static IEnumerable RadialBurst(this IEnumerable data, float range, int count, Func<FireData, bool> filter = null) { 269 - 270 - if (count == 1) 271 - return data; 272 - 273 - Func<FireData, IEnumerable<float>> burstFunc = 274 - delegate(FireData fd) { 275 - 276 - if (count <= 0) 277 - return new float[0]; 278 - 279 - float delta = range / count; 280 - float start = fd.Rotation - 0.5f * range; 281 - float[] set = new float[count]; 282 - 283 - for (var i = 0; i < set.Length; i++) 284 - set[i] = start + i * delta; 285 - 286 - return set; 287 - }; 288 - 289 - Action<FireData, float> setRotation = (fireData, f) => fireData.Rotation = f; 290 - 291 - return data.Duplicate(burstFunc, setRotation, false, filter); 292 - } 293 - 294 - public static IEnumerable LinearBurst(this IEnumerable data, int count, float dSpeed, Func<FireData, bool> filter = null) { 295 - Func<FireData, IEnumerable<float>> burstFunc = 296 - delegate(FireData fd) { 297 - float start = fd.Speed; 298 - float[] set = new float[count]; 299 - 300 - for (var i = 0; i < set.Length; i++) 301 - set[i] = start + i * dSpeed; 302 - 303 - return set; 304 - }; 305 - 306 - Action<FireData, float> setSpeed = (fireData, f) => fireData.Speed = f; 307 - 308 - return data.Duplicate(burstFunc, setSpeed, false, filter); 309 - } 310 - 311 - #region Controller Functions 312 - 313 - public static IEnumerable WithController(this IEnumerable data, 314 - Func<FireData, DanmakuController> controller, 315 - Func<FireData, bool> filter = null) { 316 - if (controller == null) 317 - return data; 318 - return data.ForEachFireData(fireData => fireData.Controller += controller(fireData), filter); 319 - } 320 - 321 - public static IEnumerable WithController(this IEnumerable data, 322 - DanmakuController controller, 323 - Func<FireData, bool> filter = null) 324 - { 325 - if (controller == null) 326 - return data; 327 - return data.ForEachFireData(fireData => fireData.Controller += controller, filter); 328 - } 329 - 330 - public static IEnumerable WithoutControllers(this IEnumerable data, Func<FireData, bool> filter = null) { 331 - return data.ForEachFireData(fireData => fireData.Controller = null, filter); 332 - } 333 - 334 - #endregion 335 - 336 - #region Timing Functions 337 - public static IEnumerable Delay(this IEnumerable coroutine, 338 - Func<FireData, int> frames, 339 - Func<FireData, bool> filter = null) { 340 - if(frames == null) 341 - throw new ArgumentNullException("frames"); 342 - return coroutine.Inject(frames, fd => true, filter); 343 - } 344 - 345 - public static IEnumerable Delay(this IEnumerable coroutine, 346 - int frames, 347 - Func<FireData, bool> filter = null) { 348 - return coroutine.Delay(fd => frames, filter); 349 - } 350 - 351 - public static IEnumerable Delay(this IEnumerable coroutine, 352 - Func<FireData, float> seconds, 353 - Func<FireData, bool> filter = null) 354 - { 355 - if (seconds == null) 356 - throw new ArgumentNullException("seconds"); 357 - return coroutine.Inject(seconds, fd => true, filter); 358 - } 359 - 360 - public static IEnumerable Delay(this IEnumerable coroutine, 361 - float seconds, 362 - Func<FireData, bool> filter = null) 363 - { 364 - return coroutine.Delay(fd => seconds, filter); 365 - } 366 - #endregion 367 - 368 - #region Position Functions 369 - public static IEnumerable From(this IEnumerable data, Func<FireData, Vector2> position, Func<FireData, bool> filter = null) 370 - { 371 - if(position == null) 372 - throw new ArgumentNullException("position"); 373 - return data.ForEachFireData(fd => fd.Position = position(fd), filter); 374 - } 375 - 376 - public static IEnumerable From(this IEnumerable data, Vector2 position, Func<FireData, bool> filter = null) { 377 - return data.ForEachFireData(fireData => fireData.Position = position, filter); 378 - } 379 - 380 - public static IEnumerable From(this IEnumerable coroutine, 381 - Func<FireData, IEnumerable<Vector2>> positions, 382 - Func<FireData, bool> filter = null) { 383 - return coroutine.Duplicate(positions, setPos, false, filter); 384 - } 385 - 386 - public static IEnumerable From(this IEnumerable coroutine, 387 - IEnumerable<Vector2> positions, 388 - Func<FireData, bool> filter = null) { 389 - return coroutine.From(fd => positions, filter); 390 - } 391 - 392 - public static IEnumerable From(this IEnumerable data, GameObject gameObject, Func<FireData, bool> filter = null) 393 - { 394 - if (gameObject == null) 395 - return data; 396 - Transform trans = gameObject.transform; 397 - return data.ForEachFireData(fd => fd.Position = ((trans) ? (Vector2) trans.position : fd.Position), filter); 398 - } 399 - 400 - public static IEnumerable From(this IEnumerable coroutine, 401 - Func<FireData, IEnumerable<GameObject>> gameObjects, 402 - Func<FireData, bool> filter = null) 403 - { 404 - return coroutine.Duplicate(gameObjects, ((data, o) => data.Position = o.transform.position), false, filter); 405 - } 406 - 407 - public static IEnumerable From(this IEnumerable coroutine, 408 - IEnumerable<GameObject> gameObjects, 409 - Func<FireData, bool> filter = null) { 410 - return coroutine.From(fd => gameObjects, filter); 411 - } 412 - 413 - public static IEnumerable From(this IEnumerable data, Component component, Func<FireData, bool> filter = null) { 414 - return component ? data.From(component.gameObject) : data; 415 - } 416 - 417 - public static IEnumerable From(this IEnumerable coroutine, 418 - Func<FireData, IEnumerable<Component>> components, 419 - Func<FireData, bool> filter = null) 420 - { 421 - return coroutine.Duplicate(components, ((data, o) => data.Position = o.transform.position), false, filter); 422 - } 423 - 424 - public static IEnumerable From(this IEnumerable coroutine, 425 - IEnumerable<Component> components, 426 - Func<FireData, bool> filter = null) 427 - { 428 - return coroutine.From(fd => components, filter); 429 - } 430 - 431 - public static IEnumerable From(this IEnumerable data, Danmaku danmaku, Func<FireData, bool> filter = null) { 432 - if(danmaku == null) 433 - throw new ArgumentNullException("danmaku"); 434 - return data.ForEachFireData(fd => fd.Position = (danmaku ? danmaku.Position : fd.Position), filter); 435 - } 436 - 437 - public static IEnumerable From(this IEnumerable coroutine, 438 - Func<FireData, IEnumerable<Danmaku>> danmaku, 439 - Func<FireData, bool> filter = null) 440 - { 441 - return coroutine.Duplicate(danmaku, ((data, o) => data.Position = o.Position), false, filter); 442 - } 443 - 444 - public static IEnumerable From(this IEnumerable coroutine, 445 - IEnumerable<Danmaku> danmaku, 446 - Func<FireData, bool> filter = null) 447 - { 448 - return coroutine.From(fd => danmaku, filter); 449 - } 450 - #endregion 451 - 452 - #region Rotation/Direction Functions 453 - public static IEnumerable InDirection(this IEnumerable coroutine, 454 - Func<FireData, float> angle, 455 - Func<FireData, bool> filter = null) 456 - { 457 - if (angle == null) 458 - throw new ArgumentNullException("angle"); 459 - return coroutine.ForEachFireData(fd => fd.Rotation = angle(fd), filter); 460 - } 461 - 462 - public static IEnumerable InDirection(this IEnumerable coroutine, 463 - float angle, 464 - Func<FireData, bool> filter = null) 465 - { 466 - return coroutine.ForEachFireData(fd => fd.Rotation = angle, filter); 467 - } 468 - 469 - public static IEnumerable Towards(this IEnumerable coroutine, 470 - Func<FireData, Vector2> target, 471 - Func<FireData, bool> filter = null) { 472 - return coroutine.ForEachFireData(fd => fd.Rotation = DanmakuUtil.AngleBetween2D(fd.Position, target(fd)), filter); 473 - } 474 - 475 - public static IEnumerable Towards(this IEnumerable coroutine, 476 - Vector2 target, 477 - Func<FireData, bool> filter = null) { 478 - return coroutine.ForEachFireData(fd => fd.Rotation = DanmakuUtil.AngleBetween2D(fd.Position, target), filter); 479 - } 480 - 481 - public static IEnumerable Towards(this IEnumerable coroutine, 482 - GameObject target, 483 - Func<FireData, bool> filter = null) 484 - { 485 - if (target == null) 486 - throw new ArgumentNullException("target"); 487 - Transform trans = target.transform; 488 - return coroutine.ForEachFireData(delegate(FireData fd) { 489 - if (trans) 490 - fd.Rotation = DanmakuUtil.AngleBetween2D(fd.Position, 491 - trans.position); 492 - }, 493 - filter); 494 - } 495 - 496 - public static IEnumerable Towards(this IEnumerable coroutine, 497 - Component target, 498 - Func<FireData, bool> filter = null) 499 - { 500 - if(target == null) 501 - throw new ArgumentNullException("target"); 502 - return coroutine.Towards(target.gameObject); 503 - } 504 - #endregion 505 - 506 - #region Speed Functions 507 - 508 - public static IEnumerable WithSpeed(this IEnumerable coroutine, 509 - Func<FireData, float> speed, 510 - Func<FireData, bool> filter = null) 511 - { 512 - if(speed == null) 513 - throw new ArgumentNullException("speed"); 514 - return coroutine.ForEachFireData(d => d.Speed = speed(d), filter); 515 - } 516 - 517 - public static IEnumerable WithSpeed(this IEnumerable coroutine, 518 - float speed, 519 - Func<FireData, bool> filter = null) 520 - { 521 - return coroutine.ForEachFireData(d => d.Speed = speed, filter); 522 - } 523 - 524 - #endregion 525 - 526 - #region Angular Speed Functions 527 - 528 - public static IEnumerable WithAngularSpeed(this IEnumerable coroutine, 529 - Func<FireData, float> angSpeed, 530 - Func<FireData, bool> filter = null) 531 - { 532 - if (angSpeed == null) 533 - throw new ArgumentNullException("angSpeed"); 534 - return coroutine.ForEachFireData(d => d.Speed = angSpeed(d), filter); 535 - } 536 - 537 - public static IEnumerable WithAngularSpeed(this IEnumerable coroutine, 538 - float angSpeed, 539 - Func<FireData, bool> filter = null) 540 - { 541 - return coroutine.ForEachFireData(d => d.Speed = angSpeed, filter); 542 - } 543 - 544 - #endregion 545 - 546 - #region Color Functions 547 - 548 - public static IEnumerable WithColor(this IEnumerable data, 549 - Func<FireData, Color?> color, 550 - Func<FireData, bool> filter = null) { 551 - if(color == null) 552 - throw new ArgumentNullException("color"); 553 - return data.ForEachFireData(fd => fd.Color = color(fd), filter); 554 - } 555 - 556 - public static IEnumerable WithColor(this IEnumerable data, 557 - Color? color, 558 - Func<FireData, bool> filter = null) 559 - { 560 - return data.ForEachFireData(fd => fd.Color = color, filter); 561 - } 562 - 563 - public static IEnumerable WithColor(this IEnumerable data, 564 - Gradient gradient, 565 - Func<FireData, bool> filter = null) { 566 - return data.WithColor(fd => gradient.Random(), filter); 567 - } 568 - 569 - #endregion 570 - 571 - #region Damage Functions 572 - 573 - public static IEnumerable WithDamage(this IEnumerable coroutine, 574 - Func<FireData, float> damage, 575 - Func<FireData, bool> filter = null) 576 - { 577 - if (damage == null) 578 - throw new ArgumentNullException("damage"); 579 - return coroutine.ForEachFireData(d => d.Damage = damage(d), filter); 580 - } 581 - 582 - public static IEnumerable WithDamage(this IEnumerable coroutine, 583 - float damage, 584 - Func<FireData, bool> filter = null) 585 - { 586 - return coroutine.ForEachFireData(d => d.Damage = damage, filter); 587 - } 588 - 589 - #endregion 590 - 591 - } 592 - 593 - }
+7 -6
Assets/Dependencies/DanmakU/_Core_/DanmakuPool.cs
··· 13 13 14 14 internal class DanmakuPool { 15 15 16 - internal Danmaku[] all; 17 - private int currentIndex; 18 - private int endIndex; 19 - internal int inactiveCount; 20 - 21 16 //FIXME: Currently not working: optimized version of pool, need to debug 22 17 23 18 // internal Danmaku[] all; ··· 111 106 // Return (obj as Danmaku); 112 107 // } 113 108 // 114 - // #endregion 109 + // #endregion 110 + 111 + internal Danmaku[] all; 112 + private int currentIndex; 113 + private int endIndex; 114 + internal int inactiveCount; 115 115 116 116 internal int[] queue; 117 117 private int size; ··· 130 130 all = new Danmaku[2]; 131 131 queue = new int[2]; 132 132 } 133 + 133 134 int endCount = totalCount + count; 134 135 if (all.Length < endCount) { 135 136 size = all.Length;
+12
Assets/Dependencies/DanmakU/_Core_/DanmakuPool.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 53e899c4b334fc9429f240945c2257a4 3 + timeCreated: 1441237559 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+12
Assets/Dependencies/DanmakU/_Core_/DanmakuPrefab.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 4a07ad0e112c37d44acf76a147bfa444 3 + timeCreated: 1441237559 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+8 -54
Assets/Dependencies/DanmakU/_Core_/DanmakuStatic.cs
··· 28 28 /// </summary> 29 29 internal const int standardSpawn = 100; 30 30 31 - /// <summary> 32 - /// A set of 2D vectors corresponding to unit circle coordinates 33 - /// Precalculated since Cosine and Sine calculations are expensive when called thousands of times per frame. 34 - /// An array access on an array of structs is much cheaper than calling both Mathf.Cos, and Mathf.Sin. 35 - /// </summary> 36 - internal static Vector2[] unitCircle; 37 - 38 - private static float invAngRes; 39 - private static int unitCircleMax; 40 31 private static int[] collisionMask; 41 32 private static DanmakuPool danmakuPool; 42 33 ··· 45 36 /// Static member accesses are slightly faster than member accesses or passing via parameters. 46 37 /// Since it is a static value within each frame, it is best to cache it as a static variable. 47 38 /// </summary> 48 - private static float dt; 39 + public static float dt; 49 40 50 41 /// <summary> 51 42 /// A map that matches colliders to respective collision handler scripts. ··· 67 58 } 68 59 69 60 public static int ActiveCount { 70 - get { return (danmakuPool != null) ? danmakuPool.totalCount : 0; } 61 + get { return (danmakuPool != null) ? danmakuPool.totalCount - danmakuPool.inactiveCount : 0; } 71 62 } 72 63 73 64 internal static void Setup(int initial = standardStart, ··· 76 67 colliderMap = new Dictionary<Collider2D, IDanmakuCollider[]>(); 77 68 collisionMask = Util.CollisionLayers2D(); 78 69 danmakuPool = new DanmakuPool(initial, spawn); 79 - invAngRes = 1f/angRes; 80 - unitCircleMax = Mathf.CeilToInt(360f/angRes); 81 - float angle = 90f; 82 - unitCircle = new Vector2[unitCircleMax]; 83 - for (int i = 0; i < unitCircleMax; i++) { 84 - angle += angRes; 85 - unitCircle[i] = Util.OnUnitCircle(angle); 86 - } 87 - } 88 - 89 - internal static int Ang2Index(float angle) { 90 - float clamp = angle - 360*Mathf.FloorToInt(angle/360); 91 - int index = (int) (clamp*invAngRes); 92 - if (index >= unitCircleMax) 93 - index = unitCircleMax - 1; 94 - if (index < 0) 95 - index = 0; 96 - return index; 97 - } 98 - 99 - internal static Vector2 UnitCircle(float angle) { 100 - return unitCircle[Ang2Index(angle)]; 101 - } 102 - 103 - internal static float Cos(float angle) { 104 - return unitCircle[Ang2Index(angle)].x; 105 - } 106 - 107 - internal static float Sin(float angle) { 108 - return unitCircle[Ang2Index(angle)].y; 109 - } 110 - 111 - internal static float Tan(float angle) { 112 - float sin = Sin(angle); 113 - if (sin == 0f) 114 - return float.NaN; 115 - return Cos(angle)/Sin(angle); 116 70 } 117 71 118 72 /// <summary> ··· 120 74 /// This should be called only once per frame. 121 75 /// </summary> 122 76 static void UpdateAll() { 123 - colliderMap.Clear(); 77 + if(colliderMap.Count > 0) 78 + colliderMap.Clear(); 124 79 //caches the change in time since the last frame 125 - Danmaku danmaku; 126 80 dt = TimeUtil.DeltaTime; 127 81 Danmaku[] all = danmakuPool.all; 128 - for (int i = 0; i < all.Length; i++) { 82 + Danmaku danmaku; 83 + for (var i = 0; i < all.Length; i++) { 129 84 danmaku = all[i]; 130 - if (danmaku != null && danmaku._isActive) { 131 - danmaku.Update(); 132 - } 85 + if (danmaku != null && danmaku._isActive) 86 + danmaku.Update(); 133 87 } 134 88 } 135 89
+12
Assets/Dependencies/DanmakU/_Core_/DanmakuStatic.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 6798559c4ae6dce4684a2b5a326d86b2 3 + timeCreated: 1441237560 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+35
Assets/Dependencies/DanmakU/_Core_/Editor/CountdownDelayDrawer.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission.> 4 + 5 + using UnityEngine; 6 + using UnityEditor; 7 + 8 + /// <summary> 9 + /// Custom editor scripts for various components of UnityUtilLib 10 + /// </summary> 11 + namespace Hourai.DanmakU.Editor { 12 + 13 + /// <summary> 14 + /// Custom <a href="http://docs.unity3d.com/ScriptReference/PropertyDrawer.html">PropertyDrawer</a> for CountdownDelay 15 + /// </summary> 16 + [CustomPropertyDrawer(typeof(CountdownDelay))] 17 + internal class CountdownDelayDrawer : PropertyDrawer { 18 + 19 + /// <summary> 20 + /// Creates the custom GUI an instance of CountdownDelay 21 + /// Abstracts away all of the hidden variables and only exposes a float field for easy editing 22 + /// </summary> 23 + /// <param name="position"> the rectangle on the screen to use for the property GUI.</param> 24 + /// <param name="property">The <a href="http://docs.unity3d.com/ScriptReference/SerializedProperty.html">SerializedProperty</a> to make the custom GUI for.</param> 25 + /// <param name="label">The label of this property</param> 26 + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { 27 + EditorGUI.BeginProperty(position, label, property); 28 + SerializedProperty maxDelayProp = property.FindPropertyRelative ("MaxDelay"); 29 + SerializedProperty currentDelayProp = property.FindPropertyRelative ("CurrentDelay"); 30 + EditorGUI.PropertyField (position, maxDelayProp, label); 31 + currentDelayProp.floatValue = maxDelayProp.floatValue; 32 + EditorGUI.EndProperty(); 33 + } 34 + } 35 + }
+12
Assets/Dependencies/DanmakU/_Core_/Editor/CountdownDelayDrawer.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: b09b8f75cf19c06478e054923485e718 3 + timeCreated: 1441237561 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+23
Assets/Dependencies/DanmakU/_Core_/Editor/CounterDrawer.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + using UnityEditor; 7 + 8 + namespace Hourai.DanmakU.Editor { 9 + 10 + [CustomPropertyDrawer(typeof(Counter))] 11 + internal class CounterDrawer : PropertyDrawer { 12 + 13 + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { 14 + EditorGUI.BeginProperty(position, label, property); 15 + SerializedProperty maxCountProp = property.FindPropertyRelative ("MaxCount"); 16 + SerializedProperty countProp = property.FindPropertyRelative ("count"); 17 + EditorGUI.PropertyField (position, maxCountProp, label); 18 + countProp.intValue = maxCountProp.intValue; 19 + EditorGUI.EndProperty(); 20 + } 21 + 22 + } 23 + }
+12
Assets/Dependencies/DanmakU/_Core_/Editor/CounterDrawer.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 04ca3d4f763e1c04387cfed087be7152 3 + timeCreated: 1441237558 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+135
Assets/Dependencies/DanmakU/_Core_/Editor/DanmakuAssets.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + using UnityEditor; 7 + 8 + using Hourai.DanmakU; 9 + //using Hourai.DanmakU.Phantasmagoria; 10 + using System.IO; 11 + 12 + /// <summary> 13 + /// A static class full of editor shortcuts for faster development 14 + /// </summary> 15 + internal static class DanmakuAssets { 16 + 17 + private static string GetProjectWindowFolder() { 18 + UnityEngine.Object activeObject = Selection.activeObject; 19 + string path = ""; 20 + if (activeObject == null) 21 + return "Assets"; // Nothing selected 22 + else 23 + path = AssetDatabase.GetAssetPath (activeObject); 24 + if (path.Length > 0) { 25 + if (Directory.Exists (path)) { 26 + return path; // path is a folder 27 + } else { 28 + // Debug.Log(path); 29 + // Debug.Log(Directory.GetParent(path).FullName); 30 + return Directory.GetParent(path).FullName; 31 + } 32 + } 33 + return ""; //path in Assets folder 34 + } 35 + 36 + /// <summary> 37 + /// Creates a blank DanmakuPrefab asset 38 + /// Found under Assets/Create/Hourai.DanmakU/Danmaku Prefab 39 + /// </summary> 40 + [MenuItem("Assets/Create/Hourai.DanmakU/Sprite Danmaku Prefab", false, 51)] 41 + public static void AddSpriteDanmakuPrefab() { 42 + GameObject temp = new GameObject ("Danmaku Prefab"); 43 + temp.AddComponent<SpriteRenderer> (); 44 + temp.AddComponent<DanmakuPrefab> (); 45 + string pathName = GetProjectWindowFolder (); 46 + PrefabUtility.CreatePrefab (pathName + "/Danmaku Prefab.prefab", temp); 47 + Object.DestroyImmediate (temp); 48 + } 49 + 50 + [MenuItem("Assets/Create/Hourai.DanmakU/Mesh Danmaku Prefab", false, 52)] 51 + public static void AddMeshDanmakuPrefab() { 52 + GameObject temp = new GameObject ("Danmaku Prefab"); 53 + temp.AddComponent<MeshFilter> (); 54 + temp.AddComponent<MeshRenderer> (); 55 + temp.AddComponent<DanmakuPrefab> (); 56 + string pathName = GetProjectWindowFolder (); 57 + PrefabUtility.CreatePrefab (pathName + "/Danmaku Prefab.prefab", temp); 58 + Object.DestroyImmediate (temp); 59 + } 60 + 61 + // /// <summary> 62 + // /// Creates the base of a full Phantasmagoria game with a single click 63 + // /// Found under GameObject/Create/Hourai.DanmakU/Phantasmagoria/Game Gamecontroller 64 + // /// </summary> 65 + // [MenuItem("GameObject/Create/Hourai.DanmakU/Phantasmagoria/Game Controller")] 66 + // public static void CreatePhantasmagoriaGame() { 67 + // GameObject temp = new GameObject ("Game Controller"); 68 + // temp.AddComponent<StaticGameObject> (); 69 + // PhantasmagoriaGameController pcg = temp.AddComponent<PhantasmagoriaGameController> (); 70 + // DanmakuField playerField1 = CreateDanmakuField (); 71 + // DanmakuField playerField2 = CreateDanmakuField (); 72 + // playerField1.gameObject.name = "Player 1 " + playerField1.gameObject.name; 73 + // playerField2.gameObject.name = "Player 2 " + playerField2.gameObject.name; 74 + // SerializedObject pcgS = new SerializedObject (pcg); 75 + // pcgS.FindProperty ("player1.field").objectReferenceValue = playerField1; 76 + // pcgS.FindProperty ("player2.field").objectReferenceValue = playerField2; 77 + // pcgS.ApplyModifiedProperties (); 78 + // playerField1.transform.position = new Vector3 (-100f, 0f, 0f); 79 + // playerField2.transform.position = new Vector3 (100f, 0f, 0f); 80 + // temp.AddComponent<TestSpawnPlayer> (); 81 + // temp.AddComponent<AudioListener> (); 82 + // temp.AddComponent<AudioSource>(); 83 + // temp.AddComponent<AudioManager> (); 84 + // } 85 + 86 + /// <summary> 87 + /// Creates a PhantasmagoriaField with a single click 88 + /// Found under GameObject/Create/Hourai.DanmakU/Phantasmagoria/Field 89 + /// </summary> 90 + /// <returns>The phantasmagoria field created.</returns> 91 + [MenuItem("GameObject/Create/Hourai.DanmakU/Danmaku Field")] 92 + public static DanmakuField CreateDanmakuField() { 93 + GameObject temp = new GameObject ("Field"); 94 + DanmakuField field = temp.AddComponent<DanmakuField> (); 95 + GameObject background = GameObject.CreatePrimitive (PrimitiveType.Quad); 96 + background.name = "Background"; 97 + background.transform.parent = field.transform; 98 + background.transform.localPosition = new Vector3 (0f, 0f, 10f); 99 + Object.DestroyImmediate(background.GetComponent<MeshCollider> ()); 100 + background.transform.localScale = new Vector3 (48.125f, 48.125f, 1f); 101 + GameObject cam = new GameObject ("Camera"); 102 + cam.transform.parent = temp.transform; 103 + cam.transform.localScale = new Vector3 (0f, 0f, -10f); 104 + Camera camera = cam.AddComponent<Camera> (); 105 + SerializedObject camS = new SerializedObject (field); 106 + camS.FindProperty ("fieldCamera").objectReferenceValue = camera; 107 + camS.ApplyModifiedProperties (); 108 + camera.orthographic = true; 109 + camera.orthographicSize = 20; 110 + camera.farClipPlane = 25; 111 + return field; 112 + } 113 + 114 + // [MenuItem("Assets/Create/Hourai.DanmakU/Custom Attack Pattern")] 115 + // public static void CreateAttackPattern() { 116 + // string text = "using UnityEngine;\nusing System.Collections;\nusing Hourai.DanmakU;\n" + 117 + // "\npublic class NewAttackPattern : AttackPattern {\n" + 118 + // "\t//Used to determine when the attack pattern is finished and can terminate" + 119 + // "\n\tprotected override bool IsFinished {\n" + 120 + // "\t\tget {\n" + 121 + // "\t\t\treturn false;\n" + 122 + // "\t\t}\n" + 123 + // "\t}\n" + 124 + // "\n\t//The main loop of the attack pattern, executed every frame" + 125 + // "\tprotected override void MainLoop() {\n" + 126 + // "\n\n\t}\n" + 127 + // "}"; 128 + // CreateScript (text, "NewAttackPattern"); 129 + // } 130 + // 131 + // private static void CreateScript(string scriptText, string name) { 132 + // File.WriteAllText (Application.dataPath + "/ " + name + ".cs", scriptText); 133 + // AssetDatabase.ImportAsset ("Assets/" + name + ".cs"); 134 + // } 135 + }
+12
Assets/Dependencies/DanmakU/_Core_/Editor/DanmakuAssets.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 37145a933a9ae58459d4d612ea9242a5 3 + timeCreated: 1441237559 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+62
Assets/Dependencies/DanmakU/_Core_/Editor/DanmakuFieldEditor.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + using UnityEditor; 7 + using System.Collections.Generic; 8 + using Hourai.DanmakU; 9 + 10 + 11 + namespace Hourai.DanmakU.Editor { 12 + 13 + [CustomEditor(typeof(DanmakuField))] 14 + internal class DanmakuFieldEditor : UnityEditor.Editor { 15 + 16 + private DanmakuField field; 17 + 18 + private SerializedProperty useClipBoundary; 19 + private SerializedProperty clipBoundary; 20 + private SerializedProperty camera3D; 21 + private SerializedProperty camera2D; 22 + private SerializedProperty size; 23 + 24 + public void OnEnable() { 25 + field = target as DanmakuField; 26 + 27 + useClipBoundary = serializedObject.FindProperty("UseClipBoundary"); 28 + clipBoundary = serializedObject.FindProperty ("ClipBoundary"); 29 + size = serializedObject.FindProperty("FieldSize"); 30 + camera2D = serializedObject.FindProperty ("camera2D"); 31 + camera3D = serializedObject.FindProperty ("otherCameras"); 32 + } 33 + 34 + public override bool RequiresConstantRepaint () { 35 + return true; 36 + } 37 + 38 + public override void OnInspectorGUI () { 39 + serializedObject.Update (); 40 + EditorGUILayout.PropertyField(useClipBoundary); 41 + if (useClipBoundary.boolValue) { 42 + EditorGUI.indentLevel++; 43 + EditorGUILayout.PropertyField (clipBoundary); 44 + EditorGUI.indentLevel--; 45 + } 46 + EditorGUILayout.PropertyField (camera2D, new GUIContent("2D Cameras")); 47 + 48 + EditorGUI.indentLevel++; 49 + if (camera2D.objectReferenceValue == null) { 50 + EditorGUILayout.PropertyField(size); 51 + } else { 52 + EditorGUILayout.PropertyField(camera3D,true); 53 + } 54 + EditorGUI.indentLevel--; 55 + 56 + if (UnityEngine.GUI.changed) { 57 + serializedObject.ApplyModifiedProperties (); 58 + field.enabled = true; 59 + } 60 + } 61 + } 62 + }
+12
Assets/Dependencies/DanmakU/_Core_/Editor/DanmakuFieldEditor.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 8278ec3a0d6acbb41aab100301b5dab2 3 + timeCreated: 1441237560 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+37
Assets/Dependencies/DanmakU/_Core_/Editor/DanmakuGameControllerEditor.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + using UnityEditor; 7 + using Hourai.DanmakU; 8 + 9 + /// <summary> 10 + /// Custom <a href="http://docs.unity3d.com/ScriptReference/Editor.html">Editor</a> for ProjectileManager 11 + /// </summary> 12 + [CustomEditor(typeof(DanmakuGame))] 13 + internal class DanmakuGameControllerEditor : UnityEditor.Editor { 14 + 15 + /// <summary> 16 + /// Creates custom GUI useful for statistics/debug on the Scene View 17 + /// Shows how many active Projectiles and how many 18 + /// </summary> 19 + public void OnSceneGUI() { 20 + GUISkin skin = GUI.skin; 21 + Handles.BeginGUI (); 22 + GUILayout.BeginArea (new Rect(0,0,150,60), skin.box); 23 + GUILayout.BeginVertical (); 24 + GUILayout.BeginHorizontal (); 25 + GUILayout.FlexibleSpace (); 26 + GUILayout.Label ("Danmaku Pool"); 27 + GUILayout.FlexibleSpace (); 28 + GUILayout.EndHorizontal(); 29 + GUILayout.Label ("Total Count: " + Danmaku.TotalCount); 30 + GUILayout.Label ("Active Count: " + Danmaku.ActiveCount); 31 + GUILayout.EndVertical (); 32 + GUILayout.EndArea (); 33 + if(GUI.changed) 34 + EditorUtility.SetDirty(target); 35 + Handles.EndGUI (); 36 + } 37 + }
+12
Assets/Dependencies/DanmakU/_Core_/Editor/DanmakuGameControllerEditor.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 6d1bf00f6eafbc04f84b78bcfcca6fd5 3 + timeCreated: 1441237560 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+21
Assets/Dependencies/DanmakU/_Core_/Editor/FrameCounterDrawer.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using UnityEngine; 6 + using UnityEditor; 7 + 8 + namespace Hourai.DanmakU.Editor { 9 + 10 + [CustomPropertyDrawer(typeof(FrameCounter))] 11 + internal class FrameCounterDrawer : PropertyDrawer { 12 + 13 + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { 14 + EditorGUI.BeginProperty(position, label, property); 15 + SerializedProperty timeProp = property.FindPropertyRelative ("Time"); 16 + EditorGUI.PropertyField (position, timeProp, label); 17 + EditorGUI.EndProperty(); 18 + } 19 + 20 + } 21 + }
+12
Assets/Dependencies/DanmakU/_Core_/Editor/FrameCounterDrawer.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: ff0b909f80a56944baa367b9af64e568 3 + timeCreated: 1441237562 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+6 -21
Assets/Dependencies/DanmakU/_Core_/FireData.cs
··· 16 16 [Serializable] 17 17 public class FireData : IEnumerable<FireData> { 18 18 19 + public Vector2 Position; 20 + public float Rotation; 21 + public Color? Color; 22 + public float Damage; 23 + public float Speed = 5f; 19 24 public float AngularSpeed; 20 - public DanmakuController Controller; 25 + public Action<Danmaku> Controller; 21 26 public Action<Danmaku> OnActivate; 22 27 public Action<Danmaku> OnDeactivate; 23 - public float Damage; 24 - public DanmakuField Field; 25 - public Vector2 Position; 26 28 public DanmakuPrefab Prefab; 27 - public float Rotation; 28 - public float Speed = 5f; 29 - public Color? Color; 30 29 31 30 public void Copy(FireData other) { 32 31 if (other == null || other == this) ··· 36 35 OnActivate = other.OnActivate; 37 36 OnDeactivate = other.OnDeactivate; 38 37 Damage = other.Damage; 39 - Field = other.Field; 40 38 Position = other.Position; 41 39 Prefab = other.Prefab; 42 40 Rotation = other.Rotation; ··· 54 52 Danmaku danmaku = Danmaku.GetInactive(this); 55 53 danmaku.Activate(); 56 54 return danmaku; 57 - } 58 - 59 - public void AddGroup(DanmakuGroup group) { 60 - if(group == null) 61 - throw new ArgumentNullException("group"); 62 - OnActivate += group.Add; 63 - } 64 - 65 - public void RemoveGroup(DanmakuGroup group) 66 - { 67 - if (group == null) 68 - throw new ArgumentNullException("group"); 69 - OnActivate -= group.Add; 70 55 } 71 56 72 57 public IEnumerator<FireData> GetEnumerator() {
+12
Assets/Dependencies/DanmakU/_Core_/FireData.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 37c2209144a878c4a9ef232ab8c1bf92 3 + timeCreated: 1441237559 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
-24
Assets/Dependencies/DanmakU/_Core_/IDanmakuCollider.cs
··· 1 - // Copyright (c) 2015 James Liu 2 - // 3 - // See the LISCENSE file for copying permission. 4 - 5 - using UnityEngine; 6 - 7 - namespace Hourai.DanmakU { 8 - 9 - /// <summary> 10 - /// An interface for any behaviour that would like to recieve messages of when danmaku collides 11 - /// with an attached collider. 12 - /// </summary> 13 - public interface IDanmakuCollider { 14 - 15 - /// <summary> 16 - /// Raises a danmaku collision event. 17 - /// </summary> 18 - /// <param name="danmaku">The danmaku collided with.</param> 19 - /// <param name="info">The relevant information about collision.</param> 20 - void OnDanmakuCollision(Danmaku danmaku, RaycastHit2D info); 21 - 22 - } 23 - 24 - }
+12
Assets/Dependencies/DanmakU/_Core_/IFireBindable.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: e245b4b565e811e4094a57b117610170 3 + timeCreated: 1441237562 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+76
Assets/Dependencies/DanmakU/_Core_/Modifiers/AngularSpeedModifiers.cs
··· 1 + using UnityEngine; 2 + using System; 3 + using System.Collections; 4 + 5 + namespace Hourai.DanmakU 6 + { 7 + 8 + public static partial class Modifier 9 + { 10 + public static float AngularSpeed(FireData fd) 11 + { 12 + return fd.AngularSpeed; 13 + } 14 + 15 + public static void SetAngularSpeed(FireData fd, float speed) 16 + { 17 + fd.AngularSpeed = speed; 18 + } 19 + 20 + public static void AngularAccelerate(FireData fd, float delta) 21 + { 22 + fd.AngularSpeed += delta; 23 + } 24 + 25 + public static Action<FireData> SetAngularSpeed(Func<FireData, float> delta) 26 + { 27 + return (fd) => fd.AngularSpeed += delta(fd); 28 + } 29 + 30 + public static Action<FireData> SetAngularSpeed(Func<float> delta) 31 + { 32 + return (fd) => fd.AngularSpeed += delta(); 33 + } 34 + 35 + public static Action<FireData> SetAngularSpeed(float delta) 36 + { 37 + return (fd) => fd.AngularSpeed += delta; 38 + } 39 + 40 + public static Action<FireData> AngularAccelerate(Func<FireData, float> delta) 41 + { 42 + return (fd) => fd.AngularSpeed += delta(fd); 43 + } 44 + 45 + public static Action<FireData> AngularAccelerate(Func<float> delta) 46 + { 47 + return (fd) => fd.AngularSpeed += delta(); 48 + } 49 + 50 + public static Action<FireData> AngularAccelerate(float delta) 51 + { 52 + return (fd) => fd.AngularSpeed += delta; 53 + } 54 + } 55 + 56 + public static class AngularSpeedModifierExtensions 57 + { 58 + 59 + public static IEnumerable WithAngularSpeed(this IEnumerable coroutine, 60 + Func<FireData, float> angSpeed, 61 + Func<FireData, bool> filter = null) 62 + { 63 + if (angSpeed == null) 64 + throw new ArgumentNullException("angSpeed"); 65 + return coroutine.ForEachFireData(Modifier.SetAngularSpeed(angSpeed), filter); 66 + } 67 + 68 + public static IEnumerable WithAngularSpeed(this IEnumerable coroutine, 69 + float angSpeed, 70 + Func<FireData, bool> filter = null) 71 + { 72 + return coroutine.ForEachFireData(Modifier.SetAngularSpeed(angSpeed), filter); 73 + } 74 + } 75 + 76 + }
+12
Assets/Dependencies/DanmakU/_Core_/Modifiers/AngularSpeedModifiers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 69182e430cae2a64f9fec8560cb56fc6 3 + timeCreated: 1441313086 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+65
Assets/Dependencies/DanmakU/_Core_/Modifiers/BurstModifiers.cs
··· 1 + using UnityEngine; 2 + using System; 3 + using System.Collections; 4 + 5 + namespace Hourai.DanmakU 6 + { 7 + 8 + public static class BurstModifierExtensions 9 + { 10 + 11 + public static IEnumerable RadialBurst(this IEnumerable data, 12 + Func<FireData, int> count, 13 + Func<FireData, float> range, 14 + Func<FireData, bool> filter = null) 15 + { 16 + 17 + if (count == null || range == null) 18 + throw new ArgumentNullException(); 19 + 20 + float delta = 0f; 21 + 22 + Action<FireData, int> setup = 23 + delegate(FireData fd, int currentCount) 24 + { 25 + 26 + if (currentCount <= 1) 27 + return; 28 + 29 + float currentRange = range(fd); 30 + delta = currentRange / currentCount; 31 + fd.Rotation -= 0.5f * currentRange; 32 + }; 33 + 34 + Action<FireData> edit = (fd) => fd.Rotation += delta; 35 + 36 + return data.Burst(count, edit, setup, filter); 37 + } 38 + 39 + public static IEnumerable RadialBurst(this IEnumerable coroutine, 40 + int count, 41 + float range = 360f, 42 + Func<FireData, bool> filter = null) 43 + { 44 + if (count == 1) 45 + return coroutine; 46 + return coroutine.RadialBurst(count.Wrap(), range.Wrap(), filter); 47 + } 48 + 49 + public static IEnumerable LinearBurst(this IEnumerable data, 50 + Func<FireData, int> count, 51 + Func<FireData, float> dSpeed, 52 + Func<FireData, bool> filter = null) 53 + { 54 + return data.Burst(count, (fd) => fd.Speed += dSpeed(fd), null, filter); 55 + } 56 + 57 + public static IEnumerable LinearBurst(this IEnumerable data, 58 + int count, 59 + float dSpeed, 60 + Func<FireData, bool> filter = null) 61 + { 62 + return data.Burst(count.Wrap(), (fd) => fd.Speed += dSpeed, null, filter); 63 + } 64 + } 65 + }
+12
Assets/Dependencies/DanmakU/_Core_/Modifiers/BurstModifiers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 05f20bee9aa7c7f4d823bd89226c1bf1 3 + timeCreated: 1441321335 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+32
Assets/Dependencies/DanmakU/_Core_/Modifiers/ColorModifiers.cs
··· 1 + using UnityEngine; 2 + using System; 3 + using System.Collections; 4 + 5 + namespace Hourai.DanmakU 6 + { 7 + public static class ColorModifierExtensions 8 + { 9 + public static IEnumerable WithColor(this IEnumerable data, 10 + Func<FireData, Color?> color, 11 + Func<FireData, bool> filter = null) 12 + { 13 + if (color == null) 14 + throw new ArgumentNullException("color"); 15 + return data.ForEachFireData(fd => fd.Color = color(fd), filter); 16 + } 17 + 18 + public static IEnumerable WithColor(this IEnumerable data, 19 + Color? color, 20 + Func<FireData, bool> filter = null) 21 + { 22 + return data.ForEachFireData(fd => fd.Color = color, filter); 23 + } 24 + 25 + public static IEnumerable WithColor(this IEnumerable data, 26 + Gradient gradient, 27 + Func<FireData, bool> filter = null) 28 + { 29 + return data.ForEachFireData(fd => fd.Color = gradient.Random(), filter); 30 + } 31 + } 32 + }
+12
Assets/Dependencies/DanmakU/_Core_/Modifiers/ColorModifiers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: d1864f67a715d464dabd6f697d0e3f77 3 + timeCreated: 1441321606 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+35
Assets/Dependencies/DanmakU/_Core_/Modifiers/ControllerModifiers.cs
··· 1 + using UnityEngine; 2 + using System; 3 + using System.Collections; 4 + 5 + namespace Hourai.DanmakU 6 + { 7 + 8 + public static class ControllerModifierExtensions 9 + { 10 + 11 + public static IEnumerable WithController(this IEnumerable data, 12 + Func<FireData, Action<Danmaku>> controller, 13 + Func<FireData, bool> filter = null) 14 + { 15 + if (controller == null) 16 + return data; 17 + return data.ForEachFireData(fireData => fireData.Controller += controller(fireData), filter); 18 + } 19 + 20 + public static IEnumerable WithController(this IEnumerable data, 21 + Action<Danmaku> controller, 22 + Func<FireData, bool> filter = null) 23 + { 24 + if (controller == null) 25 + return data; 26 + return data.ForEachFireData(fireData => fireData.Controller += controller, filter); 27 + } 28 + 29 + public static IEnumerable WithoutControllers(this IEnumerable data, Func<FireData, bool> filter = null) 30 + { 31 + return data.ForEachFireData(fireData => fireData.Controller = null, filter); 32 + } 33 + } 34 + } 35 +
+12
Assets/Dependencies/DanmakU/_Core_/Modifiers/ControllerModifiers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 3ab2f4d7d39b576409fc8f30e75c8521 3 + timeCreated: 1441321480 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+25
Assets/Dependencies/DanmakU/_Core_/Modifiers/DamageModifiers.cs
··· 1 + using System; 2 + using System.Collections; 3 + 4 + namespace Hourai.DanmakU 5 + { 6 + public static class DamageModifierExtensions 7 + { 8 + public static IEnumerable WithDamage(this IEnumerable coroutine, 9 + Func<FireData, float> damage, 10 + Func<FireData, bool> filter = null) 11 + { 12 + if (damage == null) 13 + throw new ArgumentNullException("damage"); 14 + return coroutine.ForEachFireData(d => d.Damage = damage(d), filter); 15 + } 16 + 17 + public static IEnumerable WithDamage(this IEnumerable coroutine, 18 + float damage, 19 + Func<FireData, bool> filter = null) 20 + { 21 + return coroutine.ForEachFireData(d => d.Damage = damage, filter); 22 + } 23 + } 24 + } 25 +
+12
Assets/Dependencies/DanmakU/_Core_/Modifiers/DamageModifiers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: abea06e0b1992d64cb659aa160bf71bc 3 + timeCreated: 1441321720 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+3 -2
Assets/Dependencies/DanmakU/_Core_/Modifiers/DanmakuSource.cs
··· 6 6 using System.Collections; 7 7 using System.Collections.Generic; 8 8 using UnityEngine; 9 - using Vexe.Runtime.Types; 9 + using Vexe.Runtime.Types; 10 + using Hourai; 10 11 11 - namespace Hourai.DanmakU.Modifiers { 12 + namespace Hourai.DanmakU { 12 13 13 14 public struct Pose { 14 15
+12
Assets/Dependencies/DanmakU/_Core_/Modifiers/DanmakuSource.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 169702477ddc50243b683054e0b93772 3 + timeCreated: 1441237558 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+340
Assets/Dependencies/DanmakU/_Core_/Modifiers/ModifierUtil.cs
··· 1 + using UnityEngine; 2 + using System; 3 + using System.Collections; 4 + using System.Collections.Generic; 5 + using Vexe.Runtime.Extensions; 6 + 7 + namespace Hourai.DanmakU 8 + { 9 + public static class ModifierUtil { 10 + 11 + /// <summary> 12 + /// Replaces enumerated enumeration with their elements. 13 + /// This is a shallow replacement, only works on the initial enumeration. 14 + /// For a deep replacement (a recursive replacement of all enumerated enumerations), use FullyFlatten() instead. 15 + /// </summary> 16 + /// <param name="enumeration">the target enumeration of enumerations</param> 17 + /// <returns>an flattened enumeration. Returns an empty enumeration if <paramref name="enumeration"/> is null.</returns> 18 + public static IEnumerable Flatten(this IEnumerable enumeration) 19 + { 20 + if (enumeration == null) 21 + yield break; 22 + foreach (object data in enumeration) 23 + { 24 + var fd = data as FireData; 25 + var asEnumerator = data as IEnumerator; 26 + var asEnumerable = data as IEnumerable; 27 + if (fd != null) 28 + yield return fd; 29 + else if (asEnumerable != null) 30 + foreach (var subData in asEnumerable) 31 + yield return subData; 32 + else if (asEnumerator != null) 33 + while (asEnumerator.MoveNext()) 34 + yield return asEnumerator.Current; 35 + else 36 + yield return data; 37 + } 38 + } 39 + 40 + /// <summary> 41 + /// Recursively replaces all enumerated enumerations with their elements. 42 + /// This is a deep replacement. To only flatten the initial enumeration, use Flatten() instead. 43 + /// </summary> 44 + /// <param name="enumeration">the target enumeration of enumerations</param> 45 + /// <returns>an flattened enumeration. Returns an empty enumeration if <paramref name="enumeration"/> is null.</returns> 46 + public static IEnumerable FullyFlatten(this IEnumerable enumeration) 47 + { 48 + if (enumeration == null) 49 + yield break; 50 + Stack<IEnumerator> enumerationStack = new Stack<IEnumerator>(); 51 + enumerationStack.Push(enumeration.GetEnumerator()); 52 + while (enumerationStack.Count > 0) 53 + { 54 + IEnumerator iterator = enumerationStack.Peek(); 55 + while (iterator.MoveNext()) 56 + { 57 + object current = iterator.Current; 58 + var fd = current as FireData; 59 + if (fd != null) 60 + { 61 + yield return fd; 62 + continue; 63 + } 64 + var asIterator = current as IEnumerator; 65 + var asEnumerable = current as IEnumerable; 66 + if (asEnumerable != null) 67 + asIterator = asEnumerable.GetEnumerator(); 68 + if (asIterator != null) 69 + { 70 + enumerationStack.Push(asIterator); 71 + iterator = asIterator; 72 + } 73 + else 74 + { 75 + yield return current; 76 + } 77 + } 78 + enumerationStack.Pop(); 79 + } 80 + } 81 + 82 + /// <summary> 83 + /// Replaces all elements of type <typeparamref name="TIn"/> with generated values of type <typeparamref name="TOut"/>. 84 + /// This removes all replaced elements from the resultant enumeration and maintains the size of the enumeration. 85 + /// To keep the elements in, use Inject instead. 86 + /// </summary> 87 + /// <typeparam name="TIn">the target type to replace elements of</typeparam> 88 + /// <typeparam name="TOut">the type of object to replace with</typeparam> 89 + /// <param name="enumeration">the enumeration to replace the elements of</param> 90 + /// <param name="replacement">a mapping function that maps elements to be replace to their replacement</param> 91 + /// <param name="filter">a selection function. Returns true if a element is to be replaced. If null, all elements that can be replaced will be.</param> 92 + /// <returns>the enumeration with replaced elements</returns> 93 + public static IEnumerable Replace<TIn, TOut>(this IEnumerable enumeration, 94 + Func<TIn, TOut> replacement, 95 + Predicate<TIn> filter = null) 96 + { 97 + if (replacement == null) 98 + throw new ArgumentNullException("replacement"); 99 + if (enumeration == null) 100 + yield break; 101 + foreach (object data in enumeration) 102 + { 103 + if (data is TIn && (filter == null || filter((TIn)data))) 104 + yield return replacement((TIn)data); 105 + else 106 + yield return data; 107 + } 108 + } 109 + 110 + /// <summary> 111 + /// Injects a new elements of type <typeparamref name="TOut"/> before or after elements of type <typeparamref name="TIn"/>. 112 + /// This keeps all matched elements in the enumeration. This also expands the 113 + /// </summary> 114 + /// <typeparam name="TIn"></typeparam> 115 + /// <typeparam name="TOut"></typeparam> 116 + /// <param name="coroutine"></param> 117 + /// <param name="injection"></param> 118 + /// <param name="after"></param> 119 + /// <param name="filter"></param> 120 + /// <returns></returns> 121 + public static IEnumerable Inject<TIn, TOut>(this IEnumerable coroutine, 122 + Func<TIn, TOut> injection, 123 + Func<TIn, bool> after = null, 124 + Func<TIn, bool> filter = null) where TIn : class 125 + { 126 + if (injection == null) 127 + throw new ArgumentNullException("injection"); 128 + if (coroutine == null) 129 + yield break; 130 + foreach (object data in coroutine) 131 + { 132 + var typeChecked = data as TIn; 133 + if (typeChecked != null && (filter == null || filter(typeChecked))) 134 + { 135 + if (after == null || !after((TIn)data)) 136 + { 137 + yield return data; 138 + yield return injection(typeChecked); 139 + } 140 + else 141 + { 142 + yield return injection(typeChecked); 143 + yield return data; 144 + } 145 + } 146 + else 147 + yield return data; 148 + } 149 + } 150 + 151 + public static IEnumerable Duplicate<T>(this IEnumerable coroutine, 152 + Func<FireData, IEnumerable<T>> duplicationFunc, 153 + Action<FireData, T> editFunc = null, 154 + bool includeOriginal = true, 155 + Func<FireData, bool> filter = null) { 156 + if(duplicationFunc == null) 157 + throw new ArgumentNullException("duplicationFunc"); 158 + if (coroutine == null) 159 + yield break; 160 + 161 + var alterDummy = new FireData(); 162 + foreach (var obj in coroutine) { 163 + var fd = obj as FireData; 164 + if (fd == null || (filter != null && filter(fd))) { 165 + yield return obj; 166 + continue; 167 + } 168 + if (includeOriginal) 169 + yield return fd; 170 + IEnumerable<T> alterations = duplicationFunc(fd); 171 + if (alterations == null) 172 + continue; 173 + foreach (T alteration in duplicationFunc(fd)) { 174 + alterDummy.Copy(fd); 175 + editFunc.SafeInvoke(alterDummy, alteration); 176 + yield return alterDummy; 177 + } 178 + } 179 + } 180 + 181 + public static IEnumerable Burst(this IEnumerable coroutine, 182 + Func<FireData, int> count, 183 + Action<FireData> delta = null, 184 + Action<FireData, int> setup = null, 185 + Func<FireData, bool> filter = null) 186 + { 187 + if (count == null) 188 + throw new ArgumentNullException("count"); 189 + if(coroutine == null) 190 + yield break; 191 + 192 + FireData copy = new FireData(); 193 + foreach (var obj in coroutine) { 194 + var fd = obj as FireData; 195 + if (fd == null || (filter != null && filter(fd))) { 196 + yield return obj; 197 + continue; 198 + } 199 + copy.Copy(fd); 200 + int currentCount = count(fd); 201 + if (setup != null) 202 + setup(fd, currentCount); 203 + for (var i = 0; i < currentCount; i++) { 204 + yield return copy; 205 + delta.SafeInvoke(copy); 206 + } 207 + } 208 + } 209 + 210 + public static Task Execute(this MonoBehaviour behaviour, IEnumerable coroutine) 211 + { 212 + return coroutine.Execute(behaviour); 213 + } 214 + 215 + public static Task Execute(this IEnumerable data, MonoBehaviour context = null) 216 + { 217 + if (data == null) 218 + throw new ArgumentNullException("data"); 219 + 220 + var fd = data as FireData; 221 + var dp = data as DanmakuPrefab; 222 + if (fd != null) 223 + fd.Fire(); 224 + else if (dp != null) 225 + ((FireData) dp).Fire(); 226 + else { 227 + var fireTask = new Task(context ?? DanmakuGame.Instance, 228 + FireRoutine(data)); 229 + fireTask.Start(); 230 + return fireTask; 231 + } 232 + return null; 233 + } 234 + 235 + /// The actual coroutine that is executed in Fire() calls 236 + private static IEnumerator FireRoutine(IEnumerable dataSource) { 237 + foreach (object data in dataSource.FullyFlatten()) 238 + { 239 + var yi = data as YieldInstruction; 240 + var fd = data as FireData; 241 + if (data == null || yi != null) 242 + yield return data; 243 + else if (fd != null) 244 + fd.Fire(); 245 + else if (data is int) { 246 + int frames = (int) data; 247 + if (frames <= 0) 248 + yield return null; 249 + else 250 + for (var i = 0; i < frames; i++) 251 + yield return null; 252 + } else if (data is float) { 253 + float seconds = (float) data; 254 + if (seconds < TimeUtil.DeltaTime) 255 + yield return null; 256 + else 257 + for (var t = 0f; t < seconds; t += TimeUtil.DeltaTime) 258 + yield return null; 259 + } else { 260 + yield return data; 261 + } 262 + } 263 + } 264 + 265 + private class FireManipulator : IEnumerable 266 + { 267 + private readonly IEnumerable coroutine; 268 + public readonly Func<FireData, bool> filter; 269 + public event Action<FireData> actions; 270 + private IEnumerator enumerator; 271 + 272 + public FireManipulator(IEnumerable source, Action<FireData> action, Func<FireData, bool> filter) 273 + { 274 + coroutine = source; 275 + actions = action; 276 + this.filter = filter; 277 + enumerator = filter == null ? Unfiltered() : Filtered(); 278 + } 279 + 280 + public IEnumerator GetEnumerator() 281 + { 282 + return enumerator; 283 + } 284 + 285 + IEnumerator Filtered() 286 + { 287 + if (coroutine == null) 288 + yield break; 289 + 290 + var copy = new FireData(); 291 + foreach (object data in coroutine) 292 + { 293 + var fd = data as FireData; 294 + if (fd == null || (filter != null && !filter(fd))) 295 + { 296 + yield return data; 297 + continue; 298 + } 299 + copy.Copy(fd); 300 + actions(copy); 301 + yield return copy; 302 + } 303 + } 304 + 305 + IEnumerator Unfiltered() 306 + { 307 + if (coroutine == null) 308 + yield break; 309 + 310 + var copy = new FireData(); 311 + foreach (object data in coroutine) 312 + { 313 + var fd = data as FireData; 314 + if (fd == null) 315 + { 316 + yield return data; 317 + continue; 318 + } 319 + copy.Copy(fd); 320 + actions(copy); 321 + yield return copy; 322 + } 323 + } 324 + 325 + } 326 + 327 + public static IEnumerable ForEachFireData(this IEnumerable coroutine, 328 + Action<FireData> action, 329 + Func<FireData, bool> filter = null) 330 + { 331 + if (action == null) 332 + throw new ArgumentNullException("action"); 333 + var fm = coroutine as FireManipulator; 334 + if(fm == null || fm.filter != filter) 335 + return new FireManipulator(coroutine, action, filter); 336 + fm.actions += action; 337 + return fm; 338 + } 339 + } 340 + }
+12
Assets/Dependencies/DanmakU/_Core_/Modifiers/ModifierUtil.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 592d4789b9f4b8141b9db2296e1132c9 3 + timeCreated: 1441321889 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+147
Assets/Dependencies/DanmakU/_Core_/Modifiers/PositionModifiers.cs
··· 1 + using System; 2 + using System.Collections; 3 + using UnityEngine; 4 + using System.Collections.Generic; 5 + 6 + namespace Hourai.DanmakU 7 + { 8 + 9 + public static partial class Modifier 10 + { 11 + public static Vector2 Position(FireData fd) 12 + { 13 + return fd.Position; 14 + } 15 + 16 + public static void SetPosition(FireData fd, Vector2 position) 17 + { 18 + fd.Position = position; 19 + } 20 + 21 + public static void Move(FireData fd, Vector2 delta) 22 + { 23 + fd.Position += delta; 24 + } 25 + 26 + public static Action<FireData> SetPosition(Func<FireData, Vector2> delta) 27 + { 28 + return (fd) => fd.Position += delta(fd); 29 + } 30 + 31 + public static Action<FireData> SetPosition(Func<Vector2> delta) 32 + { 33 + return (fd) => fd.Position += delta(); 34 + } 35 + 36 + public static Action<FireData> SetPosition(Vector2 delta) 37 + { 38 + return (fd) => fd.Position += delta; 39 + } 40 + 41 + public static Action<FireData> Move(Func<FireData, Vector2> delta) 42 + { 43 + return (fd) => fd.Position += delta(fd); 44 + } 45 + 46 + public static Action<FireData> Move(Func<Vector2> delta) 47 + { 48 + return (fd) => fd.Position += delta(); 49 + } 50 + 51 + public static Action<FireData> Move(Vector2 delta) 52 + { 53 + return (fd) => fd.Position += delta; 54 + } 55 + } 56 + 57 + public static class PositionModifierExtensions 58 + { 59 + public static IEnumerable From(this IEnumerable data, Func<FireData, Vector2> position, Func<FireData, bool> filter = null) 60 + { 61 + if (position == null) 62 + throw new ArgumentNullException("position"); 63 + return data.ForEachFireData(fd => fd.Position = position(fd), filter); 64 + } 65 + 66 + public static IEnumerable From(this IEnumerable data, Vector2 position, Func<FireData, bool> filter = null) 67 + { 68 + return data.ForEachFireData(Modifier.SetPosition(position), filter); 69 + } 70 + 71 + public static IEnumerable From(this IEnumerable coroutine, 72 + Func<FireData, IEnumerable<Vector2>> positions, 73 + Func<FireData, bool> filter = null) 74 + { 75 + return coroutine.Duplicate(positions, Modifier.SetPosition, false, filter); 76 + } 77 + 78 + public static IEnumerable From(this IEnumerable coroutine, 79 + IEnumerable<Vector2> positions, 80 + Func<FireData, bool> filter = null) 81 + { 82 + return coroutine.From(fd => positions, filter); 83 + } 84 + 85 + public static IEnumerable From(this IEnumerable data, GameObject gameObject, Func<FireData, bool> filter = null) 86 + { 87 + if (gameObject == null) 88 + return data; 89 + Transform trans = gameObject.transform; 90 + return data.ForEachFireData(fd => fd.Position = ((trans) ? (Vector2)trans.position : fd.Position), filter); 91 + } 92 + 93 + public static IEnumerable From(this IEnumerable coroutine, 94 + Func<FireData, IEnumerable<GameObject>> gameObjects, 95 + Func<FireData, bool> filter = null) 96 + { 97 + return coroutine.Duplicate(gameObjects, ((data, o) => data.Position = o.transform.position), false, filter); 98 + } 99 + 100 + public static IEnumerable From(this IEnumerable coroutine, 101 + IEnumerable<GameObject> gameObjects, 102 + Func<FireData, bool> filter = null) 103 + { 104 + return coroutine.From(gameObjects.Wrap(), filter); 105 + } 106 + 107 + public static IEnumerable From(this IEnumerable data, Component component, Func<FireData, bool> filter = null) 108 + { 109 + return component ? data.From(component.gameObject) : data; 110 + } 111 + 112 + public static IEnumerable From(this IEnumerable coroutine, 113 + Func<FireData, IEnumerable<Component>> components, 114 + Func<FireData, bool> filter = null) 115 + { 116 + return coroutine.Duplicate(components, ((data, o) => data.Position = o.transform.position), false, filter); 117 + } 118 + 119 + public static IEnumerable From(this IEnumerable coroutine, 120 + IEnumerable<Component> components, 121 + Func<FireData, bool> filter = null) 122 + { 123 + return coroutine.From(fd => components, filter); 124 + } 125 + 126 + public static IEnumerable From(this IEnumerable data, Danmaku danmaku, Func<FireData, bool> filter = null) 127 + { 128 + if (danmaku == null) 129 + throw new ArgumentNullException("danmaku"); 130 + return data.ForEachFireData(fd => fd.Position = (danmaku ? danmaku.Position : fd.Position), filter); 131 + } 132 + 133 + public static IEnumerable From(this IEnumerable coroutine, 134 + Func<FireData, IEnumerable<Danmaku>> danmaku, 135 + Func<FireData, bool> filter = null) 136 + { 137 + return coroutine.Duplicate(danmaku, ((data, o) => data.Position = o.Position), false, filter); 138 + } 139 + 140 + public static IEnumerable From(this IEnumerable coroutine, 141 + IEnumerable<Danmaku> danmaku, 142 + Func<FireData, bool> filter = null) 143 + { 144 + return coroutine.From(fd => danmaku, filter); 145 + } 146 + } 147 + }
+12
Assets/Dependencies/DanmakU/_Core_/Modifiers/PositionModifiers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: b80bc159a245d0a488b4d68590e28739 3 + timeCreated: 1441312253 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+113
Assets/Dependencies/DanmakU/_Core_/Modifiers/RotationModifiers.cs
··· 1 + using System; 2 + using System.Collections; 3 + using UnityEngine; 4 + 5 + namespace Hourai.DanmakU 6 + { 7 + 8 + public static partial class Modifier 9 + { 10 + public static float Rotation(FireData fd) 11 + { 12 + return fd.Rotation; 13 + } 14 + 15 + public static void SetRotation(FireData fd, float rotation) 16 + { 17 + fd.Rotation = rotation; 18 + } 19 + 20 + public static void Rotate(FireData fd, float rotation) 21 + { 22 + fd.Rotation += rotation; 23 + } 24 + 25 + public static Action<FireData> SetRotation(Func<FireData, float> delta) 26 + { 27 + return (fd) => fd.Rotation = delta(fd); 28 + } 29 + 30 + public static Action<FireData> SetRotation(Func<float> delta) 31 + { 32 + return (fd) => fd.Rotation = delta(); 33 + } 34 + 35 + public static Action<FireData> SetRotation(float delta) 36 + { 37 + return (fd) => fd.Rotation = delta; 38 + } 39 + 40 + public static Action<FireData> Rotate(Func<FireData, float> delta) 41 + { 42 + return (fd) => fd.Rotation += delta(fd); 43 + } 44 + 45 + public static Action<FireData> Rotate(Func<float> delta) 46 + { 47 + return (fd) => fd.Rotation += delta(); 48 + } 49 + 50 + public static Action<FireData> Rotate(float delta) 51 + { 52 + return (fd) => fd.Rotation += delta; 53 + } 54 + } 55 + 56 + public static class RotationModifierExtensions 57 + { 58 + public static IEnumerable InDirection(this IEnumerable coroutine, 59 + Func<FireData, float> angle, 60 + Func<FireData, bool> filter = null) 61 + { 62 + if (angle == null) 63 + throw new ArgumentNullException("angle"); 64 + return coroutine.ForEachFireData(fd => fd.Rotation = angle(fd), filter); 65 + } 66 + 67 + public static IEnumerable InDirection(this IEnumerable coroutine, 68 + float angle, 69 + Func<FireData, bool> filter = null) 70 + { 71 + return coroutine.ForEachFireData(fd => fd.Rotation = angle, filter); 72 + } 73 + 74 + public static IEnumerable Towards(this IEnumerable coroutine, 75 + Func<FireData, Vector2> target, 76 + Func<FireData, bool> filter = null) 77 + { 78 + return coroutine.ForEachFireData(fd => fd.Rotation = DanmakuUtil.AngleBetween2D(fd.Position, target(fd)), filter); 79 + } 80 + 81 + public static IEnumerable Towards(this IEnumerable coroutine, 82 + Vector2 target, 83 + Func<FireData, bool> filter = null) 84 + { 85 + return coroutine.ForEachFireData(fd => fd.Rotation = DanmakuUtil.AngleBetween2D(fd.Position, target), filter); 86 + } 87 + 88 + public static IEnumerable Towards(this IEnumerable coroutine, 89 + GameObject target, 90 + Func<FireData, bool> filter = null) 91 + { 92 + if (target == null) 93 + throw new ArgumentNullException("target"); 94 + Transform trans = target.transform; 95 + return coroutine.ForEachFireData(delegate(FireData fd) 96 + { 97 + if (trans) 98 + fd.Rotation = DanmakuUtil.AngleBetween2D(fd.Position, 99 + trans.position); 100 + }, 101 + filter); 102 + } 103 + 104 + public static IEnumerable Towards(this IEnumerable coroutine, 105 + Component target, 106 + Func<FireData, bool> filter = null) 107 + { 108 + if (target == null) 109 + throw new ArgumentNullException("target"); 110 + return coroutine.Towards(target.gameObject); 111 + } 112 + } 113 + }
+12
Assets/Dependencies/DanmakU/_Core_/Modifiers/RotationModifiers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 810d5235edccccc41b6da6e27c3ad16c 3 + timeCreated: 1441311997 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+80
Assets/Dependencies/DanmakU/_Core_/Modifiers/SpeedModifiers.cs
··· 1 + using System; 2 + using UnityEngine; 3 + using System.Collections; 4 + 5 + namespace Hourai.DanmakU 6 + { 7 + public static partial class Modifier 8 + { 9 + public static float Speed(FireData fd) 10 + { 11 + return fd.Speed; 12 + } 13 + 14 + public static void SetSpeed(FireData fd, float speed) 15 + { 16 + fd.Speed = speed; 17 + } 18 + 19 + public static void Accelerate(FireData fd, float delta) 20 + { 21 + fd.Speed += delta; 22 + } 23 + 24 + public static Action<FireData> SetSpeed(Func<FireData, float> delta) 25 + { 26 + return (fd) => fd.Speed = delta(fd); 27 + } 28 + 29 + public static Action<FireData> SetSpeed(Func<float> delta) 30 + { 31 + return (fd) => fd.Speed = delta(); 32 + } 33 + 34 + public static Action<FireData> SetSpeed(float delta) 35 + { 36 + return (fd) => fd.Speed = delta; 37 + } 38 + 39 + public static Action<FireData> Accelerate(Func<FireData, float> delta) 40 + { 41 + return (fd) => fd.Speed += delta(fd); 42 + } 43 + 44 + public static Action<FireData> Accelerate(Func<float> delta) 45 + { 46 + return (fd) => fd.Speed += delta(); 47 + } 48 + 49 + public static Action<FireData> Accelerate(float delta) 50 + { 51 + return (fd) => fd.Speed += delta; 52 + } 53 + } 54 + 55 + public static class SpeedModifierExtensions 56 + { 57 + public static IEnumerable WithSpeed(this IEnumerable coroutine, 58 + Func<FireData, float> speed, 59 + Func<FireData, bool> filter = null) 60 + { 61 + if (speed == null) 62 + throw new ArgumentNullException("speed"); 63 + return coroutine.ForEachFireData(Modifier.SetSpeed(speed), filter); 64 + } 65 + 66 + public static IEnumerable WithSpeed(this IEnumerable coroutine, 67 + Func<float> speed, 68 + Func<FireData, bool> filter = null) 69 + { 70 + return coroutine.ForEachFireData(Modifier.SetSpeed(speed), filter); 71 + } 72 + 73 + public static IEnumerable WithSpeed(this IEnumerable coroutine, 74 + float speed, 75 + Func<FireData, bool> filter = null) 76 + { 77 + return coroutine.ForEachFireData(Modifier.SetSpeed(speed), filter); 78 + } 79 + } 80 + }
+12
Assets/Dependencies/DanmakU/_Core_/Modifiers/SpeedModifiers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 9bb56808ed1984f4a92efe1994aedcf3 3 + timeCreated: 1441312781 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+43
Assets/Dependencies/DanmakU/_Core_/Modifiers/TimingModifiers.cs
··· 1 + using UnityEngine; 2 + using System; 3 + using System.Collections; 4 + 5 + namespace Hourai.DanmakU 6 + { 7 + 8 + public static class TimingModifierExtensions 9 + { 10 + public static IEnumerable Delay(this IEnumerable coroutine, 11 + Func<FireData, int> frames, 12 + Func<FireData, bool> filter = null) 13 + { 14 + if (frames == null) 15 + throw new ArgumentNullException("frames"); 16 + return coroutine.Inject(frames, fd => true, filter); 17 + } 18 + 19 + public static IEnumerable Delay(this IEnumerable coroutine, 20 + int frames, 21 + Func<FireData, bool> filter = null) 22 + { 23 + return coroutine.Delay(fd => frames, filter); 24 + } 25 + 26 + public static IEnumerable Delay(this IEnumerable coroutine, 27 + Func<FireData, float> seconds, 28 + Func<FireData, bool> filter = null) 29 + { 30 + if (seconds == null) 31 + throw new ArgumentNullException("seconds"); 32 + return coroutine.Inject(seconds, fd => true, filter); 33 + } 34 + 35 + public static IEnumerable Delay(this IEnumerable coroutine, 36 + float seconds, 37 + Func<FireData, bool> filter = null) 38 + { 39 + return coroutine.Delay(fd => seconds, filter); 40 + } 41 + } 42 + 43 + }
+12
Assets/Dependencies/DanmakU/_Core_/Modifiers/TimingModifiers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 85693753aa490af4998545a6dedc93cc 3 + timeCreated: 1441321515 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+19
Assets/Dependencies/DanmakU/_Core_/Modifiers/_Modifiers.cs
··· 1 + using System; 2 + 3 + namespace Hourai.DanmakU { 4 + 5 + public static partial class Modifier { 6 + 7 + public static Func<FireData, T> Wrap<T>(this Func<T> func) 8 + { 9 + return (fd) => func(); 10 + } 11 + 12 + public static Func<FireData, T> Wrap<T>(this T val) 13 + { 14 + return (fd) => val; 15 + } 16 + 17 + } 18 + 19 + }
+12
Assets/Dependencies/DanmakU/_Core_/Modifiers/_Modifiers.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 8cf0341fcd82ce2428261f95351c2063 3 + timeCreated: 1441311922 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+12
Assets/Dependencies/DanmakU/_Core_/Util/Bounds2D.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: db14dfa58cdbc8e4aa9f61742dcd092d 3 + timeCreated: 1441237562 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+12
Assets/Dependencies/DanmakU/_Core_/Util/Counter.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: ceeb3eb21f95cfe499d867f72bc9dc2d 3 + timeCreated: 1441237562 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+12
Assets/Dependencies/DanmakU/_Core_/Util/DanmakuUtil.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 003b8e0decfc652499c1c141822069d4 3 + timeCreated: 1441237558 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+9
Assets/Dependencies/DanmakU/_Core_/Util/Extensions.meta
··· 1 + fileFormatVersion: 2 2 + guid: f1421260e7c1b644f89e6a2368e52674 3 + folderAsset: yes 4 + timeCreated: 1431554748 5 + licenseType: Free 6 + DefaultImporter: 7 + userData: 8 + assetBundleName: 9 + assetBundleVariant:
+401
Assets/Dependencies/DanmakU/_Core_/Util/Extensions/DanmakuCollectionExtensions.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using System; 6 + using System.Collections.Generic; 7 + using UnityEngine; 8 + 9 + namespace Hourai.DanmakU { 10 + 11 + public static class DanmakuCollectionExtensions { 12 + 13 + public static IEnumerable<Danmaku> ForEach(this IEnumerable<Danmaku> danmakus, 14 + Action<Danmaku> action, 15 + Func<Danmaku, bool> filter = null) { 16 + if (danmakus == null) 17 + return null; 18 + if (action == null) 19 + throw new ArgumentNullException("action"); 20 + foreach (Danmaku danmaku in danmakus) { 21 + if (danmaku && (filter == null || filter(danmaku))) 22 + action(danmaku); 23 + } 24 + return danmakus; 25 + } 26 + 27 + #region Position Functions 28 + 29 + /// <summary> 30 + /// Moves all of the Danmaku in the collection to a specified 2D point. 31 + /// </summary> 32 + /// <remarks> 33 + /// All contained null objects will be ignored. 34 + /// If the collection is <c>null</c>, this function does nothing and returns null. 35 + /// See: <see cref="Danmaku.Position"/> 36 + /// </remarks> 37 + /// <param name="danmakus">The enumerable collection of Danmaku. Will throw NullReferenceException if null.</param> 38 + /// <param name="position">the position to move the contained danmaku to, in absolute world coordinates.</param> 39 + public static IEnumerable<Danmaku> MoveTo(this IEnumerable<Danmaku> danmakus, Vector2 position, Func<Danmaku, bool> filter = null) 40 + { 41 + return danmakus.ForEach(x => x.Position = position, filter); 42 + } 43 + 44 + /// <summary> 45 + /// Moves all of the Danmaku in the collection to random 2D points specified by a array of 2D positions. 46 + /// </summary> 47 + /// <remarks> 48 + /// Positions are chosen randomly and independently for each Danmaku from a uniform distribution. 49 + /// This function is not thread-safe: it can only be called from the Unity main thread as it utilizes Unity API calls. 50 + /// All contained null objects will be ignored. 51 + /// See: <see cref="Danmaku.Position"/> 52 + /// </remarks> 53 + /// <param name="danmakus">The enumerable collection of Danmaku. Will throw NullReferenceException if null.</param> 54 + /// <param name="positions">the potential positions to move the contained danmaku to, in absolute world coordinates.</param> 55 + /// <exception cref="ArgumentNullException">Thrown if the position array is null.</exception> 56 + public static IEnumerable<Danmaku> MoveTo(this IEnumerable<Danmaku> danmakus, ICollection<Vector2> positions, Func<Danmaku, bool> filter = null) 57 + { 58 + if (positions == null) 59 + throw new ArgumentNullException("positions"); 60 + return danmakus.ForEach(x => x.Position = positions.Random(), filter); 61 + } 62 + 63 + /// <summary> 64 + /// Moves all of the Danmaku in the collection to a specified 2D point based on a Unity Transform's absolute world position. 65 + /// </summary> 66 + /// <remarks> 67 + /// This function discards the Z axis and will place the Danmaku at the corresponding 2D location on the Z = 0 plane. 68 + /// This function is not thread-safe: it can only be called from the Unity main thread as it utilizes Unity API calls. 69 + /// All contained null objects will be ignored. 70 + /// See: <see cref="Danmaku.Position"/> 71 + /// </remarks> 72 + /// <exception cref="ArgumentNullException">Thrown if the transform is null.</exception> 73 + /// <param name="danmakus">The enumerable collection of Danmaku. Function does nothing if this is null.</param> 74 + /// <param name="transform">The Transform to move to.</param> 75 + public static IEnumerable<Danmaku> MoveTo(this IEnumerable<Danmaku> danmakus, Transform transform, Func<Danmaku, bool> filter = null) 76 + { 77 + if (transform == null) 78 + throw new ArgumentNullException("transform"); 79 + return danmakus.MoveTo(transform.position); 80 + } 81 + 82 + /// <summary> 83 + /// Moves all of the Danmaku in the collection to a specified 2D point based on a Unity Component's Transform's absolute world position. 84 + /// </summary> 85 + /// <remarks> 86 + /// This function discards the Z axis and will place the Danmaku at the corresponding 2D location on the Z = 0 plane. 87 + /// This function is not thread-safe: it can only be called from the Unity main thread as it utilizes Unity API calls. 88 + /// All contained null objects will be ignored. 89 + /// See: <see cref="Danmaku.Position"/> 90 + /// </remarks> 91 + /// <exception cref="ArgumentNullException">Thrown if the Component is null.</exception> 92 + /// <param name="danmakus">The enumerable collection of Danmaku. Function does nothing if this is null.</param> 93 + /// <param name="component">The Component to move to.</param> 94 + public static IEnumerable<Danmaku> MoveTo(this IEnumerable<Danmaku> danmakus, Component component, Func<Danmaku, bool> filter = null) 95 + { 96 + if (component == null) 97 + throw new ArgumentNullException("component"); 98 + return danmakus.MoveTo(component.transform.position); 99 + } 100 + 101 + /// <summary> 102 + /// Moves all of the Danmaku in the collection to a specified 2D point based on a Unity GameObject's Transform's absolute world position. 103 + /// </summary> 104 + /// <remarks> 105 + /// This function discards the Z axis and will place the Danmaku at the corresponding 2D location on the Z = 0 plane. 106 + /// This function is not thread-safe: it can only be called from the Unity main thread as it utilizes Unity API calls. 107 + /// All contained null objects will be ignored. 108 + /// See: <see cref="Danmaku.Position"/> 109 + /// </remarks> 110 + /// <exception cref="ArgumentNullException">Thrown if the position array is null.</exception> 111 + /// <param name="danmakus">The enumerable collection of Danmaku. Does nothing if it is null.</param> 112 + /// <param name="gameObject">The GameObject to move to. Will throw ArgumentNullException if null.</param> 113 + public static IEnumerable<Danmaku> MoveTo(this IEnumerable<Danmaku> danmakus, GameObject gameObject, Func<Danmaku, bool> filter = null) 114 + { 115 + if (gameObject == null) 116 + throw new ArgumentNullException("gameObject"); 117 + return danmakus.MoveTo(gameObject.transform.position); 118 + } 119 + 120 + /// <summary> 121 + /// Moves all of the Danmaku in the collection to a random 2D points within a specified rectangular area. 122 + /// </summary> 123 + /// <remarks> 124 + /// Positions are chosen randomly and independently for each Danmaku from a uniform distribution within a specified Rect. 125 + /// This function is not thread-safe: it can only be called from the Unity main thread as it utilizes Unity API calls. 126 + /// All contained null objects will be ignored. 127 + /// The Danmaku objects can be filtered with the <paramref name="filter"/> parameter. If it returns <c>true</c> for an Danmaku, then it is moved. 128 + /// If <paramref name="filter"/> is null, all Danmaku are moved. 129 + /// See: <see cref="Danmaku.Position"/> 130 + /// </remarks> 131 + /// <param name="danmakus">The enumerable collection of Danmaku. This function does nothing if it is null.</param> 132 + /// <param name="area">The rectangular area to move the contained Danmaku to.</param> 133 + /// <param name="filter">a function to filter whether or not to apply the action. Returns true if it should. Defaults to null.</param> 134 + public static IEnumerable<Danmaku> MoveTo(this IEnumerable<Danmaku> danmakus, Rect area, Func<Danmaku, bool> filter = null) 135 + { 136 + return danmakus.ForEach(x => x.Position = area.RandomPoint(), filter); 137 + } 138 + 139 + /// <summary> 140 + /// Moves all of the Danmaku in a collection towards a specified point in space. 141 + /// </summary> 142 + /// <remarks> 143 + /// Positions are chosen randomly and independently for each Danmaku from a uniform distribution. 144 + /// This function is not thread-safe: it can only be called from the Unity main thread as it utilizes Unity API calls. 145 + /// All contained null objects will be ignored. 146 + /// The Danmaku objects can be filtered with the <paramref name="filter"/> parameter. If it returns <c>true</c> for an Danmaku, then it is moved. 147 + /// If <paramref name="filter"/> is null, all Danmaku are moved. 148 + /// See: <see cref="Danmaku.Position"/> 149 + /// </remarks> 150 + /// <param name="danmakus">The enumerable collection of Danmaku. This function does nothing if it is null.</param> 151 + /// <param name="target">The target point in space to move towards, in absolute world coordinates.</param> 152 + /// <param name="maxDistanceDelta">The maximum distance to move.</param> 153 + /// <param name="filter">a function to filter whether or not to apply the action. Returns true if it should. Defaults to null.</param> 154 + /// <typeparam name="IEnumerable<Danmaku>">The type of the collection.</typeparam> 155 + public static IEnumerable<Danmaku> MoveTowards(this IEnumerable<Danmaku> danmakus, 156 + Vector2 target, 157 + float maxDistanceDelta, 158 + Func<Danmaku, bool> filter = null) 159 + { 160 + return danmakus.ForEach(x => x.MoveTowards(target, maxDistanceDelta), filter); 161 + } 162 + 163 + public static IEnumerable<Danmaku> MoveTowards(this IEnumerable<Danmaku> danmakus, 164 + Transform target, 165 + float maxDistanceDelta, 166 + Func<Danmaku, bool> filter = null) 167 + { 168 + if (target == null) 169 + throw new ArgumentNullException("target"); 170 + return danmakus.MoveTowards(target.position, maxDistanceDelta); 171 + } 172 + 173 + public static IEnumerable<Danmaku> MoveTowards(this IEnumerable<Danmaku> danmakus, 174 + Component target, 175 + float maxDistanceDelta, 176 + Func<Danmaku, bool> filter = null) 177 + { 178 + if (target == null) 179 + throw new ArgumentNullException("target"); 180 + return danmakus.MoveTowards(target.transform.position, 181 + maxDistanceDelta); 182 + } 183 + 184 + public static IEnumerable<Danmaku> MoveTowards(this IEnumerable<Danmaku> danmakus, 185 + GameObject target, 186 + float maxDistanceDelta, 187 + Func<Danmaku, bool> filter = null) 188 + { 189 + if (target == null) 190 + throw new ArgumentNullException("target"); 191 + return danmakus.MoveTowards(target.transform.position, 192 + maxDistanceDelta); 193 + } 194 + 195 + /// <summary> 196 + /// Instantaneously translates all of the Danmaku in the collections by a specified change in position. 197 + /// All contained null objects will be ignored. 198 + /// </summary> 199 + /// <param name="danmakus">The enumerable collection of Danmaku. Does nothing if it is null.</param> 200 + /// <param name="deltaPos">The change in position.</param> 201 + public static IEnumerable<Danmaku> Translate(this IEnumerable<Danmaku> danmakus, Vector2 deltaPos, Func<Danmaku, bool> filter = null) 202 + { 203 + if (deltaPos != Vector2.zero) 204 + return danmakus.ForEach(x => x.Position += deltaPos, filter); 205 + return danmakus; 206 + } 207 + 208 + #endregion 209 + 210 + #region Rotation Functions 211 + 212 + public static IEnumerable<Danmaku> RotateTo(this IEnumerable<Danmaku> danmakus, float rotation, Func<Danmaku, bool> filter = null) 213 + { 214 + return danmakus.ForEach(x => x.Rotation = rotation, filter); 215 + } 216 + 217 + public static IEnumerable<Danmaku> RotateTo(this IEnumerable<Danmaku> danmakus, 218 + ICollection<float> rotations, 219 + Func<Danmaku, bool> filter = null) 220 + { 221 + if (rotations == null) 222 + throw new ArgumentNullException("rotations"); 223 + return danmakus.ForEach(x => x.Rotation = rotations.Random(), filter); 224 + } 225 + 226 + public static IEnumerable<Danmaku> Rotate(this IEnumerable<Danmaku> danmakus, float delta, Func<Danmaku, bool> filter = null) 227 + { 228 + return danmakus.ForEach(x => x.Rotation += delta, filter); 229 + } 230 + 231 + #endregion 232 + 233 + #region Speed Functions 234 + 235 + public static IEnumerable<Danmaku> Speed(this IEnumerable<Danmaku> danmakus, float speed, Func<Danmaku, bool> filter = null) 236 + { 237 + return danmakus.ForEach(x => x.Speed = speed, filter); 238 + } 239 + 240 + public static IEnumerable<Danmaku> Speed(this IEnumerable<Danmaku> danmakus, ICollection<float> speeds, Func<Danmaku, bool> filter = null) 241 + { 242 + if (speeds == null) 243 + throw new ArgumentNullException("speeds"); 244 + return danmakus.ForEach(x => x.Speed = speeds.Random(), filter); 245 + } 246 + 247 + public static IEnumerable<Danmaku> Accelerate(this IEnumerable<Danmaku> danmakus, float deltaSpeed, Func<Danmaku, bool> filter = null) 248 + { 249 + return danmakus.ForEach(x => x.Speed += deltaSpeed, filter); 250 + } 251 + 252 + #endregion 253 + 254 + #region Angular Speed Functions 255 + 256 + public static IEnumerable<Danmaku> AngularSpeed(this IEnumerable<Danmaku> danmakus, 257 + float angularSpeed, 258 + Func<Danmaku, bool> filter = null) 259 + { 260 + return danmakus.ForEach(x => x.AngularSpeed = angularSpeed, filter); 261 + } 262 + 263 + public static IEnumerable<Danmaku> AngularSpeed(this IEnumerable<Danmaku> danmakus, 264 + ICollection<float> angularSpeeds, 265 + Func<Danmaku, bool> filter = null) 266 + { 267 + return danmakus.ForEach(x => x.AngularSpeed = angularSpeeds.Random(), filter); 268 + } 269 + 270 + public static IEnumerable<Danmaku> AngularAccelerate(this IEnumerable<Danmaku> danmakus, 271 + float deltaSpeed, 272 + Func<Danmaku, bool> filter = null) 273 + { 274 + return danmakus.ForEach(x => x.AngularSpeed += deltaSpeed, filter); 275 + } 276 + 277 + #endregion 278 + 279 + #region Damage Functions 280 + 281 + public static IEnumerable<Danmaku> Damage(this IEnumerable<Danmaku> danmakus, int damage, Func<Danmaku, bool> filter = null) 282 + { 283 + return danmakus.ForEach(x => x.Damage = damage, filter); 284 + } 285 + 286 + public static IEnumerable<Danmaku> Damage(this IEnumerable<Danmaku> danmakus, ICollection<int> damages, Func<Danmaku, bool> filter = null) 287 + { 288 + return danmakus.ForEach(x => x.AngularSpeed = damages.Random(), filter); 289 + } 290 + 291 + #endregion 292 + 293 + #region Color Functions 294 + 295 + public static IEnumerable<Danmaku> Color(this IEnumerable<Danmaku> danmakus, Color color, Func<Danmaku, bool> filter = null) 296 + { 297 + return danmakus.ForEach(x => x.Color = color, filter); 298 + } 299 + 300 + public static IEnumerable<Danmaku> Color(this IEnumerable<Danmaku> danmakus, ICollection<Color> colors, Func<Danmaku, bool> filter = null) 301 + { 302 + if (colors == null) 303 + throw new ArgumentNullException("colors"); 304 + return danmakus.ForEach(x => x.Color = colors.Random(), filter); 305 + } 306 + 307 + public static IEnumerable<Danmaku> Color(this IEnumerable<Danmaku> danmakus, Gradient colors, Func<Danmaku, bool> filter = null) 308 + { 309 + if (colors == null) 310 + throw new ArgumentNullException("colors"); 311 + return danmakus.ForEach(x => x.Color = colors.Random(), filter); 312 + } 313 + 314 + #endregion 315 + 316 + #region Controller Functions 317 + 318 + public static IEnumerable<Danmaku> AddController(this IEnumerable<Danmaku> danmakus, 319 + Action<Danmaku> controller, 320 + Func<Danmaku, bool> filter = null) 321 + { 322 + return danmakus.ForEach(x => x.Controller += controller, filter); 323 + } 324 + 325 + public static IEnumerable<Danmaku> RemoveController(this IEnumerable<Danmaku> danmakus, 326 + Action<Danmaku> controller, 327 + Func<Danmaku, bool> filter = null) 328 + { 329 + return danmakus.ForEach(x => x.Controller -= controller, filter); 330 + } 331 + 332 + public static IEnumerable<Danmaku> ClearControllers(this IEnumerable<Danmaku> danmakus, Func<Danmaku, bool> filter = null) 333 + { 334 + return danmakus.ForEach(x => x.ClearControllers(), filter); 335 + } 336 + 337 + #endregion 338 + 339 + #region General Functions 340 + 341 + public static IEnumerable<Danmaku> Active(this IEnumerable<Danmaku> danmakus, bool value, Func<Danmaku, bool> filter = null) 342 + { 343 + return danmakus.ForEach(x => x.IsActive = value, filter); 344 + } 345 + 346 + public static IEnumerable<Danmaku> Activate(this IEnumerable<Danmaku> danmakus, Func<Danmaku, bool> filter = null) 347 + { 348 + return danmakus.ForEach(x => x.Activate(), filter); 349 + } 350 + 351 + public static IEnumerable<Danmaku> Deactivate(this IEnumerable<Danmaku> danmakus, Func<Danmaku, bool> filter = null) 352 + { 353 + return danmakus.ForEach(x => x.Deactivate(), filter); 354 + } 355 + 356 + public static IEnumerable<Danmaku> DeactivateImmediate(this IEnumerable<Danmaku> danmakus, Func<Danmaku, bool> filter = null) 357 + { 358 + return danmakus.ForEach(x => x.DeactivateImmediate(), filter); 359 + } 360 + 361 + #endregion 362 + 363 + #region Misc Functions 364 + 365 + public static IEnumerable<Danmaku> CollisionCheck(this IEnumerable<Danmaku> danmakus, bool collisionCheck, Func<Danmaku, bool> filter = null) 366 + { 367 + return danmakus.ForEach(x => x.CollisionCheck = collisionCheck, filter); 368 + } 369 + 370 + public static IEnumerable<Danmaku> MatchPrefab(this IEnumerable<Danmaku> danmakus, DanmakuPrefab prefab, Func<Danmaku, bool> filter = null) 371 + { 372 + return danmakus.ForEach(x => x.MatchPrefab(prefab), filter); 373 + } 374 + 375 + #endregion 376 + 377 + #region Fire Functions 378 + 379 + public static IEnumerable<Danmaku> Fire(this IEnumerable<Danmaku> danmakus, 380 + FireData data, 381 + bool useRotation = true, 382 + Func<Danmaku, bool> filter = null) 383 + { 384 + Vector2 tempPos = data.Position; 385 + float tempRot = data.Rotation; 386 + danmakus.ForEach(delegate(Danmaku danmaku) { 387 + data.Position = danmaku.Position; 388 + if (useRotation) 389 + data.Rotation = danmaku.Rotation; 390 + data.Fire(); 391 + }, 392 + filter); 393 + data.Position = tempPos; 394 + data.Rotation = tempRot; 395 + return danmakus; 396 + } 397 + 398 + #endregion 399 + } 400 + 401 + }
+12
Assets/Dependencies/DanmakU/_Core_/Util/Extensions/DanmakuCollectionExtensions.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: f13c2ad2fad05a140b85717a7e0bdb1d 3 + timeCreated: 1441237562 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+76
Assets/Dependencies/DanmakU/_Core_/Util/Extensions/DanmakuControllerExtensions.cs
··· 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using System; 6 + using System.Collections.Generic; 7 + using System.Linq; 8 + 9 + namespace Hourai.DanmakU { 10 + 11 + public static class DanmakuControllerExtensions { 12 + 13 + #region Action<Danmaku> Enumerable Functions 14 + 15 + /// <summary> 16 + /// Creates a single multicast Action<Danmaku> delegate from a collection of DanmakuControllers. 17 + /// </summary> 18 + /// <remarks>Any and all <c>null</c> values within the collection will be ignored.</remarks> 19 + /// <exception cref="NullReferenceException">thrown if the controllers collection is null.</exception> 20 + /// <param name="controllers">the collection of controllers to compress.</param> 21 + public static Action<Danmaku> Compress( 22 + this IEnumerable<Action<Danmaku>> controllers) { 23 + if (controllers == null) 24 + throw new NullReferenceException(); 25 + 26 + Action<Danmaku> controller = null; 27 + var list = controllers as IList<Action<Danmaku>>; 28 + if (list != null) { 29 + int count = list.Count; 30 + for (int i = 0; i < count; i++) { 31 + Action<Danmaku> current = list[i]; 32 + if (current != null) 33 + controller += current; 34 + } 35 + } else { 36 + foreach (var current in controllers) { 37 + if (current != null) 38 + controller += current; 39 + } 40 + } 41 + return controller; 42 + } 43 + 44 + #endregion 45 + 46 + #region Action<Danmaku> 47 + 48 + public static Action<Danmaku>[] Decompose(this Action<Danmaku> controller) { 49 + if (controller == null) 50 + return new Action<Danmaku>[] {}; 51 + Delegate[] elements = controller.GetInvocationList(); 52 + Action<Danmaku>[] controllerElements = new Action<Danmaku>[elements.Length]; 53 + for (var i = 0; i < elements.Length; i++) 54 + controllerElements[i] = elements[i] as Action<Danmaku>; 55 + return controllerElements; 56 + } 57 + 58 + public static Action<Danmaku> Remove(this Action<Danmaku> source, Action<Danmaku> toRemove) { 59 + Delegate[] elements = toRemove.GetInvocationList(); 60 + foreach (var element in elements) 61 + source = Delegate.Remove(source, element) as Action<Danmaku>; 62 + return source; 63 + } 64 + 65 + public static Action<Danmaku> RemoveAll(this Action<Danmaku> source, Action<Danmaku> toRemove) { 66 + Delegate[] elements = toRemove.GetInvocationList(); 67 + foreach (var element in elements) 68 + source = Delegate.Remove(source, element) as Action<Danmaku>; 69 + return source; 70 + } 71 + 72 + #endregion 73 + 74 + } 75 + 76 + }
+12
Assets/Dependencies/DanmakU/_Core_/Util/Extensions/DanmakuControllerExtensions.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 19a00ee8d3be187419ff2ffa93695064 3 + timeCreated: 1441237558 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+12
Assets/Dependencies/DanmakU/_Core_/Util/FieldBoundary.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 7e2530d37ea689143abc385c2f2b7e9d 3 + timeCreated: 1441237560 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+12
Assets/Dependencies/DanmakU/_Core_/Util/RotationMode.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: e2a57245c329a974688fe0580f7db263 3 + timeCreated: 1441237562 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+12
Assets/Dependencies/DanmakU/_Core_/Util/Task.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: f63dfb979820eba448aa6b8d3e12098f 3 + timeCreated: 1441238342 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
-155
Assets/Dependencies/DanmakU/_Core_/Util/Util.cs
··· 1 - // Copyright (c) 2015 James Liu 2 - // 3 - // See the LISCENSE file for copying permission. 4 - 5 - using System; 6 - using System.Collections.Generic; 7 - using UnityEngine; 8 - 9 - namespace Hourai.DanmakU { 10 - 11 - /// <summary> 12 - /// A static utility class of random functions and constants that are useful in various Unity projects 13 - /// </summary> 14 - public static class Util { 15 - 16 - public const float TwoPI = 2*Mathf.PI; 17 - 18 - /// <summary> 19 - /// Creates an array of masks for collisions/raycasts in 2D physics 20 - /// Useful for mirroring collision behavior. 21 - /// </summary> 22 - /// <returns>the masks for each layer</returns> 23 - public static int[] CollisionLayers2D() { 24 - int[] collisionMask = new int[32]; 25 - for (int i = 0; i < 32; i++) { 26 - collisionMask[i] = 0; 27 - for (int j = 0; j < 32; j++) { 28 - collisionMask[i] |= 29 - (Physics2D.GetIgnoreLayerCollision(i, j)) ? 0 : (1 << j); 30 - } 31 - } 32 - return collisionMask; 33 - } 34 - 35 - /// <summary> 36 - /// Creates an array of masks for collisions/raycasts in 3D physics 37 - /// Useful for mirroring collision behavior. 38 - /// </summary> 39 - /// <returns>the masks for each layer</returns> 40 - public static int[] CollisionLayers3D() { 41 - int[] collisionMask = new int[32]; 42 - for (int i = 0; i < 32; i++) { 43 - collisionMask[i] = 0; 44 - for (int j = 0; j < 32; j++) { 45 - collisionMask[i] |= (Physics.GetIgnoreLayerCollision(i, j)) 46 - ? 0 47 - : (1 << j); 48 - } 49 - } 50 - return collisionMask; 51 - } 52 - 53 - /// <summary> 54 - /// Actually computes the sign of a floating point number 55 - /// * If it is less than 0: returns -1 56 - /// * If it is equal to 0: returns 0 57 - /// * If it is more than 0: returns 1 58 - /// </summary> 59 - /// <param name="e">the sign of the given floating point value</param> 60 - public static float Sign(float e) { 61 - return (e == 0f) ? 0f : Mathf.Sign(e); 62 - } 63 - 64 - public static Vector3 BerzierCurveVectorLerp(Vector3 start, 65 - Vector3 end, 66 - Vector3 c1, 67 - Vector3 c2, 68 - float t) { 69 - float u, uu, uuu, tt, ttt; 70 - Vector3 p, p0 = start, p1 = c1, p2 = c2, p3 = end; 71 - u = 1 - t; 72 - uu = u*u; 73 - uuu = uu*u; 74 - tt = t*t; 75 - ttt = tt*t; 76 - 77 - p = uuu*p0; //first term 78 - p += 3*uu*t*p1; //second term 79 - p += 3*u*tt*p2; //third term 80 - p += ttt*p3; //fourth term 81 - 82 - return p; 83 - } 84 - 85 - /// <summary> 86 - /// Finds the <a href="http://docs.unity3d.com/ScriptReference/Object.html">UnityEngine.Object</a> that derive from a certain type. 87 - /// Unlike <a href="http://docs.unity3d.com/ScriptReference/Object.FindObjectsOfType.html">UnityEngine.Object.FindObjectsOfType</a>, this method works on interface types as well. 88 - /// This method is for general search. For a more efficent search that only works on classes derived from <a href="http://docs.unity3d.com/ScriptReference/MonoBehaviour.html">MonoBehavior</a> 89 - /// use FindBehaviorsOfType instead. 90 - /// </summary> 91 - /// <returns>The objects of type T.</returns> 92 - /// <typeparam name="T">the type to search for</typeparam> 93 - public static T[] FindObjectsOfType<T>() where T : class { 94 - return FindObjectByType<T, UnityEngine.Object>(); 95 - } 96 - 97 - /// <summary> 98 - /// Finds the <a href="http://docs.unity3d.com/ScriptReference/Object.html">UnityEngine.Object</a> that derive from a certain type. 99 - /// Unlike <a href="http://docs.unity3d.com/ScriptReference/Object.FindObjectsOfType.html">UnityEngine.Object.FindObjectsOfType</a>, this method works on interface types as well. 100 - /// This method is for specific search on classes derived from <a href="http://docs.unity3d.com/ScriptReference/MonoBehaviour.html">MonoBehavior</a>. 101 - /// For a more general search over all objects, use FindObjectsOfType instead. 102 - /// </summary> 103 - /// <returns>The objects of type T.</returns> 104 - /// <typeparam name="T">the type to search for</typeparam> 105 - public static T[] FindBehaviorsOfType<T>() where T : class { 106 - return FindObjectByType<T, MonoBehaviour>(); 107 - } 108 - 109 - private static T[] FindObjectByType<T, V>() where T : class 110 - where V : UnityEngine.Object { 111 - UnityEngine.Object[] objects = 112 - UnityEngine.Object.FindObjectsOfType<V>(); 113 - List<T> matches = new List<T>(); 114 - for (int i = 0; i < objects.Length; i++) { 115 - if (objects[i] is T) 116 - matches.Add(objects[i] as T); 117 - } 118 - return matches.ToArray(); 119 - } 120 - 121 - /// <summary> 122 - /// Finds the closest described component to the given point 123 - /// </summary> 124 - /// <returns>The closest instance of the given Component type</returns> 125 - /// <param name="position">The closest instance of T to the given point</param> 126 - /// <typeparam name="T">The Component Type to search for</typeparam> 127 - public static T FindClosest<T>(Vector3 position) where T : Component { 128 - T returnValue = default(T); 129 - T[] objects = UnityEngine.Object.FindObjectsOfType<T>(); 130 - float minDist = float.MaxValue; 131 - for (int i = 0; i < objects.Length; i++) { 132 - float dist = 133 - (objects[i].transform.position - position).magnitude; 134 - if (dist < minDist) { 135 - returnValue = objects[i]; 136 - minDist = dist; 137 - } 138 - } 139 - return returnValue; 140 - } 141 - 142 - public static Vector2 OnUnitCircle(float degrees) { 143 - float radians = Mathf.Deg2Rad*degrees; 144 - return new Vector2((float) Math.Cos(radians), 145 - (float) Math.Sin(radians)); 146 - } 147 - 148 - public static Vector2 OnUnitCircleRadians(float radians) { 149 - return new Vector2((float) Math.Cos(radians), 150 - (float) Math.Sin(radians)); 151 - } 152 - 153 - } 154 - 155 - }
+12
Assets/Dependencies/DanmakU/_Core_/Util/UtilCoroutines.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 79c8f3aa9ede37348815d349c176582c 3 + timeCreated: 1441237560 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+79
Assets/Dependencies/HouraiLib/Util/FastTrig.cs
··· 1 + using UnityEngine; 2 + using System.Collections; 3 + 4 + namespace Hourai 5 + { 6 + 7 + public static class FastTrig 8 + { 9 + /// <summary> 10 + /// A set of 2D vectors corresponding to unit circle coordinates 11 + /// Precalculated since Cosine and Sine calculations are expensive when called thousands of times per frame. 12 + /// An array access on an array of structs is much cheaper than calling both Mathf.Cos, and Mathf.Sin. 13 + /// </summary> 14 + internal static Vector2[] unitCircle; 15 + 16 + private const float DefaultAngleResolution = 0.01f; 17 + 18 + private static float _angRes = DefaultAngleResolution; 19 + private static float invAngRes; 20 + private static int unitCircleMax; 21 + 22 + public static float AngleResolution 23 + { 24 + get { return _angRes; } 25 + set 26 + { 27 + value = Mathf.Abs(value); 28 + bool changed = _angRes != value; 29 + _angRes = value; 30 + if (changed) 31 + Calculate(); 32 + } 33 + } 34 + 35 + static FastTrig() 36 + { 37 + Calculate(); 38 + } 39 + 40 + static void Calculate() 41 + { 42 + invAngRes = 1f / _angRes; 43 + unitCircleMax = Mathf.CeilToInt(360f / _angRes); 44 + float angle = 90f; 45 + unitCircle = new Vector2[unitCircleMax]; 46 + for (int i = 0; i < unitCircleMax; i++) 47 + { 48 + angle += _angRes; 49 + unitCircle[i] = Util.OnUnitCircle(angle); 50 + } 51 + } 52 + 53 + 54 + public static Vector2 UnitCircle(float angle) 55 + { 56 + //Clamp the angle to the range [0,360] 57 + angle = (angle % 360f + 360f) % 360f; 58 + return unitCircle[(int)(angle * invAngRes)]; 59 + } 60 + 61 + public static float Cos(float angle) 62 + { 63 + return UnitCircle(angle).x; 64 + } 65 + 66 + public static float Sin(float angle) 67 + { 68 + return UnitCircle(angle).y; 69 + } 70 + 71 + public static float Tan(float angle) 72 + { 73 + Vector2 uc = UnitCircle(angle); 74 + if (uc.x == 0f) 75 + return float.NaN; 76 + return uc.y / uc.x; 77 + } 78 + } 79 + }
+12
Assets/Dependencies/HouraiLib/Util/FastTrig.cs.meta
··· 1 + fileFormatVersion: 2 2 + guid: 4dc31966bd67ac347bab516c068a3eac 3 + timeCreated: 1441318393 4 + licenseType: Free 5 + MonoImporter: 6 + serializedVersion: 2 7 + defaultReferences: [] 8 + executionOrder: 0 9 + icon: {instanceID: 0} 10 + userData: 11 + assetBundleName: 12 + assetBundleVariant:
+175 -23
Assets/Dependencies/HouraiLib/Util/Util.cs
··· 1 - using UnityEngine; 1 + using UnityEngine; 2 + using System.Collections.Generic; 3 + 4 + namespace Hourai { 5 + 6 + public static class Util { 7 + 8 + 9 + /// <summary> 10 + /// Creates an array of masks for collisions/raycasts in 2D physics 11 + /// Useful for mirroring collision behavior. 12 + /// </summary> 13 + /// <returns>the masks for each layer</returns> 14 + public static int[] CollisionLayers2D() 15 + { 16 + int[] collisionMask = new int[32]; 17 + for (int i = 0; i < 32; i++) 18 + { 19 + collisionMask[i] = 0; 20 + for (int j = 0; j < 32; j++) 21 + { 22 + collisionMask[i] |= 23 + (Physics2D.GetIgnoreLayerCollision(i, j)) ? 0 : (1 << j); 24 + } 25 + } 26 + return collisionMask; 27 + } 28 + 29 + /// <summary> 30 + /// Creates an array of masks for collisions/raycasts in 3D physics 31 + /// Useful for mirroring collision behavior. 32 + /// </summary> 33 + /// <returns>the masks for each layer</returns> 34 + public static int[] CollisionLayers3D() 35 + { 36 + int[] collisionMask = new int[32]; 37 + for (int i = 0; i < 32; i++) 38 + { 39 + collisionMask[i] = 0; 40 + for (int j = 0; j < 32; j++) 41 + { 42 + collisionMask[i] |= (Physics.GetIgnoreLayerCollision(i, j)) 43 + ? 0 44 + : (1 << j); 45 + } 46 + } 47 + return collisionMask; 48 + } 49 + 50 + /// <summary> 51 + /// Actually computes the sign of a floating point number 52 + /// * If it is less than 0: returns -1 53 + /// * If it is equal to 0: returns 0 54 + /// * If it is more than 0: returns 1 55 + /// </summary> 56 + /// <param name="e">the sign of the given floating point value</param> 57 + public static float Sign(float e) 58 + { 59 + return (e == 0f) ? 0f : Mathf.Sign(e); 60 + } 61 + 62 + public static Vector3 BerzierCurveVectorLerp(Vector3 start, 63 + Vector3 end, 64 + Vector3 c1, 65 + Vector3 c2, 66 + float t) 67 + { 68 + float u, uu, uuu, tt, ttt; 69 + Vector3 p, p0 = start, p1 = c1, p2 = c2, p3 = end; 70 + u = 1 - t; 71 + uu = u * u; 72 + uuu = uu * u; 73 + tt = t * t; 74 + ttt = tt * t; 2 75 3 - namespace Hourai { 4 - 5 - public static class Util { 6 - 7 - public const float dt = 1 / 60f; 8 - 9 - public static int Sign(this int value) { 10 - if (value > 0) 11 - return 1; 12 - if (value < 0) 13 - return -1; 14 - return 0; 15 - } 16 - 17 - public static int MatchSign(int src, int sign) { 18 - return (Sign(src) != Sign(sign)) ? -src : src; 19 - } 20 - 21 - public static float MatchSign(float src, float sign) { 22 - return (Sign((int) src) != Sign((int) sign)) ? -src : src; 23 - } 24 - 76 + p = uuu * p0; //first term 77 + p += 3 * uu * t * p1; //second term 78 + p += 3 * u * tt * p2; //third term 79 + p += ttt * p3; //fourth term 80 + 81 + return p; 82 + } 83 + 84 + /// <summary> 85 + /// Finds the <a href="http://docs.unity3d.com/ScriptReference/Object.html">UnityEngine.Object</a> that derive from a certain type. 86 + /// Unlike <a href="http://docs.unity3d.com/ScriptReference/Object.FindObjectsOfType.html">UnityEngine.Object.FindObjectsOfType</a>, this method works on interface types as well. 87 + /// This method is for general search. For a more efficent search that only works on classes derived from <a href="http://docs.unity3d.com/ScriptReference/MonoBehaviour.html">MonoBehavior</a> 88 + /// use FindBehaviorsOfType instead. 89 + /// </summary> 90 + /// <returns>The objects of type T.</returns> 91 + /// <typeparam name="T">the type to search for</typeparam> 92 + public static T[] FindObjectsOfType<T>() where T : class 93 + { 94 + return FindObjectByType<T, UnityEngine.Object>(); 95 + } 96 + 97 + /// <summary> 98 + /// Finds the <a href="http://docs.unity3d.com/ScriptReference/Object.html">UnityEngine.Object</a> that derive from a certain type. 99 + /// Unlike <a href="http://docs.unity3d.com/ScriptReference/Object.FindObjectsOfType.html">UnityEngine.Object.FindObjectsOfType</a>, this method works on interface types as well. 100 + /// This method is for specific search on classes derived from <a href="http://docs.unity3d.com/ScriptReference/MonoBehaviour.html">MonoBehavior</a>. 101 + /// For a more general search over all objects, use FindObjectsOfType instead. 102 + /// </summary> 103 + /// <returns>The objects of type T.</returns> 104 + /// <typeparam name="T">the type to search for</typeparam> 105 + public static T[] FindBehaviorsOfType<T>() where T : class 106 + { 107 + return FindObjectByType<T, MonoBehaviour>(); 108 + } 109 + 110 + private static T[] FindObjectByType<T, V>() 111 + where T : class 112 + where V : UnityEngine.Object 113 + { 114 + UnityEngine.Object[] objects = 115 + UnityEngine.Object.FindObjectsOfType<V>(); 116 + List<T> matches = new List<T>(); 117 + for (int i = 0; i < objects.Length; i++) 118 + { 119 + if (objects[i] is T) 120 + matches.Add(objects[i] as T); 121 + } 122 + return matches.ToArray(); 123 + } 124 + 125 + /// <summary> 126 + /// Finds the closest described component to the given point 127 + /// </summary> 128 + /// <returns>The closest instance of the given Component type</returns> 129 + /// <param name="position">The closest instance of T to the given point</param> 130 + /// <typeparam name="T">The Component Type to search for</typeparam> 131 + public static T FindClosest<T>(Vector3 position) where T : Component 132 + { 133 + T returnValue = default(T); 134 + T[] objects = UnityEngine.Object.FindObjectsOfType<T>(); 135 + float minDist = float.MaxValue; 136 + for (int i = 0; i < objects.Length; i++) 137 + { 138 + float dist = 139 + (objects[i].transform.position - position).magnitude; 140 + if (dist < minDist) 141 + { 142 + returnValue = objects[i]; 143 + minDist = dist; 144 + } 145 + } 146 + return returnValue; 147 + } 148 + 149 + public static int Sign(this int value) { 150 + if (value > 0) 151 + return 1; 152 + if (value < 0) 153 + return -1; 154 + return 0; 155 + } 156 + 157 + public static int MatchSign(int src, int sign) { 158 + return (Sign(src) != Sign(sign)) ? -src : src; 159 + } 160 + 161 + public static float MatchSign(float src, float sign) { 162 + return (Sign((int) src) != Sign((int) sign)) ? -src : src; 163 + } 164 + 165 + public static Vector2 OnUnitCircle(float degrees) 166 + { 167 + float radians = Mathf.Deg2Rad * degrees; 168 + return new Vector2(Mathf.Cos(radians), 169 + Mathf.Sin(radians)); 170 + } 171 + 172 + public static Vector2 OnUnitCircleRadians(float radians) 173 + { 174 + return new Vector2(Mathf.Cos(radians), 175 + Mathf.Sin(radians)); 176 + } 25 177 } 26 178 27 179 }
+4 -6
Assets/Test/BasicFireTest.cs
··· 5 5 using System.Collections; 6 6 using UnityEngine; 7 7 using Hourai.DanmakU; 8 - using Hourai.DanmakU.Modifiers; 9 8 10 9 public class BasicFireTest : MonoBehaviour { 11 10 ··· 25 24 group = DanmakuGroup.List(); 26 25 FireData data = prefab; 27 26 group.Bind(data); 28 - test = data.Infinite() 29 - //.From(gameObject.Descendants()) 30 - //.WithSpeed(2) 31 - //.Towards(Vector2.zero) 27 + test = data.Infinite(Modifier.Rotate(2.5f)) 28 + .From(gameObject.Descendants()) 29 + .WithSpeed(2) 32 30 .Delay(delay) 33 - .Circle(5,1) 31 + .RadialBurst(100) 34 32 .Execute(); 35 33 Invoke("Test", 10); 36 34 }
+14 -14
Assets/Test/Test Scene.unity
··· 334 334 grad: 335 335 key0: 336 336 serializedVersion: 2 337 - rgba: 4294967295 337 + rgba: 4278190335 338 338 key1: 339 339 serializedVersion: 2 340 - rgba: 4294967295 340 + rgba: 4278255615 341 341 key2: 342 342 serializedVersion: 2 343 - rgba: 0 343 + rgba: 65280 344 344 key3: 345 345 serializedVersion: 2 346 - rgba: 0 346 + rgba: 16774400 347 347 key4: 348 348 serializedVersion: 2 349 - rgba: 0 349 + rgba: 16711680 350 350 key5: 351 351 serializedVersion: 2 352 - rgba: 0 352 + rgba: 16711935 353 353 key6: 354 354 serializedVersion: 2 355 - rgba: 0 355 + rgba: 255 356 356 key7: 357 357 serializedVersion: 2 358 358 rgba: 0 359 359 ctime0: 0 360 - ctime1: 65535 361 - ctime2: 0 362 - ctime3: 0 363 - ctime4: 0 364 - ctime5: 0 365 - ctime6: 0 360 + ctime1: 10922 361 + ctime2: 21845 362 + ctime3: 32768 363 + ctime4: 43690 364 + ctime5: 54612 365 + ctime6: 65535 366 366 ctime7: 0 367 367 atime0: 0 368 368 atime1: 65535 ··· 372 372 atime5: 0 373 373 atime6: 0 374 374 atime7: 0 375 - m_NumColorKeys: 2 375 + m_NumColorKeys: 7 376 376 m_NumAlphaKeys: 2 377 377 --- !u!4 &1376768896 378 378 Transform: