Skip to content

Commit

Permalink
More FireBuilder Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
james7132 committed Jun 4, 2015
1 parent 5e565bb commit a8239e9
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 15 deletions.
18 changes: 14 additions & 4 deletions Assets/DanmakU/Core/FireBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,18 @@ public FireBuilder WithoutGroup () {

#endregion

#region Field Functions

public FireBuilder InField(DanmakuField field) {
if(field == null)
throw new ArgumentNullException("Field cannot be null!");

Field = field;
return this;
}

#endregion

public void Fire () {
Vector2 actualPosition = Position;
DynamicFloat actualRotation = Rotation;
Expand All @@ -465,15 +477,13 @@ public void Fire () {
Rotation = actualRotation;

if(modifiers.Count <= 0) {
Debug.Log("hello");
data.Fire();
} else if(modifiers.Count == 1) {
DanmakuModifier singleModifier = modifiers[0];
if(singleModifier == null) {
if(singleModifier == null)
data.Fire();
} else {
else
singleModifier.Fire(data);
}
} else {
DanmakuModifier[] oldSubModifiers = new DanmakuModifier[modifiers.Count];
DanmakuModifier previous = null, current, initial = null;
Expand Down
12 changes: 8 additions & 4 deletions Assets/DanmakU/Core/Modifiers/CircularBurstModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,29 @@ public CircularBurstModifier(DynamicFloat range,

public override void OnFire (Vector2 position, DynamicFloat rotation) {

Debug.Log(rotation.Value);
Debug.Log(rotation.Type);

int burstCount = Mathf.Abs(count.Value);

if (burstCount == 1) {
FireSingle (position, rotation);
} else {
float burstRange = range.Value;
float start = rotation - burstRange * 0.5f;
float delta = burstRange / burstCount;
float delta = burstRange / (burstCount - 1);

float deltaV = deltaSpeed.Value;
float deltaAV = deltaAngularSpeed.Value;

DynamicFloat tempSpeed = Speed;
DynamicFloat tempASpeed = AngularSpeed;

for (int i = 0; i < burstCount; i++) {
Speed += deltaV;
AngularSpeed += deltaAV;
FireSingle(position, start + i * delta);
}

Speed = tempSpeed;
AngularSpeed = tempASpeed;
}

}
Expand Down
5 changes: 4 additions & 1 deletion Assets/DanmakU/Core/Modifiers/LinearBurstModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public LinearBurstModifier(DynamicInt depth,
#region implemented abstract members of FireModifier

public override void OnFire (Vector2 position, DynamicFloat rotation) {
DynamicFloat tempSpeed = Speed;
DynamicFloat tempASpeed = AngularSpeed;
DynamicFloat deltaV = DeltaSpeed;
DynamicFloat deltaAV = DeltaAngularSpeed;
float depth = Depth.Value;
Expand All @@ -63,7 +65,8 @@ public override void OnFire (Vector2 position, DynamicFloat rotation) {
AngularSpeed += deltaAV;
FireSingle(position, rotation);
}

Speed = tempSpeed;
AngularSpeed = tempASpeed;
}

#endregion
Expand Down
34 changes: 34 additions & 0 deletions Assets/SourceTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2015 James Liu
//
// See the LISCENSE file for copying permission.

using UnityEngine;
using DanmakU;
using DanmakU.Modifiers;

public class SourceTest : MonoBehaviour {

[SerializeField]
private FrameCounter delay;

[SerializeField]
private DanmakuPrefab prefab;

[SerializeField]
private CircularBurstModifier circleBurst;

[SerializeField]
private LinearBurstModifier lineBurst;

void Update() {
if(delay.Tick()) {
Danmaku.ConstructFire(prefab)
.WithModifier(circleBurst)
.WithModifier(lineBurst)
.From(this)
.WithRotation(this)
.Fire();
}
}

}
12 changes: 9 additions & 3 deletions Assets/Test/CircularBurstTest.cs → Assets/Test/ModifierTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using DanmakU;
using DanmakU.Modifiers;

public class CircularBurstTest : MonoBehaviour {
public class ModifierTest : MonoBehaviour {

[SerializeField]
private FrameCounter delay;
Expand All @@ -15,11 +15,17 @@ public class CircularBurstTest : MonoBehaviour {
private DanmakuPrefab prefab;

[SerializeField]
private CircularBurstModifier burst;
private CircularBurstModifier circleBurst;

[SerializeField]
private LinearBurstModifier lineBurst;

void Update() {
if(delay.Tick()) {
Danmaku.ConstructFire(prefab).WithModifier(burst).Fire();
Danmaku.ConstructFire(prefab)
.WithModifier(circleBurst)
.WithModifier(lineBurst)
.Fire();
}
}

Expand Down
150 changes: 147 additions & 3 deletions Assets/Test/Test Scene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!114 &1376768895
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -174,8 +174,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d05c63e729f17a6418d9c10e07027dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
counter:
Time: 0
delay:
Time: 1
prefab: {fileID: 11439806, guid: bab340f2a7e388241b077215f339b191, type: 2}
--- !u!4 &1376768896
Transform:
Expand All @@ -189,3 +189,147 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
--- !u!1 &1724939925
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1724939927}
- 114: {fileID: 1724939926}
m_Layer: 0
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!114 &1724939926
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1724939925}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: eceb9500f4c5a2b4aa42f7c3c2373001, type: 3}
m_Name:
m_EditorClassIdentifier:
delay:
Time: 1
prefab: {fileID: 11439806, guid: bab340f2a7e388241b077215f339b191, type: 2}
circleBurst:
range:
type: 0
min: 120
max: 120
count:
type: 0
min: 5
max: 5
deltaSpeed:
type: 0
min: 0
max: 0
deltaAngularSpeed:
type: 0
min: 0
max: 0
lineBurst:
depth:
type: 0
min: 3
max: 3
deltaSpeed:
type: 0
min: 3
max: 3
deltaAngularSpeed:
type: 0
min: 0
max: 0
--- !u!4 &1724939927
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1724939925}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: .474208266, y: 1.20853436, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
--- !u!1 &2002943911
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 2002943913}
- 114: {fileID: 2002943912}
m_Layer: 0
m_Name: Modifier Test
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!114 &2002943912
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2002943911}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e2075bee9e523b34b8189254a50c9631, type: 3}
m_Name:
m_EditorClassIdentifier:
delay:
Time: 1
prefab: {fileID: 11439806, guid: bab340f2a7e388241b077215f339b191, type: 2}
circleBurst:
range:
type: 0
min: 360
max: 360
count:
type: 0
min: 20
max: 20
deltaSpeed:
type: 0
min: 0
max: 0
deltaAngularSpeed:
type: 0
min: 0
max: 0
lineBurst:
depth:
type: 0
min: 65
max: 65
deltaSpeed:
type: 0
min: 3
max: 3
deltaAngularSpeed:
type: 0
min: 15
max: 15
--- !u!4 &2002943913
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2002943911}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2

0 comments on commit a8239e9

Please sign in to comment.