diff --git a/Assets/Scenes/Demos/KingImpGraybox.unity b/Assets/Scenes/Demos/KingImpGraybox.unity index ac08dc1..1d4dce1 100644 --- a/Assets/Scenes/Demos/KingImpGraybox.unity +++ b/Assets/Scenes/Demos/KingImpGraybox.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.45042813, g: 0.5004341, b: 0.5752089, a: 1} + m_IndirectSpecularColor: {r: 0.45042783, g: 0.50043404, b: 0.5752084, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -9782,7 +9782,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6c342edd8126e1449a50220a14c9333e, type: 3} m_Name: m_EditorClassIdentifier: - Inv: {fileID: 0} + stats: {fileID: 0} uiPrebab: {fileID: 2234979236645149946, guid: 757a136ec05bee247970d9f727f6b5f2, type: 3} --- !u!114 &358007096 MonoBehaviour: @@ -57219,6 +57219,7 @@ MonoBehaviour: maxGrappleDistance: 25 isGrappled: 0 ropeLength: 0 + forceDirection: {x: 0, y: 0, z: 0} --- !u!1001 &1043847406924501847 PrefabInstance: m_ObjectHideFlags: 0 @@ -59178,6 +59179,7 @@ MonoBehaviour: maxVel: 25 minVel: 2 curVel: 0 + hardCapMaxVel: 60 acc: 0.1 jumpPow: 300 jumpNum: 2 @@ -59290,6 +59292,10 @@ PrefabInstance: propertyPath: m_Name value: King objectReference: {fileID: 0} + - target: {fileID: 8183403964090928733, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: m_Enabled + value: 1 + 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 61f6607..0b56d13 100644 --- a/Assets/Scripts/KingScripts/KingPlace.cs +++ b/Assets/Scripts/KingScripts/KingPlace.cs @@ -2,13 +2,14 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class KingPlace : MonoBehaviour { +public class KingPlace : MonoBehaviour +{ //Is called when the King clicks on the Block button public void OnBlockClicked() { PlaceObject(0); } - + //Is called when the King clicks on the Hail button public void OnHailClicked() { PlaceObject(1); @@ -31,26 +32,26 @@ public class KingPlace : MonoBehaviour { public GameObject Slime; public GameObject Grid; private GameObject Place; + private GameObject PlaceTemp; private bool Placing = false; + private bool HailPlacing = false; + private bool SlimePlacing = false; 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: - Debug.Log("B"); Place = Block; break; case 1: - Debug.Log("H"); Place = Hail; break; case 2: - Debug.Log("S"); Place = Slime; break; } //Create the object that will follow the Mouse - //Instantiate(Place); + PlaceTemp = Instantiate(Place); //Layout the grid Grid.GetComponent().GridSwitch(true); @@ -61,24 +62,64 @@ public class KingPlace : MonoBehaviour { [SerializeField] private Camera KingCam; [SerializeField] private LayerMask LayerMask; - private void Update() { - if(Placing == true) { - Ray Ray = KingCam.ScreenPointToRay(Input.mousePosition); + private void FixedUpdate() { + if (Placing == 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)) { - Place.transform.position = RayCastHit.point; + PlaceTemp.transform.position = RayCastHit.point; } - if (Input.GetMouseButtonUp(1)) {//Reads the player letting up the right mouse button - //foreach (Transform child in Grid.gameObject.transform) { //Finds the correct Row the cursor is in (Commented out because it's scuffed AF) - //if (child.transform.position.z >= Place.transform.position.x && child.transform.position.z - 20 <= Place.transform.position.x) - //{ - // Debug.Log("Help" + child.transform.position.z); - //Place the object (Snap it up and to Grid) - Instantiate(Place); - //break; - //} + if (Input.GetMouseButtonDown(0)) {//Reads the player clicking the left mouse button again + FindGridBox(); + } + } + if (HailPlacing == true) { + + } + if (SlimePlacing == true) { + + } + } + + private GameObject Row; + private void FindGridBox() { + int BoxSize = 20; + float i = ((PlaceTemp.transform.position.x) - 101) / -BoxSize; //Finds the Row the cursor is in + int RowNumb = (int)i; //Rounds it down + float y = ((PlaceTemp.transform.position.z) - 626) / -BoxSize; //Finds the Box in the Row the cursor is in + int Box = (int)y; //Rounds it down + int x = (RowNumb * -BoxSize) + 101;//Sets it's X to the X of the Row + int z = (Box * -BoxSize) + 626;//Sets its Z to the Z of the Box + PlaceTemp.transform.position = new Vector3(x, PlaceTemp.transform.position.y, z);//fully snaps it to the grid + GridCheck(RowNumb, Box);//Makes sure the Box is a valid position + if (Place == Slime && SlimePlacing == false) {//If Object is Hail or Slime launch into other functions + SlimePlc(); + } + else if (Place == Hail && HailPlacing == false) { + HailPlc(); + } + } + + private void GridCheck(int Row, int Box) { + GameObject RowTrue; + GameObject BoxTrue; + RowTrue = Grid.transform.Find("Row" + Row).gameObject; + if(RowTrue != null) { + BoxTrue = RowTrue.transform.Find("GridChunk(0," + Box + ")").gameObject; + if(BoxTrue != null) { Grid.GetComponent().GridSwitch(false); //Switch off the grid Placing = false;//Stop placing } } } + + private void SlimePlc() { + Grid.GetComponent().GridSwitch(true); + SlimePlacing = true; + } + + private void HailPlc() { + Grid.GetComponent().GridSwitch(true); + SlimePlacing = true; + } + } diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index 3fff0e2..f22d616 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -20,6 +20,9 @@ EditorUserSettings: RecentlyUsedScenePath-4: value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26 flags: 0 + RecentlyUsedScenePath-5: + value: 22424703114646680e0b0227036c7b151b180b650721283704240d14f0e12d3aedff78fce9332b25 + flags: 0 vcSharedLogLevel: value: 0d5e400f0650 flags: 0