projectile damaging + robots can die:)
This commit is contained in:
parent
666e6269a8
commit
0db4c49568
|
@ -13,6 +13,7 @@ GameObject:
|
||||||
- component: {fileID: 5408793041970514069}
|
- component: {fileID: 5408793041970514069}
|
||||||
- component: {fileID: 58437666630366278}
|
- component: {fileID: 58437666630366278}
|
||||||
- component: {fileID: 4851113807957284959}
|
- component: {fileID: 4851113807957284959}
|
||||||
|
- component: {fileID: 8700343489547611766}
|
||||||
m_Layer: 6
|
m_Layer: 6
|
||||||
m_Name: Bullet
|
m_Name: Bullet
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -133,3 +134,18 @@ Rigidbody:
|
||||||
m_Interpolate: 0
|
m_Interpolate: 0
|
||||||
m_Constraints: 0
|
m_Constraints: 0
|
||||||
m_CollisionDetection: 0
|
m_CollisionDetection: 0
|
||||||
|
--- !u!114 &8700343489547611766
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2962360034595352958}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: a98521a4b559621438fc196adc605f3b, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
bounciness: 0.516
|
||||||
|
damage: 10
|
||||||
|
wallRebounces: 4
|
||||||
|
|
|
@ -73,6 +73,10 @@ PrefabInstance:
|
||||||
type: 3}
|
type: 3}
|
||||||
insertIndex: -1
|
insertIndex: -1
|
||||||
addedObject: {fileID: 7883233016828513649}
|
addedObject: {fileID: 7883233016828513649}
|
||||||
|
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: eb5e13df78999ef878da1db5c63224e2,
|
||||||
|
type: 3}
|
||||||
|
insertIndex: -1
|
||||||
|
addedObject: {fileID: 5565472806559733162}
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: eb5e13df78999ef878da1db5c63224e2, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: eb5e13df78999ef878da1db5c63224e2, type: 3}
|
||||||
--- !u!1 &872127579833310669 stripped
|
--- !u!1 &872127579833310669 stripped
|
||||||
GameObject:
|
GameObject:
|
||||||
|
@ -95,7 +99,40 @@ MonoBehaviour:
|
||||||
startHealth: 100
|
startHealth: 100
|
||||||
OnHealthZero:
|
OnHealthZero:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls:
|
||||||
|
- m_Target: {fileID: 7883233016828513649}
|
||||||
|
m_TargetAssemblyTypeName: HealthComponent, Assembly-CSharp
|
||||||
|
m_MethodName: SimpleKill
|
||||||
|
m_Mode: 1
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 0
|
||||||
|
m_CallState: 2
|
||||||
OnHealthChange:
|
OnHealthChange:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls: []
|
||||||
|
--- !u!65 &5565472806559733162
|
||||||
|
BoxCollider:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 872127579833310669}
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_LayerOverridePriority: 0
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_ProvidesContacts: 0
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 3
|
||||||
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
|
|
@ -231,6 +231,36 @@ PrefabInstance:
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: BlackHole
|
value: BlackHole
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5565472806559733162, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Size.x
|
||||||
|
value: 0.5101528
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5565472806559733162, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Size.y
|
||||||
|
value: 1.8364654
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5565472806559733162, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Size.z
|
||||||
|
value: 0.5177386
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5565472806559733162, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Center.x
|
||||||
|
value: -0.022192955
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5565472806559733162, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Center.y
|
||||||
|
value: -0.0720216
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5565472806559733162, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Center.z
|
||||||
|
value: -0.008693576
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects:
|
m_AddedGameObjects:
|
||||||
|
|
|
@ -383,7 +383,7 @@ Transform:
|
||||||
m_GameObject: {fileID: 2676689439087408815}
|
m_GameObject: {fileID: 2676689439087408815}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0.00723}
|
m_LocalPosition: {x: 0, y: 0, z: 0.00846}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
|
@ -994,6 +994,36 @@ PrefabInstance:
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: Turret
|
value: Turret
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5565472806559733162, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Size.x
|
||||||
|
value: 0.5204178
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5565472806559733162, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Size.y
|
||||||
|
value: 1.2033536
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5565472806559733162, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Size.z
|
||||||
|
value: 0.6565219
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5565472806559733162, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Center.x
|
||||||
|
value: -0.02208674
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5565472806559733162, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Center.y
|
||||||
|
value: -0.07302019
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5565472806559733162, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Center.z
|
||||||
|
value: -0.05310279
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8365322460670124409, guid: f54a14318952c90c5b47a300aedb0d15,
|
- target: {fileID: 8365322460670124409, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
|
|
|
@ -1243,7 +1243,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
|
- target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_LocalRotation.w
|
propertyPath: m_LocalRotation.w
|
||||||
value: -0.1380528
|
value: -0.13805284
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
|
- target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
@ -1258,7 +1258,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
|
- target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_LocalRotation.z
|
propertyPath: m_LocalRotation.z
|
||||||
value: -0.13815574
|
value: -0.13815573
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8882344377078016156, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
|
- target: {fileID: 8882344377078016156, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
|
@ -106,7 +106,6 @@ public class AimTower : Tower
|
||||||
ghosts[poolIdx].transform.position = ghostPos;
|
ghosts[poolIdx].transform.position = ghostPos;
|
||||||
ghosts[poolIdx].SetActive(true);
|
ghosts[poolIdx].SetActive(true);
|
||||||
poolIdx = (poolIdx + 1) % trajectoryObjectPoolSize;
|
poolIdx = (poolIdx + 1) % trajectoryObjectPoolSize;
|
||||||
Debug.Log($"pool idx: {poolIdx}");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,15 @@ public class Projectile : MonoBehaviour
|
||||||
|
|
||||||
private Collider projCol;
|
private Collider projCol;
|
||||||
|
|
||||||
|
[SerializeField, Range(0, 50)]
|
||||||
|
private int damage = 10;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private int wallRebounces = 4;
|
||||||
|
private int hitWalls = 0;
|
||||||
|
|
||||||
|
public HealthComponent comingFrom;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
projCol = GetComponent<Collider>();
|
projCol = GetComponent<Collider>();
|
||||||
|
@ -19,4 +28,22 @@ public class Projectile : MonoBehaviour
|
||||||
|
|
||||||
projCol.material = pMat;
|
projCol.material = pMat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnCollisionEnter(Collision collision)
|
||||||
|
{
|
||||||
|
HealthComponent hitHealthComp = collision.gameObject.GetComponent<HealthComponent>();
|
||||||
|
if (hitHealthComp == comingFrom) return;
|
||||||
|
if (hitHealthComp)
|
||||||
|
{
|
||||||
|
hitHealthComp.TakeDamage(damage);
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (++hitWalls == wallRebounces)
|
||||||
|
{
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class ProjectileTower : AimTower
|
||||||
Debug.DrawRay(transform.position, horizontalArc.ToKnobVector, Color.red, attackSecondsDelay);
|
Debug.DrawRay(transform.position, horizontalArc.ToKnobVector, Color.red, attackSecondsDelay);
|
||||||
Debug.DrawRay(transform.position, verticalArc.ToKnobVector, Color.green, attackSecondsDelay);
|
Debug.DrawRay(transform.position, verticalArc.ToKnobVector, Color.green, attackSecondsDelay);
|
||||||
Debug.DrawRay(transform.position, AimDirection, Color.yellow, attackSecondsDelay);
|
Debug.DrawRay(transform.position, AimDirection, Color.yellow, attackSecondsDelay);
|
||||||
projectileSpawner.RunBulletSequence(barrel.transform.position, transform.up, AimDirection, projectileSequence);
|
projectileSpawner.RunBulletSequence(barrel.Tip.position, transform.up, AimDirection, projectileSequence);
|
||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,5 +28,10 @@ public class HealthComponent : MonoBehaviour
|
||||||
if (currentHealth == 0)
|
if (currentHealth == 0)
|
||||||
OnHealthZero?.Invoke();
|
OnHealthZero?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SimpleKill()
|
||||||
|
{
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ public class ProjectileSpawner : MonoBehaviour
|
||||||
|
|
||||||
projectile.transform.up = bulletDir;
|
projectile.transform.up = bulletDir;
|
||||||
projectile.GetComponent<Rigidbody>().AddForce(bulletDir * bulletPattern.Speed);
|
projectile.GetComponent<Rigidbody>().AddForce(bulletDir * bulletPattern.Speed);
|
||||||
|
projectile.GetComponent<Projectile>().comingFrom = GetComponent<HealthComponent>();
|
||||||
|
|
||||||
if (bulletPattern.Burst)
|
if (bulletPattern.Burst)
|
||||||
yield return new WaitForSeconds(bulletPattern.BurstDelay);
|
yield return new WaitForSeconds(bulletPattern.BurstDelay);
|
||||||
|
|
Loading…
Reference in New Issue