Fixes #30
This commit is contained in:
parent
1c2983053a
commit
88496c99ae
5 changed files with 20 additions and 12 deletions
|
@ -1153,7 +1153,7 @@ Prefab:
|
||||||
- target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
- target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||||
type: 2}
|
type: 2}
|
||||||
propertyPath: m_AnchoredPosition.x
|
propertyPath: m_AnchoredPosition.x
|
||||||
value: 66.396866
|
value: 65.89836
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
- target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||||
type: 2}
|
type: 2}
|
||||||
|
@ -1185,6 +1185,10 @@ Prefab:
|
||||||
propertyPath: m_SizeDelta.x
|
propertyPath: m_SizeDelta.x
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1604998495297016, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2}
|
||||||
|
propertyPath: m_IsActive
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_ParentPrefab: {fileID: 100100000, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2}
|
m_ParentPrefab: {fileID: 100100000, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2}
|
||||||
m_IsPrefabParent: 0
|
m_IsPrefabParent: 0
|
||||||
|
|
|
@ -7,13 +7,17 @@ public class Bullet : MonoBehaviour {
|
||||||
protected float speed = 1;
|
protected float speed = 1;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
int damage = 0;
|
int damage = 0;
|
||||||
|
[SerializeField]
|
||||||
GameObject owner;
|
bool start = false;
|
||||||
|
string ownertag;
|
||||||
Rigidbody2D body;
|
Rigidbody2D body;
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start () {
|
void Start () {
|
||||||
body = GetComponent<Rigidbody2D>();
|
body = GetComponent<Rigidbody2D>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartBullet() {
|
||||||
|
start = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSpeed(float spd) {
|
public void SetSpeed(float spd) {
|
||||||
|
@ -25,25 +29,25 @@ public class Bullet : MonoBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetOwner(GameObject ow) {
|
public void SetOwner(GameObject ow) {
|
||||||
owner = ow;
|
ownertag = ow.tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixedUpdate() {
|
private void FixedUpdate() {
|
||||||
if ( owner == null )
|
if ( start == false )
|
||||||
return;
|
return;
|
||||||
body.MovePosition(transform.position + transform.localRotation * Vector3.up * speed * Time.fixedDeltaTime);
|
body.MovePosition(transform.position + transform.localRotation * Vector3.up * speed * Time.fixedDeltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnTriggerEnter2D(Collider2D collider) {
|
void OnTriggerEnter2D(Collider2D collider) {
|
||||||
if ( owner == null )
|
if ( ownertag == null )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( collider.gameObject.tag != owner.tag ) {
|
if ( collider.gameObject.tag != ownertag ) {
|
||||||
Mob m = collider.gameObject.GetComponent(typeof(Mob)) as Mob;
|
Mob m = collider.gameObject.GetComponent(typeof(Mob)) as Mob;
|
||||||
if (m != null) {
|
if (m != null) {
|
||||||
m.InflictDamage(damage);
|
m.InflictDamage(damage);
|
||||||
}
|
}
|
||||||
Destroy(this.gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@ namespace Assets.Scripts.Entities.Attack {
|
||||||
bu.SetDamage(damage);
|
bu.SetDamage(damage);
|
||||||
bu.SetSpeed(speed);
|
bu.SetSpeed(speed);
|
||||||
bu.SetOwner(owner);
|
bu.SetOwner(owner);
|
||||||
GameController.instance.GetAudioControl().SfxPlay(AudioControl.Sfx.shoot);
|
bu.StartBullet();
|
||||||
|
GameController.instance.GetAudioControl().SfxPlay(AudioControl.Sfx.shoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetCooldownTime() {
|
public float GetCooldownTime() {
|
||||||
|
|
|
@ -45,9 +45,8 @@ public class Player : Mob {
|
||||||
}
|
}
|
||||||
if ( Time.timeSinceLevelLoad >= nextAttackTime && attack != null) {
|
if ( Time.timeSinceLevelLoad >= nextAttackTime && attack != null) {
|
||||||
if ( Input.GetAxis("Fire") > 0 ) {
|
if ( Input.GetAxis("Fire") > 0 ) {
|
||||||
Debug.Log("Attack pressed!");
|
|
||||||
attack.Attack();
|
attack.Attack();
|
||||||
nextAttackTime = Time.timeSinceLevelLoad + attack.GetCooldownTime();
|
nextAttackTime = Time.timeSinceLevelLoad + attack.GetCooldownTime(); // Todo put in attack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// scale particle emissions by speed
|
// scale particle emissions by speed
|
||||||
|
|
|
@ -333,7 +333,7 @@ public class GameController : MonoBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EndGame(EndedCause cause) {
|
public void EndGame(EndedCause cause) {
|
||||||
if (endCause != null && state == GameState.ENDED)
|
if (state == GameState.ENDED)
|
||||||
return; // Already ended game
|
return; // Already ended game
|
||||||
endCause = cause;
|
endCause = cause;
|
||||||
ChangeState(GameState.ENDED);
|
ChangeState(GameState.ENDED);
|
||||||
|
|
Loading…
Add table
Reference in a new issue