rev 0.4, dev panel
This commit is contained in:
93
Assets/Scripts/DevSettingsPanel.cs
Normal file
93
Assets/Scripts/DevSettingsPanel.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class DevSettingsPanel : MonoBehaviour
|
||||
{
|
||||
public static Action OnChanged;
|
||||
public static DevSettingsPanel instance;
|
||||
|
||||
public Transform contentParent;
|
||||
public DevOptionItem devOptionItemPrefab;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
StartCoroutine(CoroutinePopulate());
|
||||
}
|
||||
|
||||
IEnumerator CoroutinePopulate()
|
||||
{
|
||||
yield return new WaitForSeconds(1f); //Wait for the game manager to be initialized
|
||||
Populate();
|
||||
}
|
||||
|
||||
void Populate()
|
||||
{
|
||||
DevOptionItem puckForce = Instantiate(devOptionItemPrefab, contentParent);
|
||||
puckForce.Setup("Puck Force", 2500, 6000, GameManager.instance.puckForce);
|
||||
puckForce.OnChanged += OnPuckForceChanged;
|
||||
|
||||
DevOptionItem puckDragClampMax = Instantiate(devOptionItemPrefab, contentParent);
|
||||
puckDragClampMax.Setup("Puck Launch Max Length", 1, 10, GameManager.instance.puckDragClampMax);
|
||||
puckDragClampMax.OnChanged += OnPuckDragClampMaxChanged;
|
||||
|
||||
DevOptionItem puckDragClampMin = Instantiate(devOptionItemPrefab, contentParent);
|
||||
puckDragClampMin.Setup("Puck Launch Min Length", 0, 2, GameManager.instance.puckDragMinClamp);
|
||||
puckDragClampMin.OnChanged += OnPuckDragClampMinChanged;
|
||||
|
||||
DevOptionItem ballMoveTime = Instantiate(devOptionItemPrefab, contentParent);
|
||||
ballMoveTime.Setup("Ball Drag", 0f, 10, GameManager.instance.ballMoveTime);
|
||||
ballMoveTime.OnChanged += OnBallMoveTimeChanged;
|
||||
|
||||
DevOptionItem puckMass = Instantiate(devOptionItemPrefab, contentParent);
|
||||
puckMass.Setup("Puck Mass", 1f, 50, GameManager.instance.puckMass);
|
||||
puckMass.OnChanged += OnPuckMassChanged;
|
||||
|
||||
DevOptionItem puckDrag = Instantiate(devOptionItemPrefab, contentParent);
|
||||
puckDrag.Setup("Puck Drag", 0f, 10, GameManager.instance.puckDrag);
|
||||
puckDrag.OnChanged += OnPuckDragChanged;
|
||||
}
|
||||
|
||||
|
||||
void OnPuckForceChanged(float value)
|
||||
{
|
||||
GameManager.instance.puckForce = value;
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
|
||||
void OnPuckDragClampMaxChanged(float value)
|
||||
{
|
||||
GameManager.instance.puckDragClampMax = value;
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
|
||||
void OnPuckDragClampMinChanged(float value)
|
||||
{
|
||||
GameManager.instance.puckDragMinClamp = value;
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
|
||||
void OnBallMoveTimeChanged(float value)
|
||||
{
|
||||
GameManager.instance.ballMoveTime = value;
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
|
||||
void OnPuckMassChanged(float value)
|
||||
{
|
||||
GameManager.instance.puckMass = value;
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
|
||||
void OnPuckDragChanged(float value)
|
||||
{
|
||||
GameManager.instance.puckDrag = value;
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user