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