mirror of
https://github.com/ConjureETS/Labo_2_equ_2_a15.git
synced 2026-03-24 01:21:07 +00:00
Enemy are now using health script
This commit is contained in:
parent
f5aa6a457b
commit
615180326d
@ -13,6 +13,7 @@ GameObject:
|
|||||||
- 61: {fileID: 6163544}
|
- 61: {fileID: 6163544}
|
||||||
- 114: {fileID: 11431192}
|
- 114: {fileID: 11431192}
|
||||||
- 95: {fileID: 9512508}
|
- 95: {fileID: 9512508}
|
||||||
|
- 114: {fileID: 11482776}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Enemy
|
m_Name: Enemy
|
||||||
m_TagString: Enemy
|
m_TagString: Enemy
|
||||||
@ -43,7 +44,7 @@ Rigidbody2D:
|
|||||||
m_LinearDrag: 0
|
m_LinearDrag: 0
|
||||||
m_AngularDrag: .0500000007
|
m_AngularDrag: .0500000007
|
||||||
m_GravityScale: 1
|
m_GravityScale: 1
|
||||||
m_IsKinematic: 0
|
m_IsKinematic: 1
|
||||||
m_Interpolate: 0
|
m_Interpolate: 0
|
||||||
m_SleepingMode: 1
|
m_SleepingMode: 1
|
||||||
m_CollisionDetection: 0
|
m_CollisionDetection: 0
|
||||||
@ -89,8 +90,19 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 2995a96f18c88c3499b43774e78a5e9b, type: 3}
|
m_Script: {fileID: 11500000, guid: 2995a96f18c88c3499b43774e78a5e9b, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
HP: 2
|
|
||||||
ground: {fileID: 0}
|
ground: {fileID: 0}
|
||||||
|
--- !u!114 &11482776
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 183722}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 28110cf2b286c534c94e41ea7e145ef0, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
maxHP: 2
|
||||||
--- !u!212 &21249000
|
--- !u!212 &21249000
|
||||||
SpriteRenderer:
|
SpriteRenderer:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
@ -132,6 +144,14 @@ Prefab:
|
|||||||
propertyPath: m_TagString
|
propertyPath: m_TagString
|
||||||
value: Enemy
|
value: Enemy
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 0}
|
||||||
|
propertyPath: m_IsKinematic
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 0}
|
||||||
|
propertyPath: maxHP
|
||||||
|
value: 2
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_ParentPrefab: {fileID: 0}
|
m_ParentPrefab: {fileID: 0}
|
||||||
m_RootGameObject: {fileID: 183722}
|
m_RootGameObject: {fileID: 183722}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public class RocketBehaviour : MonoBehaviour {
|
|||||||
// If it hits an enemy...
|
// If it hits an enemy...
|
||||||
if (collision.gameObject.tag == "Enemy") {
|
if (collision.gameObject.tag == "Enemy") {
|
||||||
// ... find the Enemy script and call the Hurt function.
|
// ... find the Enemy script and call the Hurt function.
|
||||||
collision.gameObject.GetComponent<EnemyBehavior> ().Hurt ();
|
collision.gameObject.GetComponent<Health> ().removeHP(1);
|
||||||
|
|
||||||
// call the explosion animation
|
// call the explosion animation
|
||||||
Explode ();
|
Explode ();
|
||||||
|
|||||||
@ -8,7 +8,7 @@ public class EnemyBehavior : MonoBehaviour {
|
|||||||
private bool facingRight = true;
|
private bool facingRight = true;
|
||||||
private bool dead = false;
|
private bool dead = false;
|
||||||
|
|
||||||
public int HP = 2;
|
private Health hp;
|
||||||
|
|
||||||
|
|
||||||
// Ground
|
// Ground
|
||||||
@ -20,6 +20,7 @@ public class EnemyBehavior : MonoBehaviour {
|
|||||||
rb = GetComponent<Rigidbody2D>();
|
rb = GetComponent<Rigidbody2D>();
|
||||||
|
|
||||||
groundBounds = ground.GetComponent<Renderer>().bounds;
|
groundBounds = ground.GetComponent<Renderer>().bounds;
|
||||||
|
hp = GetComponent<Health>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
@ -34,7 +35,7 @@ public class EnemyBehavior : MonoBehaviour {
|
|||||||
flip();
|
flip();
|
||||||
|
|
||||||
// If the enemy has zero or fewer hit points and isn't dead yet...
|
// If the enemy has zero or fewer hit points and isn't dead yet...
|
||||||
if(HP <= 0 && !dead)
|
if(GetComponent<Health>().getHP() == 0 && !dead)
|
||||||
// ... call the death function.
|
// ... call the death function.
|
||||||
Death ();
|
Death ();
|
||||||
|
|
||||||
@ -48,12 +49,6 @@ public class EnemyBehavior : MonoBehaviour {
|
|||||||
transform.localScale = scale;
|
transform.localScale = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Hurt()
|
|
||||||
{
|
|
||||||
// Reduce the number of hit points by one.
|
|
||||||
HP--;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Death()
|
void Death()
|
||||||
{
|
{
|
||||||
// Set dead to true.
|
// Set dead to true.
|
||||||
|
|||||||
@ -8,7 +8,6 @@ PlayerSettings:
|
|||||||
defaultScreenOrientation: 4
|
defaultScreenOrientation: 4
|
||||||
targetDevice: 2
|
targetDevice: 2
|
||||||
targetResolution: 0
|
targetResolution: 0
|
||||||
useOnDemandResources: 0
|
|
||||||
accelerometerFrequency: 60
|
accelerometerFrequency: 60
|
||||||
companyName: DefaultCompany
|
companyName: DefaultCompany
|
||||||
productName: Laboratoire_2_Equipe_2
|
productName: Laboratoire_2_Equipe_2
|
||||||
@ -29,7 +28,6 @@ PlayerSettings:
|
|||||||
androidShowActivityIndicatorOnLoading: -1
|
androidShowActivityIndicatorOnLoading: -1
|
||||||
iosAppInBackgroundBehavior: 0
|
iosAppInBackgroundBehavior: 0
|
||||||
displayResolutionDialog: 1
|
displayResolutionDialog: 1
|
||||||
iosAllowHTTPDownload: 1
|
|
||||||
allowedAutorotateToPortrait: 1
|
allowedAutorotateToPortrait: 1
|
||||||
allowedAutorotateToPortraitUpsideDown: 1
|
allowedAutorotateToPortraitUpsideDown: 1
|
||||||
allowedAutorotateToLandscapeRight: 1
|
allowedAutorotateToLandscapeRight: 1
|
||||||
@ -137,15 +135,6 @@ PlayerSettings:
|
|||||||
iOSLaunchScreenFillPct: 100
|
iOSLaunchScreenFillPct: 100
|
||||||
iOSLaunchScreenSize: 100
|
iOSLaunchScreenSize: 100
|
||||||
iOSLaunchScreenCustomXibPath:
|
iOSLaunchScreenCustomXibPath:
|
||||||
iOSLaunchScreeniPadType: 0
|
|
||||||
iOSLaunchScreeniPadImage: {fileID: 0}
|
|
||||||
iOSLaunchScreeniPadBackgroundColor:
|
|
||||||
serializedVersion: 2
|
|
||||||
rgba: 0
|
|
||||||
iOSLaunchScreeniPadFillPct: 100
|
|
||||||
iOSLaunchScreeniPadSize: 100
|
|
||||||
iOSLaunchScreeniPadCustomXibPath:
|
|
||||||
iOSDeviceRequirements: []
|
|
||||||
AndroidTargetDevice: 0
|
AndroidTargetDevice: 0
|
||||||
AndroidSplashScreenScale: 0
|
AndroidSplashScreenScale: 0
|
||||||
androidSplashScreen: {fileID: 0}
|
androidSplashScreen: {fileID: 0}
|
||||||
@ -235,8 +224,6 @@ PlayerSettings:
|
|||||||
ps4SdkOverride:
|
ps4SdkOverride:
|
||||||
ps4BGMPath:
|
ps4BGMPath:
|
||||||
ps4ShareFilePath:
|
ps4ShareFilePath:
|
||||||
ps4ShareOverlayImagePath:
|
|
||||||
ps4PrivacyGuardImagePath:
|
|
||||||
ps4NPtitleDatPath:
|
ps4NPtitleDatPath:
|
||||||
ps4RemotePlayKeyAssignment: -1
|
ps4RemotePlayKeyAssignment: -1
|
||||||
ps4RemotePlayKeyMappingDir:
|
ps4RemotePlayKeyMappingDir:
|
||||||
@ -258,7 +245,6 @@ PlayerSettings:
|
|||||||
ps4attribMoveSupport: 0
|
ps4attribMoveSupport: 0
|
||||||
ps4attrib3DSupport: 0
|
ps4attrib3DSupport: 0
|
||||||
ps4attribShareSupport: 0
|
ps4attribShareSupport: 0
|
||||||
ps4IncludedModules: []
|
|
||||||
monoEnv:
|
monoEnv:
|
||||||
psp2Splashimage: {fileID: 0}
|
psp2Splashimage: {fileID: 0}
|
||||||
psp2NPTrophyPackPath:
|
psp2NPTrophyPackPath:
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
m_EditorVersion: 5.2.1f1
|
m_EditorVersion: 5.2.0f3
|
||||||
m_StandardAssetsVersion: 0
|
m_StandardAssetsVersion: 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user