Upgrade System
This commit is contained in:
@@ -41,6 +41,7 @@ Transform:
|
||||
- {fileID: 4152598028236711869}
|
||||
- {fileID: 4740856695113674186}
|
||||
- {fileID: 1598670840411184170}
|
||||
- {fileID: 749125587594098812}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!212 &4824869534615406026
|
||||
@@ -262,12 +263,24 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
Health: 100
|
||||
MaxHealth: 100
|
||||
HealValue: 1
|
||||
Speed: 2
|
||||
Exp: 0
|
||||
Level: 1
|
||||
BeamDamages: 50
|
||||
BeamFequency: 5
|
||||
SwordsDamages: 25
|
||||
ArrowDamages: 15
|
||||
ArrowRange: 5
|
||||
ArrowFrequency: 2
|
||||
laserOnX: 0
|
||||
laserOnY: 0
|
||||
MayorKills: 0
|
||||
MinautorKills: 0
|
||||
BringerOfDeathKills: 0
|
||||
pauseMenu: {fileID: 1161238801143918071}
|
||||
deathScreen: {fileID: 8536456763282141865}
|
||||
_upgradeScreen: {fileID: 3552072345333957438}
|
||||
--- !u!114 &2991086602376010793
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -281,8 +294,6 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
laser: {fileID: 4893257253370123985, guid: 95cb513377bf0e248bd66d6f7ddae920, type: 3}
|
||||
laserOnX: 0
|
||||
laserOnY: 0
|
||||
arrow: {fileID: 6280786298679187013, guid: 856a449688373494987701d49b79a7af, type: 3}
|
||||
--- !u!1001 &993819705047970090
|
||||
PrefabInstance:
|
||||
@@ -292,10 +303,6 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 3622515600777588477}
|
||||
m_Modifications:
|
||||
- target: {fileID: -8230784050683220836, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
|
||||
propertyPath: initialSwordsCount
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3957911104700806788, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Halo
|
||||
@@ -513,6 +520,10 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: Death Screen
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7779035698592798071, guid: be2de9e5d757ee447a79f8ad0528d930, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
@@ -528,3 +539,70 @@ GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 7779035698592798071, guid: be2de9e5d757ee447a79f8ad0528d930, type: 3}
|
||||
m_PrefabInstance: {fileID: 2126607160633550814}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &3519923663120457319
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 3622515600777588477}
|
||||
m_Modifications:
|
||||
- target: {fileID: 113215708914507097, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Upgrade Screen
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4232304121047868955, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4232304121047868955, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4232304121047868955, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4232304121047868955, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4232304121047868955, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4232304121047868955, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4232304121047868955, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4232304121047868955, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4232304121047868955, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4232304121047868955, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
--- !u!4 &749125587594098812 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 4232304121047868955, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
m_PrefabInstance: {fileID: 3519923663120457319}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &3552072345333957438 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 113215708914507097, guid: c16dc07d15aa39d4ba76ea86b13d279e, type: 3}
|
||||
m_PrefabInstance: {fileID: 3519923663120457319}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
|
||||
@@ -3,17 +3,25 @@ using UnityEngine;
|
||||
|
||||
[
|
||||
RequireComponent(typeof(PlayerManager)),
|
||||
RequireComponent(typeof(SpriteRenderer))
|
||||
RequireComponent(typeof(SpriteRenderer)),
|
||||
RequireComponent(typeof(CircleCollider2D))
|
||||
]
|
||||
public class PlayerCollisions : MonoBehaviour
|
||||
{
|
||||
private PlayerManager _pm;
|
||||
private PlayerManager _manager;
|
||||
private SpriteRenderer _sr;
|
||||
private CircleCollider2D _trigger;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_pm = GetComponent<PlayerManager>();
|
||||
_manager = GetComponent<PlayerManager>();
|
||||
_sr = GetComponent<SpriteRenderer>();
|
||||
_trigger = GetComponent<CircleCollider2D>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
_trigger.radius = _manager.OrbAbsorberRadius;
|
||||
}
|
||||
|
||||
private void OnTriggerStay2D(Collider2D collision)
|
||||
@@ -39,7 +47,7 @@ public class PlayerCollisions : MonoBehaviour
|
||||
|
||||
if (orb.transform.position == transform.position)
|
||||
{
|
||||
_pm.AddExperience((int)orb.GetComponent<OrbStats>().OrbValue);
|
||||
_manager.AddExperience((int)orb.GetComponent<OrbStats>().OrbValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,28 +3,44 @@ using UnityEngine;
|
||||
public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
// Character stats
|
||||
public int Health = 100;
|
||||
public int MaxHealth = 100;
|
||||
public int HealValue = 1;
|
||||
[Header("Character Stats")]
|
||||
public float Health = 100f;
|
||||
public float MaxHealth = 100f;
|
||||
public float HealValue = 1f;
|
||||
public float Speed = 2f;
|
||||
public int Exp = 0;
|
||||
public int Level = 1;
|
||||
public float Exp = 0f;
|
||||
public float Level = 1f;
|
||||
public float OrbAbsorberRadius = 0.7f;
|
||||
|
||||
// Weapons stats
|
||||
public int BeamDamages = 50;
|
||||
public int SwordsDamages = 25;
|
||||
public int ArrowDamages = 15;
|
||||
[Header("Weapons Stats")]
|
||||
public float BeamDamages = 50f;
|
||||
public float BeamFrequency = 5f;
|
||||
public float BeamLife = 0.5f;
|
||||
|
||||
public float SwordsHaloRadius = 1f;
|
||||
public float SwordsDamages = 25f;
|
||||
public float SwordsQuantity = 5f;
|
||||
|
||||
public float ArrowDamages = 15f;
|
||||
public float ArrowRange = 5f;
|
||||
public float ArrowFrequency = 2f;
|
||||
|
||||
public float laserOnX = 0f;
|
||||
public float laserOnY = 0f;
|
||||
|
||||
// Kills stats
|
||||
[Header("Kills Stats")]
|
||||
public int MayorKills = 0;
|
||||
public int MinautorKills = 0;
|
||||
public int BringerOfDeathKills = 0;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject pauseMenu;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject deathScreen;
|
||||
[SerializeField]
|
||||
private GameObject _upgradeScreen;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -33,6 +49,16 @@ public class PlayerManager : MonoBehaviour
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (BeamFrequency < 0f)
|
||||
{
|
||||
BeamFrequency = 0f;
|
||||
}
|
||||
|
||||
if (ArrowFrequency < 0.5f)
|
||||
{
|
||||
ArrowFrequency = 0.5f;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
pauseMenu.SetActive(true);
|
||||
@@ -48,6 +74,9 @@ public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
Exp -= Level * 10;
|
||||
Level++;
|
||||
Time.timeScale = 0f;
|
||||
_upgradeScreen.SetActive(true);
|
||||
_upgradeScreen.GetComponentInChildren<UpgradeScreen>().GenerateChoice();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,12 +88,9 @@ public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
Health = 0;
|
||||
|
||||
// Death animation + menu
|
||||
Time.timeScale = 0f;
|
||||
deathScreen.SetActive(true);
|
||||
deathScreen.GetComponent<DeathScreen>().ShowScreen();
|
||||
} else
|
||||
{
|
||||
// Damage animation
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +1,84 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent (typeof(PlayerMovements))]
|
||||
public class PlayerWeapons : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject laser;
|
||||
[SerializeField] private bool laserOnX;
|
||||
[SerializeField] private bool laserOnY;
|
||||
|
||||
[SerializeField] private GameObject arrow;
|
||||
|
||||
private PlayerMovements _pm;
|
||||
private PlayerManager _manager;
|
||||
|
||||
private float oldBeamFrequency;
|
||||
private bool oldBeamX;
|
||||
private bool oldBeamY;
|
||||
|
||||
private float oldArrowFrequency;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_pm = GetComponent<PlayerMovements>();
|
||||
_manager = GetComponent<PlayerManager>();
|
||||
|
||||
InvokeRepeating(nameof(ShootBeam), 5f, 5f);
|
||||
InvokeRepeating(nameof(ShootArrow), 2f, 2f);
|
||||
oldBeamFrequency = _manager.BeamFrequency;
|
||||
oldBeamX = Convert.ToBoolean(_manager.laserOnX);
|
||||
oldBeamY = Convert.ToBoolean(_manager.laserOnY);
|
||||
oldArrowFrequency = _manager.ArrowFrequency;
|
||||
|
||||
InvokeRepeating(nameof(ShootBeam), _manager.BeamFrequency, _manager.BeamFrequency);
|
||||
InvokeRepeating(nameof(ShootArrow), _manager.ArrowFrequency, _manager.ArrowFrequency);
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (_manager.BeamFrequency != oldBeamFrequency)
|
||||
{
|
||||
if (_manager.BeamFrequency > 0f)
|
||||
{
|
||||
CancelInvoke(nameof(ShootBeam));
|
||||
InvokeRepeating(nameof(ShootBeam), _manager.BeamFrequency, _manager.BeamFrequency);
|
||||
}
|
||||
else
|
||||
{
|
||||
CancelInvoke(nameof(ShootBeam));
|
||||
ShootBeam();
|
||||
}
|
||||
oldBeamFrequency = _manager.BeamFrequency;
|
||||
}
|
||||
|
||||
if (_manager.BeamFrequency == 0)
|
||||
{
|
||||
if (oldBeamX != Convert.ToBoolean(_manager.laserOnX) || oldBeamY != Convert.ToBoolean(_manager.laserOnY))
|
||||
{
|
||||
foreach (var beam in GameObject.FindGameObjectsWithTag("Beam"))
|
||||
{
|
||||
Destroy(beam);
|
||||
}
|
||||
oldBeamX = Convert.ToBoolean(_manager.laserOnX);
|
||||
oldBeamY = Convert.ToBoolean(_manager.laserOnY);
|
||||
ShootBeam();
|
||||
}
|
||||
}
|
||||
|
||||
if (_manager.ArrowFrequency != oldArrowFrequency)
|
||||
{
|
||||
CancelInvoke(nameof(ShootArrow));
|
||||
InvokeRepeating(nameof(ShootArrow), _manager.ArrowFrequency, _manager.ArrowFrequency);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShootBeam()
|
||||
{
|
||||
GameObject defaultBeam = Instantiate(laser, transform.position, _pm.lookOnRight ? Quaternion.identity : Quaternion.Euler(0, 0, 180), transform);
|
||||
defaultBeam.GetComponent<LaserBeam>().Damages = _manager.BeamDamages;
|
||||
Instantiate(laser, transform.position, Quaternion.identity, transform);
|
||||
|
||||
if (laserOnX)
|
||||
if (_manager.laserOnX > 0)
|
||||
{
|
||||
Instantiate(laser, transform.position, _pm.lookOnRight ? Quaternion.Euler(0, 0, 180) : Quaternion.identity, transform);
|
||||
Instantiate(laser, transform.position, Quaternion.Euler(0, 0, 180), transform);
|
||||
}
|
||||
|
||||
if (laserOnY)
|
||||
if (_manager.laserOnY > 0)
|
||||
{
|
||||
Instantiate(laser, transform.position, Quaternion.Euler(0, 0, 90), transform);
|
||||
Instantiate(laser, transform.position, Quaternion.Euler(0, 0, 270), transform);
|
||||
@@ -43,7 +89,7 @@ public class PlayerWeapons : MonoBehaviour
|
||||
private void ShootArrow()
|
||||
{
|
||||
// Get all enemies in given radius
|
||||
Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, 20f, LayerMask.GetMask("Enemy"));
|
||||
Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, _manager.ArrowRange, LayerMask.GetMask("Enemy"));
|
||||
|
||||
if (hits.Length <= 0)
|
||||
{
|
||||
@@ -68,7 +114,6 @@ public class PlayerWeapons : MonoBehaviour
|
||||
{
|
||||
GameObject spawnedArrow = Instantiate(arrow, transform.position, Quaternion.identity);
|
||||
spawnedArrow.GetComponent<Arrow>().target = target;
|
||||
spawnedArrow.GetComponent<Arrow>().Damages = _manager.ArrowDamages;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user