Upgrade System

This commit is contained in:
2023-10-22 15:08:39 +02:00
parent d265c8214a
commit 7ebff78708
34 changed files with 1901 additions and 199 deletions
+24 -6
View File
@@ -5,13 +5,31 @@ using UnityEngine;
[RequireComponent (typeof(BoxCollider2D))]
public class LaserBeam : MonoBehaviour
{
public int Damages = 50;
public float lifeSeconds = .2f;
private PlayerManager _manager;
private PlayerMovements _movements;
public void Start()
{
StartCoroutine(nameof(EndLifeAfterXSeconds));
_manager = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerManager>();
_movements = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerMovements>();
if (_manager.BeamFrequency > 0)
{
StartCoroutine(nameof(EndLifeAfterXSeconds));
}
}
private void Update()
{
if (_manager.laserOnX == 0)
{
if (!_movements.lookOnRight)
{
transform.rotation = Quaternion.Euler(0f, 180f, 0f);
} else
{
transform.rotation = Quaternion.Euler(0f, 0f, 0f);
}
}
}
private void OnTriggerEnter2D(Collider2D collision)
@@ -26,13 +44,13 @@ public class LaserBeam : MonoBehaviour
{
if (collision.CompareTag("Ennemy"))
{
collision.gameObject.GetComponent<Ennemy>().Life -= (int)(Damages * Time.deltaTime);
collision.gameObject.GetComponent<Ennemy>().Life -= (int)(_manager.BeamDamages * Time.deltaTime);
}
}
private IEnumerator EndLifeAfterXSeconds()
{
yield return new WaitForSeconds(lifeSeconds);
yield return new WaitForSeconds(_manager.BeamLife);
Destroy(gameObject);
}
}
+3 -4
View File
@@ -72,7 +72,7 @@ SpriteRenderer:
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: -1
m_SortingOrder: 0
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
@@ -97,7 +97,7 @@ GameObject:
- component: {fileID: 1475843655422961594}
m_Layer: 0
m_Name: Laser Beam
m_TagString: Untagged
m_TagString: Beam
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@@ -133,7 +133,7 @@ BoxCollider2D:
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_Bits: 63
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
@@ -175,4 +175,3 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 85af5326636cca14082a8bc4f4dfedcc, type: 3}
m_Name:
m_EditorClassIdentifier:
Damages: 50