Laser beam
This commit is contained in:
@@ -17,6 +17,7 @@ GameObject:
|
||||
- component: {fileID: 3787322971358149925}
|
||||
- component: {fileID: 7397454076540391921}
|
||||
- component: {fileID: 8339747699126584523}
|
||||
- component: {fileID: 2991086602376010793}
|
||||
m_Layer: 0
|
||||
m_Name: Player
|
||||
m_TagString: Player
|
||||
@@ -232,6 +233,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 32f5e7611866dce4ab320c814d279d84, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
lookOnRight: 1
|
||||
--- !u!114 &7397454076540391921
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -261,7 +263,23 @@ MonoBehaviour:
|
||||
Speed: 2
|
||||
Exp: 0
|
||||
Level: 1
|
||||
MayorKills: 0
|
||||
pauseMenu: {fileID: 1161238801143918071}
|
||||
--- !u!114 &2991086602376010793
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1784956759114531697}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ce23672c2f6b5bd42adf4a7776a52005, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
laser: {fileID: 4893257253370123985, guid: 95cb513377bf0e248bd66d6f7ddae920, type: 3}
|
||||
laserOnX: 0
|
||||
laserOnY: 0
|
||||
--- !u!1001 &1611953582756194365
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 -------------------------------------------*/
|
||||
|
||||
@@ -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:
|
||||
Reference in New Issue
Block a user