Worked on re-implementing powerups through GUI

main
Ivy 4 years ago
parent 9da379ebc6
commit 061b635c27

@ -777,7 +777,19 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 526643977} m_TargetGraphic: {fileID: 526643977}
m_OnClick: m_OnClick:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls:
- m_Target: {fileID: 1874083437}
m_TargetAssemblyTypeName: GameManager, Assembly-CSharp
m_MethodName: GliderButtonClicked
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &526643977 --- !u!114 &526643977
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1409,7 +1421,19 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 974869914} m_TargetGraphic: {fileID: 974869914}
m_OnClick: m_OnClick:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls:
- m_Target: {fileID: 1874083437}
m_TargetAssemblyTypeName: GameManager, Assembly-CSharp
m_MethodName: ShrinkButtonClicked
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &974869914 --- !u!114 &974869914
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

@ -137,36 +137,17 @@ public class GameManager : MonoBehaviour
private void doPowerupCheck() private void doPowerupCheck()
{ {
if (obtainedPowerups.Contains(Powerup.Glider)) //if (obtainedPowerups.Contains(Powerup.Glider))
{ //{
if (Input.GetKeyDown("1")) // if (Input.GetKeyDown("1"))
{ // {
var index = Array.IndexOf(obtainedPowerups.ToArray(), Powerup.Glider); // var index = Array.IndexOf(obtainedPowerups.ToArray(), Powerup.Glider);
var status = powerupStatus[index]; // var status = powerupStatus[index];
player.GetComponent<Glider>().IsGliding = !status; // player.GetComponent<Glider>().IsGliding = !status;
powerupStatus[index] = !status; // powerupStatus[index] = !status;
} // }
} //}
if (obtainedPowerups.Contains(Powerup.HealthUp))
{
player.GetComponent<Health>().maxHealth = 150;
}
if (obtainedPowerups.Contains(Powerup.DoubleJump))
{
player.GetComponent<movement>().maxJumps = 2;
}
if (obtainedPowerups.Contains(Powerup.Shrink))
{
if (Input.GetKeyDown("2"))
{
player.GetComponent<Shrink>().startShrinking();
Debug.Log("Start Shrink Logic");
}
}
} }
public GameObject GetPlayer() public GameObject GetPlayer()
@ -228,5 +209,22 @@ public class GameManager : MonoBehaviour
disablePowerup(i); disablePowerup(i);
} }
} }
public void GliderButtonClicked()
{
Debug.Log("Is Gliding? " + player.GetComponent<Glider>().IsGliding);
player.GetComponent<Glider>().IsGliding = !player.GetComponent<Glider>().IsGliding;
}
public void ShrinkButtonClicked()
{
player.GetComponent<Shrink>().startShrinking();
Debug.Log("Start Shrink Logic");
}
public void DoubleJumpClicked()
{
player.GetComponent<movement>().maxJumps = 2;
}
} }

@ -19,8 +19,7 @@ public class HealthUpPowerup : MonoBehaviour
private void OnTriggerEnter2D(Collider2D collision) private void OnTriggerEnter2D(Collider2D collision)
{ {
Debug.Log("HealthUp Powerup Obtained"); Debug.Log("HealthUp Powerup Obtained");
GameManager.Instance.obtainedPowerups.Add(Powerup.HealthUp); GameManager.Instance.player.GetComponent<Health>().maxHealth = 150;
GameManager.Instance.powerupStatus.Add(false);
Destroy(gameObject); Destroy(gameObject);
} }
} }

Loading…
Cancel
Save