Laser beam

This commit is contained in:
2023-10-16 12:15:44 +02:00
parent 6bfb6f8642
commit eb51da13ed
16 changed files with 336 additions and 3 deletions
+3
View File
@@ -10,6 +10,9 @@ public class PlayerManager : MonoBehaviour
public int Exp = 0;
public int Level = 1;
// Kills stats
public int MayorKills = 0;
[SerializeField]
private GameObject pauseMenu;
+4
View File
@@ -7,6 +7,8 @@ public class PlayerMovements : MonoBehaviour
private Animator _animator;
private PlayerManager _pm;
public bool lookOnRight = true;
private void Start()
{
_sr = GetComponent<SpriteRenderer>();
@@ -26,9 +28,11 @@ public class PlayerMovements : MonoBehaviour
if (moveH < 0)
{
_sr.flipX = true;
lookOnRight = false;
} else if (moveH > 0)
{
_sr.flipX = false;
lookOnRight = true;
}
/** --- update animator -------------------------------------------*/
+35
View File
@@ -0,0 +1,35 @@
using UnityEngine;
[RequireComponent (typeof(PlayerMovements))]
public class PlayerWeapons : MonoBehaviour
{
[SerializeField] private GameObject laser;
[Header("If all are false: only on 1 side")]
[SerializeField] private bool laserOnX;
[SerializeField] private bool laserOnY;
private PlayerMovements _pm;
private void Start()
{
_pm = GetComponent<PlayerMovements>();
InvokeRepeating(nameof(ShootBeam), 5f, 5f);
}
private void ShootBeam()
{
Instantiate(laser, transform.position, _pm.lookOnRight ? Quaternion.identity : Quaternion.Euler(0, 0, 180), transform);
if (laserOnX)
{
Instantiate(laser, transform.position, _pm.lookOnRight ? Quaternion.Euler(0, 0, 180) : Quaternion.identity, transform);
}
if (laserOnY)
{
Instantiate(laser, transform.position, Quaternion.Euler(0, 0, 90), transform);
Instantiate(laser, transform.position, Quaternion.Euler(0, 0, 270), transform);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce23672c2f6b5bd42adf4a7776a52005
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: