An open source Danmaku development kit for Unity3D.
0
fork

Configure Feed

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

More Optimizations

Danmaku is no longer globally pooled, but instead pooled on a per-prefab
basis, and the pooling is based more on other more successful particle
systems (no queue structures or metadata, just maintains an array index,
and swaps out active and inactive bullets).

Also removed the redundant array accesses in update loops for rendering
and updating danmaku.

Rendering and updating loops are now done in-tandem, to reduce overhead of
iterating over basically the same collection multiple times.

There does seem to be a small bug where otherwise active bullets are being
"paused" and unrenderered when other bullets are destroyed, which should
be fixable.

james713 b2028585 8992b30c

+1007 -1293
+2 -2
Assets/Dependencies/DanmakU/Colliders/DeactivationCollider.cs
··· 7 7 namespace Hourai.DanmakU.Collider { 8 8 9 9 /// <summary> 10 - /// A DanmakuCollider that deactivates all valid danmaku that come in contact with it. 10 + /// A DanmakuCollider that Destroys all valid danmaku that come in contact with it. 11 11 /// </summary> 12 12 [AddComponentMenu("Hourai.DanmakU/Colliders/Deactivation Collider")] 13 13 public class DeactivationCollider : DanmakuCollider { ··· 20 20 /// <param name="info">additional information about the collision</param> 21 21 protected override void DanmakuCollision(Danmaku danmaku, 22 22 RaycastHit2D info) { 23 - danmaku.Deactivate(); 23 + danmaku.Destroy(); 24 24 } 25 25 26 26 #endregion
+5 -5
Assets/Dependencies/DanmakU/Colliders/PrefabChangeCollider.cs
··· 23 23 } 24 24 25 25 protected override void Awake() { 26 - base.Awake(); 26 + base.Awake(); 27 27 affected = DanmakuGroup.Set(); 28 28 } 29 29 ··· 37 37 protected override void DanmakuCollision(Danmaku danmaku, 38 38 RaycastHit2D info) { 39 39 if (affected.Contains(danmaku)) 40 - return; 41 - 42 - if (prefab != null) 43 - danmaku.MatchPrefab(prefab); 40 + return; 41 + 42 + if (prefab != null) 43 + prefab.Match(danmaku); 44 44 45 45 affected.Add(danmaku); 46 46 }
+1 -1
Assets/Dependencies/DanmakU/_Core_/Controllers/DeactivationControllers.cs
··· 12 12 return delegate(Danmaku danmaku) 13 13 { 14 14 if (deactivation(danmaku)) 15 - danmaku.Deactivate(); 15 + danmaku.Destroy(); 16 16 }; 17 17 } 18 18 }
+50 -228
Assets/Dependencies/DanmakU/_Core_/Danmaku.cs
··· 27 27 28 28 } 29 29 30 - private bool _isActive; 31 30 private Action<Danmaku> _onUpdate; 32 31 33 - /// <summary> 34 - /// Initializes a new instance of the <see cref="Hourai.DanmakU.Danmaku"/> class. 35 - /// </summary> 36 32 internal Danmaku(int poolIndex) { 37 33 PoolIndex = poolIndex; 38 34 } ··· 40 36 /// <summary> 41 37 /// Gets or sets a value indicating whether this instance is active. 42 38 /// </summary> 43 - /// <remarks> 44 - /// Setting it to true while inactive is equal to calling Activate. 45 - /// Setting it to false while active is equal to calling DeactivateImmediate. 46 - /// </remarks> 47 39 /// <value><c>true</c> if this instance is active; otherwise, <c>false</c>.</value> 48 40 public bool IsActive { 49 - get { return _isActive; } 50 - set { 51 - if (_isActive) { 52 - if (!value) 53 - DeactivateImmediate(); 54 - } else { 55 - if (value) 56 - Activate(); 57 - } 58 - _isActive = value; 59 - } 41 + get { return PoolIndex <= Type._activeCount; } 60 42 } 61 43 62 44 /// <summary> 63 - /// Occurs when the Danmaku instance is activated. 45 + /// Called when the Danmaku instance is activated. 64 46 /// </summary> 65 47 public event Action<Danmaku> OnActivate; 66 48 67 49 /// <summary> 68 - /// Occurs when the Danmaku instance is deactivated. 50 + /// Called when the Danmaku instance is destroyed. 69 51 /// </summary> 70 - public event Action<Danmaku> OnDeactivate; 52 + public event Action<Danmaku> OnDestroy; 71 53 72 54 public event Action<Danmaku> Controller { 73 55 add { ··· 80 62 } 81 63 } 82 64 65 + /// <summary> 66 + /// Clears all cotnrollers from this 67 + /// </summary> 83 68 public void ClearControllers() { 84 69 _controllerCheck = true; 85 70 _onUpdate = null; ··· 117 102 float sqrDistance = movementVector.sqrMagnitude; 118 103 float cx = colliderOffset.x; 119 104 float cy = colliderOffset.y; 120 - if (Mathf.Approximately(cx, 0f) && Mathf.Approximately(cy, 0f)) 105 + if (cx == 0 && cy == 0) 121 106 _collisionCenter = _originalPosition; 122 107 else { 123 108 float c = direction.x; ··· 194 179 195 180 foreach (IDanmakuCollider script in scripts) 196 181 script.OnDanmakuCollision(this, hit); 197 - 198 - if (!to_deactivate) 199 - continue; 200 - 201 - position.x = hit.point.x; 202 - position.y = hit.point.y; 203 - DeactivateImmediate(); 204 - return; 205 182 } 206 183 } 207 - } 208 - 209 - if (!_isActive || to_deactivate) { 210 - DeactivateImmediate(); 211 - return; 212 184 } 213 185 214 186 frames++; 215 187 time += dt; 216 188 } 217 189 218 - public void MatchPrefab(DanmakuPrefab prefab) { 219 - if (prefab == null) { 220 - Debug.LogError("Tried to match a null prefab"); 221 - return; 222 - } 223 - if (this.prefab != prefab) { 224 - this.prefab = prefab; 225 - 226 - if (_isActive) { 227 - runtime.currentDanmaku.Remove(this); 228 - runtime = prefab.GetRuntime(); 229 - runtime.currentDanmaku.Add(this); 230 - } else 231 - runtime = prefab.GetRuntime(); 232 - 233 - Vector2 scale = runtime.cachedScale; 234 - colliderType = runtime.collisionType; 235 - switch (colliderType) { 236 - default: 237 - colliderSize = Vector2.zero; 238 - sizeSquared = 0; 239 - break; 240 - case ColliderType.Circle: 241 - colliderSize = runtime.colliderSize*scale.Max(); 242 - break; 243 - case ColliderType.Line: 244 - colliderSize = runtime.colliderSize; 245 - break; 246 - } 247 - sizeSquared = colliderSize.y * colliderSize.y; 248 - colliderOffset = scale.Hadamard2(runtime.colliderOffset); 249 - } 250 - 251 - Color = runtime.Color; 252 - Scale = 1f; 253 - layer = runtime.cachedLayer; 254 - colliderMask = collisionMask[layer]; 255 - } 256 - 257 190 public static implicit operator FireData(Danmaku danmaku) { 258 - var fd = new FireData { 191 + var fd = new FireData () { 259 192 Position = danmaku.Position, 260 193 Rotation = danmaku.Rotation, 261 194 AngularSpeed = danmaku.AngularSpeed, 262 195 Speed = danmaku.Speed, 263 - Prefab = danmaku.Prefab, 196 + Prefab = danmaku.prefab, 264 197 Controller = danmaku._onUpdate, 265 198 Damage = danmaku.Damage, 266 199 }; ··· 268 201 return fd; 269 202 } 270 203 271 - /// <summary> 272 - /// Fires a single bullet from the bullet's current position. 273 - /// </summary> 274 - /// <remarks> 275 - /// By default, firing using this method also uses the rotation of the bullet to fire the bullet. 276 - /// Set <c>useRotation</c> to false to disable this. 277 - /// </remarks> 278 - /// <param name="data">the data used to create the .</param> 279 - /// <param name="useRotation">If set to <c>true</c>, the bullet will use the current rotation of the bullet to fire with.</param> 280 - public Danmaku Fire(FireData data, bool useRotation = true) { 281 - Vector2 tempPos = data.Position; 282 - float tempRot = data.Rotation; 283 - data.Position = Position; 284 - if (useRotation) 285 - data.Rotation = Rotation; 286 - Danmaku danmaku = data.Fire(); 287 - data.Position = tempPos; 288 - data.Rotation = tempRot; 289 - return danmaku; 290 - } 291 - 292 - /// <summary> 293 - /// Activates the Danmaku instance. 294 - /// </summary> 295 - /// <remarks> 296 - /// Calling this on a already active instance does nothing. 297 - /// Calling this on a instance marked for deactivation will unmark the projectile and keep it from deactivating. 298 - /// </remarks> 299 204 public void Activate() { 300 - if (DanmakuGame.Instance == null) 301 - new GameObject("Danmaku Game Controller").AddComponent<DanmakuGame>(); 302 - to_deactivate = false; 303 - runtime.currentDanmaku.Add(this); 304 - if (_isActive) 205 + if (IsActive) 305 206 return; 207 + 306 208 if(OnActivate != null) 307 209 OnActivate(this); 308 - _isActive = true; 210 + 211 + Type.Activate(this); 212 + 309 213 frames = 0; 310 214 time = 0f; 311 215 } 312 216 313 217 /// <summary> 314 - /// Marks the instance for deactivation. 218 + /// Marks the instance for destruction. 219 + /// 315 220 /// </summary> 316 - /// <remarks> 317 - /// Deactivated bullets are removed from the active set, and all 318 - /// The instance removed from the active set and all bullet functionality will cease after current 319 - /// If Danmaku needs to be deactivated in a moment when it is not being updated (i.e. when the game is paused), use <see cref="DeactivateImmediate"/> instead. 320 - /// </remarks> 321 - public void Deactivate() { 322 - Debug.Log("Hello"); 323 - to_deactivate = true; 221 + public void Destroy() 222 + { 223 + Type.toDestroy.Add(this); 324 224 } 225 + 226 + internal void DestroyImpl() { 227 + if (!IsActive) 228 + return; 325 229 326 - /// <summary> 327 - /// Immediately deactivates this Danmaku and ceases all processing done on it. 328 - /// Calling this generally unadvised. Use <see cref="Deactivate"/> whenever possible. 329 - /// This method should only be used when dealing with Projectiles while the game is paused or when ProjectileManager is not enabled 330 - /// </summary> 331 - public void DeactivateImmediate() { 332 - if (_isActive && OnDeactivate != null) 333 - OnDeactivate(this); 230 + if (OnDestroy != null) 231 + OnDestroy(this); 334 232 335 233 _onUpdate = null; 336 234 OnActivate = null; 337 - OnDeactivate = null; 235 + OnDestroy = null; 338 236 _controllerCheck = false; 339 237 Damage = 0; 340 238 CollisionCheck = true; 341 - _isActive = false; 342 - danmakuPool.Return(this); 239 + 240 + Type.Return(this); 343 241 } 344 242 345 243 /// <summary> ··· 352 250 353 251 #region Private and Internal Fields 354 252 355 - /// <summary> 356 - /// The Danmaku instance's index within the DanmakuPool. 357 - /// </summary> 358 - internal readonly int PoolIndex; 359 - 360 - //internal int renderIndex; 361 - 253 + internal int PoolIndex; 362 254 internal Vector2 direction; 363 255 364 256 //Cached information about the Danmaku from its prefab 365 257 internal ColliderType colliderType = ColliderType.Circle; 366 258 internal Vector2 colliderOffset = Vector2.zero; 367 259 internal Vector2 colliderSize = Vector2.zero; 368 - private float sizeSquared; 260 + internal float sizeSquared; 369 261 internal int layer; 370 262 internal int frames; 371 263 internal float time; 372 264 373 265 //Prefab information 374 - private DanmakuPrefab prefab; 375 - private DanmakuPrefab runtime; 266 + internal DanmakuPrefab prefab; 376 267 377 268 //Collision related variables 378 269 private int colliderMask; 379 270 380 - private bool to_deactivate; 381 - 382 271 internal Vector3 position; 383 272 internal float rotation; 384 273 ··· 410 299 public float AngularSpeed; 411 300 412 301 public DanmakuPrefab Prefab { 413 - get { return runtime; } 302 + get { return prefab; } 303 + set 304 + { 305 + if (prefab) 306 + prefab.Match(this); 307 + } 414 308 } 415 309 416 - public Sprite Sprite { 417 - get { return runtime.Sprite; } 418 - } 419 - 420 - public Mesh Mesh { 421 - get { return runtime.Mesh; } 422 - } 423 - 424 - public Material Material { 425 - get { 426 - //return material; 427 - return runtime.Material; 428 - } 310 + public DanmakuType Type 311 + { 312 + get { return prefab.type; } 429 313 } 430 314 431 315 /// <summary> ··· 445 329 /// </summary> 446 330 /// <remarks> 447 331 /// If viewed from a unrotated orthographic camera: 448 - /// 0 - Straight up 449 - /// 90 - Straight Left 450 - /// 180 - Straight Down 451 - /// 270 - Straight Right 332 + /// 0 - Straight right 333 + /// 90 - Straight up 334 + /// 180 - Straight left 335 + /// 270 - Straight down 452 336 /// </remarks> 453 337 /// <value>The rotation of the bullet in degrees.</value> 454 338 public float Rotation { ··· 476 360 } 477 361 } 478 362 363 + public Vector2 Velocity { 364 + get { return direction * Speed; } 365 + } 366 + 479 367 public float Scale; 480 368 481 369 /// <summary> ··· 513 401 /// </summary> 514 402 /// <remarks> 515 403 /// Unlike GameObject's layers, this layer value only affects collision behavior. 404 + /// Lighting and 516 405 /// </remarks> 517 406 /// <value>The layer used for collision detection.</value> 518 407 public int Layer { ··· 521 410 layer = value; 522 411 colliderMask = collisionMask[layer]; 523 412 } 524 - } 525 - 526 - #endregion 527 - 528 - #region Position Functions 529 - 530 - /// <summary> 531 - /// Moves the bullet closer to the specified target point. 532 - /// 533 - /// If <c>maxDisntanceDelta</c> is negative, the bullet will instead move away from the target point. 534 - /// </summary> 535 - /// <param name="target">The target position to move towards in absolute world coordinates.</param> 536 - /// <param name="maxDistanceDelta">The maximum distance traversed by a single call to this function.</param> 537 - public void MoveTowards(Vector2 target, float maxDistanceDelta) { 538 - Position = Vector2.MoveTowards(position, target, maxDistanceDelta); 539 - } 540 - 541 - /// <summary> 542 - /// Moves the bullet closer to the specified target Transform's position. 543 - /// 544 - /// If <c>maxDisntanceDelta</c> is negative, the bullet will instead move away from the target point. 545 - /// </summary> 546 - /// <exception cref="System.ArgumentNullException">Thrown if the target Transform is null.</exception> 547 - /// <param name="target">The Transform of the object to move towards.</param> 548 - /// <param name="maxDistanceDelta">The maximum distance traversed by a single call to this function.</param> 549 - public void MoveTowards(Transform target, float maxDistanceDelta) { 550 - if (target == null) 551 - throw new ArgumentNullException(); 552 - Position = Vector2.MoveTowards(position, 553 - target.position, 554 - maxDistanceDelta); 555 - } 556 - 557 - /// <summary> 558 - /// Moves the bullet closer to the specified target Component's position. 559 - /// 560 - /// If <c>maxDisntanceDelta</c> is negative, the bullet will instead move away from the target point. 561 - /// </summary> 562 - /// <exception cref="System.ArgumentNullException">Thrown if the target Component is null.</exception> 563 - /// <param name="target">The Component of the object to move towards.</param> 564 - /// <param name="maxDistanceDelta">The maximum distance traversed by a single call to this function.</param> 565 - public void MoveTowards(Component target, float maxDistanceDelta) { 566 - if (target == null) 567 - throw new ArgumentNullException(); 568 - Position = Vector2.MoveTowards(position, 569 - target.transform.position, 570 - maxDistanceDelta); 571 - } 572 - 573 - /// <summary> 574 - /// Moves the bullet closer to the specified target GameObject's position. 575 - /// 576 - /// If <c>maxDisntanceDelta</c> is negative, the bullet will instead move away from the target point. 577 - /// </summary> 578 - /// <exception cref="System.ArgumentNullException">Thrown if the target GameObject is null.</exception> 579 - /// <param name="target">The GameObject of the object to move towards.</param> 580 - /// <param name="maxDistanceDelta">The maximum distance traversed by a single call to this function.</param> 581 - public void MoveTowards(GameObject target, float maxDistanceDelta) { 582 - if (target == null) 583 - throw new System.ArgumentNullException(); 584 - Position = Vector2.MoveTowards(position, 585 - target.transform.position, 586 - maxDistanceDelta); 587 - } 588 - 589 - public void Translate(Vector2 deltaPos) { 590 - Position += deltaPos; 591 413 } 592 414 593 415 #endregion
+9 -62
Assets/Dependencies/DanmakU/_Core_/DanmakuField.cs
··· 26 26 private static readonly Vector2 InfiniteSize = float.PositiveInfinity* 27 27 Vector2.one; 28 28 29 - private DanmakuGroup activeDanmaku; 30 - 31 29 internal Bounds2D bounds; 32 30 33 31 [SerializeField] ··· 150 148 public virtual void Awake() { 151 149 if (_fields == null) 152 150 _fields = new List<DanmakuField>(); 153 - _fields.Add(this); 154 - activeDanmaku = DanmakuGroup.List(); 151 + _fields.Add(this); 155 152 TargetField = this; 156 153 } 157 154 ··· 178 175 movementBounds.Extents.Max(); 179 176 } else 180 177 bounds.Extents = InfiniteSize; 181 - activeDanmaku.RemoveAll(d => bounds.Contains(d.Position)); 182 178 } 183 179 184 180 private void OnDestroy() { ··· 256 252 return clone; 257 253 } 258 254 259 - public Danmaku SpawnDanmaku(DanmakuPrefab prefab, 260 - Vector2 location, 261 - float rotation, 262 - CoordinateSystem coordSys = CoordinateSystem.View) { 263 - if (TargetField == null) 264 - TargetField = this; 265 - Danmaku danmaku = Danmaku.GetInactive(prefab, 266 - TargetField.WorldPoint(location, coordSys), 267 - rotation); 268 - danmaku.Activate(); 269 - activeDanmaku.Add(danmaku); 270 - return danmaku; 271 - } 272 - 273 - public Danmaku FireLinear(DanmakuPrefab prefab, 274 - Vector2 location, 275 - float rotation, 276 - float speed, 277 - CoordinateSystem coordSys = CoordinateSystem.View) { 278 - if (TargetField == null) 279 - TargetField = this; 280 - Vector2 position = TargetField.WorldPoint(location, coordSys); 281 - Danmaku danmaku = Danmaku.GetInactive(prefab, position, rotation); 282 - danmaku.Activate(); 283 - danmaku.Speed = speed; 284 - danmaku.AngularSpeed = 0f; 285 - activeDanmaku.Add(danmaku); 286 - return danmaku; 287 - } 288 - 289 - public Danmaku FireCurved(DanmakuPrefab prefab, 290 - Vector2 location, 291 - float rotation, 292 - float speed, 293 - float angularSpeed, 294 - CoordinateSystem coordSys = CoordinateSystem.View) { 295 - if (TargetField == null) 296 - TargetField = this; 297 - Vector2 position = TargetField.WorldPoint(location, coordSys); 298 - Danmaku danmaku = Danmaku.GetInactive(prefab, position, rotation); 299 - danmaku.Activate(); 300 - danmaku.Speed = speed; 301 - danmaku.AngularSpeed = angularSpeed; 302 - activeDanmaku.Add(danmaku); 303 - return danmaku; 304 - } 305 - 306 - public Danmaku Fire(FireData data) { 307 - if (TargetField == null) 308 - TargetField = this; 309 - Danmaku danmaku = data.Fire(); 310 - activeDanmaku.Add(danmaku); 311 - return danmaku; 312 - } 313 - 314 255 #if UNITY_EDITOR 315 256 private void OnDrawGizmos() { 316 257 Gizmos.color = Color.yellow; ··· 322 263 323 264 public void Bind(FireData fireData) 324 265 { 325 - activeDanmaku.Bind(fireData); 266 + fireData.Controller += DestroyOnLeave; 326 267 } 327 268 328 269 public void Unbind(FireData fireData) 329 270 { 330 - activeDanmaku.Unbind(fireData); 271 + fireData.Controller -= DestroyOnLeave; 272 + } 273 + 274 + void DestroyOnLeave(Danmaku danmaku) 275 + { 276 + if (!bounds.Contains(danmaku.Position)) 277 + danmaku.Destroy(); 331 278 } 332 279 } 333 280
-40
Assets/Dependencies/DanmakU/_Core_/DanmakuGame.cs
··· 1 - // Copyright (c) 2015 James Liu 2 - // 3 - // See the LISCENSE file for copying permission. 4 - 5 - using UnityEngine; 6 - using Hourai; 7 - 8 - namespace Hourai.DanmakU { 9 - 10 - /// <summary> 11 - /// A Game implementation for 2D Danmaku games. 12 - /// </summary> 13 - [AddComponentMenu("Hourai.DanmakU/Danmaku Game")] 14 - public sealed class DanmakuGame : Game { 15 - 16 - [SerializeField] 17 - private float angleResolution = 0.1f; 18 - 19 - [SerializeField] 20 - private int danmakuInitialCount = Danmaku.standardStart; 21 - 22 - [SerializeField] 23 - private int danmakuSpawnOnEmpty = Danmaku.standardSpawn; 24 - 25 - public bool FrameRateIndependent = true; 26 - 27 - protected override void Awake() { 28 - base.Awake(); 29 - Danmaku.Setup(danmakuInitialCount, 30 - danmakuSpawnOnEmpty, 31 - angleResolution); 32 - } 33 - 34 - private void OnLevelWasLoaded(int level) { 35 - Danmaku.DeactivateAll(); 36 - } 37 - 38 - } 39 - 40 - }
-12
Assets/Dependencies/DanmakU/_Core_/DanmakuGame.cs.meta
··· 1 - fileFormatVersion: 2 2 - guid: abc5854c68616b4438f7892b026c5b76 3 - timeCreated: 1441237561 4 - licenseType: Free 5 - MonoImporter: 6 - serializedVersion: 2 7 - defaultReferences: [] 8 - executionOrder: 0 9 - icon: {instanceID: 0} 10 - userData: 11 - assetBundleName: 12 - assetBundleVariant:
+5 -5
Assets/Dependencies/DanmakU/_Core_/DanmakuGroup.cs
··· 38 38 else 39 39 list = new List<Danmaku>(source); 40 40 return new DanmakuGroup(list); 41 - } 41 + } 42 42 43 43 public DanmakuGroup(ICollection<Danmaku> collection) 44 44 { ··· 49 49 return; 50 50 foreach (Danmaku danmaku in _group) 51 51 if (danmaku != null) 52 - danmaku.OnDeactivate += RemoveEvent; 52 + danmaku.OnDestroy += RemoveEvent; 53 53 } 54 54 55 55 public void AddRange(IEnumerable<Danmaku> collection) { ··· 59 59 if(OnAdd == null) 60 60 foreach (var danmaku in collection) { 61 61 if (danmaku != null) 62 - danmaku.OnDeactivate += RemoveEvent; 62 + danmaku.OnDestroy += RemoveEvent; 63 63 _group.Add(danmaku); 64 64 } 65 65 else 66 66 foreach (Danmaku danmaku in collection) { 67 67 if (danmaku != null) { 68 - danmaku.OnDeactivate += RemoveEvent; 68 + danmaku.OnDestroy += RemoveEvent; 69 69 OnAdd(danmaku); 70 70 } 71 71 _group.Add(danmaku); ··· 118 118 public void Add(Danmaku item) { 119 119 _group.Add(item); 120 120 if (item != null) 121 - item.OnDeactivate += RemoveEvent; 121 + item.OnDestroy += RemoveEvent; 122 122 123 123 } 124 124
-214
Assets/Dependencies/DanmakU/_Core_/DanmakuPool.cs
··· 1 - // Copyright (c) 2015 James Liu 2 - // 3 - // See the LISCENSE file for copying permission. 4 - 5 - using System; 6 - using UnityEngine; 7 - 8 - /// <summary> 9 - /// A development kit for quick development of 2D Danmaku games 10 - /// </summary> 11 - 12 - namespace Hourai.DanmakU { 13 - 14 - internal class DanmakuPool { 15 - 16 - //FIXME: Currently not working: optimized version of pool, need to debug 17 - 18 - // internal Danmaku[] all; 19 - // 20 - // internal int totalCount; 21 - // internal int spawnCount; 22 - // internal int activeIndex; 23 - // 24 - // public DanmakuPool(int initial, int spawn) { 25 - // this.spawnCount = spawn; 26 - // totalCount = 0; 27 - // activeIndex = 0; 28 - // all = new Danmaku[Mathf.NextPowerOfTwo(initial + 1)]; 29 - // Spawn(initial); 30 - // } 31 - // 32 - // private void Spawn(int count) { 33 - // int endCount = totalCount + count; 34 - // if(all.Length < endCount) { 35 - // //Debug.Log("extend"); 36 - // 37 - // Danmaku[] temp = new Danmaku[Mathf.NextPowerOfTwo(endCount + 1)]; 38 - // Array.Copy(all, temp, all.Length); 39 - // // int test = 0; 40 - // // while(all[test] != null) { 41 - // // test++; 42 - // // } 43 - // // Debug.Log(test); 44 - // all = temp; 45 - // } 46 - // for(int i = totalCount; i < endCount; i++) { 47 - // Danmaku newDanmaku = new Danmaku(); 48 - // newDanmaku.poolIndex = i; 49 - // newDanmaku.Pool = this; 50 - // all[i] = newDanmaku; 51 - // } 52 - // totalCount = endCount; 53 - // } 54 - // 55 - // public void Get(Danmaku[] danmaku) { 56 - // if (danmaku == null) 57 - // throw new ArgumentNullException ("Danmaku array can't be null"); 58 - // int count = danmaku.Length; 59 - // if(count + activeIndex > totalCount) 60 - // Spawn (count); 61 - // Array.Copy(all, activeIndex + 1, danmaku, 0, count); 62 - // activeIndex += count; 63 - // } 64 - // 65 - // public void Return(Danmaku[] danmaku) { 66 - // if(danmaku == null) 67 - // throw new ArgumentNullException ("Danmaku array can't be null"); 68 - // int count = danmaku.Length; 69 - // for(int i = 0; i < count; i++) { 70 - // Return(danmaku[i]); 71 - // } 72 - // } 73 - // 74 - // #region IPool implementation 75 - // 76 - // public Danmaku Get () { 77 - // activeIndex++; 78 - // if (activeIndex >= totalCount) { 79 - // Spawn(spawnCount); 80 - // } 81 - // // if (all [activeCount] == null) { 82 - // // Debug.Log(activeCount); 83 - // // } 84 - // return all [activeIndex]; 85 - // } 86 - // 87 - // public void Return (Danmaku obj) { 88 - // int deadIndex = obj.poolIndex;; 89 - // Danmaku temp = all [activeIndex]; 90 - // all [activeIndex] = obj; 91 - // all [deadIndex] = temp; 92 - // obj.poolIndex = activeIndex; 93 - // temp.poolIndex = deadIndex; 94 - // activeIndex--; 95 - // } 96 - // 97 - // #endregion 98 - // 99 - // #region IPool implementation 100 - // 101 - // object IPool.Get () { 102 - // return Get (); 103 - // } 104 - // 105 - // public void Return (object obj) { 106 - // Return (obj as Danmaku); 107 - // } 108 - // 109 - // #endregion 110 - 111 - internal Danmaku[] all; 112 - private int currentIndex; 113 - private int endIndex; 114 - internal int inactiveCount; 115 - 116 - internal int[] queue; 117 - private int size; 118 - internal int spawnCount; 119 - internal int totalCount; 120 - 121 - public DanmakuPool(int initial, int spawn) { 122 - spawnCount = spawn; 123 - totalCount = 0; 124 - inactiveCount = 0; 125 - Spawn(initial); 126 - } 127 - 128 - protected void Spawn(int count) { 129 - if (all == null || queue == null) { 130 - all = new Danmaku[2]; 131 - queue = new int[2]; 132 - } 133 - 134 - int endCount = totalCount + count; 135 - if (all.Length < endCount) { 136 - size = all.Length; 137 - if (size <= endCount) 138 - size = Mathf.NextPowerOfTwo(endCount); 139 - 140 - Danmaku[] temp = new Danmaku[size]; 141 - 142 - Array.Copy(all, temp, all.Length); 143 - all = temp; 144 - 145 - int[] tempQueue = new int[size]; 146 - 147 - // if the queue's current index is less than the end index, the queue has not wrapped around 148 - // simply copy it as needed 149 - if (currentIndex < endIndex) 150 - Array.Copy(queue, currentIndex, tempQueue, 0, endIndex - currentIndex); 151 - else { 152 - // otherwise the queue has wrapped around and needs to be copied in two seperate chunks 153 - int initial = 0; 154 - initial = queue.Length - currentIndex - 1; 155 - Array.Copy(queue, currentIndex, tempQueue, 0, initial); 156 - Array.Copy(queue, 0, tempQueue, initial, endIndex); 157 - } 158 - currentIndex = 0; 159 - endIndex = inactiveCount; 160 - queue = tempQueue; 161 - } 162 - for (var i = totalCount; i < endCount; i++, endIndex++) { 163 - var danmaku = new Danmaku(i); 164 - all[i] = danmaku; 165 - if (endIndex >= queue.Length) 166 - endIndex = 0; 167 - queue[endIndex] = i; 168 - } 169 - totalCount = endCount; 170 - inactiveCount += count; 171 - } 172 - 173 - public void Get(Danmaku[] danmakus) { 174 - if (danmakus == null) 175 - throw new ArgumentNullException("Projectiles can't be null"); 176 - int count = danmakus.Length; 177 - if (inactiveCount < count) 178 - Spawn(count - inactiveCount); 179 - inactiveCount -= count; 180 - for (var i = 0; i < danmakus.Length; i++) { 181 - danmakus[i] = all[queue[currentIndex]]; 182 - currentIndex = (currentIndex + 1)%size; 183 - } 184 - } 185 - 186 - public void Return(Danmaku[] danmakus) { 187 - if (danmakus == null) 188 - throw new ArgumentNullException("Projectiles can't be null"); 189 - int count = danmakus.Length; 190 - inactiveCount += count; 191 - for (var i = 0; i < count; i++) { 192 - queue[endIndex] = danmakus[i].PoolIndex; 193 - endIndex = (endIndex + 1)%size; 194 - } 195 - } 196 - 197 - public Danmaku Get() { 198 - if (inactiveCount <= 0) 199 - Spawn(spawnCount); 200 - inactiveCount--; 201 - int index = queue[currentIndex]; 202 - currentIndex = (currentIndex + 1)%size; 203 - return all[index]; 204 - } 205 - 206 - public void Return(Danmaku obj) { 207 - queue[endIndex] = obj.PoolIndex; 208 - endIndex = (endIndex + 1)%size; 209 - inactiveCount++; 210 - } 211 - 212 - } 213 - 214 - }
+2 -2
Assets/Dependencies/DanmakU/_Core_/DanmakuPool.cs.meta Assets/Dependencies/DanmakU/_Core_/Flters.cs.meta
··· 1 1 fileFormatVersion: 2 2 - guid: 53e899c4b334fc9429f240945c2257a4 3 - timeCreated: 1441237559 2 + guid: e7d846d4fd9081141922737e595c8832 3 + timeCreated: 1441333579 4 4 licenseType: Free 5 5 MonoImporter: 6 6 serializedVersion: 2
+441 -258
Assets/Dependencies/DanmakU/_Core_/DanmakuPrefab.cs
··· 2 2 // 3 3 // See the LISCENSE file for copying permission. 4 4 5 + using System; 5 6 using System.Collections; 6 7 using System.Collections.Generic; 7 8 using UnityEngine; 8 9 using UnityEngine.Rendering; 9 10 using Vexe.Runtime.Types; 11 + using Vexe.Runtime.Extensions; 12 + using System.Linq; 10 13 #if UNITY_EDITOR 11 14 using UnityEditor; 12 15 #endif 13 16 14 17 namespace Hourai.DanmakU { 15 18 16 - public class DanmakuType : MonoBehaviour 19 + [RequireComponent(typeof(ParticleSystem))] 20 + public abstract class DanmakuType : MonoBehaviour, IEnumerable<Danmaku> 17 21 { 18 - } 22 + private DanmakuPrefab prefab; 19 23 20 - /// <summary> 21 - /// A container behavior used on prefabs to define how a bullet looks or behaves 22 - /// </summary> 23 - [DisallowMultipleComponent] 24 - [AddComponentMenu("Hourai.DanmakU/Danmaku Prefab")] 25 - public sealed class DanmakuPrefab : BetterBehaviour, IEnumerable<FireData> { 24 + public List<Danmaku> toDestroy; 26 25 27 - public enum RenderingType { 26 + // Pool variables 27 + internal Danmaku[] all; 28 + internal int _totalCount; 29 + internal int _spawnCount; 30 + internal int _activeCount; 31 + internal int _releasedCount; 28 32 29 - Sprite, 30 - Mesh 33 + // Particle System variables 34 + private ParticleSystem danmakuSystem; 35 + private ParticleSystemRenderer dRenderer; 36 + private ParticleSystem.Particle[] particles; 31 37 38 + // Rendedring variables 39 + internal Mesh mesh; 40 + internal Color color; 41 + internal Material material; 42 + internal int sortingLayer; 43 + internal int sortingOrder; 44 + 45 + #region Public Properties 46 + public int IotalCount { 47 + get { return _totalCount; } 32 48 } 33 49 34 - private void Update() { 35 - danmakuCount = currentDanmaku.Count; 36 - if (danmakuCount <= 0) 37 - return; 38 - int count = runtimeSystem.particleCount; 39 - if (danmakuCount > count) { 40 - runtimeSystem.maxParticles = Mathf.NextPowerOfTwo(danmakuCount); 41 - runtimeSystem.Emit(danmakuCount - count); 50 + public int ActiveCount { 51 + get { return _activeCount; } 52 + } 53 + 54 + public int SpawnCount { 55 + get { return _spawnCount; } 56 + set { _spawnCount = value; } 57 + } 58 + 59 + public int SortingLayer { 60 + get { return sortingLayer; } 61 + set { 62 + sortingLayer = value; 63 + dRenderer.sortingLayerID = value; 42 64 } 43 - if (danmakuCount > particles.Length) { 44 - particles = 45 - new ParticleSystem.Particle[ 46 - Mathf.NextPowerOfTwo(danmakuCount + 1)]; 65 + } 66 + 67 + public int SortingOrder { 68 + get { return sortingOrder; } 69 + set { 70 + sortingOrder = value; 71 + dRenderer.sortingOrder = value; 47 72 } 73 + } 48 74 49 - runtimeSystem.GetParticles(particles); 75 + public Mesh Mesh { 76 + get { return mesh; } 77 + } 50 78 51 - if (fixedAngle) { 52 - for (var i = 0; i < danmakuCount; i++) { 53 - Danmaku danmaku = currentDanmaku[i]; 54 - particles[i].position = danmaku.position; 55 - particles[i].size = danmaku.Scale; 56 - particles[i].lifetime = 1000; 57 - particles[i].color = danmaku.Color; 58 - } 59 - } else { 60 - Vector3 forward = Vector3.forward; 61 - for (var i = 0; i < danmakuCount; i++) { 62 - Danmaku danmaku = currentDanmaku[i]; 63 - particles[i].position = danmaku.position; 64 - particles[i].rotation = danmaku.rotation; 65 - particles[i].size = danmaku.Scale; 66 - particles[i].axisOfRotation = forward; 67 - particles[i].color = danmaku.Color; 68 - particles[i].lifetime = 1000; 69 - } 79 + public Color Color { 80 + get { return color; } 81 + set { 82 + color = value; 83 + danmakuSystem.startColor = value; 70 84 } 71 - runtimeSystem.SetParticles(particles, danmakuCount); 72 85 } 73 86 74 - public void Awake() { 75 - Vector3[] vertexes; 87 + public Material Material { 88 + get { return material; } 89 + } 90 + #endregion 76 91 77 - var singleRenderer = GetComponent<Renderer>(); 78 - var spriteRenderer = singleRenderer as SpriteRenderer; 79 - var meshRenderer = singleRenderer as MeshRenderer; 80 - if (singleRenderer == null || 81 - (spriteRenderer == null && meshRenderer == null)) { 82 - Debug.LogError("Danmaku Prefab (" + name + 83 - ") has neither SpriteRenderer or MeshRenderer. Attach one or the other to it."); 84 - Destroy(this); 85 - return; 86 - } 92 + #region Initialization 93 + void Awake() 94 + { 95 + DontDestroyOnLoad(this); 96 + danmakuSystem = GetComponent<ParticleSystem>(); 97 + dRenderer = GetComponent<ParticleSystemRenderer>(); 98 + 99 + Transform root = transform.root; 100 + transform.parent = null; 101 + transform.localPosition = Vector3.zero; 102 + 103 + danmakuSystem.simulationSpace = ParticleSystemSimulationSpace.World; 104 + danmakuSystem.startSize = 1; 105 + danmakuSystem.startLifetime = float.PositiveInfinity; 106 + danmakuSystem.gravityModifier = 0f; 107 + danmakuSystem.startSpeed = 0; 108 + danmakuSystem.enableEmission = false; 109 + 110 + particles = new ParticleSystem.Particle[danmakuSystem.particleCount]; 111 + dRenderer.renderMode = ParticleSystemRenderMode.Mesh; 87 112 88 - singleRenderer.enabled = false; 113 + dRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off; 114 + dRenderer.receiveShadows = false; 115 + dRenderer.shadowCastingMode = ShadowCastingMode.Off; 116 + dRenderer.useLightProbes = false; 89 117 90 - foreach ( 91 - Component otherComponent in GetComponentsInChildren<Component>() 92 - ) { 93 - if (otherComponent != this && !(otherComponent is Transform)) 94 - Destroy(otherComponent); 95 - } 118 + //gameObject.hideFlags = HideFlags.HideInHierarchy; 96 119 120 + // Destroy rest of hiearchy 121 + if(root != transform) 122 + Destroy(root.gameObject); 97 123 gameObject.Children().Destroy(); 98 124 99 - cachedScale = transform.localScale; 100 - cachedTag = gameObject.tag; 101 - cachedLayer = gameObject.layer; 125 + Component[] whitelist = new Component[] { this, danmakuSystem, dRenderer, transform }; 126 + foreach (Component comp in GetComponents<Component>()) 127 + if (!whitelist.Contains(comp)) 128 + Destroy(comp); 129 + } 102 130 103 - if (danmakuSystemPrefab != null) 104 - runtimeSystem = Instantiate(danmakuSystemPrefab); 105 - if (runtimeSystem == null) { 106 - GameObject runtimeObject = 107 - Instantiate(Resources.Load("Danmaku Particle System")) as 108 - GameObject; 109 - if (runtimeObject == null) 110 - runtimeObject = new GameObject(name); 111 - if (runtimeSystem == null) 112 - runtimeSystem = runtimeObject.GetComponent<ParticleSystem>(); 113 - if (runtimeSystem == null) 114 - runtimeSystem = runtimeObject.AddComponent<ParticleSystem>(); 131 + // MUST be called from a DanmakuPrefab 132 + internal void Init(Renderer renderer, DanmakuPrefab prefab) 133 + { 134 + if (!prefab) 135 + throw new ArgumentNullException("prefab"); 136 + 137 + this.prefab = prefab; 138 + 139 + _totalCount = 0; 140 + _activeCount = 0; 141 + _spawnCount = prefab.spawnCount; 142 + if (_spawnCount <= 0) 143 + _spawnCount = 1; 144 + all = new Danmaku[prefab.initialCount * 2]; 145 + Spawn(prefab.initialCount); 146 + toDestroy = new List<Danmaku>(); 147 + 148 + material = renderer.sharedMaterial; 149 + sortingLayer = renderer.sortingLayerID; 150 + sortingOrder = renderer.sortingOrder; 151 + mesh = new Mesh(); 152 + 153 + OnInit(renderer); 154 + 155 + Matrix4x4 rot = Matrix4x4.TRS(Vector3.zero, 156 + Quaternion.Euler(0f, 0f, prefab.rotationOffset), 157 + prefab.transform.localScale); 158 + Vector3[] verts = mesh.vertices; 159 + for (int i = 0; i < verts.Length; i++) 160 + verts[i] = rot * verts[i]; 161 + mesh.vertices = verts; 162 + 163 + dRenderer.mesh = mesh; 164 + 165 + danmakuSystem.startColor = color; 166 + dRenderer.sharedMaterial = material; 167 + dRenderer.sortingLayerID = sortingLayer; 168 + dRenderer.sortingOrder = sortingOrder; 169 + } 170 + 171 + internal abstract void OnInit(Renderer renderer); 172 + #endregion 173 + public bool updating; 174 + 175 + void Update() 176 + { 177 + //-------------------------------------------------------------------- 178 + // Rendering Update 179 + //-------------------------------------------------------------------- 180 + int particleCount = danmakuSystem.particleCount; 181 + if (_activeCount > particleCount) 182 + { 183 + danmakuSystem.maxParticles = Mathf.NextPowerOfTwo(_activeCount); 184 + danmakuSystem.Emit(_activeCount - particleCount); 115 185 } 186 + if (_activeCount > particles.Length) 187 + Array.Resize(ref particles, Mathf.NextPowerOfTwo(_activeCount + 1)); 116 188 117 - Transform runtimeTransform = runtimeSystem.transform; 189 + if (_activeCount <= 0 && particleCount <= 0) 190 + return; 191 + 192 + danmakuSystem.GetParticles(particles); 193 + int staticActiveCount = _activeCount; 194 + 195 + updating = true; 196 + 197 + // For some reason, new ParticleSystem.Particle breaks bullet systems 198 + // but accessing a 199 + ParticleSystem.Particle particle = particles[0]; 200 + particle.axisOfRotation = Vector3.forward; 201 + int i = 0; 202 + if (prefab.fixedAngle) { 203 + while (i < staticActiveCount) { 204 + Danmaku danmaku = all[i]; 205 + danmaku.Update(); 206 + particle.position = danmaku.position; 207 + particle.size = danmaku.Scale; 208 + particle.color = danmaku.Color; 209 + particles[i] = particle; 210 + i++; 211 + } 212 + } 213 + else 214 + { 215 + while (i < staticActiveCount) 216 + { 217 + Danmaku danmaku = all[i]; 218 + danmaku.Update(); 219 + particle.position = danmaku.position; 220 + particle.rotation = danmaku.rotation; 221 + particle.size = danmaku.Scale; 222 + particle.color = danmaku.Color; 223 + particles[i] = particle; 224 + i++; 225 + } 226 + } 227 + updating = false; 228 + // Destroy extra particles 229 + while (i < particleCount) { 230 + particles[i].lifetime = 0; 231 + i++; 232 + } 233 + 234 + int destroyedCount = toDestroy.Count; 235 + // Remove destroyed particles 236 + for (i = 0; i < destroyedCount; i++) 237 + toDestroy[i].DestroyImpl(); 238 + toDestroy.Clear(); 239 + 240 + danmakuSystem.SetParticles(particles, _activeCount); 241 + } 242 + 243 + protected virtual void OnDestroy() { 244 + Destroy(mesh); 245 + } 246 + 247 + public void DestroyAll() 248 + { 249 + for (int i = 0; i < _activeCount; i++) 250 + all[i].Destroy(); 251 + } 252 + 253 + void Spawn(int count) 254 + { 255 + int endCount = _totalCount + count; 256 + if (all.Length < endCount) 257 + Array.Resize(ref all, Mathf.NextPowerOfTwo(endCount + 1)); 258 + for (int i = _totalCount; i < all.Length; i++) 259 + all[i] = new Danmaku(i); 260 + _totalCount = endCount; 261 + } 262 + 263 + #region Pooling Functions 264 + /// <summary> 265 + /// Retrievese a inactive Danmaku from the pool. 266 + /// The Danmaku wil not be rendered or be updated until Activate is called on it. 267 + /// </summary> 268 + /// <returns></returns> 269 + public Danmaku Get() 270 + { 271 + if (_releasedCount >= _totalCount) 272 + Spawn(_spawnCount); 273 + Danmaku inactive = all[_releasedCount]; 274 + inactive.Color = color; 275 + inactive.prefab = prefab; 276 + inactive.Scale = 1f; 277 + _releasedCount++; 278 + return inactive; 279 + } 280 + 281 + internal void Activate(Danmaku danmaku) 282 + { 283 + Danmaku active = all[_activeCount]; // This should be a released but not active bullet 284 + all[danmaku.PoolIndex] = active; 285 + all[active.PoolIndex] = danmaku; 286 + 287 + active.PoolIndex = danmaku.PoolIndex; 288 + danmaku.PoolIndex = _activeCount; 289 + _activeCount++; 290 + } 291 + 292 + internal void Return(Danmaku danmaku) 293 + { 294 + Danmaku released = all[_releasedCount]; 295 + Danmaku active = all[_activeCount]; 118 296 119 - //runtimeTransform.parent = null; 120 - runtimeTransform.localPosition = Vector3.zero; 297 + all[_releasedCount] = danmaku; 298 + all[_activeCount] = released; 299 + all[danmaku.PoolIndex] = active; 121 300 122 - runtimeRenderer = 123 - runtimeSystem.GetComponent<ParticleSystemRenderer>(); 301 + released.PoolIndex = active.PoolIndex; 302 + active.PoolIndex = danmaku.PoolIndex; 303 + danmaku.PoolIndex = _releasedCount; 124 304 125 - renderMesh = new Mesh(); 305 + _activeCount--; 306 + _releasedCount--; 307 + } 308 + #endregion 126 309 127 - if (meshRenderer == null) { 128 - renderingType = RenderingType.Sprite; 129 - singleRenderer = spriteRenderer; 130 - cachedSprite = spriteRenderer.sprite; 131 - cachedColor = spriteRenderer.color; 132 - cachedMaterial = spriteRenderer.sharedMaterial; 133 - cachedSortingLayer = spriteRenderer.sortingLayerID; 134 - cachedSortingOrder = spriteRenderer.sortingOrder; 310 + #region IEnumerable Implementation 311 + public IEnumerator<Danmaku> GetEnumerator() 312 + { 313 + for (var i = 0; i < _activeCount; i++) 314 + yield return all[i]; 315 + } 135 316 136 - //renderMaterial = cachedMaterial; 317 + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 318 + { 319 + return GetEnumerator(); 320 + } 321 + #endregion 322 + } 137 323 138 - renderMaterial = new Material(cachedMaterial); 139 - renderMaterial.mainTexture = Sprite.texture; 324 + internal sealed class SpriteDanmaku : DanmakuType { 140 325 141 - if (cachedSprite == null) 142 - runtimeRenderer.mesh = null; 143 - else { 144 - var verts = cachedSprite.vertices; 145 - var tris = cachedSprite.triangles; 326 + internal override void OnInit(Renderer renderer) 327 + { 328 + SpriteRenderer sr = renderer as SpriteRenderer; 329 + if (sr == null) 330 + return; 331 + //cachedSprite = renderer.sprite; 332 + color = sr.color; 146 333 147 - vertexes = new Vector3[verts.Length]; 148 - int[] triangles = new int[tris.Length]; 334 + Sprite sprite = sr.sprite; 335 + material = new Material(material); 336 + material.mainTexture = sprite.texture; 149 337 150 - Matrix4x4 rot = Matrix4x4.TRS(Vector3.zero, 151 - Quaternion.Euler(0f, 0f, rotationOffset), 152 - Vector3.one); 338 + if (sprite == null) 339 + Destroy(mesh); 340 + else 341 + { 342 + var verts = sprite.vertices; 343 + var tris = sprite.triangles; 153 344 154 - for (int i = 0; i < verts.Length; i++) 155 - vertexes[i] = rot * verts[i]; 345 + var vertexes = new Vector3[verts.Length]; 346 + int[] triangles = new int[tris.Length]; 156 347 157 - for (int i = 0; i < tris.Length; i++) 158 - triangles[i] = tris[i]; 348 + for (int i = 0; i < verts.Length; i++) 349 + vertexes[i] = verts[i]; 159 350 160 - renderMesh.vertices = vertexes; 161 - renderMesh.uv = cachedSprite.uv; 162 - renderMesh.triangles = triangles; 163 - } 164 - } else { 165 - renderingType = RenderingType.Mesh; 166 - singleRenderer = meshRenderer; 167 - cachedSprite = null; 168 - cachedColor = Color.white; 169 - cachedMaterial = meshRenderer.sharedMaterial; 170 - cachedSortingLayer = meshRenderer.sortingLayerID; 171 - cachedSortingOrder = meshRenderer.sortingOrder; 351 + for (int i = 0; i < tris.Length; i++) 352 + triangles[i] = tris[i]; 172 353 173 - renderMaterial = meshRenderer.sharedMaterial; 174 - MeshFilter filter = meshRenderer.GetComponent<MeshFilter>(); 175 - if (filter == null) { 176 - Debug.LogError("Danmaku Prefab (" + name + 177 - ") is trying to use a MeshRenderer as a base, but no MeshFilter is found. Please add one."); 178 - } else { 179 - Mesh filterMesh = filter.mesh; 180 - renderMesh.vertices = filterMesh.vertices; 181 - renderMesh.uv = filterMesh.uv; 182 - renderMesh.triangles = filterMesh.triangles; 183 - renderMesh.colors = filterMesh.colors; 184 - renderMesh.normals = filterMesh.normals; 185 - renderMesh.tangents = filterMesh.tangents; 186 - } 354 + mesh.vertices = vertexes; 355 + mesh.uv = sprite.uv; 356 + mesh.triangles = triangles; 187 357 } 358 + } 188 359 189 - if (renderMesh != null) { 190 - //Scale the mesh as necessary based on prefab's scale 360 + protected override void OnDestroy() 361 + { 362 + base.OnDestroy(); 363 + Destroy(material); 364 + } 365 + } 191 366 192 - Matrix4x4 transformMatrix = Matrix4x4.TRS(Vector3.zero, 193 - Quaternion.identity, 194 - transform.localScale); 195 - vertexes = renderMesh.vertices; 196 - for (int i = 0; i < vertexes.Length; i++) { 197 - //Debug.Log(vertexes[i]); 198 - vertexes[i] = transformMatrix*vertexes[i]; 199 - } 200 - renderMesh.vertices = vertexes; 201 - renderMesh.Optimize(); 367 + internal sealed class MeshDanmaku : DanmakuType 368 + { 369 + internal override void OnInit(Renderer renderer) 370 + { 371 + var mr = renderer as MeshRenderer; 372 + if (mr == null) 373 + return; 374 + color = Color.white; 375 + 376 + MeshFilter filter = mr.GetComponent<MeshFilter>(); 377 + Debug.Log(filter); 378 + if (filter == null) 379 + { 380 + Debug.LogError("Danmaku Prefab (" + name + 381 + ") is trying to use a MeshRenderer as a base, but no MeshFilter is found. Please add one."); 382 + } 383 + else 384 + { 385 + Mesh fMesh = filter.sharedMesh; 386 + mesh.vertices = fMesh.vertices; 387 + mesh.uv = fMesh.uv; 388 + mesh.triangles = fMesh.triangles; 389 + mesh.colors = fMesh.colors; 390 + mesh.normals = fMesh.normals; 391 + mesh.tangents = fMesh.tangents; 202 392 } 393 + } 394 + } 395 + 396 + /// <summary> 397 + /// A container behavior used on prefabs to define how a bullet looks or behaves 398 + /// </summary> 399 + [DisallowMultipleComponent] 400 + [AddComponentMenu("Hourai.DanmakU/Danmaku Prefab")] 401 + public sealed class DanmakuPrefab : BetterBehaviour, IEnumerable<FireData> { 203 402 204 - runtimeRenderer.mesh = renderMesh; 403 + public enum RenderingType { 404 + 405 + Sprite, 406 + Mesh 407 + 408 + } 409 + 410 + void Awake() 411 + { 412 + Destroy(gameObject); 413 + } 414 + 415 + void Init() 416 + { 417 + var singleRenderer = GetComponent<Renderer>(); 418 + var spriteRenderer = singleRenderer as SpriteRenderer; 419 + var meshRenderer = singleRenderer as MeshRenderer; 420 + if (spriteRenderer == null && meshRenderer == null) 421 + { 422 + Debug.LogError("Danmaku Prefab (" + name + 423 + ") has neither SpriteRenderer or MeshRenderer. Attach one or the other to it."); 424 + Destroy(this); 425 + return; 426 + } 205 427 206 - //singleRenderer.enabled = false; 207 - //GetComponent<CircleCollider2D>().enabled = false; 208 - //Disable all other components 209 - foreach (Behaviour comp in GetComponentsInChildren<Behaviour>()) { 210 - if (comp != this) 211 - comp.enabled = false; 428 + ParticleSystem system = null; 429 + if (danmakuSystemPrefab != null) 430 + system = Instantiate(danmakuSystemPrefab); 431 + if (system == null) 432 + { 433 + GameObject runtimeObject = 434 + Instantiate(Resources.Load("Danmaku Particle System")) as 435 + GameObject ?? new GameObject(name); 436 + system = runtimeObject.GetOrAddComponent<ParticleSystem>(); 212 437 } 438 + if(meshRenderer) 439 + type = system.gameObject.AddComponent<MeshDanmaku>(); 440 + else 441 + type = system.gameObject.AddComponent<SpriteDanmaku>(); 442 + type.Init(singleRenderer, this); 443 + type.gameObject.SetActive(true); 444 + } 213 445 214 - runtimeSystem.simulationSpace = ParticleSystemSimulationSpace.World; 215 - runtimeSystem.startColor = cachedColor; 216 - runtimeSystem.startSize = 1; 217 - runtimeSystem.startLifetime = float.PositiveInfinity; 218 - runtimeSystem.gravityModifier = 0f; 219 - runtimeSystem.startSpeed = 0f; 220 - runtimeSystem.enableEmission = false; 446 + public Danmaku Get() 447 + { 448 + if (!type) 449 + Init(); 450 + return type.Get(); 451 + } 221 452 222 - currentDanmaku = new List<Danmaku>(); 223 - currentGroup = new DanmakuGroup(currentDanmaku); 224 - particles = new ParticleSystem.Particle[runtimeSystem.particleCount]; 453 + public void Match(Danmaku danmaku) 454 + { 455 + throw new System.Exception(); 456 + if (danmaku.prefab != this) 457 + { 458 + danmaku.prefab = this; 225 459 226 - runtimeRenderer.mesh = renderMesh; 227 - runtimeRenderer.renderMode = ParticleSystemRenderMode.Mesh; 460 + // TODO: Figure out how to transfer Danmaku from pool to pool here 461 + 462 + danmaku.colliderType = collisionType; 463 + switch (collisionType) 464 + { 465 + default: 466 + danmaku.colliderSize = Vector2.zero; 467 + break; 468 + case Danmaku.ColliderType.Circle: 469 + danmaku.colliderSize = colliderSize * Mathf.Max(cachedScale.x, cachedScale.y); 470 + break; 471 + case Danmaku.ColliderType.Line: 472 + danmaku.colliderSize = colliderSize; 473 + break; 474 + } 475 + danmaku.sizeSquared = colliderSize.y * colliderSize.y; 476 + danmaku.colliderOffset = cachedScale.Hadamard2(colliderOffset); 477 + } 228 478 229 - runtimeRenderer.sharedMaterial = renderMaterial; 230 - runtimeRenderer.sortingLayerID = cachedSortingLayer; 231 - runtimeRenderer.sortingOrder = cachedSortingOrder; 232 - runtimeRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off; 233 - runtimeRenderer.receiveShadows = false; 234 - runtimeRenderer.shadowCastingMode = ShadowCastingMode.Off; 235 - runtimeRenderer.useLightProbes = false; 479 + danmaku.Color = cachedColor; 480 + danmaku.Scale = 1f; 481 + danmaku.Layer = cachedLayer; 482 + } 236 483 237 - gameObject.hideFlags = HideFlags.HideInHierarchy; 238 - runtimeSystem.gameObject.hideFlags = HideFlags.HideInHierarchy; 484 + void Initialize() 485 + { 486 + cachedScale = transform.localScale; 487 + cachedTag = gameObject.tag; 488 + cachedLayer = gameObject.layer; 239 489 } 240 490 241 491 #if UNITY_EDITOR ··· 281 531 #endif 282 532 283 533 private void OnDestroy() { 284 - if (runtimeSystem != null) 285 - Destroy(runtimeSystem.gameObject); 286 - if (renderMesh != null) 287 - Destroy(renderMesh); 288 - } 289 - 290 - internal DanmakuPrefab GetRuntime() { 291 - if (runtime == null) 292 - runtime = CreateRuntimeInstance(this); 293 - return runtime; 294 - } 295 - 296 - private static DanmakuPrefab CreateRuntimeInstance(DanmakuPrefab prefab) { 297 - DanmakuPrefab runtime = Instantiate(prefab); 298 - runtime.enabled = true; 299 - runtime.gameObject.SetActive(true); 300 - return runtime; 534 + if (type) 535 + Destroy(type.gameObject); 301 536 } 302 537 303 538 public static implicit operator FireData(DanmakuPrefab prefab) { ··· 319 554 internal Vector2 colliderOffset; 320 555 321 556 [Serialize, fSlider(-180f, 180f)] 322 - private float rotationOffset; 557 + internal float rotationOffset; 323 558 324 559 #if UNITY_EDITOR 325 560 public override void Reset() { ··· 346 581 [Serialize] 347 582 internal bool fixedAngle; 348 583 584 + [Serialize, Default(1000)] 585 + internal int initialCount; 586 + 587 + [Serialize, Default(100)] 588 + internal int spawnCount; 589 + 349 590 internal Vector3 cachedScale; 350 591 internal string cachedTag; 351 592 internal int cachedLayer; ··· 360 601 361 602 #region Runtime fields 362 603 363 - private DanmakuPrefab runtime; 364 - private Mesh renderMesh; 365 - private Material renderMaterial; 366 - private ParticleSystem runtimeSystem; 367 - private ParticleSystemRenderer runtimeRenderer; 368 - private ParticleSystem.Particle[] particles; 369 - internal List<Danmaku> currentDanmaku; 604 + internal DanmakuType type; 605 + private HashSet<Danmaku> currentDanmaku; 370 606 internal DanmakuGroup currentGroup; 371 - private int danmakuCount; 372 - private RenderingType renderingType; 373 607 374 608 #endregion 375 609 376 610 #region Accessor Properties 377 611 378 - public RenderingType RenderType { 379 - get { return renderingType; } 380 - } 381 - 382 612 public bool FixedAngle { 383 613 get { return fixedAngle; } 384 614 } 385 615 386 - public Vector3 Scale { 387 - get { return cachedScale; } 388 - } 389 - 390 - public string Tag { 391 - get { return cachedTag; } 392 - } 393 - 394 - public int Layer { 395 - get { return cachedLayer; } 396 - } 397 - 398 616 /// <summary> 399 617 /// Gets the radius of the instance's collider 400 618 /// </summary> ··· 411 629 get { return colliderOffset; } 412 630 } 413 631 414 - /// <summary> 415 - /// Gets the sprite of the instance's SpriteRenderer 416 - /// </summary> 417 - /// <value>The sprite to be rendered.</value> 418 - public Sprite Sprite { 419 - get { return cachedSprite; } 420 - } 421 - 422 - public Mesh Mesh { 423 - get { return renderMesh; } 424 - } 425 - 426 - /// <summary> 427 - /// Gets the color of the instance's SpriteRenderer 428 - /// </summary> 429 - /// <value>The color to be rendered with.</value> 430 - public Color Color { 431 - get { return cachedColor; } 432 - } 433 - 434 - /// <summary> 435 - /// Gets the material used by the instance's SpriteRenderer 436 - /// </summary> 437 - /// <value>The material to be rendered with.</value> 438 - public Material Material { 439 - get { return cachedMaterial; } 440 - } 441 - 442 - /// <summary> 443 - /// Gets the sorting layer 444 - /// </summary> 445 - /// <value>The sorting layer to be used when rendering.</value> 446 - public int SortingLayerID { 447 - get { return cachedSortingLayer; } 448 - } 449 - 450 - public int SortingOrder { 451 - get { return cachedSortingOrder; } 632 + public DanmakuType Renderer 633 + { 634 + get { return type; } 452 635 } 453 636 454 637 #endregion 455 638 456 639 public IEnumerable Infinite() { 457 - return ((FireData)this).Infinite(); 640 + return new FireData() { Prefab = this }.Infinite(); 458 641 } 459 642 460 643 public IEnumerator<FireData> GetEnumerator() { 461 - yield return ((FireData) this); 644 + yield return new FireData() { Prefab = this }; 462 645 } 463 646 464 647 IEnumerator System.Collections.IEnumerable.GetEnumerator()
+103 -270
Assets/Dependencies/DanmakU/_Core_/DanmakuStatic.cs
··· 29 29 internal const int standardSpawn = 100; 30 30 31 31 private static int[] collisionMask; 32 - private static DanmakuPool danmakuPool; 33 32 34 33 /// <summary> 35 34 /// A cached delta time value for procesing bullet updates. ··· 47 46 48 47 static Danmaku() { 49 48 Setup(); 50 - Game.OnUpdate += UpdateAll; 49 + Game.OnUpdate += GlobalUpdate; 51 50 52 - // Deactivate all Danmaku when the 53 - Game.OnLoad += level => DeactivateAll(); 51 + // Destroy all Danmaku when the 52 + Game.OnLoad += level => DestroyAll(); 54 53 } 55 54 56 - public static int TotalCount { 57 - get { return (danmakuPool != null) ? danmakuPool.totalCount : 0; } 58 - } 59 - 60 - public static int ActiveCount { 61 - get { return (danmakuPool != null) ? danmakuPool.totalCount - danmakuPool.inactiveCount : 0; } 55 + static void GlobalUpdate() 56 + { 57 + dt = TimeUtil.DeltaTime; 58 + if (colliderMap.Count > 0) 59 + colliderMap.Clear(); 62 60 } 63 61 64 - internal static void Setup(int initial = standardStart, 65 - int spawn = standardSpawn, 66 - float angRes = 0.1f) { 62 + internal static void Setup(float angRes = 0.1f) { 67 63 colliderMap = new Dictionary<Collider2D, IDanmakuCollider[]>(); 68 64 collisionMask = Util.CollisionLayers2D(); 69 - danmakuPool = new DanmakuPool(initial, spawn); 70 65 } 71 66 72 - /// <summary> 73 - /// Does a frame update on all currently active bullets. 74 - /// This should be called only once per frame. 75 - /// </summary> 76 - static void UpdateAll() { 77 - if(colliderMap.Count > 0) 78 - colliderMap.Clear(); 79 - //caches the change in time since the last frame 80 - dt = TimeUtil.DeltaTime; 81 - Danmaku[] all = danmakuPool.all; 82 - Danmaku danmaku; 83 - for (var i = 0; i < all.Length; i++) { 84 - danmaku = all[i]; 85 - if (danmaku != null && danmaku._isActive) 86 - danmaku.Update(); 87 - } 88 - } 89 - 90 - /// <summary> 91 - /// Deactivates all currently active bullets. 92 - /// </summary> 93 - public static void DeactivateAll() { 94 - Danmaku danmaku; 95 - Danmaku[] all = danmakuPool.all; 96 - for (int i = 0; i < all.Length; i++) { 97 - danmaku = all[i]; 98 - if (danmaku != null && danmaku._isActive) 99 - danmaku.Deactivate(); 100 - } 101 - } 102 - 103 - /// <summary> 104 - /// Deactivates all currently active bullets. 105 - /// </summary> 106 - public static void DeactivateAllImmediate() { 107 - Danmaku[] all = danmakuPool.all; 108 - for (int i = 0; i < all.Length; i++) { 109 - if (all[i] != null && all[i]._isActive) 110 - all[i].DeactivateImmediate(); 111 - } 67 + public static void DestroyAll() { 68 + throw new NotImplementedException(); // TODO: Reimplement 112 69 } 113 70 114 - public static void DeactivateInCircle(Vector2 center, 71 + public static void DestroyInCircle(Vector2 center, 115 72 float radius, 116 73 int layerMask = ~0) { 117 - Danmaku[] all = danmakuPool.all; 118 - Danmaku current; 119 - float sqrRadius = radius*radius; 120 - for (int i = 0; i < all.Length; i++) { 121 - current = all[i]; 122 - if ((layerMask & (1 << current.layer)) != 0 && 123 - sqrRadius >= (current.Position - center).sqrMagnitude) 124 - current.Deactivate(); 125 - } 74 + throw new NotImplementedException(); // TODO: Reimplement 75 + //Danmaku current; 76 + //float sqrRadius = radius*radius; 77 + //for (int i = 0; i < _activeCount; i++) { 78 + // current = all[i]; 79 + // if ((layerMask & (1 << current.layer)) != 0 && 80 + // sqrRadius >= (current.Position - center).sqrMagnitude) 81 + // current.Destroy(); 82 + //} 126 83 } 127 84 128 - public static void DeactivateInCircleImmediate(Vector2 center, 129 - float radius, 130 - int layerMask = ~0) { 131 - Danmaku[] all = danmakuPool.all; 132 - Danmaku current; 133 - float sqrRadius = radius*radius; 134 - for (int i = 0; i < all.Length; i++) { 135 - current = all[i]; 136 - if ((layerMask & (1 << current.layer)) != 0 && 137 - sqrRadius >= (current.Position - center).sqrMagnitude) 138 - current.DeactivateImmediate(); 139 - } 140 - } 85 + public static Danmaku FindByTag(string tag) 86 + { 87 + throw new NotImplementedException(); // TODO: Reimplement 88 + //if (tag == null) 89 + // throw new ArgumentNullException("tag"); 141 90 142 - public static Danmaku FindByTag(string tag) { 143 - if (tag == null) 144 - throw new ArgumentNullException("tag"); 91 + //for (int i = 0; i < _activeCount; i++) 92 + // if (all[i].Tag == tag) 93 + // return all[i]; 145 94 146 - Danmaku current; 147 - Danmaku[] all = danmakuPool.all; 148 - for (int i = 0; i < all.Length; i++) { 149 - current = all[i]; 150 - if (current._isActive && current.Tag == tag) 151 - return current; 152 - } 153 - return null; 95 + //return null; 154 96 } 155 97 156 98 public static Danmaku[] FindAllByTag(string tag) { 157 99 if (tag == null) 158 100 throw new ArgumentNullException("tag"); 101 + throw new NotImplementedException(); // TODO: Reimplement 102 + //List<Danmaku> matches = new List<Danmaku>(); 103 + //for (int i = 0; i < _activeCount; i++) 104 + // if(all[i].Tag == tag) 105 + // matches.Add(all[i]); 159 106 160 - Danmaku current; 161 - List<Danmaku> matches = new List<Danmaku>(); 162 - Danmaku[] all = danmakuPool.all; 163 - for (int i = 0; i < all.Length; i++) { 164 - current = all[i]; 165 - if (current._isActive && current.Tag == tag) 166 - matches.Add(current); 167 - } 168 - return matches.ToArray(); 107 + //return matches.ToArray(); 169 108 } 170 109 171 110 public static int FindAllByTagNoAlloc(string tag, 172 111 IList<Danmaku> list, 173 112 int start = 0) { 113 + 114 + throw new NotImplementedException(); // TODO: Reimplement 115 + //if (tag == null) 116 + // throw new ArgumentNullException("tag"); 117 + //if (list == null) 118 + // throw new ArgumentNullException("collection"); 174 119 175 - if (tag == null) 176 - throw new ArgumentNullException("tag"); 177 - if (list == null) 178 - throw new ArgumentNullException("collection"); 179 - Danmaku current; 180 - int index = start, count = -1, size = list.Count; 181 - Danmaku[] all = danmakuPool.all; 182 - for (var i = 0; i < all.Length; i++) { 183 - current = all[i]; 184 - if (!current._isActive || current.Tag != tag) 185 - continue; 186 - index++; 187 - count++; 188 - list[index] = current; 189 - if (index >= size) 190 - break; 191 - } 192 - return count; 120 + //Danmaku current; 121 + //int index = start, count = -1, size = list.Count; 122 + //for (var i = 0; i < _activeCount; i++) 123 + //{ 124 + // current = all[i]; 125 + // if (current.Tag != tag) 126 + // continue; 127 + // index++; 128 + // count++; 129 + // list[index] = current; 130 + // if (index >= size) 131 + // break; 132 + //} 133 + //return count; 193 134 } 194 135 195 136 public static int AddAllByTag(string tag, 196 - ICollection<Danmaku> collection) { 197 - if (tag == null) 198 - throw new ArgumentNullException("tag"); 199 - if (collection == null) 200 - throw new ArgumentNullException("collection"); 137 + ICollection<Danmaku> collection) 138 + { 139 + throw new NotImplementedException(); // TODO: Reimplement 140 + //if (tag == null) 141 + // throw new ArgumentNullException("tag"); 142 + //if (collection == null) 143 + // throw new ArgumentNullException("collection"); 201 144 202 - int count = -1; 203 - Danmaku current; 204 - Danmaku[] all = danmakuPool.all; 205 - for (int i = 0; i < all.Length; i++) { 206 - current = all[i]; 207 - if (current._isActive && current.Tag == tag) 208 - collection.Add(current); 209 - } 210 - return count; 145 + //int count = -1; 146 + //for (int i = 0; i < _activeCount; i++) 147 + //{ 148 + // if (all[i].Tag == tag) 149 + // collection.Add(all[i]); 150 + //} 151 + //return count; 211 152 } 212 153 213 - /// <summary> 214 - /// Retrieves an inactive Danmaku object. 215 - /// </summary> 216 - /// <remarks> 217 - /// The returned Danmaku object does not have any of its properties altered, and its state is likely to be completely randomized. 218 - /// The returned Danmaku object also is not active and must be activated before it actually appears or does anything. 219 - /// This method does not allocate any memory. 220 - /// </remarks> 221 - /// <returns>The inactive Danmaku.</returns> 222 - public static Danmaku GetInactive() { 223 - return danmakuPool.Get(); 224 - } 225 - 226 - /// <summary> 227 - /// Retrieves a number of inactive Danmaku objects. 228 - /// </summary> 229 - /// <remarks> 230 - /// The returned Danmaku objects does not have any of its properties altered, and their state is likely to be completely randomized. 231 - /// The returned Danmaku objects also is not active and must be activated before it actually appears or does anything. 232 - /// This method allocates memory for array. 233 - /// </remarks> 234 - /// <returns>The inactive Danmaku objects in an array.</returns> 235 - /// <param name="count">the number of inactive Danmaku objects to retrieve.</param> 236 - public static Danmaku[] GetInactive(int count) { 237 - Danmaku[] array = new Danmaku[count]; 238 - danmakuPool.Get(array); 239 - return array; 240 - } 241 - 242 - /// <summary> 243 - /// Retrieves a number of inactive Danmaku objects. 244 - /// </summary> 245 - /// <remarks> 246 - /// This method fills an existing array of Danmaku with inactive instances. 247 - /// The returned Danmaku objects does not have any of its properties altered, and their state is likely to be completely randomized. 248 - /// The returned Danmaku objects also is not active and must be activated before it actually appears or does anything. 249 - /// This method does not allocate any memory. 250 - /// </remarks> 251 - /// <exception cref="ArgumentNullException">thrown if the preallocated array is null.</exception> 252 - /// <param name="prealloc">the preallocated array to fill.</param> 253 - public static void GetInactive(Danmaku[] prealloc) { 254 - if (prealloc == null) 255 - throw new System.ArgumentNullException(); 256 - danmakuPool.Get(prealloc); 257 - } 258 - 259 - /// <summary> 260 - /// Retreives an inactive Danmaku object, and places it 261 - /// </summary> 262 - /// <returns>The inactive.</returns> 263 - /// <param name="position">Position.</param> 264 - /// <param name="rotation">Rotation.</param> 265 - public static Danmaku GetInactive(Vector2 position, 266 - float rotation) { 267 - Danmaku danmaku = danmakuPool.Get(); 268 - danmaku.position.x = position.x; 269 - danmaku.position.y = position.y; 154 + public Danmaku SpawnDanmaku(DanmakuPrefab prefab, 155 + Vector2 location, 156 + float rotation) 157 + { 158 + if (prefab == null) 159 + throw new ArgumentNullException("prefab"); 160 + Danmaku danmaku = prefab.Get(); 161 + danmaku.Position = position; 270 162 danmaku.Rotation = rotation; 271 163 return danmaku; 272 164 } 273 165 274 - public static Danmaku[] GetInactive(Vector2 position, 275 - float rotation, 276 - int count) { 277 - Danmaku[] array = new Danmaku[count]; 278 - GetInactive(position, rotation, array); 279 - danmakuPool.Get(array); 280 - array.MoveTo(position).RotateTo(rotation); 281 - return array; 282 - } 283 - 284 - public static void GetInactive(Vector2 position, 285 - float rotation, 286 - Danmaku[] prealloc) { 287 - danmakuPool.Get(prealloc); 288 - prealloc.MoveTo(position).RotateTo(rotation); 289 - } 290 - 291 - public static Danmaku GetInactive(DanmakuPrefab danmakuType, 292 - Vector2 position, 293 - float rotation) { 294 - Danmaku danmaku = danmakuPool.Get(); 295 - danmaku.MatchPrefab(danmakuType); 296 - danmaku.position.x = position.x; 297 - danmaku.position.y = position.y; 166 + public Danmaku FireLinear(DanmakuPrefab prefab, 167 + Vector2 location, 168 + float rotation, 169 + float speed) 170 + { 171 + if (prefab == null) 172 + throw new ArgumentNullException("prefab"); 173 + Danmaku danmaku = prefab.Get(); 174 + danmaku.Position = position; 298 175 danmaku.Rotation = rotation; 176 + danmaku.Speed = speed; 177 + danmaku.AngularSpeed = 0f; 299 178 return danmaku; 300 179 } 301 180 302 - public static Danmaku[] GetInactive(DanmakuPrefab danmakuType, 303 - Vector2 position, 304 - float rotation, 305 - int count) { 306 - Danmaku[] array = new Danmaku[count]; 307 - danmakuPool.Get(array); 308 - for (int i = 0; i < array.Length; i++) { 309 - Danmaku danmaku = array[i]; 310 - danmaku.MatchPrefab(danmakuType); 311 - danmaku.position.x = position.x; 312 - danmaku.position.y = position.y; 313 - danmaku.Rotation = rotation; 314 - } 315 - return array; 316 - } 317 - 318 - public static void GetInactive(DanmakuPrefab danmakuType, 319 - Vector2 position, 320 - float rotation, 321 - Danmaku[] prealloc) { 322 - danmakuPool.Get(prealloc); 323 - for (int i = 0; i < prealloc.Length; i++) { 324 - Danmaku danmaku = prealloc[i]; 325 - danmaku.MatchPrefab(danmakuType); 326 - danmaku.position.x = position.x; 327 - danmaku.position.y = position.y; 328 - danmaku.Rotation = rotation; 329 - } 330 - } 331 - 332 - private void Match(FireData data) { 333 - MatchPrefab(data.Prefab); 334 - Position = data.Position; 335 - Rotation = data.Rotation; 336 - Speed = data.Speed; 337 - AngularSpeed = data.AngularSpeed; 338 - _onUpdate = data.Controller; 339 - Damage = data.Damage; 340 - OnActivate = data.OnActivate; 341 - OnDeactivate = data.OnDeactivate; 342 - if (data.Color != null) 343 - Color = data.Color.Value; 344 - } 345 - 346 - public static Danmaku GetInactive(FireData data) { 347 - Danmaku danmaku = danmakuPool.Get(); 348 - danmaku.Match(data); 181 + public Danmaku FireCurved(DanmakuPrefab prefab, 182 + Vector2 location, 183 + float rotation, 184 + float speed, 185 + float angularSpeed) 186 + { 187 + if (prefab == null) 188 + throw new ArgumentNullException("prefab"); 189 + Danmaku danmaku = prefab.Get(); 190 + danmaku.Position = position; 191 + danmaku.Rotation = rotation; 192 + danmaku.Speed = speed; 193 + danmaku.AngularSpeed = angularSpeed; 349 194 return danmaku; 350 195 } 351 196 352 - public static Danmaku[] GetInactive(FireData data, int count) { 353 - var danmakus = new Danmaku[count]; 354 - GetInactive(data, danmakus); 355 - return danmakus; 356 - } 357 - 358 - public static void GetInactive(FireData data, Danmaku[] prealloc) { 359 - danmakuPool.Get(prealloc); 360 - for (int i = 0; i < prealloc.Length; i++) 361 - prealloc[i].Match(data); 362 - } 363 - 364 197 public static implicit operator bool(Danmaku danmaku) { 365 - return danmaku != null && danmaku._isActive; 198 + return danmaku != null && danmaku.IsActive; 366 199 } 367 200 368 201 }
+4 -4
Assets/Dependencies/DanmakU/_Core_/Editor/DanmakuFieldEditor.cs
··· 24 24 public void OnEnable() { 25 25 field = target as DanmakuField; 26 26 27 - useClipBoundary = serializedObject.FindProperty("UseClipBoundary"); 28 - clipBoundary = serializedObject.FindProperty ("ClipBoundary"); 29 - size = serializedObject.FindProperty("FieldSize"); 27 + useClipBoundary = serializedObject.FindProperty("useClipBoundary"); 28 + clipBoundary = serializedObject.FindProperty ("clipBoundary"); 29 + size = serializedObject.FindProperty("fieldSize"); 30 30 camera2D = serializedObject.FindProperty ("camera2D"); 31 31 camera3D = serializedObject.FindProperty ("otherCameras"); 32 32 } ··· 37 37 38 38 public override void OnInspectorGUI () { 39 39 serializedObject.Update (); 40 - EditorGUILayout.PropertyField(useClipBoundary); 40 + EditorGUILayout.PropertyField(useClipBoundary); 41 41 if (useClipBoundary.boolValue) { 42 42 EditorGUI.indentLevel++; 43 43 EditorGUILayout.PropertyField (clipBoundary);
+34 -34
Assets/Dependencies/DanmakU/_Core_/Editor/DanmakuGameControllerEditor.cs
··· 1 - // Copyright (c) 2015 James Liu 2 - // 3 - // See the LISCENSE file for copying permission. 1 + //// Copyright (c) 2015 James Liu 2 + //// 3 + //// See the LISCENSE file for copying permission. 4 4 5 - using UnityEngine; 6 - using UnityEditor; 7 - using Hourai.DanmakU; 5 + //using UnityEngine; 6 + //using UnityEditor; 7 + //using Hourai.DanmakU; 8 8 9 - /// <summary> 10 - /// Custom <a href="http://docs.unity3d.com/ScriptReference/Editor.html">Editor</a> for ProjectileManager 11 - /// </summary> 12 - [CustomEditor(typeof(DanmakuGame))] 13 - internal class DanmakuGameControllerEditor : UnityEditor.Editor { 9 + ///// <summary> 10 + ///// Custom <a href="http://docs.unity3d.com/ScriptReference/Editor.html">Editor</a> for ProjectileManager 11 + ///// </summary> 12 + //[CustomEditor(typeof(DanmakuGame))] 13 + //internal class DanmakuGameControllerEditor : UnityEditor.Editor { 14 14 15 - /// <summary> 16 - /// Creates custom GUI useful for statistics/debug on the Scene View 17 - /// Shows how many active Projectiles and how many 18 - /// </summary> 19 - public void OnSceneGUI() { 20 - GUISkin skin = GUI.skin; 21 - Handles.BeginGUI (); 22 - GUILayout.BeginArea (new Rect(0,0,150,60), skin.box); 23 - GUILayout.BeginVertical (); 24 - GUILayout.BeginHorizontal (); 25 - GUILayout.FlexibleSpace (); 26 - GUILayout.Label ("Danmaku Pool"); 27 - GUILayout.FlexibleSpace (); 28 - GUILayout.EndHorizontal(); 29 - GUILayout.Label ("Total Count: " + Danmaku.TotalCount); 30 - GUILayout.Label ("Active Count: " + Danmaku.ActiveCount); 31 - GUILayout.EndVertical (); 32 - GUILayout.EndArea (); 33 - if(GUI.changed) 34 - EditorUtility.SetDirty(target); 35 - Handles.EndGUI (); 36 - } 37 - } 15 + // /// <summary> 16 + // /// Creates custom GUI useful for statistics/debug on the Scene View 17 + // /// Shows how many active Projectiles and how many 18 + // /// </summary> 19 + // public void OnSceneGUI() { 20 + // GUISkin skin = GUI.skin; 21 + // Handles.BeginGUI (); 22 + // GUILayout.BeginArea (new Rect(0,0,150,60), skin.box); 23 + // GUILayout.BeginVertical (); 24 + // GUILayout.BeginHorizontal (); 25 + // GUILayout.FlexibleSpace (); 26 + // GUILayout.Label ("Danmaku Pool"); 27 + // GUILayout.FlexibleSpace (); 28 + // GUILayout.EndHorizontal(); 29 + // GUILayout.Label ("Total Count: " + Danmaku.TotalCount); 30 + // GUILayout.Label ("Active Count: " + Danmaku.ActiveCount); 31 + // GUILayout.EndVertical (); 32 + // GUILayout.EndArea (); 33 + // if(GUI.changed) 34 + // EditorUtility.SetDirty(target); 35 + // Handles.EndGUI (); 36 + // } 37 + //}
+102 -93
Assets/Dependencies/DanmakU/_Core_/FireData.cs
··· 1 - // Copyright (c) 2015 James Liu 2 - // 3 - // See the LISCENSE file for copying permission. 4 - 5 - using System; 6 - using System.Collections; 7 - using System.Collections.Generic; 8 - using UnityEngine; 9 - 10 - namespace Hourai.DanmakU { 11 - 12 - /// <summary> 13 - /// A container class for passing information about firing a single bullet. 14 - /// For creating more complex firing. See FireBuilder. 15 - /// </summary> 16 - [Serializable] 17 - public class FireData : IEnumerable<FireData> { 18 - 19 - public Vector2 Position; 20 - public float Rotation; 21 - public Color? Color; 22 - public float Damage; 23 - public float Speed = 5f; 24 - public float AngularSpeed; 25 - public Action<Danmaku> Controller; 26 - public Action<Danmaku> OnActivate; 27 - public Action<Danmaku> OnDeactivate; 28 - public DanmakuPrefab Prefab; 29 - 30 - public void Copy(FireData other) { 31 - if (other == null || other == this) 32 - return; 33 - AngularSpeed = other.AngularSpeed; 34 - Controller = other.Controller; 35 - OnActivate = other.OnActivate; 36 - OnDeactivate = other.OnDeactivate; 37 - Damage = other.Damage; 38 - Position = other.Position; 39 - Prefab = other.Prefab; 40 - Rotation = other.Rotation; 41 - Speed = other.Speed; 42 - Color = other.Color; 43 - } 44 - 45 - public FireData Clone() { 46 - var data = new FireData(); 47 - data.Copy(this); 48 - return data; 49 - } 50 - 51 - public Danmaku Fire() { 52 - Danmaku danmaku = Danmaku.GetInactive(this); 53 - danmaku.Activate(); 54 - return danmaku; 55 - } 56 - 57 - public IEnumerator<FireData> GetEnumerator() { 58 - yield return this; 59 - } 60 - 61 - IEnumerator IEnumerable.GetEnumerator() { 62 - return GetEnumerator(); 63 - } 64 - 65 - public IEnumerable Multiple(int count, Action<FireData> delta = null) { 66 - if (delta != null) { 67 - FireData clone = Clone(); 68 - for (var i = 0; i < count; i++) { 69 - delta(clone); 70 - yield return clone; 71 - } 72 - } else { 73 - for (var i = 0; i < count; i++) 74 - yield return this; 75 - } 76 - } 77 - 78 - public IEnumerable Infinite(Action<FireData> delta = null) 79 - { 80 - if (delta != null) 81 - { 82 - FireData clone = Clone(); 83 - while(true) { 84 - delta(clone); 85 - yield return clone; 86 - } 87 - } 88 - while (true) 89 - yield return this; 90 - } 91 - 92 - } 93 - 1 + // Copyright (c) 2015 James Liu 2 + // 3 + // See the LISCENSE file for copying permission. 4 + 5 + using System; 6 + using System.Collections; 7 + using System.Collections.Generic; 8 + using UnityEngine; 9 + 10 + namespace Hourai.DanmakU { 11 + 12 + /// <summary> 13 + /// A container class for passing information about firing a single bullet. 14 + /// For creating more complex firing. See FireBuilder. 15 + /// </summary> 16 + [Serializable] 17 + public class FireData : IEnumerable<FireData> { 18 + 19 + public Vector2 Position; 20 + public float Rotation; 21 + public Color? Color; 22 + public float Damage; 23 + public float Speed = 5f; 24 + public float AngularSpeed; 25 + public Action<Danmaku> Controller; 26 + public Action<Danmaku> OnActivate; 27 + public Action<Danmaku> OnDestroy; 28 + public DanmakuPrefab Prefab; 29 + 30 + public FireData Copy(FireData other) { 31 + if (other == null || other == this) 32 + return this; 33 + AngularSpeed = other.AngularSpeed; 34 + Controller = other.Controller; 35 + OnActivate = other.OnActivate; 36 + OnDestroy = other.OnDestroy; 37 + Damage = other.Damage; 38 + Position = other.Position; 39 + Prefab = other.Prefab; 40 + Rotation = other.Rotation; 41 + Speed = other.Speed; 42 + Color = other.Color; 43 + return this; 44 + } 45 + 46 + public FireData Clone() { 47 + return new FireData().Copy(this); 48 + } 49 + 50 + public Danmaku Fire() { 51 + Danmaku danmaku = Prefab.Get(); 52 + danmaku.Position = Position; 53 + danmaku.Rotation = Rotation; 54 + danmaku.Speed = Speed; 55 + danmaku.AngularSpeed = AngularSpeed; 56 + danmaku.Controller += Controller; 57 + danmaku.Damage = Damage; 58 + danmaku.OnActivate += OnActivate; 59 + danmaku.OnDestroy += OnDestroy; 60 + if (Color != null) 61 + Color = Color.Value; 62 + danmaku.Activate(); 63 + return danmaku; 64 + } 65 + 66 + public IEnumerator<FireData> GetEnumerator() { 67 + yield return this; 68 + } 69 + 70 + IEnumerator IEnumerable.GetEnumerator() { 71 + return GetEnumerator(); 72 + } 73 + 74 + public IEnumerable Multiple(int count, Action<FireData> delta = null) { 75 + if (delta != null) { 76 + FireData clone = Clone(); 77 + for (var i = 0; i < count; i++) { 78 + delta(clone); 79 + yield return clone; 80 + } 81 + } else { 82 + for (var i = 0; i < count; i++) 83 + yield return this; 84 + } 85 + } 86 + 87 + public IEnumerable Infinite(Action<FireData> delta = null) 88 + { 89 + if (delta != null) 90 + { 91 + FireData clone = Clone(); 92 + while(true) { 93 + delta(clone); 94 + yield return clone; 95 + } 96 + } 97 + while (true) 98 + yield return this; 99 + } 100 + 101 + } 102 + 94 103 }
+26
Assets/Dependencies/DanmakU/_Core_/Flters.cs
··· 1 + using UnityEngine; 2 + using System; 3 + using System.Collections; 4 + 5 + namespace Hourai.DanmakU 6 + { 7 + public static class Filter 8 + { 9 + public static Func<FireData, bool> Everything() 10 + { 11 + return (fd) => false; 12 + } 13 + 14 + public static Func<FireData, bool> Random(float split = 0.5f) 15 + { 16 + if(split > 1.0f) 17 + return Everything(); 18 + if(split <= 0f) 19 + return null; 20 + return delegate(FireData fd) 21 + { 22 + return UnityEngine.Random.value > split; 23 + }; 24 + } 25 + } 26 + }
+46 -2
Assets/Dependencies/DanmakU/_Core_/Modifiers/ModifierUtil.cs
··· 1 1 using UnityEngine; 2 2 using System; 3 + using System.Linq; 3 4 using System.Collections; 4 5 using System.Collections.Generic; 5 6 using Vexe.Runtime.Extensions; 6 7 7 8 namespace Hourai.DanmakU 8 9 { 10 + public static partial class Modifier 11 + { 12 + /// <summary> 13 + /// Concatenates two enumerations together. The second enumeration will be appended to the end of the first. 14 + /// If the first never ends, the second will never be reached. 15 + /// If one is null, the other will be returned. 16 + /// If both are null, an empty enumeration is returned; 17 + /// </summary> 18 + /// <param name="s1"></param> 19 + /// <param name="s2"></param> 20 + /// <returns></returns> 21 + public static IEnumerable Concat(this IEnumerable s1, IEnumerable s2) 22 + { 23 + if (s1 == null && s2 == null) 24 + return new object[0]; 25 + if (s1 == null) 26 + return s2; 27 + if (s2 == null) 28 + return s1; 29 + return ConcatImpl(s1, s2); 30 + } 31 + 32 + static IEnumerable ConcatImpl(IEnumerable s1, IEnumerable s2) 33 + { 34 + foreach (var obj in s1) 35 + yield return obj; 36 + foreach (var obj in s2) 37 + yield return obj; 38 + } 39 + 40 + public static IEnumerable TerminateOn(this IEnumerable coroutine, Func<bool> condition) 41 + { 42 + if (condition == null) 43 + throw new ArgumentNullException("conition"); 44 + foreach (var obj in coroutine) 45 + { 46 + yield return obj; 47 + if (condition()) 48 + yield break; 49 + } 50 + } 51 + } 52 + 9 53 public static class ModifierUtil { 10 54 11 55 /// <summary> ··· 224 268 else if (dp != null) 225 269 ((FireData) dp).Fire(); 226 270 else { 227 - var fireTask = new Task(context ?? DanmakuGame.Instance, 271 + var fireTask = new Task(context ?? Game.Instance, 228 272 FireRoutine(data)); 229 273 fireTask.Start(); 230 274 return fireTask; ··· 336 380 fm.actions += action; 337 381 return fm; 338 382 } 339 - } 383 + } 340 384 }
+8 -23
Assets/Dependencies/DanmakU/_Core_/Util/Extensions/DanmakuCollectionExtensions.cs
··· 153 153 /// <param name="filter">a function to filter whether or not to apply the action. Returns true if it should. Defaults to null.</param> 154 154 /// <typeparam name="IEnumerable<Danmaku>">The type of the collection.</typeparam> 155 155 public static IEnumerable<Danmaku> MoveTowards(this IEnumerable<Danmaku> danmakus, 156 - Vector2 target, 157 - float maxDistanceDelta, 158 - Func<Danmaku, bool> filter = null) 156 + Vector2 target, 157 + float maxDistanceDelta, 158 + Func<Danmaku, bool> filter = null) 159 159 { 160 - return danmakus.ForEach(x => x.MoveTowards(target, maxDistanceDelta), filter); 160 + return danmakus.ForEach(x => x.Position = Vector2.MoveTowards(x.Position, target, maxDistanceDelta), filter); 161 161 } 162 162 163 163 public static IEnumerable<Danmaku> MoveTowards(this IEnumerable<Danmaku> danmakus, ··· 338 338 339 339 #region General Functions 340 340 341 - public static IEnumerable<Danmaku> Active(this IEnumerable<Danmaku> danmakus, bool value, Func<Danmaku, bool> filter = null) 342 - { 343 - return danmakus.ForEach(x => x.IsActive = value, filter); 344 - } 345 - 346 - public static IEnumerable<Danmaku> Activate(this IEnumerable<Danmaku> danmakus, Func<Danmaku, bool> filter = null) 341 + public static IEnumerable<Danmaku> Destroy(this IEnumerable<Danmaku> danmakus, Func<Danmaku, bool> filter = null) 347 342 { 348 - return danmakus.ForEach(x => x.Activate(), filter); 349 - } 350 - 351 - public static IEnumerable<Danmaku> Deactivate(this IEnumerable<Danmaku> danmakus, Func<Danmaku, bool> filter = null) 352 - { 353 - return danmakus.ForEach(x => x.Deactivate(), filter); 354 - } 355 - 356 - public static IEnumerable<Danmaku> DeactivateImmediate(this IEnumerable<Danmaku> danmakus, Func<Danmaku, bool> filter = null) 357 - { 358 - return danmakus.ForEach(x => x.DeactivateImmediate(), filter); 343 + return danmakus.ForEach(x => x.Destroy(), filter); 359 344 } 360 345 361 346 #endregion ··· 367 352 return danmakus.ForEach(x => x.CollisionCheck = collisionCheck, filter); 368 353 } 369 354 370 - public static IEnumerable<Danmaku> MatchPrefab(this IEnumerable<Danmaku> danmakus, DanmakuPrefab prefab, Func<Danmaku, bool> filter = null) 355 + public static IEnumerable<Danmaku> Match(this IEnumerable<Danmaku> danmakus, DanmakuPrefab prefab, Func<Danmaku, bool> filter = null) 371 356 { 372 - return danmakus.ForEach(x => x.MatchPrefab(prefab), filter); 357 + return danmakus.ForEach(x => prefab.Match(x), filter); 373 358 } 374 359 375 360 #endregion
+13 -13
Assets/Dependencies/HouraiLib/Editor/Util/EditorUtil.cs
··· 21 21 } else { 22 22 EditorGUILayout.BeginHorizontal(style); 23 23 } 24 - } else { 25 - if (style == null) { 26 - EditorGUILayout.BeginHorizontal(options); 27 - } else { 28 - EditorGUILayout.BeginHorizontal(style, options); 29 - } 24 + } else { 25 + if (style == null) { 26 + EditorGUILayout.BeginHorizontal(options); 27 + } else { 28 + EditorGUILayout.BeginHorizontal(style, options); 29 + } 30 30 } 31 - } 32 - 33 - public void Dispose() { 34 - EditorGUILayout.EndHorizontal(); 35 - } 31 + } 32 + 33 + public void Dispose() { 34 + EditorGUILayout.EndHorizontal(); 35 + } 36 36 } 37 37 38 38 public static IDisposable Horizontal(GUIStyle style = null, params GUILayoutOption[] options) { ··· 40 40 }*/ 41 41 42 42 /// <summary> 43 - /// Since GameObject.GetComponentInChildren does not work on deactivated objects, which include 43 + /// Since GameObject.GetComponentInChildren does not work on Destroyd objects, which include 44 44 /// prefabs in the Editor. This method is a workaround for finding Components on children of 45 45 /// prefabs. 46 46 /// ··· 60 60 } 61 61 62 62 /// <summary> 63 - /// Since GameObject.GetComponentsInChildren does not work on deactivated objects, which include 63 + /// Since GameObject.GetComponentsInChildren does not work on Destroyd objects, which include 64 64 /// prefabs in the Editor. This method is a workaround for finding Components on children of 65 65 /// prefabs. 66 66 ///
+1 -1
Assets/Dependencies/Vexe/HISTORY.txt
··· 409 409 410 410 Helpers/Extensions: 411 411 - Added HasFlag Enum extension method 412 - - Added Activate/Deactivate Transform extension methods 412 + - Added Activate/Destroy Transform extension methods 413 413 - Added GetCurrentSceneName to RuntimeHelper 414 414 - Added GetCallStack(bool verbose) in RuntimeHelper 415 415
+2 -2
Assets/Dependencies/Vexe/Runtime/Library/Extensions/GameObjectExtensions.cs
··· 96 96 } 97 97 98 98 /// <summary> 99 - /// Deactivates (calls SetActive(false)) this gameObject 99 + /// Destroys (calls SetActive(false)) this gameObject 100 100 /// </summary> 101 - public static void Deactivate(this GameObject go) 101 + public static void Destroy(this GameObject go) 102 102 { 103 103 go.SetActive(false); 104 104 }
+2 -2
Assets/Dependencies/Vexe/Runtime/Library/Extensions/TransformExtensions.cs
··· 9 9 t.gameObject.Activate(); 10 10 } 11 11 12 - public static void Deactivate(this Transform t) 12 + public static void Destroy(this Transform t) 13 13 { 14 - t.gameObject.Deactivate(); 14 + t.gameObject.Destroy(); 15 15 } 16 16 17 17 /// <summary>
+29 -12
Assets/Test/BasicFireTest.cs
··· 4 4 5 5 using System.Collections; 6 6 using UnityEngine; 7 + using Hourai; 7 8 using Hourai.DanmakU; 8 9 9 10 public class BasicFireTest : MonoBehaviour { ··· 17 18 [SerializeField] 18 19 private Gradient grad; 19 20 21 + [SerializeField] 22 + private float speed; 23 + 24 + [SerializeField] 25 + private int burstCount; 26 + 20 27 private Task test; 21 28 private DanmakuGroup group; 22 29 23 30 private void Start() { 24 - group = DanmakuGroup.List(); 31 + TimeUtil.FrameRateIndependent = false; 32 + DanmakuField field = DanmakuField.FindClosest(this); 33 + //group = DanmakuGroup.List(); 25 34 FireData data = prefab; 26 - group.Bind(data); 27 - test = data.Infinite(Modifier.Rotate(2.5f)) 28 - //.From(gameObject.Descendants()) 29 - .WithSpeed(2) 30 - .Delay(delay) 31 - .RadialBurst(100) 32 - .Execute(); 33 - Invoke("Test", 10); 35 + //group.Bind(data); 36 + Debug.Log(field); 37 + if (field) 38 + field.Bind(data); 39 + 40 + Spiral(data.Infinite(Modifier.Rotate(5f))).Execute(); 41 + //Spiral(data.Infinite(Modifier.Rotate(-3f)).WithColor(Color.blue)).Execute(); 42 + //InvokeRepeating("DAALL", 10, 10); 43 + } 44 + 45 + void DAALL() 46 + { 47 + Danmaku.DestroyAll(); 34 48 } 35 49 36 - void Test() { 37 - group.Deactivate(); 38 - test.Stop(); 50 + IEnumerable Spiral(IEnumerable pos) 51 + { 52 + return pos 53 + .WithSpeed(speed) 54 + .Delay(delay) 55 + .RadialBurst(burstCount); 39 56 } 40 57 41 58 }
+113 -5
Assets/Test/Test Scene.unity
··· 87 87 cellSize: .166666672 88 88 manualCellSize: 0 89 89 m_NavMeshData: {fileID: 0} 90 + --- !u!1 &15054798 91 + GameObject: 92 + m_ObjectHideFlags: 0 93 + m_PrefabParentObject: {fileID: 0} 94 + m_PrefabInternal: {fileID: 0} 95 + serializedVersion: 4 96 + m_Component: 97 + - 4: {fileID: 15054799} 98 + - 33: {fileID: 15054801} 99 + - 23: {fileID: 15054800} 100 + m_Layer: 0 101 + m_Name: Background 102 + m_TagString: Untagged 103 + m_Icon: {fileID: 0} 104 + m_NavMeshLayer: 0 105 + m_StaticEditorFlags: 0 106 + m_IsActive: 1 107 + --- !u!4 &15054799 108 + Transform: 109 + m_ObjectHideFlags: 0 110 + m_PrefabParentObject: {fileID: 0} 111 + m_PrefabInternal: {fileID: 0} 112 + m_GameObject: {fileID: 15054798} 113 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 114 + m_LocalPosition: {x: 0, y: 0, z: 10} 115 + m_LocalScale: {x: 48.125, y: 48.125, z: 1} 116 + m_Children: [] 117 + m_Father: {fileID: 1741943684} 118 + m_RootOrder: 1 119 + --- !u!23 &15054800 120 + MeshRenderer: 121 + m_ObjectHideFlags: 0 122 + m_PrefabParentObject: {fileID: 0} 123 + m_PrefabInternal: {fileID: 0} 124 + m_GameObject: {fileID: 15054798} 125 + m_Enabled: 1 126 + m_CastShadows: 1 127 + m_ReceiveShadows: 1 128 + m_Materials: 129 + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 130 + m_SubsetIndices: 131 + m_StaticBatchRoot: {fileID: 0} 132 + m_UseLightProbes: 1 133 + m_ReflectionProbeUsage: 1 134 + m_ProbeAnchor: {fileID: 0} 135 + m_ScaleInLightmap: 1 136 + m_PreserveUVs: 1 137 + m_ImportantGI: 0 138 + m_AutoUVMaxDistance: .5 139 + m_AutoUVMaxAngle: 89 140 + m_LightmapParameters: {fileID: 0} 141 + m_SortingLayerID: 0 142 + m_SortingOrder: 0 143 + --- !u!33 &15054801 144 + MeshFilter: 145 + m_ObjectHideFlags: 0 146 + m_PrefabParentObject: {fileID: 0} 147 + m_PrefabInternal: {fileID: 0} 148 + m_GameObject: {fileID: 15054798} 149 + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 90 150 --- !u!1 &207080291 91 151 GameObject: 92 152 m_ObjectHideFlags: 0 ··· 229 289 m_LocalPosition: {x: 0, y: 0, z: -10} 230 290 m_LocalScale: {x: 1, y: 1, z: 1} 231 291 m_Children: [] 232 - m_Father: {fileID: 0} 233 - m_RootOrder: 1 292 + m_Father: {fileID: 1741943684} 293 + m_RootOrder: 0 234 294 --- !u!1001 &555474685 235 295 Prefab: 236 296 m_ObjectHideFlags: 0 ··· 329 389 m_Script: {fileID: 11500000, guid: 42f54d3639c02544385383898827713d, type: 3} 330 390 m_Name: 331 391 m_EditorClassIdentifier: 332 - delay: 0 392 + delay: .100000001 333 393 prefab: {fileID: 11409350, guid: 5c0c5bf0c434853449fa68def8d34e65, type: 2} 334 394 grad: 335 395 key0: ··· 374 434 atime7: 0 375 435 m_NumColorKeys: 7 376 436 m_NumAlphaKeys: 2 437 + speed: 5 438 + burstCount: 20 377 439 --- !u!4 &1376768896 378 440 Transform: 379 441 m_ObjectHideFlags: 0 ··· 387 449 - {fileID: 207080292} 388 450 - {fileID: 730316083} 389 451 m_Father: {fileID: 0} 390 - m_RootOrder: 2 452 + m_RootOrder: 1 391 453 --- !u!1 &1552973383 392 454 GameObject: 393 455 m_ObjectHideFlags: 0 ··· 414 476 m_LocalScale: {x: 1, y: 1, z: 1} 415 477 m_Children: [] 416 478 m_Father: {fileID: 0} 417 - m_RootOrder: 3 479 + m_RootOrder: 2 418 480 --- !u!1 &1715873554 419 481 GameObject: 420 482 m_ObjectHideFlags: 0 ··· 442 504 m_Children: [] 443 505 m_Father: {fileID: 207080292} 444 506 m_RootOrder: 0 507 + --- !u!1 &1741943683 508 + GameObject: 509 + m_ObjectHideFlags: 0 510 + m_PrefabParentObject: {fileID: 0} 511 + m_PrefabInternal: {fileID: 0} 512 + serializedVersion: 4 513 + m_Component: 514 + - 4: {fileID: 1741943684} 515 + - 114: {fileID: 1741943685} 516 + m_Layer: 0 517 + m_Name: Field 518 + m_TagString: Untagged 519 + m_Icon: {fileID: 0} 520 + m_NavMeshLayer: 0 521 + m_StaticEditorFlags: 0 522 + m_IsActive: 1 523 + --- !u!4 &1741943684 524 + Transform: 525 + m_ObjectHideFlags: 0 526 + m_PrefabParentObject: {fileID: 0} 527 + m_PrefabInternal: {fileID: 0} 528 + m_GameObject: {fileID: 1741943683} 529 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 530 + m_LocalPosition: {x: 0, y: 0, z: 0} 531 + m_LocalScale: {x: 1, y: 1, z: 1} 532 + m_Children: 533 + - {fileID: 513550417} 534 + - {fileID: 15054799} 535 + m_Father: {fileID: 0} 536 + m_RootOrder: 3 537 + --- !u!114 &1741943685 538 + MonoBehaviour: 539 + m_ObjectHideFlags: 0 540 + m_PrefabParentObject: {fileID: 0} 541 + m_PrefabInternal: {fileID: 0} 542 + m_GameObject: {fileID: 1741943683} 543 + m_Enabled: 1 544 + m_EditorHideFlags: 0 545 + m_Script: {fileID: 11500000, guid: 8700f30fe9e49ad4fb2ed407eba26a75, type: 3} 546 + m_Name: 547 + m_EditorClassIdentifier: 548 + camera2D: {fileID: 0} 549 + clipBoundary: 1 550 + fieldSize: {x: 20, y: 20} 551 + otherCameras: [] 552 + useClipBoundary: 1 445 553 --- !u!1 &1948333897 446 554 GameObject: 447 555 m_ObjectHideFlags: 0
+9 -3
Assets/Test/bullet petal.prefab
··· 40 40 m_Script: {fileID: 11500000, guid: 4a07ad0e112c37d44acf76a147bfa444, type: 3} 41 41 m_Name: 42 42 m_EditorClassIdentifier: 43 - _id: -9034 43 + _id: 7814 44 44 dbg: 0 45 45 _serializationData: 46 46 serializedObjects: ··· 51 51 - ColliderType collisionType 52 52 - Vector2 colliderSize 53 53 - Vector2 colliderOffset 54 + - float rotationOffset 54 55 - bool fixedAngle 56 + - int initialCount 57 + - int spawnCount 55 58 values: 56 59 - 0 57 60 - '"Circle"' 58 61 - '{"x":1.0,"y":1.0}' 59 62 - '{"x":0.0,"y":0.0}' 63 + - -90.0 60 64 - false 65 + - 1000 66 + - 100 61 67 danmakuSystemPrefab: {fileID: 19876622, guid: 1369960486de0844c8c02f62913f5ffb, 62 68 type: 2} 63 69 --- !u!212 &21290556 ··· 123 129 objectReference: {fileID: 0} 124 130 - target: {fileID: 0} 125 131 propertyPath: _serializationData.serializedStrings.values.Array.data[4] 126 - value: false 132 + value: -90.0 127 133 objectReference: {fileID: 0} 128 134 - target: {fileID: 0} 129 135 propertyPath: _serializationData.serializedStrings.values.Array.data[5] 130 - value: '[]' 136 + value: false 131 137 objectReference: {fileID: 0} 132 138 m_RemovedComponents: [] 133 139 m_ParentPrefab: {fileID: 0}