From b992b8cd9cd835c5a44cb85c40f96dca2aa06000 Mon Sep 17 00:00:00 2001 From: james7132 Date: Sat, 21 Mar 2015 12:45:43 -0400 Subject: [PATCH] Dump from Dogfight --- Assets/Demo.meta | 9 + Assets/Demo/Phantasmagoria Demo.meta | 9 + Assets/Demo/Standard Demo.meta | 9 + Assets/External Libraries.meta | 2 +- Assets/External Libraries/DanmakuUnity2D.meta | 2 +- .../DanmakuUnity2D/Attack Patterns.meta | 2 +- .../DanmakuUnity2D/Attack Patterns/Burst.cs | 2 +- .../Attack Patterns/ControlledBurst.cs | 2 +- .../Attack Patterns/CurvedBurst.cs | 2 +- .../Attack Patterns/LinearBurst.cs | 2 +- .../DanmakuUnity2D/Controllers.meta | 2 +- .../Controllers/PlayerControllers.meta | 2 +- .../PlayerControllers/Player Hitboxes.meta | 2 +- .../Controllers/Projectile Cotnrollers.meta | 2 +- .../AggregateProjectileController.cs | 11 +- .../AnimationCurveControl.cs | 17 +- .../ControllerWrapperBehavior.cs | 14 +- .../IProjectileController.cs | 8 +- .../IProjectileGroupController.cs | 16 - .../LinearProjectileControl.cs | 15 +- .../ProjectileControlBehavior.cs | 10 +- .../ProjectileController.cs | 136 ------ .../DanmakuUnity2D/Core.meta | 2 +- .../DanmakuUnity2D/Core/AttackPattern.cs | 24 +- .../DanmakuUnity2D/Core/DanmakuField.cs | 408 ++++++++++++++---- .../DanmakuUnity2D/Core/DanmakuField.cs.meta | 6 +- .../DanmakuUnity2D/Core/Projectile.cs | 7 +- .../DanmakuUnity2D/Core/ProjectileGroup.cs | 14 +- .../DanmakuUnity2D/Core/ProjectileManager.cs | 16 + .../DanmakuUnity2D/Core/ProjectilePrefab.cs | 32 +- .../DanmakuUnity2D/Editor.meta | 2 +- .../Editor/AtomicMovementDrawer.cs | 73 ++-- .../DanmakuUnity2D/Editor/DanmakuAssets.cs | 200 +++++---- .../Editor/DanmakuFieldEditor.cs | 211 +++++++++ .../DanmakuFieldEditor.cs.meta} | 6 +- .../Editor/FieldMovementPatternEditor.cs | 1 + .../Editor/ProjectileManagerEditor.cs | 53 ++- .../Editor/ProjectilePrefabEditor.cs | 46 +- .../DanmakuUnity2D/FieldBoundary.cs | 106 +++++ ...ntroller.cs.meta => FieldBoundary.cs.meta} | 6 +- .../DanmakuUnity2D/FieldMovementPattern.cs | 2 +- .../DanmakuUnity2D/Materials.meta | 2 +- .../Materials/BulletShader.shader | 2 +- .../DanmakuUnity2D/Phantasmagoria.meta | 2 +- .../Phantasmagoria/BulletTransferArea.cs | 2 +- .../DanmakuUnity2D/Phantasmagoria/GUI.meta | 2 +- .../Phantasmagoria/GUI/ChargeBarGUI.cs | 2 +- .../Phantasmagoria/PhantasmagoriaEnemy.cs | 2 +- .../Phantasmagoria/PhantasmagoriaField.cs | 40 -- .../PhantasmagoriaGameController.cs | 35 +- .../ProjectileTransferBoundary.cs | 6 +- .../DanmakuUnity2D/ProjectileEmitter.cs | 29 ++ ...ller.cs.meta => ProjectileEmitter.cs.meta} | 6 +- Assets/External Libraries/UnityUtilLib.meta | 2 +- .../UnityUtilLib/Editor.meta | 2 +- .../UnityUtilLib/Editor/Doxygen.meta | 2 +- .../Editor/Doxygen/Resources.meta | 2 +- .../Editor/Doxygen/Resources/DarkTheme.meta | 2 +- .../Editor/Doxygen/Resources/LightTheme.meta | 2 +- .../UnityUtilLib/Editor/EditorUtil.cs | 143 ------ .../Editor/FixedScreenAreaCameraEditor.cs | 2 - .../Editor/MeshRendererSortingLayerEditor.cs | 92 ++++ .../MeshRendererSortingLayerEditor.cs.meta | 12 + .../UnityUtilLib/Editor/UnhideAllObjects.cs | 1 + .../UnityUtilLib/EditorUtil.cs | 177 ++++++++ .../{Editor => }/EditorUtil.cs.meta | 4 +- .../UnityUtilLib/FixedScreenAreaCamera.cs | 2 +- .../External Libraries/UnityUtilLib/GUI.meta | 2 +- .../UnityUtilLib/GUI/FPSCounter.cs | 37 +- .../UnityUtilLib/Interface.meta | 2 +- .../UnityUtilLib/Managers.meta | 2 +- .../UnityUtilLib/Managers/GameController.cs | 38 ++ .../UnityUtilLib/Microfunctionality.meta | 2 +- .../UnityUtilLib/Pooling.meta | 2 +- .../UnityUtilLib/Singleton.cs | 1 + .../UnityUtilLib/UtilExtensionMethods.cs | 14 + .../UnityUtilLib/UtilGizmos.cs | 9 + .../UnityUtilLib/UtilGizmos.cs.meta | 12 + 78 files changed, 1420 insertions(+), 767 deletions(-) create mode 100644 Assets/Demo.meta create mode 100644 Assets/Demo/Phantasmagoria Demo.meta create mode 100644 Assets/Demo/Standard Demo.meta delete mode 100644 Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/IProjectileGroupController.cs delete mode 100644 Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ProjectileController.cs create mode 100644 Assets/External Libraries/DanmakuUnity2D/Editor/DanmakuFieldEditor.cs rename Assets/External Libraries/DanmakuUnity2D/{Phantasmagoria/PhantasmagoriaField.cs.meta => Editor/DanmakuFieldEditor.cs.meta} (52%) create mode 100644 Assets/External Libraries/DanmakuUnity2D/FieldBoundary.cs rename Assets/External Libraries/DanmakuUnity2D/{Controllers/Projectile Cotnrollers/IProjectileGroupController.cs.meta => FieldBoundary.cs.meta} (52%) delete mode 100644 Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaField.cs create mode 100644 Assets/External Libraries/DanmakuUnity2D/ProjectileEmitter.cs rename Assets/External Libraries/DanmakuUnity2D/{Controllers/Projectile Cotnrollers/ProjectileController.cs.meta => ProjectileEmitter.cs.meta} (52%) delete mode 100644 Assets/External Libraries/UnityUtilLib/Editor/EditorUtil.cs create mode 100644 Assets/External Libraries/UnityUtilLib/Editor/MeshRendererSortingLayerEditor.cs create mode 100644 Assets/External Libraries/UnityUtilLib/Editor/MeshRendererSortingLayerEditor.cs.meta create mode 100644 Assets/External Libraries/UnityUtilLib/EditorUtil.cs rename Assets/External Libraries/UnityUtilLib/{Editor => }/EditorUtil.cs.meta (76%) create mode 100644 Assets/External Libraries/UnityUtilLib/UtilGizmos.cs create mode 100644 Assets/External Libraries/UnityUtilLib/UtilGizmos.cs.meta diff --git a/Assets/Demo.meta b/Assets/Demo.meta new file mode 100644 index 00000000..15387422 --- /dev/null +++ b/Assets/Demo.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: acdbd32f2ffbd1f4c91f7a49feb1c7e1 +folderAsset: yes +timeCreated: 1426702176 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Demo/Phantasmagoria Demo.meta b/Assets/Demo/Phantasmagoria Demo.meta new file mode 100644 index 00000000..eebf5dd9 --- /dev/null +++ b/Assets/Demo/Phantasmagoria Demo.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b266ad9eba5f371479eea47cfb5a3c28 +folderAsset: yes +timeCreated: 1426702191 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Demo/Standard Demo.meta b/Assets/Demo/Standard Demo.meta new file mode 100644 index 00000000..b00a4856 --- /dev/null +++ b/Assets/Demo/Standard Demo.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: bca3983a1c6ca0b46b440bcc1d0370c0 +folderAsset: yes +timeCreated: 1426702182 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External Libraries.meta b/Assets/External Libraries.meta index ca36dbf2..afecb45c 100644 --- a/Assets/External Libraries.meta +++ b/Assets/External Libraries.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 3ff7dc67737bcbe4493bccb3b07dcc25 folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/DanmakuUnity2D.meta b/Assets/External Libraries/DanmakuUnity2D.meta index 04fca992..7883e742 100644 --- a/Assets/External Libraries/DanmakuUnity2D.meta +++ b/Assets/External Libraries/DanmakuUnity2D.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: d67c7618ed1e35d4798efbd2df519e76 folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/DanmakuUnity2D/Attack Patterns.meta b/Assets/External Libraries/DanmakuUnity2D/Attack Patterns.meta index 13934d2d..de86b76e 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Attack Patterns.meta +++ b/Assets/External Libraries/DanmakuUnity2D/Attack Patterns.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 0fbd30016b6c30d419ef6ecfae52b3ba folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/Burst.cs b/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/Burst.cs index bde6e9a2..8dc1d6e1 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/Burst.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/Burst.cs @@ -28,7 +28,7 @@ public abstract class Burst : AttackPattern { /// An overridable factory method for subclasses to control the various /// /// The controller to be used with the bullets fired with this attack pattern - protected abstract IProjectileGroupController BurstController { + protected abstract IProjectileController BurstController { get; } diff --git a/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/ControlledBurst.cs b/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/ControlledBurst.cs index 1c81ae8d..433aa7d9 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/ControlledBurst.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/ControlledBurst.cs @@ -18,7 +18,7 @@ public class ControlledBurst : Burst { #region implemented abstract members of Burst - protected override IProjectileGroupController BurstController { + protected override IProjectileController BurstController { get { // if(controller is ControllerWrapperBehavior) { // return (controller as ControllerWrapperBehavior).Controller; diff --git a/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/CurvedBurst.cs b/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/CurvedBurst.cs index dd547062..7d05221d 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/CurvedBurst.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/CurvedBurst.cs @@ -17,7 +17,7 @@ public class CurvedBurst : Burst { #region implemented abstract members of Burst - protected override IProjectileGroupController BurstController { + protected override IProjectileController BurstController { get { return CurvedController; } diff --git a/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/LinearBurst.cs b/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/LinearBurst.cs index c8a5e161..cb4b6761 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/LinearBurst.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Attack Patterns/LinearBurst.cs @@ -18,7 +18,7 @@ public class LinearBurst : Burst { #region implemented abstract members of Burst - protected override IProjectileGroupController BurstController { + protected override IProjectileController BurstController { get { return LinearController; } diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers.meta b/Assets/External Libraries/DanmakuUnity2D/Controllers.meta index 18615926..5250fdd2 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers.meta +++ b/Assets/External Libraries/DanmakuUnity2D/Controllers.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 36c7286cac9cb7648a99e19902fa7472 folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers/PlayerControllers.meta b/Assets/External Libraries/DanmakuUnity2D/Controllers/PlayerControllers.meta index bb829e55..b7083199 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers/PlayerControllers.meta +++ b/Assets/External Libraries/DanmakuUnity2D/Controllers/PlayerControllers.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 5f6a95d957e09934bb7942c31903469f folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers/PlayerControllers/Player Hitboxes.meta b/Assets/External Libraries/DanmakuUnity2D/Controllers/PlayerControllers/Player Hitboxes.meta index 508cd620..51fa704a 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers/PlayerControllers/Player Hitboxes.meta +++ b/Assets/External Libraries/DanmakuUnity2D/Controllers/PlayerControllers/Player Hitboxes.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: b8e03f49b83b0434bbb40f7092686870 folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers.meta b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers.meta index 3d22f8cc..4fe7191a 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers.meta +++ b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 531d1843896cf4e4b8dad31f377066b3 folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/AggregateProjectileController.cs b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/AggregateProjectileController.cs index ec54aa5b..58a864c4 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/AggregateProjectileController.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/AggregateProjectileController.cs @@ -3,7 +3,7 @@ namespace Danmaku2D.ProjectileControllers { - public class AggregateProjectileController : ProjectileController, ICollection { + public class AggregateProjectileController : IProjectileController, ICollection { private List children; @@ -11,13 +11,14 @@ public AggregateProjectileController(params IProjectileController[] children) { this.children = new List (children); } - #region implemented abstract members of ProjectileController - public override void UpdateProjectile (float dt) { + #region IProjectileController implementation + + public void UpdateProjectile (Projectile projectile, float dt) { for(int i = 0; i < children.Count; i++) { - children[i].Projectile = Projectile; - children[i].UpdateProjectile(dt); + children[i].UpdateProjectile(projectile, dt); } } + #endregion #region ICollection implementation diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/AnimationCurveControl.cs b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/AnimationCurveControl.cs index bd622abc..047aad0c 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/AnimationCurveControl.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/AnimationCurveControl.cs @@ -15,25 +15,12 @@ protected override AnimationCurveController CreateController () { } [System.Serializable] - public class AnimationCurveController : ProjectileController, IProjectileGroupController { + public class AnimationCurveController : IProjectileController { [SerializeField] private AnimationCurve velocityCurve; - #region implemented abstract members of ProjectileController - - public sealed override void UpdateProjectile (float dt) { - UpdateProjectile (Projectile, dt); - } - - #endregion - - #region IProjectileGroupController implementation - - public ProjectileGroup ProjectileGroup { - get; - set; - } + #region IProjectileController implementation public virtual void UpdateProjectile (Projectile projectile, float dt) { // if(acceleration != 0) { diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ControllerWrapperBehavior.cs b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ControllerWrapperBehavior.cs index bb11b262..f2ee8637 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ControllerWrapperBehavior.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ControllerWrapperBehavior.cs @@ -10,9 +10,9 @@ namespace Danmaku2D.ProjectileControllers { /// An abstract generic superclass to mirror the functionality of any implementor of IPorjectileGroupController in a ProjectileControlBehavior. /// It can be used with other ProjectileControlBehavior implementations; however it is best used with IProjectileGroupController implementations that don't derive from ProjectileControlBehavior. /// - public abstract class ControllerWrapperBehavior : ProjectileControlBehavior where T : IProjectileGroupController { + public abstract class ControllerWrapperBehavior : ProjectileControlBehavior where T : IProjectileController { - private T controller; + private T projectileController; /// /// Gets the underlying IProjectileGroupController. @@ -20,15 +20,15 @@ public abstract class ControllerWrapperBehavior : ProjectileControlBehavior w /// The underlying controller. public T Controller { get { - return controller; + return projectileController; } } public override void Awake () { base.Awake (); - if (controller == null) { - controller = CreateController (); - if (controller == null) { + if (projectileController == null) { + projectileController = CreateController (); + if (projectileController == null) { throw new System.NotImplementedException(GetType().ToString() + " does not implement CreateController() properly"); } } @@ -43,7 +43,7 @@ public override void Awake () { #region implemented abstract members of ProjectileControlBehavior public sealed override void UpdateProjectile (Projectile projectile, float dt) { - controller.UpdateProjectile(projectile, dt); + projectileController.UpdateProjectile(projectile, dt); } #endregion diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/IProjectileController.cs b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/IProjectileController.cs index 008d4e54..7fdabc77 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/IProjectileController.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/IProjectileController.cs @@ -12,18 +12,12 @@ namespace Danmaku2D { /// public interface IProjectileController { - /// - /// Gets or sets the projectile controlled by this controller. - /// - /// The projectile controlled by this controller - Projectile Projectile { get; set; } - /// /// Updates the Projectile controlled by the controller instance. /// /// the displacement from the Projectile's original position after udpating /// the change in time since the last update - void UpdateProjectile (float dt); + void UpdateProjectile (Projectile projectile, float dt); } } \ No newline at end of file diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/IProjectileGroupController.cs b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/IProjectileGroupController.cs deleted file mode 100644 index be788583..00000000 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/IProjectileGroupController.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using UnityEngine; - -namespace Danmaku2D { - - public interface IProjectileGroupController { - - /// - /// Gets or sets the ProjectileGroup controlled by this - /// - /// The projectile group. - ProjectileGroup ProjectileGroup { get; set; } - void UpdateProjectile (Projectile projectile, float dt); - } -} - diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/LinearProjectileControl.cs b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/LinearProjectileControl.cs index 635247b7..9f7a0175 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/LinearProjectileControl.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/LinearProjectileControl.cs @@ -25,7 +25,7 @@ namespace Danmaku2D { /// A ProjectileController or ProjectileGroupController for creating bullets that move along a straight path. /// [System.Serializable] - public class LinearProjectile : ProjectileController, IProjectileGroupController { + public class LinearProjectile : IProjectileController { [SerializeField] private float velocity = 5; @@ -75,19 +75,6 @@ public void SetAcceleration(float accel, float cap) { #region IProjectileController implementation - public sealed override void UpdateProjectile (float dt) { - UpdateProjectile (Projectile, dt); - } - - #endregion - - #region IProjectileGroupController implementation - - public ProjectileGroup ProjectileGroup { - get; - set; - } - public virtual void UpdateProjectile (Projectile projectile, float dt) { // if(acceleration != 0) { // float accelSign = Util.Sign(acceleration); diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ProjectileControlBehavior.cs b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ProjectileControlBehavior.cs index a137fba3..aee7a220 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ProjectileControlBehavior.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ProjectileControlBehavior.cs @@ -3,7 +3,7 @@ namespace Danmaku2D { - public abstract class ProjectileControlBehavior : MonoBehaviour, IProjectileGroupController { + public abstract class ProjectileControlBehavior : MonoBehaviour, IProjectileController { private SpriteRenderer spriteRenderer; public SpriteRenderer SpriteRenderer { @@ -32,8 +32,12 @@ public virtual void Awake() { ProjectileGroup = new ProjectileGroup (); ProjectileGroup.Controller = this; } - - public abstract void UpdateProjectile(Projectile projectile, float dt); + + #region IProjectileController implementation + + public abstract void UpdateProjectile (Projectile projectile, float dt); + + #endregion } } diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ProjectileController.cs b/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ProjectileController.cs deleted file mode 100644 index 9f97e969..00000000 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ProjectileController.cs +++ /dev/null @@ -1,136 +0,0 @@ -using UnityEngine; -using System; -using System.Collections.Generic; - -/// -/// A development kit for quick development of 2D Danmaku games -/// -namespace Danmaku2D { - - /// - /// An abstract class implementation of IProjectileController. - /// - public abstract class ProjectileController : IProjectileController { - #region IProjectileController implementation - - /// - /// Updates the Projectile controlled by the controller instance. - /// - /// the displacement from the Projectile's original position after udpating - /// the change in time since the last update - public abstract void UpdateProjectile (float dt); - - /// - /// Gets or sets the projectile controlled by this controller. - /// - /// The projectile controlled by this controller - public Projectile Projectile { - get; - set; - } - - #endregion - - /// - /// Gets or sets the damage of the Projecitle controlled by this controller. - /// See . - /// - /// The damage of the Projectile - public int Damage { - get { - return Projectile.Damage; - } - set { - Projectile.Damage = value; - } - } - - /// - /// Gets the sprite of the Projectile controlled by this controller. - /// See . - /// - /// The sprite of the Projectile controlled by this controller. - public Sprite Sprite { - get { - return Projectile.Sprite; - } - } - - /// - /// Gets or sets the color of the Projectile controlled by this controller. - /// See . - /// - /// The color of the Projectile controlled by this contorller. - public Color Color { - get { - return Projectile.Color; - } - set { - Projectile.Color = value; - } - } - - /// - /// Gets or sets the absolute world coordinate of the position of where the Projectile contorlled by this controller is. - /// See . - /// - /// The absolute world coordinate of the position of where the Projectile contorlled by this controller is. - public Vector2 Position { - get { - return Projectile.Position; - } - set { - Projectile.Position = value; - } - } - - /// - /// Gets or sets the rotation of the Projectile controlled by this controller in degrees. - /// See . - /// - /// The rotation of the Projectile controlled by this controller in degrees./value> - public float Rotation { - get { - return Projectile.Rotation; - } - set { - Projectile.Rotation = value; - } - } - - /// - /// Gets the direction that Projectile controlled by this controller is moving in. - /// See . - /// - /// The direction that Projectile controlled by this controller is moving in. - public Vector2 Direction { - get { - return Projectile.Direction; - } - } - - /// - /// Gets the time since the Projectile controlled by this controller was fired. - /// See . - /// - /// The time since the Projectile controlled by this controller was fired. - public float Time { - get { - return Projectile.Time; - } - } - - /// - /// Gets the number of frames that have passed since the Projectile controlled by this controller was fired. - /// See . - /// - /// The number of frames that have passed since the Projectile controlled by this controller was fired. - public int Frames { - get { - return Projectile.Frames; - } - } - - - } -} \ No newline at end of file diff --git a/Assets/External Libraries/DanmakuUnity2D/Core.meta b/Assets/External Libraries/DanmakuUnity2D/Core.meta index feed4821..bbde57f7 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Core.meta +++ b/Assets/External Libraries/DanmakuUnity2D/Core.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: ad54ef5f6134f724a82991258f39074a folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/DanmakuUnity2D/Core/AttackPattern.cs b/Assets/External Libraries/DanmakuUnity2D/Core/AttackPattern.cs index a25a7150..658c5b6a 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Core/AttackPattern.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Core/AttackPattern.cs @@ -91,32 +91,32 @@ private IEnumerator Execute() { /// Helper method for subclasses to quickly spawn projectiles. /// /// The projectile spawned with the given parameters - /// The defining characteristics behind this projectile + /// The defining characteristics behind this projectile /// The location the bullet is to be spawned at. Expected value varies with the provided CoordinateSystem /// The rotation the bullet is to be spawned with. /// The Coordinate system the location is to be spawned using - protected Projectile SpawnProjectile(ProjectilePrefab bulletType, + protected Projectile SpawnProjectile(ProjectilePrefab projectileType, Vector2 location, float rotation, DanmakuField.CoordinateSystem coordSys = DanmakuField.CoordinateSystem.View) { - return TargetField.SpawnProjectile (bulletType, location, rotation, coordSys); + return TargetField.SpawnProjectile (projectileType, location, rotation, coordSys); } /// /// Helper method for subclasses to quickly firing straight moving bullets. /// /// The projectile spawned with the given parameters - /// The defining characteristics behind this projectile + /// The defining characteristics behind this projectile /// The location the bullet is to be fired from. Expected value varies with the provided CoordinateSystem /// The rotation the bullet is to be fired with. /// The Coordinate system the location is to be spawned using - protected LinearProjectile FireLinearBullet(ProjectilePrefab bulletType, + protected LinearProjectile FireLinearBullet(ProjectilePrefab projectileType, Vector2 location, float rotation, float velocity, DanmakuField.CoordinateSystem coordSys = DanmakuField.CoordinateSystem.View) { LinearProjectile linearProjectile = new LinearProjectile (velocity); - Projectile bullet = ProjectileManager.Get (bulletType); + Projectile bullet = ProjectileManager.Get (projectileType); bullet.PositionImmediate = TargetField.WorldPoint(location, coordSys); bullet.Rotation = rotation; bullet.Field = TargetField; @@ -129,18 +129,18 @@ protected LinearProjectile FireLinearBullet(ProjectilePrefab bulletType, /// Helper method for subclasses to quickly firing bullet that move along curved paths. /// /// The projectile spawned with the given parameters - /// The defining characteristics behind this projectile + /// The defining characteristics behind this projectile /// The location the bullet is to be fired from. Expected value varies with the provided CoordinateSystem /// The rotation the bullet is to be fired with. /// The Coordinate system the location is to be spawned using - protected CurvedProjectile FireCurvedBullet(ProjectilePrefab bulletType, + protected CurvedProjectile FireCurvedBullet(ProjectilePrefab projectileType, Vector2 location, float rotation, float velocity, float angularVelocity, DanmakuField.CoordinateSystem coordSys = DanmakuField.CoordinateSystem.View) { CurvedProjectile curvedProjectile = new CurvedProjectile (velocity, angularVelocity); - Projectile bullet = ProjectileManager.Get (bulletType); + Projectile bullet = ProjectileManager.Get (projectileType); bullet.PositionImmediate = TargetField.WorldPoint(location, coordSys); bullet.Rotation = rotation; bullet.Field = TargetField; @@ -153,16 +153,16 @@ protected CurvedProjectile FireCurvedBullet(ProjectilePrefab bulletType, /// Helper method for subclasses to quickly firing bullets with custom behavior. /// /// The projectile spawned with the given parameters - /// The defining characteristics behind this projectile + /// The defining characteristics behind this projectile /// The location the bullet is to be fired from. Expected value varies with the provided CoordinateSystem /// The rotation the bullet is to be fired with. /// The Coordinate system the location is to be spawned using - protected void FireControlledBullet(ProjectilePrefab bulletType, + protected void FireControlledBullet(ProjectilePrefab projectileType, Vector2 location, float rotation, IProjectileController controller, DanmakuField.CoordinateSystem coordSys = DanmakuField.CoordinateSystem.View) { - Projectile bullet = ProjectileManager.Get (bulletType); + Projectile bullet = ProjectileManager.Get (projectileType); bullet.PositionImmediate = TargetField.WorldPoint(location, coordSys); bullet.Rotation = rotation; bullet.Field = TargetField; diff --git a/Assets/External Libraries/DanmakuUnity2D/Core/DanmakuField.cs b/Assets/External Libraries/DanmakuUnity2D/Core/DanmakuField.cs index 96fbe43b..9482aa66 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Core/DanmakuField.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Core/DanmakuField.cs @@ -1,49 +1,125 @@ using UnityEngine; using UnityUtilLib; +using System.Collections.Generic; +#if UNITY_EDITOR +using UnityEditor; +#endif /// /// A development kit for quick development of 2D Danmaku games /// namespace Danmaku2D { - public abstract class DanmakuField : PausableGameObject { + [ExecuteInEditMode] + [DisallowMultipleComponent] + public sealed class DanmakuField : MonoBehaviour { + + internal static List fields; public enum CoordinateSystem { View, Relative, World } + + public float ClipBoundary = 1f; + + public float GamePlaneDistance = 10f; + + [SerializeField] + private float camera2DRotation = 0f; + + [SerializeField] + private Transform cameraTransform2D; + + [SerializeField] + private float size; + + [SerializeField] + private bool fixedCameraArea; + + [SerializeField] + private float cameraScreenAnchorPoint = 0.5f; + + [SerializeField] + private float nativeScreenAspectRatio = 4f/3f; + + [SerializeField] + private Rect nativeScreenBounds; + [SerializeField] private Vector2 playerSpawnLocation = new Vector2(0.5f, 0.25f); - public abstract DanmakuField TargetField { get; } + [SerializeField] + private Camera camera2D; + + [SerializeField] + private Camera camera3D; + + [System.NonSerialized] + public DanmakuField TargetField; private DanmakuPlayer player; + private float currentAspectRatio; + private float screenOffset; + private Bounds bounds; + private Bounds movementBounds; + private Vector2 x, y, z, scale, bottomLeft; + + [SerializeField] + private Rect viewportRect = new Rect(0f, 0f, 1f, 1f); + + [SerializeField] + private LayerMask cullingMask; + + [SerializeField] + private float depth; + + [SerializeField] + private RenderingPath renderingPath; + + [SerializeField] + private RenderTexture renderTexture; + + [SerializeField] + private bool occlusionCulling; + + [SerializeField] + private bool hdr; + + public float Camera2DRotation { + get { + return camera2DRotation; + } + set { + cameraTransform2D.localRotation = Quaternion.Euler(0f, 0f, value); + camera2DRotation = value; + } + } public DanmakuPlayer Player { get { return player; } } - [SerializeField] - private Camera fieldCamera; - - private Transform cameraTransform2D; - public Transform CameraTransform2D { + public Bounds Bounds { get { - return cameraTransform2D; + return bounds; + } + } + + public Bounds MovementBounds { + get { + return movementBounds; } } public void RecomputeWorldPoints() { - Vector3 UL, BR; - bottomLeft = fieldCamera.ViewportToWorldPoint (new Vector3(0f, 0f, gamePlaneDistance)); - UL = fieldCamera.ViewportToWorldPoint (Vector3.up); - BR = fieldCamera.ViewportToWorldPoint (Vector3.right); + Vector2 UL, BR; + bottomLeft = camera2D.ViewportToWorldPoint (new Vector3(0f, 0f, 0f)); + UL = camera2D.ViewportToWorldPoint (Vector2.up); + BR = camera2D.ViewportToWorldPoint (Vector2.right); x = (BR - bottomLeft); y = (UL - bottomLeft); - z = transform.forward * gamePlaneDistance; - scale = new Vector3 (x.magnitude, y.magnitude, gamePlaneDistance); + scale = new Vector2 (x.magnitude, y.magnitude); } - - private Vector3 x, y, z, scale, bottomLeft; public float XSize { get { return scale.x; } @@ -53,58 +129,174 @@ public float YSize { get { return scale.y; } } - public Vector3 BottomLeft { - get { return WorldPoint (new Vector3(0f, 0f, 0f)); } + public Vector2 BottomLeft { + get { return WorldPoint (new Vector2(0f, 0f)); } } - public Vector3 BottomRight { - get { return WorldPoint (new Vector3(1f, 0f, 0f)); } + public Vector2 BottomRight { + get { return WorldPoint (new Vector2(1f, 0f)); } } - public Vector3 TopLeft { - get { return WorldPoint (new Vector3(0f, 1f, 0f)); } + public Vector2 TopLeft { + get { return WorldPoint (new Vector2(0f, 1f)); } } - public Vector3 TopRight { - get { return WorldPoint (new Vector3(1f, 1f, 0f)); } + public Vector2 TopRight { + get { return WorldPoint (new Vector2(1f, 1f)); } } - public Vector3 Center { - get { return WorldPoint (new Vector3(0.5f, 0.5f, 0f)); } + public Vector2 Center { + get { return WorldPoint (new Vector2(0.5f, 0.5f)); } } - public Vector3 Top { - get { return WorldPoint (new Vector3 (0.5f, 1f, 0f)); } + public Vector2 Top { + get { return WorldPoint (new Vector2 (0.5f, 1f)); } } - public Vector3 Bottom { - get { return WorldPoint (new Vector3 (0.5f, 0f, 0f));} + public Vector2 Bottom { + get { return WorldPoint (new Vector2 (0.5f, 0f));} } - public Vector3 Right { - get { return WorldPoint (new Vector3 (1f, 0.5f, 0f)); } + public Vector2 Right { + get { return WorldPoint (new Vector2 (1f, 0.5f)); } } - public Vector3 Left { - get { return WorldPoint (new Vector3 (0f, 0.5f, 0f));} + public Vector2 Left { + get { return WorldPoint (new Vector2 (0f, 0.5f));} } - public override void Awake () { - base.Awake (); - fieldCamera.orthographic = true; - cameraTransform2D = fieldCamera.transform; + void Awake () { + if (fields == null) { + fields = new List(); + } + fields.Add (this); + TargetField = this; + CameraSetup (); + + #if UNITY_EDITOR + EditorApplication.playmodeStateChanged += PlayStateModeChange; + #endif + RecomputeWorldPoints (); + + screenOffset = nativeScreenBounds.x + 0.5f * nativeScreenBounds.width - cameraScreenAnchorPoint; + + #if UNITY_EDITOR + if(!Application.isEditor) { + #endif + if(fixedCameraArea) { + currentAspectRatio = (float)Screen.width / (float)Screen.height; + Resize (); + } + #if UNITY_EDITOR + } + #endif } - [SerializeField] - private float gamePlaneDistance = 10; - public float GamePlaneDistance { - get { - return gamePlaneDistance; + #if UNITY_EDITOR + + void PlayStateModeChange() { + if(!EditorApplication.isPlaying){ + camera2D.rect = viewportRect; + //camera2D.cullingMask = cullingMask; + camera2D.depth = depth; + camera2D.renderingPath = renderingPath; + camera2D.targetTexture = renderTexture; + camera2D.useOcclusionCulling = occlusionCulling; + camera2D.hdr = hdr; + } + } + + #endif + + void Start() { + CameraSetup (); + } + + private void Resize() { + float changeRatio = nativeScreenAspectRatio / currentAspectRatio; + float targetWidth = changeRatio * nativeScreenBounds.width; + float center = cameraScreenAnchorPoint + changeRatio * screenOffset; + Rect cameraRect = camera2D.rect; + cameraRect.x = center - targetWidth / 2; + cameraRect.width = targetWidth; + camera2D.rect = cameraRect; + } + + private void CameraSetup() { + if (camera2D == null) { + Debug.Log("Camera is null"); + GameObject camObj = gameObject.FindChild("Field Camera"); + if(camObj == null) { + camObj = new GameObject ("Field Camera"); + } + cameraTransform2D = camObj.transform; + camera2D = camObj.GetComponent(); + if(camera2D == null){ + camera2D = camObj.AddComponent(); + } + camObj.hideFlags = HideFlags.HideInHierarchy; } + camera2D.orthographic = true; + cameraTransform2D.parent = transform; + cameraTransform2D.position = transform.position + Vector3.back * GamePlaneDistance; + cameraTransform2D.LookAt ((Vector2)transform.position); + camera2D.clearFlags = CameraClearFlags.Depth; + //camera2D.cullingMask = cullingMask; + camera2D.depth = depth; + camera2D.renderingPath = renderingPath; + camera2D.targetTexture = renderTexture; + camera2D.useOcclusionCulling = occlusionCulling; + camera2D.hdr = hdr; } - public Vector3 WorldPoint(Vector3 point, CoordinateSystem coordSys = CoordinateSystem.View) { + void Update() { + Vector3 camPos = cameraTransform2D.position; + camPos.z = -GamePlaneDistance; + cameraTransform2D.position = camPos; + cameraTransform2D.rotation = Quaternion.Euler ((camPos.z > 0) ? 180f : 0f, 0f, camera2DRotation); + camera2D.clearFlags = CameraClearFlags.Depth; + camera2D.nearClipPlane = 0f; + camera2D.farClipPlane = Mathf.Abs(camPos.z * 2); + if (camera3D != null) { + camera3D.rect = camera2D.rect; + } + movementBounds.center = bounds.center = (Vector2)transform.position; + float size = camera2D.orthographicSize; + movementBounds.extents = new Vector2 (camera2D.aspect * size, size); + bounds.extents = movementBounds.extents + (Vector3)(Vector2.one * ClipBoundary * Util.MaxComponent2 (movementBounds.extents)); + #if UNITY_EDITOR + if(Application.isPlaying) { + #endif + if(fixedCameraArea) { + float newAspectRatio = (float)Screen.width / (float)Screen.height; + if (currentAspectRatio != newAspectRatio) { + currentAspectRatio = newAspectRatio; + Resize (); + } + } + #if UNITY_EDITOR + } + #endif + } + + void OnDestroy() { + if (fields != null) { + fields.Remove(this); + } + #if UNITY_EDITOR + EditorApplication.playmodeStateChanged -= PlayStateModeChange; + if(Application.isEditor) { + DestroyImmediate (camera2D.gameObject); + } else { + Destroy (camera2D.gameObject); + } + #else + Destroy(camera2D.gameObject); + #endif + } + + public Vector2 WorldPoint(Vector2 point, CoordinateSystem coordSys = CoordinateSystem.View) { switch (coordSys) { case CoordinateSystem.World: return point; @@ -112,11 +304,11 @@ public Vector3 WorldPoint(Vector3 point, CoordinateSystem coordSys = CoordinateS return bottomLeft + point; default: case CoordinateSystem.View: - return bottomLeft + point.x * x + point.y * y + point.z * z; + return bottomLeft + point.x * x + point.y * y; } } - public Vector3 RelativePoint(Vector3 point, CoordinateSystem coordSys = CoordinateSystem.View) { + public Vector2 RelativePoint(Vector2 point, CoordinateSystem coordSys = CoordinateSystem.View) { switch (coordSys) { case CoordinateSystem.World: return point - bottomLeft; @@ -124,24 +316,22 @@ public Vector3 RelativePoint(Vector3 point, CoordinateSystem coordSys = Coordina return point; default: case CoordinateSystem.View: - return point.x * x + point.y * y + point.z * z; + return point.x * x + point.y * y; } } - public Vector3 ViewPoint(Vector3 point, CoordinateSystem coordSys = CoordinateSystem.World) { + public Vector2 ViewPoint(Vector2 point, CoordinateSystem coordSys = CoordinateSystem.World) { switch (coordSys) { default: case CoordinateSystem.World: - Vector3 offset = point - bottomLeft; - return new Vector3( + Vector2 offset = point - bottomLeft; + return new Vector2( Vector3.Project (offset, x).magnitude / scale.x, - Vector3.Project (offset, y).magnitude / scale.y, - Vector3.Project (offset, z).magnitude / scale.z); + Vector3.Project (offset, y).magnitude / scale.y); case CoordinateSystem.Relative: - return new Vector3( + return new Vector2( Vector3.Project (point, x).magnitude / scale.x, - Vector3.Project (point, y).magnitude / scale.y, - Vector3.Project (point, z).magnitude / scale.z); + Vector3.Project (point, y).magnitude / scale.y); case CoordinateSystem.View: return point; } @@ -157,7 +347,7 @@ public float AngleTowardPlayer(Vector2 startLocation, CoordinateSystem coordinat /// Character prefab, defines character behavior and attack patterns. /// Controller for the player, allows for a user to manually control it or let an AI take over. public DanmakuPlayer SpawnPlayer(DanmakuPlayer playerCharacter, CoordinateSystem coordSys = CoordinateSystem.View) { - Vector3 spawnPos = WorldPoint((Vector3)playerSpawnLocation, coordSys); + Vector2 spawnPos = WorldPoint((Vector2)playerSpawnLocation, coordSys); player = (DanmakuPlayer) Instantiate(playerCharacter, spawnPos, Quaternion.identity); if(player != null) { player.Reset (5); @@ -185,36 +375,43 @@ public Projectile SpawnProjectile(ProjectilePrefab bulletType, Vector2 location, bullet.Activate (); return bullet; } + + public void SpawnEnemy(Enemy prefab, Vector2 location, CoordinateSystem coordSys = CoordinateSystem.View) { + Enemy enemy = (Enemy)Instantiate(prefab); + Transform transform = enemy.transform; + transform.position = WorldPoint((Vector2)location, coordSys); + enemy.Field = this; + } - public LinearProjectile FireLinearProjectile(ProjectilePrefab bulletType, + public FireData FireLinearProjectile(ProjectilePrefab bulletType, Vector2 location, float rotation, float velocity, CoordinateSystem coordSys = CoordinateSystem.View) { - LinearProjectile linearProjectile = new LinearProjectile (velocity); - Projectile bullet = ProjectileManager.Get (bulletType); - bullet.PositionImmediate = WorldPoint(location, coordSys); - bullet.Rotation = rotation; - bullet.Field = this; - bullet.Activate (); - bullet.Controller = linearProjectile; - return linearProjectile; + LinearProjectile controller = new LinearProjectile (velocity); + Projectile projectile = ProjectileManager.Get (bulletType); + projectile.PositionImmediate = WorldPoint(location, coordSys); + projectile.Rotation = rotation; + projectile.Field = this; + projectile.Activate (); + projectile.Controller = controller; + return new FireData(projectile, controller); } - public CurvedProjectile FireCurvedProjectile(ProjectilePrefab bulletType, + public FireData FireCurvedProjectile(ProjectilePrefab bulletType, Vector2 location, float rotation, float velocity, float angularVelocity, CoordinateSystem coordSys = CoordinateSystem.View) { - CurvedProjectile curvedProjectile = new CurvedProjectile (velocity, angularVelocity); - Projectile bullet = ProjectileManager.Get (bulletType); - bullet.PositionImmediate = WorldPoint(location, coordSys); - bullet.Rotation = rotation; - bullet.Field = this; - bullet.Activate (); - bullet.Controller = curvedProjectile; - return curvedProjectile; + CurvedProjectile controller = new CurvedProjectile (velocity, angularVelocity); + Projectile projectile = ProjectileManager.Get (bulletType); + projectile.PositionImmediate = WorldPoint(location, coordSys); + projectile.Rotation = rotation; + projectile.Field = this; + projectile.Activate (); + projectile.Controller = controller; + return new FireData(projectile, controller); } public void FireControlledProjectile(ProjectilePrefab bulletType, @@ -222,19 +419,58 @@ public void FireControlledProjectile(ProjectilePrefab bulletType, float rotation, IProjectileController controller, CoordinateSystem coordSys = CoordinateSystem.View) { - Projectile bullet = ProjectileManager.Get (bulletType); - bullet.PositionImmediate = WorldPoint(location, coordSys); - bullet.Rotation = rotation; - bullet.Field = this; - bullet.Activate (); - bullet.Controller = controller; + Projectile projectile = ProjectileManager.Get (bulletType); + projectile.PositionImmediate = WorldPoint(location, coordSys); + projectile.Rotation = rotation; + projectile.Field = this; + projectile.Activate (); + projectile.Controller = controller; } - public void SpawnEnemy(Enemy prefab, Vector2 location, CoordinateSystem coordSys = CoordinateSystem.View) { - Enemy enemy = (Enemy)Instantiate(prefab); - Transform transform = enemy.transform; - transform.position = WorldPoint((Vector3)location, coordSys); - enemy.Field = this; + public delegate IProjectileController BurstController(int depth); + + public void SpawnBurst(ProjectilePrefab bulletType, + Vector2 location, + float direction, + float range, + int count, + ProjectileGroup group = null, + int depth = 1, + BurstController burstController = null, + CoordinateSystem coordSys = CoordinateSystem.View) { + bool haveGroup = group != null; + bool haveController = burstController != null; + count = Mathf.Abs (count); + depth = Mathf.Abs (depth); + range = Mathf.Abs (range); + Vector2 position = WorldPoint (location, coordSys); + float start = direction - range * 0.5f; + float end = direction + range * 0.5f; + float delta = range / count; + for (int j = 0; j < depth; j++) { + IProjectileController controller = (haveController) ? burstController(j) : null; + for (float rotation = start; rotation <= end; rotation += delta) { + Projectile bullet = ProjectileManager.Get (bulletType); + bullet.PositionImmediate = position; + bullet.Rotation = rotation; + bullet.Field = this; + bullet.Controller = controller; + bullet.Activate (); + if (haveGroup) { + group.Add (bullet); + } + } + } + } + } + + public struct FireData where T : IProjectileController { + public Projectile Projectile; + public T Controller; + + public FireData(Projectile projectile, T controller) { + Projectile = projectile; + Controller = controller; } } -} +} \ No newline at end of file diff --git a/Assets/External Libraries/DanmakuUnity2D/Core/DanmakuField.cs.meta b/Assets/External Libraries/DanmakuUnity2D/Core/DanmakuField.cs.meta index ae2dc9a5..1a344c36 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Core/DanmakuField.cs.meta +++ b/Assets/External Libraries/DanmakuUnity2D/Core/DanmakuField.cs.meta @@ -1,8 +1,12 @@ fileFormatVersion: 2 guid: d76c239fde6757549963073cca304778 +timeCreated: 1426642188 +licenseType: Free MonoImporter: serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -29000 icon: {instanceID: 0} userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External Libraries/DanmakuUnity2D/Core/Projectile.cs b/Assets/External Libraries/DanmakuUnity2D/Core/Projectile.cs index 79953fe5..56313c23 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Core/Projectile.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Core/Projectile.cs @@ -76,9 +76,6 @@ public IProjectileController Controller { set { controller = value; controllerCheck = controller != null; - if(controllerCheck) { - controller.Projectile = this; - } } } @@ -240,12 +237,12 @@ internal void Update(float dt) { originalPosition = Position; if (controllerCheck) { - controller.UpdateProjectile (dt); + controller.UpdateProjectile (this, dt); } if(groupCheck) { for(int i = 0; i < groupCountCache; i++) { - IProjectileGroupController groupController = groups[i].controller; + IProjectileController groupController = groups[i].Controller; if(groupController != null) groupController.UpdateProjectile(this, dt); } diff --git a/Assets/External Libraries/DanmakuUnity2D/Core/ProjectileGroup.cs b/Assets/External Libraries/DanmakuUnity2D/Core/ProjectileGroup.cs index be53a018..e18f80e6 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Core/ProjectileGroup.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Core/ProjectileGroup.cs @@ -4,20 +4,12 @@ using UnityEngine; namespace Danmaku2D { - public class ProjectileGroup : ICollection { + + public sealed class ProjectileGroup : ICollection { internal HashSet group; - internal IProjectileGroupController controller; - public IProjectileGroupController Controller { - get { - return controller; - } - set { - controller = value; - controller.ProjectileGroup = this; - } - } + public IProjectileController Controller; public ProjectileGroup() { group = new HashSet (); diff --git a/Assets/External Libraries/DanmakuUnity2D/Core/ProjectileManager.cs b/Assets/External Libraries/DanmakuUnity2D/Core/ProjectileManager.cs index d5a32df2..c680a6a4 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Core/ProjectileManager.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Core/ProjectileManager.cs @@ -86,6 +86,9 @@ public void Return (object obj) { [SerializeField] private int spawnOnEmpty = 100; + + [SerializeField] + private LayerMask defaultCollisionMask = ((LayerMask)~0); public override void Awake () { base.Awake (); @@ -93,6 +96,7 @@ public override void Awake () { } public void Start () { + Debug.Log (((int)defaultCollisionMask).ToString ("X8")); if(projectilePool == null) { projectilePool = new ProjectilePool (initialCount, spawnOnEmpty); } @@ -118,10 +122,22 @@ public void Update() { public void NormalUpdate () { float dt = Util.TargetDeltaTime; int totalCount = projectilePool.totalCount; + DanmakuField[] fields = DanmakuField.fields.ToArray (); + int fieldCount = fields.Length; for (int i = 0; i < totalCount; i++) { Projectile proj = projectilePool.all[i]; if(proj.is_active) { proj.Update(dt); + bool check = true; + for(int j = 0; j < fieldCount; j++) { + if(fields[j].Bounds.Contains(proj.Position)) { + check = false; + break; + } + } + if(check) { + proj.DeactivateImmediate(); + } } } } diff --git a/Assets/External Libraries/DanmakuUnity2D/Core/ProjectilePrefab.cs b/Assets/External Libraries/DanmakuUnity2D/Core/ProjectilePrefab.cs index 43b889bf..06eda44e 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Core/ProjectilePrefab.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Core/ProjectilePrefab.cs @@ -12,11 +12,14 @@ namespace Danmaku2D { [RequireComponent(typeof(SpriteRenderer))] public sealed class ProjectilePrefab : CachedObject { + [HideInInspector] [SerializeField] private CircleCollider2D circleCollider; + + [HideInInspector] [SerializeField] private SpriteRenderer spriteRenderer; - [SerializeField] + private ProjectileControlBehavior[] extraControllers; private ProjectilePrefab runtime; @@ -33,19 +36,19 @@ public sealed class ProjectilePrefab : CachedObject { private Material cachedMaterial; private int cachedSortingLayer; - public Vector3 Scale { + internal Vector3 Scale { get { return cachedScale; } } - public string Tag { + internal string Tag { get { return cachedTag; } } - public int Layer { + internal int Layer { get { return cachedLayer; } @@ -55,7 +58,7 @@ public int Layer { /// Gets the radius of the ProjectilePrefab instance's collider /// /// the radius of the collider. - public float ColliderRadius { + internal float ColliderRadius { get { return cachedColliderRadius; } @@ -65,7 +68,7 @@ public float ColliderRadius { /// Gets the offset of the ProjectilePrefab instance's collider from it's position /// /// the offset of the collider. - public Vector2 ColliderOffset { + internal Vector2 ColliderOffset { get { return cachedColliderOffset; } @@ -75,7 +78,7 @@ public Vector2 ColliderOffset { /// Gets the sprite of the ProjectilePrefab instance to be rendered /// /// The sprite to be rendered. - public Sprite Sprite { + internal Sprite Sprite { get { return cachedSprite; } @@ -85,7 +88,7 @@ public Sprite Sprite { /// Gets the color of the ProjectilePrefab instance to be rendered /// /// The color to be rendered with. - public Color Color { + internal Color Color { get { return cachedColor; } @@ -95,7 +98,7 @@ public Color Color { /// Gets the material of the ProjectilePrefab instance to be rendered /// /// The material to be rendered with. - public Material Material { + internal Material Material { get { return cachedMaterial; } @@ -105,13 +108,13 @@ public Material Material { /// Gets the sorting layer to be used when rendering these bullets /// /// The sorting layer to be used when rendering. - public int SortingLayerID { + internal int SortingLayerID { get { return cachedSortingLayer; } } - public ProjectileControlBehavior[] ExtraControllers { + internal ProjectileControlBehavior[] ExtraControllers { get { return extraControllers; } @@ -122,17 +125,16 @@ public override void Awake() { if (circleCollider == null) { circleCollider = GetComponent(); if(circleCollider == null) { - throw new System.InvalidOperationException("ProjectilePrefab without a Collider"); + throw new System.InvalidOperationException("ProjectilePrefab without a Collider! (" + name + ")"); } } if (spriteRenderer == null) { spriteRenderer = GetComponent(); if(spriteRenderer == null) { - throw new System.InvalidOperationException("ProjectilePrefab without a SpriteRenderer"); + throw new System.InvalidOperationException("ProjectilePrefab without a SpriteRenderer (" + name + ")"); } } - if(extraControllers == null) - extraControllers = GetComponents(); + extraControllers = GetComponents(); cachedScale = transform.localScale; cachedTag = gameObject.tag; cachedLayer = gameObject.layer; diff --git a/Assets/External Libraries/DanmakuUnity2D/Editor.meta b/Assets/External Libraries/DanmakuUnity2D/Editor.meta index 86875a49..ba88b7b0 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Editor.meta +++ b/Assets/External Libraries/DanmakuUnity2D/Editor.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 65f6caea4d0249f47992d1ec7ad8bd0c folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/DanmakuUnity2D/Editor/AtomicMovementDrawer.cs b/Assets/External Libraries/DanmakuUnity2D/Editor/AtomicMovementDrawer.cs index 04cbe91d..f0008dc7 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Editor/AtomicMovementDrawer.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Editor/AtomicMovementDrawer.cs @@ -2,51 +2,46 @@ using UnityEditor; using System; using System.Collections; +using Danmaku2D; /// -/// Custom editor scripts for various components of the Danmaku2D development kit +/// Custom PropertyDrawer for FieldMovementPattern.AtomicMovement /// -namespace Danmaku2D.Editor { +[CustomPropertyDrawer(typeof(FieldMovementPattern.AtomicMovement))] +internal class AtomicMovementDrawer : PropertyDrawer { + + float individualHeight = 17f; /// - /// Custom PropertyDrawer for FieldMovementPattern.AtomicMovement + /// Gets the height of the property in the Inspector. /// - [CustomPropertyDrawer(typeof(FieldMovementPattern.AtomicMovement))] - internal class AtomicMovementDrawer : PropertyDrawer { - - float individualHeight = 17f; - - /// - /// Gets the height of the property in the Inspector. - /// - /// The height in pixels. - /// The SerializedProperty to make the custom GUI for. - /// The label of this property - public override float GetPropertyHeight (SerializedProperty property, GUIContent label) { - return 4 * individualHeight; - } + /// The height in pixels. + /// The SerializedProperty to make the custom GUI for. + /// The label of this property + public override float GetPropertyHeight (SerializedProperty property, GUIContent label) { + return 4 * individualHeight; + } - /// - /// Creates the custom GUI an instance of FieldMovementPattern.AtomicMovement - /// - /// the rectangle on the screen to use for the property GUI. - /// The SerializedProperty to make the custom GUI for. - /// The label of this property - public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUI.BeginProperty(position, label, property); - Rect timeRect = new Rect (position.x, position.y, position.width, individualHeight); - Rect targetLocationRect = new Rect (position.x, position.y + 1 * individualHeight, position.width, individualHeight); - SerializedProperty tl = property.FindPropertyRelative ("targetLocation"); - SerializedProperty t = property.FindPropertyRelative ("time"); - EditorGUI.PropertyField (timeRect, t); - EditorGUI.PropertyField (targetLocationRect, tl); - SerializedProperty c1 = property.FindPropertyRelative ("curveControlPoint1"); - SerializedProperty c2 = property.FindPropertyRelative ("curveControlPoint2"); - Rect point1Rect = new Rect (position.x, position.y + 2 * individualHeight, position.width, individualHeight); - Rect point2Rect = new Rect (position.x, position.y + 3 * individualHeight, position.width, individualHeight); - EditorGUI.PropertyField(point1Rect, c1); - EditorGUI.PropertyField(point2Rect, c2); - EditorGUI.EndProperty(); - } + /// + /// Creates the custom GUI an instance of FieldMovementPattern.AtomicMovement + /// + /// the rectangle on the screen to use for the property GUI. + /// The SerializedProperty to make the custom GUI for. + /// The label of this property + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { + EditorGUI.BeginProperty(position, label, property); + Rect timeRect = new Rect (position.x, position.y, position.width, individualHeight); + Rect targetLocationRect = new Rect (position.x, position.y + 1 * individualHeight, position.width, individualHeight); + SerializedProperty tl = property.FindPropertyRelative ("targetLocation"); + SerializedProperty t = property.FindPropertyRelative ("time"); + EditorGUI.PropertyField (timeRect, t); + EditorGUI.PropertyField (targetLocationRect, tl); + SerializedProperty c1 = property.FindPropertyRelative ("curveControlPoint1"); + SerializedProperty c2 = property.FindPropertyRelative ("curveControlPoint2"); + Rect point1Rect = new Rect (position.x, position.y + 2 * individualHeight, position.width, individualHeight); + Rect point2Rect = new Rect (position.x, position.y + 3 * individualHeight, position.width, individualHeight); + EditorGUI.PropertyField(point1Rect, c1); + EditorGUI.PropertyField(point2Rect, c2); + EditorGUI.EndProperty(); } } \ No newline at end of file diff --git a/Assets/External Libraries/DanmakuUnity2D/Editor/DanmakuAssets.cs b/Assets/External Libraries/DanmakuUnity2D/Editor/DanmakuAssets.cs index ea28dee6..f4c97206 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Editor/DanmakuAssets.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Editor/DanmakuAssets.cs @@ -1,107 +1,123 @@ using UnityEngine; using UnityEditor; using UnityUtilLib; +using Danmaku2D; using Danmaku2D.Phantasmagoria; using System.IO; /// -/// Custom editor scripts for various components of the Danmaku2D development kit +/// A static class full of editor shortcuts for faster development /// -namespace Danmaku2D.Editor { +internal static class DanmakuAssets { - /// - /// A static class full of editor shortcuts for faster development - /// - internal static class DanmakuAssets { - - /// - /// Creates a blank ProjectilePrefab asset - /// Found under Assets/Create/Danmaku 2D/Projectile Prefab - /// - [MenuItem("Assets/Create/Danmaku 2D/Projectile Prefab", false, 51)] - public static void AddProjectilePrefab() { - GameObject temp = new GameObject ("Projectile Prefab"); - temp.AddComponent (); - temp.AddComponent (); - temp.AddComponent (); - ProjectWindowUtil.CreatePrefab (); - PrefabUtility.CreatePrefab ("Assets/Projectile Prefab.prefab", temp); - Object.DestroyImmediate (temp); + private static string GetProjectWindowFolder() { + UnityEngine.Object activeObject = Selection.activeObject; + string path = ""; + if (activeObject == null) + return "Assets"; // Nothing selected + else + path = AssetDatabase.GetAssetPath (activeObject); + if (path.Length > 0) { + if (Directory.Exists (path)) { + return path; // path is a folder + } else { + Debug.Log(path); + Debug.Log(Directory.GetParent(path).FullName); + return Directory.GetParent(path).FullName; + } } + return ""; //path in Assets folder + } - /// - /// Creates the base of a full Phantasmagoria game with a single click - /// Found under GameObject/Create/Danmaku 2D/Phantasmagoria/Game Gamecontroller - /// - [MenuItem("GameObject/Create/Danmaku 2D/Phantasmagoria/Game Controller")] - public static void CreatePhantasmagoriaGame() { - GameObject temp = new GameObject ("Game Controller"); - temp.AddComponent (); - PhantasmagoriaGameController pcg = temp.AddComponent (); - PhantasmagoriaField playerField1 = CreatePhantasmagoriaField (); - PhantasmagoriaField playerField2 = CreatePhantasmagoriaField (); - playerField1.gameObject.name = "Player 1 " + playerField1.gameObject.name; - playerField2.gameObject.name = "Player 2 " + playerField2.gameObject.name; - SerializedObject pcgS = new SerializedObject (pcg); - pcgS.FindProperty ("player1.field").objectReferenceValue = playerField1; - pcgS.FindProperty ("player2.field").objectReferenceValue = playerField2; - pcgS.ApplyModifiedProperties (); - playerField1.transform.position = new Vector3 (-100f, 0f, 0f); - playerField2.transform.position = new Vector3 (100f, 0f, 0f); - temp.AddComponent (); - temp.AddComponent (); - temp.AddComponent(); - temp.AddComponent (); - } + /// + /// Creates a blank ProjectilePrefab asset + /// Found under Assets/Create/Danmaku 2D/Projectile Prefab + /// + [MenuItem("Assets/Create/Danmaku 2D/Projectile Prefab", false, 51)] + public static void AddProjectilePrefab() { + GameObject temp = new GameObject ("Projectile Prefab"); + temp.AddComponent (); + string pathName = GetProjectWindowFolder (); + GameObject prefab = PrefabUtility.CreatePrefab (pathName + "/Projectile Prefab.prefab", temp); + Object.DestroyImmediate (temp); + SerializedObject so = new SerializedObject (prefab.GetComponent ()); + so.FindProperty ("circleCollider").objectReferenceValue = prefab.GetComponent (); + so.FindProperty ("spriteRenderer").objectReferenceValue = prefab.GetComponent (); + so.ApplyModifiedProperties (); + } - /// - /// Creates a PhantasmagoriaField with a single click - /// Found under GameObject/Create/Danmaku 2D/Phantasmagoria/Field - /// - /// The phantasmagoria field created. - [MenuItem("GameObject/Create/Danmaku 2D/Phantasmagoria/Field")] - public static PhantasmagoriaField CreatePhantasmagoriaField() { - GameObject temp = new GameObject ("Field"); - PhantasmagoriaField field = temp.AddComponent (); - GameObject background = GameObject.CreatePrimitive (PrimitiveType.Quad); - background.name = "Background"; - background.transform.parent = field.transform; - background.transform.localPosition = new Vector3 (0f, 0f, field.GamePlaneDistance); - Object.DestroyImmediate(background.GetComponent ()); - background.transform.localScale = new Vector3 (48.125f, 48.125f, 1f); - GameObject cam = new GameObject ("Camera"); - cam.transform.parent = temp.transform; - cam.transform.localScale = new Vector3 (0f, 0f, -field.GamePlaneDistance); - Camera camera = cam.AddComponent (); - SerializedObject camS = new SerializedObject (field); - camS.FindProperty ("fieldCamera").objectReferenceValue = camera; - camS.ApplyModifiedProperties (); - camera.orthographic = true; - camera.orthographicSize = 20; - camera.farClipPlane = 2 * field.GamePlaneDistance; - return field; - } + /// + /// Creates the base of a full Phantasmagoria game with a single click + /// Found under GameObject/Create/Danmaku 2D/Phantasmagoria/Game Gamecontroller + /// + [MenuItem("GameObject/Create/Danmaku 2D/Phantasmagoria/Game Controller")] + public static void CreatePhantasmagoriaGame() { + GameObject temp = new GameObject ("Game Controller"); + temp.AddComponent (); + PhantasmagoriaGameController pcg = temp.AddComponent (); + DanmakuField playerField1 = CreateDanmakuField (); + DanmakuField playerField2 = CreateDanmakuField (); + playerField1.gameObject.name = "Player 1 " + playerField1.gameObject.name; + playerField2.gameObject.name = "Player 2 " + playerField2.gameObject.name; + SerializedObject pcgS = new SerializedObject (pcg); + pcgS.FindProperty ("player1.field").objectReferenceValue = playerField1; + pcgS.FindProperty ("player2.field").objectReferenceValue = playerField2; + pcgS.ApplyModifiedProperties (); + playerField1.transform.position = new Vector3 (-100f, 0f, 0f); + playerField2.transform.position = new Vector3 (100f, 0f, 0f); + temp.AddComponent (); + temp.AddComponent (); + temp.AddComponent(); + temp.AddComponent (); + } - // [MenuItem("Assets/Create/Danmaku 2D/Custom Attack Pattern")] - // public static void CreateAttackPattern() { - // string text = "using UnityEngine;\nusing System.Collections;\nusing Danmaku2D;\n" + - // "\npublic class NewAttackPattern : AttackPattern {\n" + - // "\t//Used to determine when the attack pattern is finished and can terminate" + - // "\n\tprotected override bool IsFinished {\n" + - // "\t\tget {\n" + - // "\t\t\treturn false;\n" + - // "\t\t}\n" + - // "\t}\n" + - // "\n\t//The main loop of the attack pattern, executed every frame" + - // "\tprotected override void MainLoop() {\n" + - // "\n\n\t}\n" + - // "}"; - // CreateScript (text, "NewAttackPattern"); - // } - // - // private static void CreateScript(string scriptText, string name) { - // File.WriteAllText (Application.dataPath + "/ " + name + ".cs", scriptText); - // AssetDatabase.ImportAsset ("Assets/" + name + ".cs"); - // } + /// + /// Creates a PhantasmagoriaField with a single click + /// Found under GameObject/Create/Danmaku 2D/Phantasmagoria/Field + /// + /// The phantasmagoria field created. + [MenuItem("GameObject/Create/Danmaku 2D/Danmaku Field")] + public static DanmakuField CreateDanmakuField() { + GameObject temp = new GameObject ("Field"); + DanmakuField field = temp.AddComponent (); + GameObject background = GameObject.CreatePrimitive (PrimitiveType.Quad); + background.name = "Background"; + background.transform.parent = field.transform; + background.transform.localPosition = new Vector3 (0f, 0f, 10f); + Object.DestroyImmediate(background.GetComponent ()); + background.transform.localScale = new Vector3 (48.125f, 48.125f, 1f); + GameObject cam = new GameObject ("Camera"); + cam.transform.parent = temp.transform; + cam.transform.localScale = new Vector3 (0f, 0f, -10f); + Camera camera = cam.AddComponent (); + SerializedObject camS = new SerializedObject (field); + camS.FindProperty ("fieldCamera").objectReferenceValue = camera; + camS.ApplyModifiedProperties (); + camera.orthographic = true; + camera.orthographicSize = 20; + camera.farClipPlane = 25; + return field; } + +// [MenuItem("Assets/Create/Danmaku 2D/Custom Attack Pattern")] +// public static void CreateAttackPattern() { +// string text = "using UnityEngine;\nusing System.Collections;\nusing Danmaku2D;\n" + +// "\npublic class NewAttackPattern : AttackPattern {\n" + +// "\t//Used to determine when the attack pattern is finished and can terminate" + +// "\n\tprotected override bool IsFinished {\n" + +// "\t\tget {\n" + +// "\t\t\treturn false;\n" + +// "\t\t}\n" + +// "\t}\n" + +// "\n\t//The main loop of the attack pattern, executed every frame" + +// "\tprotected override void MainLoop() {\n" + +// "\n\n\t}\n" + +// "}"; +// CreateScript (text, "NewAttackPattern"); +// } +// +// private static void CreateScript(string scriptText, string name) { +// File.WriteAllText (Application.dataPath + "/ " + name + ".cs", scriptText); +// AssetDatabase.ImportAsset ("Assets/" + name + ".cs"); +// } } diff --git a/Assets/External Libraries/DanmakuUnity2D/Editor/DanmakuFieldEditor.cs b/Assets/External Libraries/DanmakuUnity2D/Editor/DanmakuFieldEditor.cs new file mode 100644 index 00000000..61a883bf --- /dev/null +++ b/Assets/External Libraries/DanmakuUnity2D/Editor/DanmakuFieldEditor.cs @@ -0,0 +1,211 @@ +using UnityEngine; +using UnityEditor; +using System.Collections.Generic; +using Danmaku2D; +using UnityUtilLib; + +namespace Danmaku2D.Editor { + + [CustomEditor(typeof(DanmakuField))] + internal class DanmakuFieldEditor : UnityEditor.Editor { + + private DanmakuField field; + + private SerializedProperty clipBoundary; + private SerializedProperty playerSpawnLocation; + private SerializedProperty gamePlaneDistance; + private SerializedProperty camera3D; + private SerializedProperty camera2D; + private SerializedProperty cameraTransform2D; + + private SerializedProperty camera2Drotation; + + private SerializedProperty size; + private SerializedProperty viewportRect; + //private SerializedProperty cullingMask; + private SerializedProperty depth; + private SerializedProperty renderingPath; + private SerializedProperty renderTexture; + private SerializedProperty occlusionCulling; + private SerializedProperty hdr; + + private SerializedProperty c_size; + private SerializedProperty c_viewportRect; + private SerializedProperty c_cullingMask; + private SerializedProperty c_depth; + private SerializedProperty c_renderingPath; + private SerializedProperty c_renderTexture; + private SerializedProperty c_occlusionCulling; + private SerializedProperty c_hdr; + + private SerializedProperty fixedCameraArea; + private SerializedProperty anchorPoint; + private SerializedProperty nativeAspect; + private SerializedProperty nativeScreenBounds; + + private SerializedObject cameraSO; + + private GUIContent camera3DLabel; + private GUIContent sizeLabel; + private GUIContent cullingMaskLabel; + private GUIContent viewportLabel; + private GUIContent depthLabel; + private GUIContent renderingPathLabel; + private GUIContent renderTextureLabel; + private GUIContent occlusionCullingLabel; + private GUIContent hdrLabel; + + private GUIContent rotationLabel; + + private Camera camera2Dobj; + + public void OnEnable() { + field = target as DanmakuField; + + clipBoundary = serializedObject.FindProperty ("ClipBoundary"); + playerSpawnLocation = serializedObject.FindProperty ("playerSpawnLocation"); + gamePlaneDistance = serializedObject.FindProperty ("GamePlaneDistance"); + camera3D = serializedObject.FindProperty ("camera3D"); + camera2D = serializedObject.FindProperty ("camera2D"); + cameraTransform2D = serializedObject.FindProperty ("cameraTransform2D"); + + camera2Drotation = serializedObject.FindProperty ("camera2DRotation"); + + viewportRect = serializedObject.FindProperty ("normalArea"); + + fixedCameraArea = serializedObject.FindProperty("fixedCameraArea"); + anchorPoint = serializedObject.FindProperty("cameraScreenAnchorPoint"); + nativeAspect = serializedObject.FindProperty("nativeScreenAspectRatio"); + nativeScreenBounds = serializedObject.FindProperty("nativeScreenBounds"); + + size = serializedObject.FindProperty ("size"); + viewportRect = serializedObject.FindProperty ("viewportRect"); + //cullingMask = serializedObject.FindProperty ("cullingMask"); + depth = serializedObject.FindProperty ("depth"); + renderingPath = serializedObject.FindProperty("renderingPath"); + renderTexture = serializedObject.FindProperty ("renderTexture"); + occlusionCulling = serializedObject.FindProperty("occlusionCulling"); + hdr = serializedObject.FindProperty("hdr"); + + camera3DLabel = new GUIContent ("3D Camera"); + sizeLabel = new GUIContent ("size"); + cullingMaskLabel = new GUIContent ("Culling Mask"); + viewportLabel = new GUIContent ("Viewport Rect"); + depthLabel = new GUIContent("Depth"); + renderingPathLabel = new GUIContent ("Rendering Path"); + renderTextureLabel = new GUIContent ("Target Texture"); + occlusionCullingLabel = new GUIContent ("Occlusion Culling"); + hdrLabel = new GUIContent ("HDR"); + + rotationLabel = new GUIContent ("Rotation"); + + SetupCamera (); + } + + private void SetupCamera() { + camera2Dobj = camera2D.objectReferenceValue as Camera; + if (camera2Dobj == null) { + cameraSO = null; + cameraTransform2D.objectReferenceValue = null; + } else { + cameraSO = new SerializedObject (camera2Dobj); + cameraTransform2D.objectReferenceValue = camera2Dobj.transform; + c_size = cameraSO.FindProperty ("orthographic size"); + c_cullingMask = cameraSO.FindProperty ("m_CullingMask"); + c_viewportRect = cameraSO.FindProperty ("m_NormalizedViewPortRect"); + c_depth = cameraSO.FindProperty ("m_Depth"); + c_renderingPath= cameraSO.FindProperty ("m_RenderingPath"); + c_renderTexture = cameraSO.FindProperty ("m_TargetTexture"); + c_occlusionCulling = cameraSO.FindProperty ("m_OcclusionCulling"); + c_hdr = cameraSO.FindProperty ("m_HDR"); + } + } + + public override bool RequiresConstantRepaint () { + return true; + } + + public override void OnInspectorGUI () { + serializedObject.Update (); + EditorGUILayout.PropertyField (clipBoundary); + EditorGUILayout.PropertyField (playerSpawnLocation); + EditorGUILayout.PropertyField (gamePlaneDistance); + EditorGUILayout.PropertyField (camera3D, camera3DLabel); + +// if(camera2Dobj != null) { +// camera2Dobj.orthographicSize = size.floatValue; +// camera2Dobj.cullingMask = cullingMask.intValue; +// camera2Dobj.rect = viewportRect.rectValue; +// camera2Dobj.depth = depth.floatValue; +// camera2Dobj.renderingPath = (RenderingPath)renderingPath.enumValueIndex; +// camera2Dobj.targetTexture = (RenderTexture)renderTexture.objectReferenceValue; +// camera2Dobj.useOcclusionCulling = occlusionCulling.boolValue; +// camera2Dobj.hdr = hdr.boolValue; +// } + + SetupCamera (); + + if (cameraSO != null) { + cameraSO.Update(); + EditorGUILayout.PropertyField (c_size, sizeLabel); + EditorGUILayout.LabelField ("2D Camera"); + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(camera2Drotation, rotationLabel); + EditorGUILayout.PropertyField (c_cullingMask, cullingMaskLabel); + EditorGUILayout.PropertyField (c_viewportRect, viewportLabel); + EditorGUILayout.PropertyField (c_depth, depthLabel); + EditorGUILayout.PropertyField (c_renderingPath, renderingPathLabel); + EditorGUILayout.PropertyField (c_renderTexture, renderTextureLabel); + EditorGUILayout.PropertyField (c_occlusionCulling, occlusionCullingLabel); + EditorGUILayout.PropertyField (c_hdr, hdrLabel); + + size.floatValue = c_size.floatValue; +// cullingMask.intValue = c_cullingMask.intValue; +// Debug.Log(cullingMask.intValue); +// Debug.Log(c_cullingMask.intValue); + viewportRect.rectValue = c_viewportRect.rectValue; + depth.floatValue = c_depth.floatValue; + renderingPath.enumValueIndex = c_renderingPath.enumValueIndex; + renderTexture.objectReferenceValue = c_renderTexture.objectReferenceValue; + occlusionCulling.boolValue = c_occlusionCulling.boolValue; + hdr.boolValue = c_hdr.boolValue; + + EditorGUILayout.PropertyField(fixedCameraArea); + if(fixedCameraArea.boolValue) { + EditorGUILayout.PropertyField(anchorPoint); + EditorGUILayout.PropertyField(nativeAspect); + EditorGUILayout.PropertyField(nativeScreenBounds); + if(GUILayout.Button("Reinitialize")) { + Vector2 screenSize = EditorUtil.GetGameViewAspectRatio(); + if(screenSize == Vector2.zero) { + Debug.LogWarning("Warning: Game View in Free Aspect. Native Aspect Ratio is improperly initialized. Try again with a fixed aspect ratio."); + } + nativeAspect.floatValue = screenSize.x / screenSize.y; + nativeScreenBounds.rectValue = camera2Dobj.rect; + } + } + EditorGUI.indentLevel--; + } + if (UnityEngine.GUI.changed) { + cameraSO.ApplyModifiedProperties(); + serializedObject.ApplyModifiedProperties (); + camera2Dobj.enabled = true; + field.enabled = true; + } + } + + [DrawGizmo(GizmoType.SelectedOrChild | GizmoType.NotSelected)] + internal static void DrawGizmos(DanmakuField field, GizmoType gizmoType) { + Gizmos.color = Color.yellow; + Gizmos.DrawWireCube (field.Bounds.center, field.Bounds.size); + Gizmos.color = Color.cyan; + Gizmos.DrawWireCube (field.MovementBounds.center, field.MovementBounds.size); + Vector3 newExtents = field.MovementBounds.size; + newExtents.z = 2 * field.GamePlaneDistance; + Gizmos.color = Color.white; + Vector3 camPos = field.MovementBounds.center; + Gizmos.matrix = Matrix4x4.TRS(camPos, Quaternion.Euler((camPos.z > 0) ? 180f : 0f, 0f, -field.Camera2DRotation), Vector3.one); + Gizmos.DrawWireCube(Vector3.zero, newExtents); + } + } +} \ No newline at end of file diff --git a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaField.cs.meta b/Assets/External Libraries/DanmakuUnity2D/Editor/DanmakuFieldEditor.cs.meta similarity index 52% rename from Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaField.cs.meta rename to Assets/External Libraries/DanmakuUnity2D/Editor/DanmakuFieldEditor.cs.meta index 004f1054..4f0ae850 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaField.cs.meta +++ b/Assets/External Libraries/DanmakuUnity2D/Editor/DanmakuFieldEditor.cs.meta @@ -1,8 +1,12 @@ fileFormatVersion: 2 -guid: f7b81252429a3004c825e2087f18c4a7 +guid: 1927904deafb5874994d90336135a925 +timeCreated: 1426731333 +licenseType: Free MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External Libraries/DanmakuUnity2D/Editor/FieldMovementPatternEditor.cs b/Assets/External Libraries/DanmakuUnity2D/Editor/FieldMovementPatternEditor.cs index f7c5e3e9..935add71 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Editor/FieldMovementPatternEditor.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Editor/FieldMovementPatternEditor.cs @@ -1,6 +1,7 @@ using UnityEngine; using UnityEditor; using UnityUtilLib; +using Danmaku2D; /// /// Custom editor scripts for various components of the Danmaku2D development kit diff --git a/Assets/External Libraries/DanmakuUnity2D/Editor/ProjectileManagerEditor.cs b/Assets/External Libraries/DanmakuUnity2D/Editor/ProjectileManagerEditor.cs index d64ef04a..be4f06cf 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Editor/ProjectileManagerEditor.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Editor/ProjectileManagerEditor.cs @@ -1,39 +1,34 @@ using UnityEngine; using UnityEditor; +using Danmaku2D; /// -/// Custom editor scripts for various components of the Danmaku2D development kit +/// Custom Editor for ProjectileManager /// -namespace Danmaku2D.Editor { +[CustomEditor(typeof(ProjectileManager))] +internal class ProjectileManagerEditor : UnityEditor.Editor { /// - /// Custom Editor for ProjectileManager + /// Creates custom GUI useful for statistics/debug on the Scene View + /// Shows how many active Projectiles and how many /// - [CustomEditor(typeof(ProjectileManager))] - internal class ProjectileManagerEditor : UnityEditor.Editor { - - /// - /// Creates custom GUI useful for statistics/debug on the Scene View - /// Shows how many active Projectiles and how many - /// - public void OnSceneGUI() { - ProjectileManager pool = target as ProjectileManager; - GUISkin skin = GUI.skin; - Handles.BeginGUI (); - GUILayout.BeginArea (new Rect(0,0,150,60), skin.box); - GUILayout.BeginVertical (); - GUILayout.BeginHorizontal (); - GUILayout.FlexibleSpace (); - GUILayout.Label ("Projectile Pool"); - GUILayout.FlexibleSpace (); - GUILayout.EndHorizontal(); - GUILayout.Label ("Total Count: " + pool.TotalCount); - GUILayout.Label ("Active Count: " + pool.ActiveCount); - GUILayout.EndVertical (); - GUILayout.EndArea (); - if(GUI.changed) - EditorUtility.SetDirty(target); - Handles.EndGUI (); - } + public void OnSceneGUI() { + ProjectileManager pool = target as ProjectileManager; + GUISkin skin = GUI.skin; + Handles.BeginGUI (); + GUILayout.BeginArea (new Rect(0,0,150,60), skin.box); + GUILayout.BeginVertical (); + GUILayout.BeginHorizontal (); + GUILayout.FlexibleSpace (); + GUILayout.Label ("Projectile Pool"); + GUILayout.FlexibleSpace (); + GUILayout.EndHorizontal(); + GUILayout.Label ("Total Count: " + pool.TotalCount); + GUILayout.Label ("Active Count: " + pool.ActiveCount); + GUILayout.EndVertical (); + GUILayout.EndArea (); + if(GUI.changed) + EditorUtility.SetDirty(target); + Handles.EndGUI (); } } \ No newline at end of file diff --git a/Assets/External Libraries/DanmakuUnity2D/Editor/ProjectilePrefabEditor.cs b/Assets/External Libraries/DanmakuUnity2D/Editor/ProjectilePrefabEditor.cs index ea497fe1..51888b37 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Editor/ProjectilePrefabEditor.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Editor/ProjectilePrefabEditor.cs @@ -1,37 +1,31 @@ using UnityEngine; using UnityEditor; +using Danmaku2D; /// -/// Custom editor scripts for various components of the Danmaku2D development kit +/// Custom Editor for ProjectilePrefab /// -namespace Danmaku2D.Editor { +[CustomEditor(typeof(ProjectilePrefab))] +internal class ProjectilePrefabEditor : UnityEditor.Editor { /// - /// Custom Editor for ProjectilePrefab + /// Creates the custom Inspector GUI for an instance of ProjectilePrefab. + /// Adds an extra button to quickly set all the values of the instance so that the user does not need to manually drag in each one. /// - [CustomEditor(typeof(ProjectilePrefab))] - internal class ProjectilePrefabEditor : UnityEditor.Editor { - - /// - /// Creates the custom Inspector GUI for an instance of ProjectilePrefab. - /// Adds an extra button to quickly set all the values of the instance so that the user does not need to manually drag in each one. - /// - public override void OnInspectorGUI () { - base.OnInspectorGUI (); - ProjectilePrefab prefab = target as ProjectilePrefab; - if(GUILayout.Button("Reinitialize")) { - SerializedProperty collider = serializedObject.FindProperty("circleCollider"); - SerializedProperty renderer = serializedObject.FindProperty("spriteRenderer"); - SerializedProperty controllers = serializedObject.FindProperty("extraControllers"); - collider.objectReferenceValue = prefab.GetComponent(); - renderer.objectReferenceValue = prefab.GetComponent(); - ProjectileControlBehavior[] controllerScripts = prefab.GetComponents(); - controllers.arraySize = controllerScripts.Length; - for(int i = 0; i < controllerScripts.Length; i++) { - controllers.GetArrayElementAtIndex(i).objectReferenceValue = controllerScripts[i]; - } - serializedObject.ApplyModifiedProperties(); - } + public override void OnInspectorGUI () { + base.OnInspectorGUI (); + ProjectilePrefab prefab = target as ProjectilePrefab; + if(GUILayout.Button("Reinitialize")) { + SerializedProperty collider = serializedObject.FindProperty("circleCollider"); + SerializedProperty renderer = serializedObject.FindProperty("spriteRenderer"); + collider.objectReferenceValue = prefab.GetComponent(); + renderer.objectReferenceValue = prefab.GetComponent(); +// ProjectileControlBehavior[] controllerScripts = prefab.GetComponents(); +// controllers.arraySize = controllerScripts.Length; +// for(int i = 0; i < controllerScripts.Length; i++) { +// controllers.GetArrayElementAtIndex(i).objectReferenceValue = controllerScripts[i]; +// } + serializedObject.ApplyModifiedProperties(); } } } \ No newline at end of file diff --git a/Assets/External Libraries/DanmakuUnity2D/FieldBoundary.cs b/Assets/External Libraries/DanmakuUnity2D/FieldBoundary.cs new file mode 100644 index 00000000..d7dab7a4 --- /dev/null +++ b/Assets/External Libraries/DanmakuUnity2D/FieldBoundary.cs @@ -0,0 +1,106 @@ +using System; +using UnityEngine; +using UnityUtilLib; + +namespace Danmaku2D { + + [ExecuteInEditMode] + public class FieldBoundary : CachedObject { + + private enum Edge { Top = 0, Bottom = 1, Left = 2, Right = 3} + + private static Vector2[] fixedPoints = new Vector2[] { + new Vector2 (0, 1f), + new Vector2 (0, -1f), + new Vector2 (-1f, 0f), + new Vector2 (1f, 0f) + }; + + [SerializeField] + private DanmakuField field; + + [SerializeField] + private Edge location; + + [SerializeField] + private float bufferRatio = 0.1f; + + [SerializeField] + private float hangoverRatio = 0f; + + [SerializeField] + private float spaceRatio = 0; + + private BoxCollider2D boundary; + private Bounds oldBounds; + private Bounds newBounds; + + public override void Awake () { + base.Awake (); + boundary = GetComponent (); + if (field == null) { + Debug.Log("No field provided, searching in ancestor GameObjects..."); + field = GetComponentInParent(); + } + if (field == null) { + Debug.LogError ("Field Boundary without a DanmakuField"); + } else { + UpdatePosition (); + } + } + + void Update () { + if (field != null && field.MovementBounds != oldBounds) { + UpdatePosition (); + } + } + + void OnDrawGizmos() { + Gizmos.color = Color.green; + Gizmos.DrawWireCube (boundary.bounds.center, boundary.bounds.size); + } + + private void UpdatePosition() { + oldBounds = field.MovementBounds; + + float size = Util.MaxComponent2 (oldBounds.size); + Vector2 newPosition = (Vector2)oldBounds.center + Util.HadamardProduct2(fixedPoints [(int)location], oldBounds.extents); + float buffer = bufferRatio * size; + float space = spaceRatio * size; + float hangover = hangoverRatio * size; + + Vector2 area = boundary.size; + switch(location) { + case Edge.Top: + case Edge.Bottom: + area.y = buffer; + area.x = oldBounds.size.x + hangover; + break; + case Edge.Left: + case Edge.Right: + area.x = buffer; + area.y = oldBounds.size.y + hangover; + break; + } + boundary.size = area; + + oldBounds = boundary.bounds; + switch(location) { + case Edge.Top: + newPosition.y += oldBounds.extents.y + space; + break; + case Edge.Bottom: + newPosition.y -= oldBounds.extents.y + space; + break; + case Edge.Left: + newPosition.x -= oldBounds.extents.x + space; + break; + case Edge.Right: + newPosition.x += oldBounds.extents.x + space; + break; + } + + transform.position = newPosition; + } + } +} \ No newline at end of file diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/IProjectileGroupController.cs.meta b/Assets/External Libraries/DanmakuUnity2D/FieldBoundary.cs.meta similarity index 52% rename from Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/IProjectileGroupController.cs.meta rename to Assets/External Libraries/DanmakuUnity2D/FieldBoundary.cs.meta index 484df821..7c55d0ce 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/IProjectileGroupController.cs.meta +++ b/Assets/External Libraries/DanmakuUnity2D/FieldBoundary.cs.meta @@ -1,8 +1,12 @@ fileFormatVersion: 2 -guid: 48b0c0f96b46b1e469f75788473ea0ff +guid: 35b973bd15e9f644da738535041ad0c3 +timeCreated: 1426901102 +licenseType: Free MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External Libraries/DanmakuUnity2D/FieldMovementPattern.cs b/Assets/External Libraries/DanmakuUnity2D/FieldMovementPattern.cs index d71fb431..0f6b2f92 100644 --- a/Assets/External Libraries/DanmakuUnity2D/FieldMovementPattern.cs +++ b/Assets/External Libraries/DanmakuUnity2D/FieldMovementPattern.cs @@ -45,7 +45,7 @@ public Vector3 NextControlPoint2(DanmakuField field, Vector3 startLocation) { private Vector3 Interpret(Vector2 loc, DanmakuField field, Vector3 startLocation) { Vector3 nextLocation = loc; - return startLocation + field.WorldPoint(nextLocation, DanmakuField.CoordinateSystem.Relative); + return startLocation + (Vector3)field.WorldPoint(nextLocation, DanmakuField.CoordinateSystem.Relative); } } diff --git a/Assets/External Libraries/DanmakuUnity2D/Materials.meta b/Assets/External Libraries/DanmakuUnity2D/Materials.meta index fb96ad6a..34c2f70b 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Materials.meta +++ b/Assets/External Libraries/DanmakuUnity2D/Materials.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: c6dbe02d60cf5dd40a9a26cdb9b56174 folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/DanmakuUnity2D/Materials/BulletShader.shader b/Assets/External Libraries/DanmakuUnity2D/Materials/BulletShader.shader index 397887d4..b702c474 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Materials/BulletShader.shader +++ b/Assets/External Libraries/DanmakuUnity2D/Materials/BulletShader.shader @@ -67,7 +67,7 @@ { fixed4 texColor = tex2D(_MainTex, IN.texcoord); fixed greyScale = (texColor.r + texColor.g + texColor.b) / 3; - fixed4 a = (1, 1, 1, texColor.a), b; + fixed4 a = (1, 1, 1, texColor.a * IN.color.a), b; if(greyScale >= 0.5) { b = lerp(IN.color, _UpperColor, (greyScale - 0.5) * 2); diff --git a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria.meta b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria.meta index c91797f7..9f813b6c 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria.meta +++ b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 9d0662f6d910813478af147c5ccf2f45 folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/BulletTransferArea.cs b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/BulletTransferArea.cs index ef30962c..7bd8adcb 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/BulletTransferArea.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/BulletTransferArea.cs @@ -9,7 +9,7 @@ namespace Danmaku2D.Phantasmagoria { [RequireComponent(typeof(Collider2D))] public class BulletTransferArea : PausableGameObject { - public void Run(float duration, float maxScale, PhantasmagoriaField origin) { + public void Run(float duration, float maxScale, DanmakuField origin) { ProjectileTransferBoundary ptb = GetComponent (); ptb.Field = origin; StartCoroutine (Execute (duration, maxScale)); diff --git a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/GUI.meta b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/GUI.meta index 23a89f11..f44e3ae2 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/GUI.meta +++ b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/GUI.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: c16b88c981971484f8c9d4c8130d68eb folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/GUI/ChargeBarGUI.cs b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/GUI/ChargeBarGUI.cs index 82ed5d63..de3c62ec 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/GUI/ChargeBarGUI.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/GUI/ChargeBarGUI.cs @@ -8,7 +8,7 @@ namespace Danmaku2D.Phantasmagoria.GUI { public class ChargeBarGUI : MonoBehaviour { [SerializeField] - private PhantasmagoriaField field; + private DanmakuField field; private PhantasmagoriaPlayableCharacter player; [SerializeField] diff --git a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaEnemy.cs b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaEnemy.cs index 97a9876e..9500810c 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaEnemy.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaEnemy.cs @@ -16,7 +16,7 @@ public class PhantasmagoriaEnemy : BasicEnemy { protected override void OnDeath () { BulletTransferArea transferArea = (BulletTransferArea)Instantiate (bulletTransferPrefab, transform.position, Quaternion.identity); - transferArea.Run (deathReflectDuration, deathReflectRadius, (PhantasmagoriaField)Field); + transferArea.Run (deathReflectDuration, deathReflectRadius, Field); } } } \ No newline at end of file diff --git a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaField.cs b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaField.cs deleted file mode 100644 index 7519350a..00000000 --- a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaField.cs +++ /dev/null @@ -1,40 +0,0 @@ -using UnityEngine; -using UnityUtilLib; -using System.Collections; -using System.Collections.Generic; - -namespace Danmaku2D.Phantasmagoria { - public class PhantasmagoriaField : DanmakuField { - - private DanmakuField targetField; - public override DanmakuField TargetField { - get { - return targetField; - } - } - - private int playerNumber = 1; - public int PlayerNumber { - get { - return playerNumber; - } - set { - playerNumber = value; - } - } - - public void Transfer(Projectile projectile) { - Vector2 relativePos = ViewPoint (transform.position); - projectile.Position = targetField.WorldPoint (relativePos); - } - - public void SetTargetField(DanmakuField field) { - targetField = field; - } - - public void RoundReset() { - Player.Reset (DanmakuGameController.MaximumLives); - CameraTransform2D.rotation = Quaternion.identity; - } - } -} \ No newline at end of file diff --git a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaGameController.cs b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaGameController.cs index 301f3ef8..9bb3e40e 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaGameController.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/PhantasmagoriaGameController.cs @@ -10,8 +10,8 @@ public class PhantasmagoriaGameController : DanmakuGameController { public class PlayerData { [SerializeField] - private PhantasmagoriaField field; - public PhantasmagoriaField Field { + private DanmakuField field; + public DanmakuField Field { get { return field; } @@ -63,15 +63,14 @@ public override void Awake() { base.Awake (); Physics2D.raycastsHitTriggers = true; if(player1.Field != null && player2.Field != null) { - player1.Field.SetTargetField(player2.Field); - player2.Field.SetTargetField(player1.Field); - player1.Field.PlayerNumber = 1; - player2.Field.PlayerNumber = 2; + player1.Field.TargetField = player2.Field; + player2.Field.TargetField = player1.Field; StartRound(); } } - void Update() { + public override void Update() { + base.Update (); if (!reseting && (player1.Field.Player.LivesRemaining <= 0 || player2.Field.Player.LivesRemaining <= 0)) { StartCoroutine(RoundReset ()); } @@ -91,6 +90,22 @@ public void StartRound() { guardianSummoned = false; } + private int playerNumber = 1; + public int PlayerNumber { + get { + return playerNumber; + } + set { + playerNumber = value; + } + } + + public static void Transfer(Projectile projectile) { + DanmakuField field = projectile.Field; + Vector2 relativePos = field.ViewPoint (projectile.Position); + projectile.Position = field.TargetField.WorldPoint (relativePos); + } + public IEnumerator RoundReset() { if(reseting) yield break; @@ -128,8 +143,10 @@ public IEnumerator RoundReset() { } else if(p2win) { //Declare Player 2 the winner } - player1.Field.RoundReset (); - player2.Field.RoundReset (); + player1.Field.Player.Reset (MaximumLives); + player2.Field.Player.Reset (MaximumLives); + player1.Field.Camera2DRotation = 0f; + player2.Field.Camera2DRotation = 0f; ProjectileManager.DeactivateAll (); Enemy[] allEnemies = FindObjectsOfType (); for(int i = 0; i < allEnemies.Length; i++) { diff --git a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/ProjectileTransferBoundary.cs b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/ProjectileTransferBoundary.cs index 5aa1c053..16ca243b 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/ProjectileTransferBoundary.cs +++ b/Assets/External Libraries/DanmakuUnity2D/Phantasmagoria/ProjectileTransferBoundary.cs @@ -5,8 +5,8 @@ namespace Danmaku2D.Phantasmagoria { public class ProjectileTransferBoundary : ProjectileBoundary { [SerializeField] - private PhantasmagoriaField field; - public PhantasmagoriaField Field { + private DanmakuField field; + public DanmakuField Field { get { return field; } @@ -17,7 +17,7 @@ public PhantasmagoriaField Field { protected override void ProcessProjectile (Projectile proj) { if (field != null) { - field.Transfer(proj); + PhantasmagoriaGameController.Transfer(proj); } } } diff --git a/Assets/External Libraries/DanmakuUnity2D/ProjectileEmitter.cs b/Assets/External Libraries/DanmakuUnity2D/ProjectileEmitter.cs new file mode 100644 index 00000000..29c201b9 --- /dev/null +++ b/Assets/External Libraries/DanmakuUnity2D/ProjectileEmitter.cs @@ -0,0 +1,29 @@ +using UnityEngine; +using UnityUtilLib; +using System.Collections; + +namespace Danmaku2D { + + public abstract class ProjectileEmitter : PausableGameObject { + + public DanmakuField field; + public ProjectilePrefab prefab; + + [SerializeField] + private FrameCounter delay; + + public override void NormalUpdate () { + if(delay.Tick() && prefab != null) { +// Fire(prefab, controller); + } + } + +// public abstract void FireSingle( +// +// public void FireSingle(ProjectilePrefab prefab, IProjectileCollider controller) { +// if (field != null) { +// field.FireControlledProjectile(prefab, transform.position, transform.rotation.eulerAngles.z, controller, DanmakuField.CoordinateSystem.World); +// } +// } + } +} \ No newline at end of file diff --git a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ProjectileController.cs.meta b/Assets/External Libraries/DanmakuUnity2D/ProjectileEmitter.cs.meta similarity index 52% rename from Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ProjectileController.cs.meta rename to Assets/External Libraries/DanmakuUnity2D/ProjectileEmitter.cs.meta index fde37384..e7248b9e 100644 --- a/Assets/External Libraries/DanmakuUnity2D/Controllers/Projectile Cotnrollers/ProjectileController.cs.meta +++ b/Assets/External Libraries/DanmakuUnity2D/ProjectileEmitter.cs.meta @@ -1,8 +1,12 @@ fileFormatVersion: 2 -guid: 83da5f4865992a748a1f74d09a76c454 +guid: ffe233db523780e44a86aa5929c44306 +timeCreated: 1426897776 +licenseType: Free MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External Libraries/UnityUtilLib.meta b/Assets/External Libraries/UnityUtilLib.meta index f1a4af59..9e1edfd4 100644 --- a/Assets/External Libraries/UnityUtilLib.meta +++ b/Assets/External Libraries/UnityUtilLib.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 94eca80f15bb73a4f8ac3201112a0b94 folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/UnityUtilLib/Editor.meta b/Assets/External Libraries/UnityUtilLib/Editor.meta index debbbda4..486a5f76 100644 --- a/Assets/External Libraries/UnityUtilLib/Editor.meta +++ b/Assets/External Libraries/UnityUtilLib/Editor.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 77c50c715b587424c8012895bb6c9f85 folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/UnityUtilLib/Editor/Doxygen.meta b/Assets/External Libraries/UnityUtilLib/Editor/Doxygen.meta index f2eb88ff..117c1e9d 100644 --- a/Assets/External Libraries/UnityUtilLib/Editor/Doxygen.meta +++ b/Assets/External Libraries/UnityUtilLib/Editor/Doxygen.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 6af686edccadc904a93f9a5e5a85b8be folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/UnityUtilLib/Editor/Doxygen/Resources.meta b/Assets/External Libraries/UnityUtilLib/Editor/Doxygen/Resources.meta index 7b09d78b..70afa4a0 100644 --- a/Assets/External Libraries/UnityUtilLib/Editor/Doxygen/Resources.meta +++ b/Assets/External Libraries/UnityUtilLib/Editor/Doxygen/Resources.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: b7fe4672d1034194083138b99280b84f folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/UnityUtilLib/Editor/Doxygen/Resources/DarkTheme.meta b/Assets/External Libraries/UnityUtilLib/Editor/Doxygen/Resources/DarkTheme.meta index 4b7a9847..08aaed10 100644 --- a/Assets/External Libraries/UnityUtilLib/Editor/Doxygen/Resources/DarkTheme.meta +++ b/Assets/External Libraries/UnityUtilLib/Editor/Doxygen/Resources/DarkTheme.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 7dd6fdfbaa787b24987e2f63b678a906 folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/UnityUtilLib/Editor/Doxygen/Resources/LightTheme.meta b/Assets/External Libraries/UnityUtilLib/Editor/Doxygen/Resources/LightTheme.meta index 0bd644c8..45d1e9fa 100644 --- a/Assets/External Libraries/UnityUtilLib/Editor/Doxygen/Resources/LightTheme.meta +++ b/Assets/External Libraries/UnityUtilLib/Editor/Doxygen/Resources/LightTheme.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 1aa285b73b4cbd04ab37c8e0f5e7d19f folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/UnityUtilLib/Editor/EditorUtil.cs b/Assets/External Libraries/UnityUtilLib/Editor/EditorUtil.cs deleted file mode 100644 index 820221f5..00000000 --- a/Assets/External Libraries/UnityUtilLib/Editor/EditorUtil.cs +++ /dev/null @@ -1,143 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; - -namespace UnityUtilLib.Editor { - - /// - /// A static class of an assortment of utility functions useful when making Editor extensions - /// - public static class EditorUtil { - - /// - /// Returns the EditorWindow containing the Game View. - /// Note: this method uses Reflection to access internal variables in the Unity Editor. This is prone to change with future releases of Unity. - /// Currently tested and working with Unity 5.0. - /// - /// The Game View EditorWindow. - public static EditorWindow GetMainGameView() { - Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor"); - MethodInfo GetMainGameView = T.GetMethod("GetMainGameView",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); - object Res = GetMainGameView.Invoke(null,null); - return (UnityEditor.EditorWindow)Res; - } - - /// - /// Gets the Editor Game View aspect ratio. - /// Will return Vector2.zero if the Game View is set to Free Aspect. - /// Note: this method uses Reflection to access internal variables in the Unity Editor. This is prone to change with future releases of Unity. - /// Currently tested and working with Unity 5.0. - /// - /// The Game View's aspect ratio. - public static Vector2 GetGameViewAspectRatio() { - EditorWindow gameView = GetMainGameView(); - PropertyInfo prop = gameView.GetType().GetProperty("currentGameViewSize", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); - object gvsize = prop.GetValue(gameView, new object[0]{}); - Type gvSizeType = gvsize.GetType(); - - int ScreenHeight = (int)gvSizeType.GetProperty("height", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).GetValue(gvsize, new object[0]{}); - int ScreenWidth = (int)gvSizeType.GetProperty("width", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).GetValue(gvsize, new object[0]{}); - return new Vector2 ((float)ScreenWidth, (float)ScreenHeight); - } - - /// - /// Finds the concrete types that derive from a given type. - /// This searches all assemblies in the current domain. Not just the current assembly. - /// - /// The concrete types that derive from the given type - /// the name of the type to search from - public static Type[] FindConcreteTypes() { - return FindConcreteTypes (typeof(T)); - } - - /// - /// Finds the concrete types that derive from a given type. - /// This searches all assemblies in the current domain. Not just the current assembly. - /// - /// The concrete types that derive from the given type - /// the name of the type to search from - public static Type[] FindConcreteTypes(string typeName) { - return FindConcreteTypes (Type.GetType (typeName)); - } - - /// - /// Finds the concrete types that derive from a given type. - /// This searches all assemblies in the current domain. Not just the current assembly. - /// - /// The concrete types that derive from the given type - /// the type to search from - public static Type[] FindConcreteTypes(Type parentType) { - Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies (); - List types = new List (); - for (int i = 0; i < assemblies.Length; i++) { - Type[] assemblyTypes = null; - try { - assemblyTypes = assemblies[i].GetTypes(); - } catch (ReflectionTypeLoadException loadException) { - assemblyTypes = loadException.Types; - } - for(int j = 0; j < assemblyTypes.Length; j++) { - Type typeCheck = assemblyTypes[j]; - if(typeCheck != null && - !typeCheck.Equals(parentType) && - typeCheck.IsAssignableFrom(parentType) && - !typeCheck.IsAbstract && - !typeCheck.IsInterface){ - types.Add(assemblyTypes[j]); - } - } - } - return types.ToArray (); - } - - /// - /// Create a blank ScriptableObject of type T - /// - /// The type of the ScriptableObject to create - public static void CreateScriptableAsset() where T : ScriptableObject { - T asset = ScriptableObject.CreateInstance (); - CreateAsset (asset); - } - - /// - /// Create a blank ScriptableObject of the type specified by the provided type name. - /// - /// The name of the type of the ScriptableObject to create - public static void CreateScriptableAsset(string typeName) { - UnityEngine.Object asset = ScriptableObject.CreateInstance(typeName); - CreateAsset (asset); - } - - /// - /// Create a blank ScriptableObject of the type specified by the provided type name. - /// - /// The type of the ScriptableObject to create - public static void CreateScriptableAsset(Type type) { - UnityEngine.Object asset = ScriptableObject.CreateInstance (type); - CreateAsset (asset); - } - - /// - /// Creates an *.asset Asset from a given object at the selected project folder - /// - /// the object to make an asset out of - public static void CreateAsset(UnityEngine.Object asset) { -// string path = AssetDatabase.GetAssetPath (Selection.activeObject); -// if (path == "") { -// path = "Assets"; -// } else if (Path.GetExtension (path) != "") { -// path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), ""); -// } -// string uniquePath = AssetDatabase.GenerateUniqueAssetPath (path + "/New " + asset.GetType ().ToString () + ".asset"); -// AssetDatabase.CreateAsset (asset, uniquePath); -// AssetDatabase.SaveAssets (); -// AssetDatabase.Refresh (); -// EditorUtility.FocusProjectWindow (); -// Selection.activeObject = asset; - ProjectWindowUtil.CreateAsset (asset, "New " + asset.GetType ().Name + ".asset"); - } - } -} \ No newline at end of file diff --git a/Assets/External Libraries/UnityUtilLib/Editor/FixedScreenAreaCameraEditor.cs b/Assets/External Libraries/UnityUtilLib/Editor/FixedScreenAreaCameraEditor.cs index 723d78b0..1006dbee 100644 --- a/Assets/External Libraries/UnityUtilLib/Editor/FixedScreenAreaCameraEditor.cs +++ b/Assets/External Libraries/UnityUtilLib/Editor/FixedScreenAreaCameraEditor.cs @@ -1,7 +1,5 @@ using UnityEditor; using UnityEngine; -using UnityUtilLib; -using UnityUtilLib.Editor; namespace UnityUtilLib.Editor { diff --git a/Assets/External Libraries/UnityUtilLib/Editor/MeshRendererSortingLayerEditor.cs b/Assets/External Libraries/UnityUtilLib/Editor/MeshRendererSortingLayerEditor.cs new file mode 100644 index 00000000..e7b47a69 --- /dev/null +++ b/Assets/External Libraries/UnityUtilLib/Editor/MeshRendererSortingLayerEditor.cs @@ -0,0 +1,92 @@ +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +using UnityEditorInternal; +using System.Reflection; +using System; +#endif + +namespace UnityUtilLib.Editor { + //Expose SortingLayer SortingOrder on MeshRenderer + //With nice drop down and revert to prefab functionality. + + //Base exposing code by neror http://forum.unity3d.com/threads/212006-Drawing-order-of-Meshes-and-Sprites + //Get all sorting layer name and ID by guavaman Ivan.Murashko http://answers.unity3d.com/questions/585108/how-do-you-access-sorting-layers-via-scripting.html + //Sorting Layer drop down menu, bold text on prefab override, revert to prefab and instant update on Order change functionality by 5argon + + [CustomEditor(typeof(MeshRenderer))] + [CanEditMultipleObjects] + internal class MeshRendererSortingLayersEditor : UnityEditor.Editor { + + public override void OnInspectorGUI() { + base.OnInspectorGUI(); + + serializedObject.Update(); + + SerializedProperty sortingLayerID = serializedObject.FindProperty("m_SortingLayerID"); + SerializedProperty sortingOrder = serializedObject.FindProperty("m_SortingOrder"); + + Rect firstHoriz = EditorGUILayout.BeginHorizontal(); + + EditorGUI.BeginChangeCheck(); + + EditorGUI.BeginProperty(firstHoriz,GUIContent.none,sortingLayerID); + + string[] layerNames = GetSortingLayerNames(); + int[] layerID = GetSortingLayerUniqueIDs(); + + int selected = -1; + //What is selected? + int sID = sortingLayerID.intValue; + for(int i = 0 ; i < layerID.Length ; i++) { + //Debug.Log(sID + " " + layerID[i]); + if(sID == layerID[i]) { + selected = i; + } + } + + if(selected == -1) + { + //Select Default. + for(int i = 0 ; i < layerID.Length ; i++) + { + if(layerID[i] == 0) + { + selected = i; + } + } + } + + selected = EditorGUILayout.Popup("Sorting Layer" ,selected,layerNames); + + //Translate to ID + sortingLayerID.intValue = layerID[selected]; + + + EditorGUI.EndProperty(); + + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.BeginHorizontal(); + EditorGUI.BeginChangeCheck(); + + EditorGUILayout.PropertyField(sortingOrder,new GUIContent("Order in Layer")); + + EditorGUILayout.EndHorizontal(); + serializedObject.ApplyModifiedProperties(); + } + + public string[] GetSortingLayerNames() { + Type internalEditorUtilityType = typeof(InternalEditorUtility); + PropertyInfo sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic); + return (string[])sortingLayersProperty.GetValue(null, new object[0]); + } + + public int[] GetSortingLayerUniqueIDs() { + Type internalEditorUtilityType = typeof(InternalEditorUtility); + PropertyInfo sortingLayerUniqueIDsProperty = internalEditorUtilityType.GetProperty("sortingLayerUniqueIDs", BindingFlags.Static | BindingFlags.NonPublic); + return (int[])sortingLayerUniqueIDsProperty.GetValue(null, new object[0]); + } + + } +} \ No newline at end of file diff --git a/Assets/External Libraries/UnityUtilLib/Editor/MeshRendererSortingLayerEditor.cs.meta b/Assets/External Libraries/UnityUtilLib/Editor/MeshRendererSortingLayerEditor.cs.meta new file mode 100644 index 00000000..3399aa08 --- /dev/null +++ b/Assets/External Libraries/UnityUtilLib/Editor/MeshRendererSortingLayerEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e422658a9c938a64dba4ac9befdbef56 +timeCreated: 1426896634 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External Libraries/UnityUtilLib/Editor/UnhideAllObjects.cs b/Assets/External Libraries/UnityUtilLib/Editor/UnhideAllObjects.cs index 273f7809..8fbc05cb 100644 --- a/Assets/External Libraries/UnityUtilLib/Editor/UnhideAllObjects.cs +++ b/Assets/External Libraries/UnityUtilLib/Editor/UnhideAllObjects.cs @@ -2,6 +2,7 @@ using UnityEditor; using System.Collections; +[assembly: AssemblyIsEditorAssembly] namespace UnityUtilib.Editor { public static class UnhideAllObjects { diff --git a/Assets/External Libraries/UnityUtilLib/EditorUtil.cs b/Assets/External Libraries/UnityUtilLib/EditorUtil.cs new file mode 100644 index 00000000..f507febc --- /dev/null +++ b/Assets/External Libraries/UnityUtilLib/EditorUtil.cs @@ -0,0 +1,177 @@ +#if UNITY_EDITOR +using UnityEngine; +using UnityEditor; +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; + +/// +/// A static class of an assortment of utility functions useful when making Editor extensions +/// +public static class EditorUtil { + + public static string GetProjectWindowFolder() { + UnityEngine.Object activeObject = Selection.activeObject; + string path = ""; + if (activeObject == null) + return "Assets"; // Nothing selected + else + path = AssetDatabase.GetAssetPath (activeObject); + if (path.Length > 0) { + if (Directory.Exists (path)) { + return path; // path is a folder + } else { + Debug.Log(path); + Debug.Log(Directory.GetParent(path).FullName); + return Directory.GetParent(path).FullName; + } + } + return ""; //path in Assets folder + } + + public static bool IsFolder(UnityEngine.Object asset) { + string path = ""; + if (asset == null) { + return false; + } + path = AssetDatabase.GetAssetPath (asset); + if (path.Length > 0) { + if(Directory.Exists(path)) { + return true; + } else { + return false; + } + } + return false; + } + + /// + /// Returns the EditorWindow containing the Game View. + /// Note: this method uses Reflection to access internal variables in the Unity Editor. This is prone to change with future releases of Unity. + /// Currently tested and working with Unity 5.0. + /// + /// The Game View EditorWindow. + public static EditorWindow GetMainGameView() { + Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor"); + MethodInfo GetMainGameView = T.GetMethod("GetMainGameView",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); + object Res = GetMainGameView.Invoke(null,null); + return (UnityEditor.EditorWindow)Res; + } + + /// + /// Gets the Editor Game View aspect ratio. + /// Will return Vector2.zero if the Game View is set to Free Aspect. + /// Note: this method uses Reflection to access internal variables in the Unity Editor. This is prone to change with future releases of Unity. + /// Currently tested and working with Unity 5.0. + /// + /// The Game View's aspect ratio. + public static Vector2 GetGameViewAspectRatio() { + EditorWindow gameView = GetMainGameView(); + PropertyInfo prop = gameView.GetType().GetProperty("currentGameViewSize", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); + object gvsize = prop.GetValue(gameView, new object[0]{}); + Type gvSizeType = gvsize.GetType(); + + int ScreenHeight = (int)gvSizeType.GetProperty("height", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).GetValue(gvsize, new object[0]{}); + int ScreenWidth = (int)gvSizeType.GetProperty("width", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).GetValue(gvsize, new object[0]{}); + return new Vector2 ((float)ScreenWidth, (float)ScreenHeight); + } + + /// + /// Finds the concrete types that derive from a given type. + /// This searches all assemblies in the current domain. Not just the current assembly. + /// + /// The concrete types that derive from the given type + /// the name of the type to search from + public static Type[] FindConcreteTypes() { + return FindConcreteTypes (typeof(T)); + } + + /// + /// Finds the concrete types that derive from a given type. + /// This searches all assemblies in the current domain. Not just the current assembly. + /// + /// The concrete types that derive from the given type + /// the name of the type to search from + public static Type[] FindConcreteTypes(string typeName) { + return FindConcreteTypes (Type.GetType (typeName)); + } + + /// + /// Finds the concrete types that derive from a given type. + /// This searches all assemblies in the current domain. Not just the current assembly. + /// + /// The concrete types that derive from the given type + /// the type to search from + public static Type[] FindConcreteTypes(Type parentType) { + Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies (); + List types = new List (); + for (int i = 0; i < assemblies.Length; i++) { + Type[] assemblyTypes = null; + try { + assemblyTypes = assemblies[i].GetTypes(); + } catch (ReflectionTypeLoadException loadException) { + assemblyTypes = loadException.Types; + } + for(int j = 0; j < assemblyTypes.Length; j++) { + Type typeCheck = assemblyTypes[j]; + if(typeCheck != null && + !typeCheck.Equals(parentType) && + typeCheck.IsAssignableFrom(parentType) && + !typeCheck.IsAbstract && + !typeCheck.IsInterface){ + types.Add(assemblyTypes[j]); + } + } + } + return types.ToArray (); + } + + /// + /// Create a blank ScriptableObject of type T + /// + /// The type of the ScriptableObject to create + public static void CreateScriptableAsset() where T : ScriptableObject { + T asset = ScriptableObject.CreateInstance (); + CreateAsset (asset); + } + + /// + /// Create a blank ScriptableObject of the type specified by the provided type name. + /// + /// The name of the type of the ScriptableObject to create + public static void CreateScriptableAsset(string typeName) { + UnityEngine.Object asset = ScriptableObject.CreateInstance(typeName); + CreateAsset (asset); + } + + /// + /// Create a blank ScriptableObject of the type specified by the provided type name. + /// + /// The type of the ScriptableObject to create + public static void CreateScriptableAsset(Type type) { + UnityEngine.Object asset = ScriptableObject.CreateInstance (type); + CreateAsset (asset); + } + + /// + /// Creates an *.asset Asset from a given object at the selected project folder + /// + /// the object to make an asset out of + public static void CreateAsset(UnityEngine.Object asset) { +// string path = AssetDatabase.GetAssetPath (Selection.activeObject); +// if (path == "") { +// path = "Assets"; +// } else if (Path.GetExtension (path) != "") { +// path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), ""); +// } +// string uniquePath = AssetDatabase.GenerateUniqueAssetPath (path + "/New " + asset.GetType ().ToString () + ".asset"); +// AssetDatabase.CreateAsset (asset, uniquePath); +// AssetDatabase.SaveAssets (); +// AssetDatabase.Refresh (); +// EditorUtility.FocusProjectWindow (); +// Selection.activeObject = asset; + ProjectWindowUtil.CreateAsset (asset, "New " + asset.GetType ().Name + ".asset"); + } +} +#endif \ No newline at end of file diff --git a/Assets/External Libraries/UnityUtilLib/Editor/EditorUtil.cs.meta b/Assets/External Libraries/UnityUtilLib/EditorUtil.cs.meta similarity index 76% rename from Assets/External Libraries/UnityUtilLib/Editor/EditorUtil.cs.meta rename to Assets/External Libraries/UnityUtilLib/EditorUtil.cs.meta index 5fef230c..8f2594d1 100644 --- a/Assets/External Libraries/UnityUtilLib/Editor/EditorUtil.cs.meta +++ b/Assets/External Libraries/UnityUtilLib/EditorUtil.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 7b6b34adff6a69d4a9557d2af23173e4 -timeCreated: 1425888368 +guid: 7b0869901d8bc824d83a422bc7604575 +timeCreated: 1426814576 licenseType: Free MonoImporter: serializedVersion: 2 diff --git a/Assets/External Libraries/UnityUtilLib/FixedScreenAreaCamera.cs b/Assets/External Libraries/UnityUtilLib/FixedScreenAreaCamera.cs index 30a418a1..1dd12923 100644 --- a/Assets/External Libraries/UnityUtilLib/FixedScreenAreaCamera.cs +++ b/Assets/External Libraries/UnityUtilLib/FixedScreenAreaCamera.cs @@ -8,7 +8,7 @@ namespace UnityUtilLib { /// [RequireComponent(typeof(Camera))] public class FixedScreenAreaCamera : MonoBehaviour { - + private Camera fixedCamera; private float currentAspectRatio; private float offset; diff --git a/Assets/External Libraries/UnityUtilLib/GUI.meta b/Assets/External Libraries/UnityUtilLib/GUI.meta index 5055a067..81c4398e 100644 --- a/Assets/External Libraries/UnityUtilLib/GUI.meta +++ b/Assets/External Libraries/UnityUtilLib/GUI.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 4c71803d579552645a966a5edb9ed455 folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/UnityUtilLib/GUI/FPSCounter.cs b/Assets/External Libraries/UnityUtilLib/GUI/FPSCounter.cs index 805d2fd1..2406b967 100644 --- a/Assets/External Libraries/UnityUtilLib/GUI/FPSCounter.cs +++ b/Assets/External Libraries/UnityUtilLib/GUI/FPSCounter.cs @@ -12,6 +12,7 @@ namespace UnityUtilLib.GUI { [RequireComponent(typeof(GUIText))] public class FPSCounter : MonoBehaviour { + [SerializeField] private float updateInterval = 0.5f; private float accum = 0.0f; // FPS accumulated over the interval @@ -22,25 +23,35 @@ public class FPSCounter : MonoBehaviour { private GUIText display; + private bool controllerCheck; + void Start () { display = GetComponent(); + controllerCheck = GameController.Instance != null; } void Update () { - float dt = Time.deltaTime; - timeleft -= dt ; - accum += Time.timeScale / dt; - ++frames; - - // Interval ended - update GUI text and start new interval - if( timeleft <= 0.0 ) - { - // display two fractional digits (f2 format) - display.text = (accum/frames).ToString("f2") + " fps"; - timeleft = updateInterval; - accum = 0.0f; - frames = 0f; + if (controllerCheck) { + DisplayFPS(GameController.FPS); + } else { + float dt = Time.unscaledDeltaTime; + timeleft -= dt ; + accum += dt; + ++frames; + + // Interval ended - update GUI text and start new interval + if( timeleft <= 0.0 ) { + // display two fractional digits (f2 format) + DisplayFPS(frames / accum); + timeleft = updateInterval; + accum = 0.0f; + frames = 0f; + } } } + + private void DisplayFPS(float fps) { + display.text = fps.ToString("f2") + " fps"; + } } } diff --git a/Assets/External Libraries/UnityUtilLib/Interface.meta b/Assets/External Libraries/UnityUtilLib/Interface.meta index c4649f5e..c6490d37 100644 --- a/Assets/External Libraries/UnityUtilLib/Interface.meta +++ b/Assets/External Libraries/UnityUtilLib/Interface.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: b42155d77953f90458744d26307302ed folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/UnityUtilLib/Managers.meta b/Assets/External Libraries/UnityUtilLib/Managers.meta index abc7ae29..0673d1cc 100644 --- a/Assets/External Libraries/UnityUtilLib/Managers.meta +++ b/Assets/External Libraries/UnityUtilLib/Managers.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: fadc23584f7d51e40bef612bfac44f81 folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/UnityUtilLib/Managers/GameController.cs b/Assets/External Libraries/UnityUtilLib/Managers/GameController.cs index b1eb081c..81f857b5 100644 --- a/Assets/External Libraries/UnityUtilLib/Managers/GameController.cs +++ b/Assets/External Libraries/UnityUtilLib/Managers/GameController.cs @@ -12,6 +12,17 @@ namespace UnityUtilLib { /// public abstract class GameController : Singleton { + [SerializeField] + private float fpsUpdateInterval = 0.5f; + + private float accum = 0.0f; // FPS accumulated over the interval + + private float frames = 0f; // Frames drawn over the interval + + private float timeleft; // Left time for current interval + + private static float fps = float.NaN; + private static float oldTimeScale; private static bool gamePaused; @@ -25,6 +36,33 @@ public static bool IsGamePaused { } } + /// + /// Gets the game's FPS. + /// Will return float.NaN if no GameController Instance does not exist. + /// + /// The FPS. + public static float FPS { + get { + return fps; + } + } + + public virtual void Update() { + float dt = Time.unscaledDeltaTime; + timeleft -= dt ; + accum += dt; + ++frames; + + // Interval ended - update GUI text and start new interval + if( timeleft <= 0.0 ) { + // display two fractional digits (f2 format) + fps = (frames/accum); + timeleft = fpsUpdateInterval; + accum = 0.0f; + frames = 0f; + } + } + /// /// Pauses the game. All MonoBehaviours that implement IPausable will be paused. /// diff --git a/Assets/External Libraries/UnityUtilLib/Microfunctionality.meta b/Assets/External Libraries/UnityUtilLib/Microfunctionality.meta index 7ae7fc09..c89f9abb 100644 --- a/Assets/External Libraries/UnityUtilLib/Microfunctionality.meta +++ b/Assets/External Libraries/UnityUtilLib/Microfunctionality.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 8e1c9c4f1c769b04ab0314d84322c3ff folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/UnityUtilLib/Pooling.meta b/Assets/External Libraries/UnityUtilLib/Pooling.meta index fb186eff..33c1bcc6 100644 --- a/Assets/External Libraries/UnityUtilLib/Pooling.meta +++ b/Assets/External Libraries/UnityUtilLib/Pooling.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: b71ac24cb0950b248b550e597d01a7a9 folderAsset: yes -timeCreated: 1426622486 +timeCreated: 1426955464 licenseType: Free DefaultImporter: userData: diff --git a/Assets/External Libraries/UnityUtilLib/Singleton.cs b/Assets/External Libraries/UnityUtilLib/Singleton.cs index 10789664..ae1d02e5 100644 --- a/Assets/External Libraries/UnityUtilLib/Singleton.cs +++ b/Assets/External Libraries/UnityUtilLib/Singleton.cs @@ -19,6 +19,7 @@ public abstract class Singleton : CachedObject where T : Singleton { public static T Instance { get { if(instance == null) { + Debug.Log("hi"); instance = FindObjectOfType(); } return instance; diff --git a/Assets/External Libraries/UnityUtilLib/UtilExtensionMethods.cs b/Assets/External Libraries/UnityUtilLib/UtilExtensionMethods.cs index cb67fc73..dfaee78a 100644 --- a/Assets/External Libraries/UnityUtilLib/UtilExtensionMethods.cs +++ b/Assets/External Libraries/UnityUtilLib/UtilExtensionMethods.cs @@ -43,6 +43,20 @@ public static List GetChildrenList(this GameObject go) { return children; } + public static GameObject[] GetChildren(this GameObject go) { + return go.GetChildrenList ().ToArray (); + } + + public static GameObject FindChild(this GameObject go, string childName) { + GameObject[] children = go.GetChildren (); + for(int i = 0; i < children.Length; i++) { + if(children[i].name == childName) { + return children[i]; + } + } + return null; + } + /// /// Safe get component method. Is a defensive alternative to the GetComponent method. /// This will tell you when it does not find the component. diff --git a/Assets/External Libraries/UnityUtilLib/UtilGizmos.cs b/Assets/External Libraries/UnityUtilLib/UtilGizmos.cs new file mode 100644 index 00000000..132129f6 --- /dev/null +++ b/Assets/External Libraries/UnityUtilLib/UtilGizmos.cs @@ -0,0 +1,9 @@ +using System; +using UnityEngine; + +namespace UnityUtilLib { + public static class UtilGizmos { + + } +} + diff --git a/Assets/External Libraries/UnityUtilLib/UtilGizmos.cs.meta b/Assets/External Libraries/UnityUtilLib/UtilGizmos.cs.meta new file mode 100644 index 00000000..14caf5a2 --- /dev/null +++ b/Assets/External Libraries/UnityUtilLib/UtilGizmos.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1fe01179a5d0012439bbed2840642607 +timeCreated: 1426732297 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: