diff options
Diffstat (limited to 'Assets')
-rw-r--r-- | Assets/Scripts/Actors/Enemy.cs | 22 | ||||
-rw-r--r-- | Assets/Scripts/Actors/Enemy.cs.meta (renamed from Assets/Scripts/Weapon.cs.meta) | 2 | ||||
-rw-r--r-- | Assets/Scripts/Actors/Player.cs | 8 | ||||
-rw-r--r-- | Assets/Scripts/Weapon.cs | 23 |
4 files changed, 31 insertions, 24 deletions
diff --git a/Assets/Scripts/Actors/Enemy.cs b/Assets/Scripts/Actors/Enemy.cs new file mode 100644 index 0000000..b45f7d3 --- /dev/null +++ b/Assets/Scripts/Actors/Enemy.cs @@ -0,0 +1,22 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace MontanaJohns.Actors +{ + [RequireComponent(typeof(Rigidbody2D))] + public class Enemy : Actor + { + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } + } +} diff --git a/Assets/Scripts/Weapon.cs.meta b/Assets/Scripts/Actors/Enemy.cs.meta index 6546dd7..26a1d77 100644 --- a/Assets/Scripts/Weapon.cs.meta +++ b/Assets/Scripts/Actors/Enemy.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2b8de137e60a3cb418e266e99100d25f +guid: 6751c31468656894092c67dc838ac9a6 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Actors/Player.cs b/Assets/Scripts/Actors/Player.cs index 3192338..012c09a 100644 --- a/Assets/Scripts/Actors/Player.cs +++ b/Assets/Scripts/Actors/Player.cs @@ -10,6 +10,8 @@ namespace MontanaJohns.Actors { public Transform ActorTransform => _transform; public Camera MainCamera => _camera; + public GameObject projectilePrefab; + public Transform firePoint; Camera _camera; PlayerInput playerInput; @@ -27,6 +29,7 @@ namespace MontanaJohns.Actors jump.started += context => Jump(); use.started += context => Use(); + use.started += context => Fire(); } protected override void Start() @@ -49,5 +52,10 @@ namespace MontanaJohns.Actors base.Move(move.ReadValue<Vector2>().x); } } + + protected void Fire() + { + Instantiate(projectilePrefab, firePoint.position, firePoint.rotation); + } } }
\ No newline at end of file diff --git a/Assets/Scripts/Weapon.cs b/Assets/Scripts/Weapon.cs deleted file mode 100644 index 1af1abb..0000000 --- a/Assets/Scripts/Weapon.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Weapon : MonoBehaviour -{ - public Transform firePoint; - public GameObject projectilePrefab; - - // Update is called once per frame - void Update() - { - if (Input.GetButtonDown("Fire1")) - { - Shoot(); - } - } - - void Shoot() - { - Instantiate(projectilePrefab, firePoint.position, firePoint.rotation); - } -} |