mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-09-13 12:55:16 -05:00
Radial Menu
>Radial Menu has been bugfixed and updated >Clicking a button hides the menu >Player can cancel placing something
This commit is contained in:
@@ -20,6 +20,7 @@ public class KingPlace : NetworkBehaviour
|
||||
public void OnBlockClicked() {
|
||||
if (BoxAvaliable) {
|
||||
PlaceObject(0);
|
||||
MenuOff();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +28,7 @@ public class KingPlace : NetworkBehaviour
|
||||
public void OnHailClicked() {
|
||||
if (HailAvaliable) {
|
||||
PlaceObject(1);
|
||||
MenuOff();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +36,7 @@ public class KingPlace : NetworkBehaviour
|
||||
public void OnSlimeClicked() {
|
||||
if (SlimeAvaliable) {
|
||||
PlaceObject(2);
|
||||
MenuOff();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +46,7 @@ public class KingPlace : NetworkBehaviour
|
||||
if (ThundAvaliable) {
|
||||
//TODO thunderstorm
|
||||
Cooldown(3);
|
||||
MenuOff();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,8 +57,9 @@ public class KingPlace : NetworkBehaviour
|
||||
public GameObject HailObject;
|
||||
public GameObject Slime;
|
||||
private GameObject Grid;
|
||||
public GameObject Panel;
|
||||
private GameObject Place;
|
||||
private GameObject PlaceTemp;
|
||||
private GameObject PlaceTemp = null;
|
||||
private GameObject HailCorner;
|
||||
private int SlimeDir;
|
||||
private bool FirstPlacing = false;
|
||||
@@ -72,31 +77,36 @@ public class KingPlace : NetworkBehaviour
|
||||
}
|
||||
|
||||
private void PlaceObject(int ID) {
|
||||
//Switch statement, ID-0 = Block,ID-1 = Hail,ID-2 = Slime
|
||||
switch (ID) {//Parses in the button clicked into the right object that the King is placing
|
||||
case 0:
|
||||
Place = BlockWithoutNetwork;
|
||||
break;
|
||||
case 1:
|
||||
Place = HailSprite;
|
||||
break;
|
||||
case 2:
|
||||
Place = Slime;
|
||||
break;
|
||||
}
|
||||
//Create the object that will follow the Mouse
|
||||
PlaceTemp = Instantiate(Place);
|
||||
//Layout the grid
|
||||
Grid.GetComponent<GridReveal>().GridSwitch(true);
|
||||
//Switch statement, ID-0 = Block,ID-1 = Hail,ID-2 = Slime
|
||||
switch (ID)
|
||||
{//Parses in the button clicked into the right object that the King is placing
|
||||
case 0:
|
||||
Place = BlockWithoutNetwork;
|
||||
break;
|
||||
case 1:
|
||||
Place = HailSprite;
|
||||
break;
|
||||
case 2:
|
||||
Place = Slime;
|
||||
break;
|
||||
}
|
||||
//Create the object that will follow the Mouse
|
||||
PlaceTemp = Instantiate(Place);
|
||||
//Layout the grid
|
||||
Grid.GetComponent<GridReveal>().GridSwitch(true);
|
||||
|
||||
//The player can then see where the object will be placed, reletive to the Grid
|
||||
FirstPlacing = true;
|
||||
//The player can then see where the object will be placed, reletive to the Grid
|
||||
FirstPlacing = true;
|
||||
}
|
||||
|
||||
private void MenuOff() {
|
||||
Panel.GetComponent<RadialMenu>().MenuOff();
|
||||
}
|
||||
|
||||
[SerializeField] private Camera KingCam;
|
||||
[SerializeField] private LayerMask LayerMask;
|
||||
|
||||
private void Update() { //TODO Canceling out an input
|
||||
private void Update() {
|
||||
if (FirstPlacing == true) {
|
||||
Ray Ray = KingCam.ScreenPointToRay(Input.mousePosition);//Raycast to find the point where the mouse cursor is
|
||||
if (Physics.Raycast(Ray, out RaycastHit RayCastHit, float.MaxValue, LayerMask)) {
|
||||
@@ -105,6 +115,11 @@ public class KingPlace : NetworkBehaviour
|
||||
if (Input.GetMouseButtonDown(0)) {//Reads the player clicking the left mouse button
|
||||
FindGridBox();
|
||||
}
|
||||
if (Input.GetMouseButtonUp(1)) {//Allows the player to cancel out a button press
|
||||
Destroy(PlaceTemp);
|
||||
Grid.GetComponent<GridReveal>().GridSwitch(false);
|
||||
FirstPlacing = false;
|
||||
}
|
||||
}
|
||||
if (HailPlacing == true) {
|
||||
Ray Ray = KingCam.ScreenPointToRay(Input.mousePosition);//Raycast to find the point where the mouse cursor is
|
||||
@@ -129,6 +144,7 @@ public class KingPlace : NetworkBehaviour
|
||||
|
||||
private void FixedUpdate() {
|
||||
CooldownTimer();
|
||||
EnergyRefill();
|
||||
}
|
||||
|
||||
private GameObject Row;
|
||||
@@ -210,6 +226,8 @@ public class KingPlace : NetworkBehaviour
|
||||
GameObject Temp;
|
||||
Temp = Instantiate(HailObject);
|
||||
Temp.GetComponent<HailArea>().SetArea(PlaceTemp.transform.position.x, HailCorner.transform.position.x, PlaceTemp.transform.position.z, HailCorner.transform.position.z);
|
||||
Destroy(PlaceTemp);
|
||||
Destroy(HailCorner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,6 +324,22 @@ public class KingPlace : NetworkBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private bool SpendEnergy(int cost) {
|
||||
if (Energy > cost) {
|
||||
Energy -= cost;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void EnergyRefill() {
|
||||
if(Energy < 100) {
|
||||
Energy++;
|
||||
}
|
||||
}
|
||||
|
||||
[ServerRpc(RequireOwnership = false)]
|
||||
private void SpawnBoxServerRPC(Vector3 spawnLoc) {
|
||||
boxPlaced = Instantiate(Block, spawnLoc, Quaternion.identity);
|
||||
|
||||
@@ -13,6 +13,7 @@ public class RadialMenu : MonoBehaviour
|
||||
transform.position = Input.mousePosition;//Moved the UI to where the mouse is
|
||||
}
|
||||
if(Input.GetAxis("RadialMenu") > 0) {//Pressing Q makes the UI appear
|
||||
//Stop placing if already placing
|
||||
MenuOn();
|
||||
}
|
||||
if (Input.GetAxis("RadialMenu") < 0) {//Pressing E makes the UI dissapear
|
||||
@@ -20,20 +21,18 @@ public class RadialMenu : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void MenuOn()
|
||||
private void MenuOn()
|
||||
{
|
||||
foreach (Transform child in transform) { //Turns on all of the different buttons attached to this panel and stops it from moving
|
||||
child.gameObject.SetActive(true);
|
||||
Debug.Log("Wax On");
|
||||
UIOn = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuOff()
|
||||
public void MenuOff()
|
||||
{
|
||||
foreach (Transform child in transform) { //Turns off all of the different buttons attached to this panel and starts it moving again
|
||||
child.gameObject.SetActive(false);
|
||||
Debug.Log("Wax Off");
|
||||
UIOn = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user