diff --git a/Assets/Scenes/Demos/KingImpGraybox.unity b/Assets/Scenes/Demos/KingImpGraybox.unity index 69d288b..75a841c 100644 --- a/Assets/Scenes/Demos/KingImpGraybox.unity +++ b/Assets/Scenes/Demos/KingImpGraybox.unity @@ -61626,6 +61626,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 4195644339311798069, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: Panel + value: + objectReference: {fileID: 1884077319} - target: {fileID: 4195644339311798069, guid: d23bf55f2a40d494487eb188930f895d, type: 3} propertyPath: Slime value: @@ -61722,6 +61726,10 @@ PrefabInstance: propertyPath: m_IsActive value: 1 objectReference: {fileID: 0} + - target: {fileID: 8183403963861912040, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} - target: {fileID: 8183403963861912047, guid: d23bf55f2a40d494487eb188930f895d, type: 3} propertyPath: m_SizeDelta.x value: 45 @@ -61802,10 +61810,26 @@ PrefabInstance: propertyPath: m_Enabled value: 1 objectReference: {fileID: 0} + - target: {fileID: 8183403964090928733, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: field of view + value: 50 + objectReference: {fileID: 0} - target: {fileID: 8183403964090928733, guid: d23bf55f2a40d494487eb188930f895d, type: 3} propertyPath: far clip plane value: 3000 objectReference: {fileID: 0} + - target: {fileID: 8183403964090928735, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: m_LocalRotation.w + value: 0.9063079 + objectReference: {fileID: 0} + - target: {fileID: 8183403964090928735, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: m_LocalRotation.x + value: 0.42261827 + objectReference: {fileID: 0} + - target: {fileID: 8183403964090928735, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 50 + objectReference: {fileID: 0} - target: {fileID: 8183403964692436328, guid: d23bf55f2a40d494487eb188930f895d, type: 3} propertyPath: m_SizeDelta.x value: 45 @@ -61828,7 +61852,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 8183403964692436329, guid: d23bf55f2a40d494487eb188930f895d, type: 3} propertyPath: m_IsActive - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 8183403964692436334, guid: d23bf55f2a40d494487eb188930f895d, type: 3} propertyPath: m_Color.b @@ -61878,6 +61902,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 8183403965182652615, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} - target: {fileID: 8183403965183742968, guid: d23bf55f2a40d494487eb188930f895d, type: 3} propertyPath: m_SizeDelta.x value: 45 @@ -61898,6 +61926,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 8183403965183742969, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: d23bf55f2a40d494487eb188930f895d, type: 3} --- !u!143 &8445875816224330693 diff --git a/Assets/Scripts/KingScripts/KingPlace.cs b/Assets/Scripts/KingScripts/KingPlace.cs index 721a6ef..65dfb87 100644 --- a/Assets/Scripts/KingScripts/KingPlace.cs +++ b/Assets/Scripts/KingScripts/KingPlace.cs @@ -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().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().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().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().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().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); diff --git a/Assets/Scripts/KingScripts/RadialMenu.cs b/Assets/Scripts/KingScripts/RadialMenu.cs index 1b45ce3..e03c312 100644 --- a/Assets/Scripts/KingScripts/RadialMenu.cs +++ b/Assets/Scripts/KingScripts/RadialMenu.cs @@ -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; } }