Skip to content

Commit 1770cef

Browse files
committed
Updated astroids, starting to work on weapon refactor
1 parent 307635b commit 1770cef

File tree

14 files changed

+265
-147
lines changed

14 files changed

+265
-147
lines changed

3d Space Shooter/Assets/_project/Scenes/Main.unity

Lines changed: 152 additions & 137 deletions
Large diffs are not rendered by default.

3d Space Shooter/Assets/_project/prefabs/weapons/PlayerProjectile.prefab

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ GameObject:
1010
m_Component:
1111
- component: {fileID: 5431537632488067617}
1212
- component: {fileID: 2180402012114632322}
13-
m_Layer: 0
13+
m_Layer: 7
1414
m_Name: Point Light
1515
m_TagString: Untagged
1616
m_Icon: {fileID: 0}
@@ -107,7 +107,7 @@ GameObject:
107107
- component: {fileID: 7193285325348713242}
108108
- component: {fileID: 6560869677144345826}
109109
- component: {fileID: -2242831835989082323}
110-
m_Layer: 0
110+
m_Layer: 7
111111
m_Name: PlayerProjectile
112112
m_TagString: Untagged
113113
m_Icon: {fileID: 0}
@@ -312,7 +312,7 @@ GameObject:
312312
- component: {fileID: 8521477749198998380}
313313
- component: {fileID: 2864937483986811375}
314314
- component: {fileID: 642948304268538313}
315-
m_Layer: 0
315+
m_Layer: 7
316316
m_Name: Capsule
317317
m_TagString: Untagged
318318
m_Icon: {fileID: 0}

3d Space Shooter/Assets/_project/scripts/Asteroids/Asteroid.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,30 @@
22
using System.Collections.Generic;
33
using UnityEngine;
44

5-
public class Asteroid : MonoBehaviour
5+
public class Asteroid : MonoBehaviour, IDamagable
66
{
7+
[SerializeField] private FracturedAstroid _fracturedAsteroidPrefab;
8+
[SerializeField] private Detonator _explosionPrefab;
9+
10+
public void TakeDamage(int damage, Vector3 hitPosition)
11+
{
12+
FractureAstroid(hitPosition);
13+
}
14+
15+
private Transform _transform;
16+
private void Awake() {
17+
_transform = transform;
18+
}
19+
20+
private void FractureAstroid(Vector3 hitposition) {
21+
if (_fracturedAsteroidPrefab != null) {
22+
Instantiate(_fracturedAsteroidPrefab, _transform.position, _transform.rotation);
23+
}
24+
if (_explosionPrefab != null) {
25+
Instantiate(_explosionPrefab, hitposition, Quaternion.identity);
26+
}
27+
}
28+
729
// Start is called before the first frame update
830
void Start()
931
{

3d Space Shooter/Assets/_project/scripts/Asteroids/FracturedAstroid.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
public class FracturedAstroid : MonoBehaviour
66
{
7+
[SerializeField] [Range(1f, 60f)] private float _duration = 10f;
78
// Start is called before the first frame update
8-
void Start()
9+
void OnEnable()
910
{
10-
11+
Destroy(gameObject, _duration);
1112
}
1213

1314
// Update is called once per frame
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using UnityEngine;
2+
3+
public interface IDamagable {
4+
public void TakeDamage(int damage, Vector3 hitPosition);
5+
}

3d Space Shooter/Assets/_project/scripts/Asteroids/IDamagable.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using UnityEngine;
2+
3+
public class DesktopWeaponControls : WeaponControlsBase
4+
{
5+
public override bool PrimaryFired => Input.GetMouseButton(0);
6+
7+
public override bool SecondaryFired => Input.GetMouseButton(1);
8+
}

3d Space Shooter/Assets/_project/scripts/ShipControls/DesktopWeaponControls.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
public interface IWeaponControls
3+
{
4+
bool PrimaryFired {get;}
5+
6+
bool SecondaryFired{get;}
7+
8+
}

3d Space Shooter/Assets/_project/scripts/ShipControls/IWeaponControls.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)