Update Enemy Return Func & Pastie Spawning
This commit is contained in:
parent
6688ec3137
commit
eea58ac447
@ -176,6 +176,10 @@ MonoBehaviour:
|
|||||||
rigidbody2D: {fileID: 0}
|
rigidbody2D: {fileID: 0}
|
||||||
normalSpeed: 5
|
normalSpeed: 5
|
||||||
returnSpeed: 5
|
returnSpeed: 5
|
||||||
|
droppedObject: {fileID: 2252406525984333962, guid: a445f9af9bec11a4e89494c4031e6162,
|
||||||
|
type: 3}
|
||||||
|
deathEffect: {fileID: 1496494696399852, guid: e61802031429a4e2e8f547dbca07fe84,
|
||||||
|
type: 3}
|
||||||
--- !u!114 &114000011533140650
|
--- !u!114 &114000011533140650
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
20
Unity-Files/Assets/Examples/Defender/Pastie.prefab
generated
20
Unity-Files/Assets/Examples/Defender/Pastie.prefab
generated
@ -11,6 +11,7 @@ GameObject:
|
|||||||
- component: {fileID: 3590677777586087654}
|
- component: {fileID: 3590677777586087654}
|
||||||
- component: {fileID: 1762312007996219834}
|
- component: {fileID: 1762312007996219834}
|
||||||
- component: {fileID: 9035969042858155278}
|
- component: {fileID: 9035969042858155278}
|
||||||
|
- component: {fileID: 2612555762601387375}
|
||||||
- component: {fileID: 885697997895152444}
|
- component: {fileID: 885697997895152444}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Pastie
|
m_Name: Pastie
|
||||||
@ -28,7 +29,7 @@ Transform:
|
|||||||
m_GameObject: {fileID: 2252406525984333962}
|
m_GameObject: {fileID: 2252406525984333962}
|
||||||
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}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 2, y: 2, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 4878835270198494247}
|
- {fileID: 4878835270198494247}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
@ -111,6 +112,19 @@ BoxCollider2D:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 0.29, y: 0.14}
|
m_Size: {x: 0.29, y: 0.14}
|
||||||
m_EdgeRadius: 0
|
m_EdgeRadius: 0
|
||||||
|
--- !u!114 &2612555762601387375
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2252406525984333962}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2d5bb11f68e548f4b8699da51f5e5982, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
timeToDestruction: 10
|
||||||
--- !u!210 &885697997895152444
|
--- !u!210 &885697997895152444
|
||||||
SortingGroup:
|
SortingGroup:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -121,7 +135,7 @@ SortingGroup:
|
|||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_SortingLayerID: 0
|
m_SortingLayerID: 0
|
||||||
m_SortingLayer: 0
|
m_SortingLayer: 0
|
||||||
m_SortingOrder: 0
|
m_SortingOrder: -6
|
||||||
--- !u!1 &8759752071964469198
|
--- !u!1 &8759752071964469198
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -203,7 +217,7 @@ TextMesh:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 8759752071964469198}
|
m_GameObject: {fileID: 8759752071964469198}
|
||||||
m_Text: 5
|
m_Text:
|
||||||
m_OffsetZ: 0
|
m_OffsetZ: 0
|
||||||
m_CharacterSize: 0.05
|
m_CharacterSize: 0.05
|
||||||
m_LineSpacing: 1
|
m_LineSpacing: 1
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 7fb007fc909a54d4e9f2700296b8898d
|
guid: 2d5bb11f68e548f4b8699da51f5e5982
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
@ -10,6 +10,10 @@ public class EnemyReturn : Physics2DObject
|
|||||||
public float normalSpeed = 5f;
|
public float normalSpeed = 5f;
|
||||||
[Tooltip("The amount of speed in which the boat moves away from the castle")]
|
[Tooltip("The amount of speed in which the boat moves away from the castle")]
|
||||||
public float returnSpeed = 5f;
|
public float returnSpeed = 5f;
|
||||||
|
[Header("Dropped Object")]
|
||||||
|
public GameObject droppedObject;
|
||||||
|
[Header("Death Effect When Shot")]
|
||||||
|
public GameObject deathEffect;
|
||||||
|
|
||||||
private bool isReturning = false;
|
private bool isReturning = false;
|
||||||
private Vector2 movement = new Vector2(0f, 0f);
|
private Vector2 movement = new Vector2(0f, 0f);
|
||||||
@ -43,14 +47,28 @@ public class EnemyReturn : Physics2DObject
|
|||||||
string playerTag = otherCollider.gameObject.tag;
|
string playerTag = otherCollider.gameObject.tag;
|
||||||
if (playerTag == "Player" || playerTag == "Player2")
|
if (playerTag == "Player" || playerTag == "Player2")
|
||||||
{
|
{
|
||||||
HealthSystemAttribute healthScript = otherCollider.gameObject.GetComponent<HealthSystemAttribute>();
|
// HealthSystemAttribute healthScript = otherCollider.gameObject.GetComponent<HealthSystemAttribute>();
|
||||||
if (healthScript != null)
|
// if (healthScript != null)
|
||||||
{
|
// {
|
||||||
// subtract health from the player
|
// // subtract health from the player
|
||||||
healthScript.ModifyHealth(-1);
|
// healthScript.ModifyHealth(-1);
|
||||||
}
|
// }
|
||||||
this.GetComponent<SpriteRenderer>().flipY = false;
|
this.GetComponent<SpriteRenderer>().flipY = false;
|
||||||
isReturning = true;
|
isReturning = true;
|
||||||
}
|
}
|
||||||
|
else if (playerTag == "Bullet")
|
||||||
|
{
|
||||||
|
if (deathEffect != null)
|
||||||
|
{
|
||||||
|
GameObject newDeathEffect = Instantiate<GameObject>(deathEffect);
|
||||||
|
newDeathEffect.transform.position = this.transform.position;
|
||||||
|
}
|
||||||
|
float randomX = Random.Range(0, 1);
|
||||||
|
float randomY = Random.Range(0, 1);
|
||||||
|
GameObject newDroppedObject = Instantiate<GameObject>(droppedObject);
|
||||||
|
newDroppedObject.transform.position = new Vector2(randomX + this.transform.position.x, randomY + this.transform.position.y);
|
||||||
|
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user