Merge branch 'KingGrid'

This commit is contained in:
Katherine 2022-02-04 13:13:46 -06:00
commit 212a17ad7e
17 changed files with 877718 additions and 886916 deletions

View File

@ -0,0 +1,71 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &573422093271248785
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_LocalScale.x
value: 150
objectReference: {fileID: 0}
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_LocalScale.y
value: 150
objectReference: {fileID: 0}
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_LocalScale.z
value: 150
objectReference: {fileID: 0}
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_LocalPosition.x
value: 101.23
objectReference: {fileID: 0}
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_LocalPosition.y
value: 24.6
objectReference: {fileID: 0}
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_LocalPosition.z
value: 384.85
objectReference: {fileID: 0}
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6785323308835931190, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8397943440757562192, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}
propertyPath: m_Name
value: Block2Inch_Wood_King
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 14529042a14497c499bdce8f966e884c
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,46 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2793902819963175725
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2793902819963175727}
- component: {fileID: 2793902819963175726}
m_Layer: 0
m_Name: HailArea
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2793902819963175727
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2793902819963175725}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 460.34732, y: 505.96527, z: 1316.0963}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2793902819963175726
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2793902819963175725}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fd71374cb5b4801478a3035abe5bbaf5, type: 3}
m_Name:
m_EditorClassIdentifier:
Hail: {fileID: 3697101767757923800, guid: 5137ba8741866bd429180e6ae058498a, type: 3}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c642a15af2183e94f81d67ead9ec7326
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 8d12e8c259faaf4499d94b55863d10a9
guid: 29189dd9c413d634fab6cef95039358d
PrefabImporter:
externalObjects: {}
userData:

View File

@ -27,7 +27,7 @@ Transform:
m_GameObject: {fileID: 2481528670431999298}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 7.36, y: 0, z: -111.7}
m_LocalScale: {x: 0.25, y: 0, z: 0.25}
m_LocalScale: {x: 0.1, y: 0, z: 0.1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0

File diff suppressed because it is too large Load Diff

View File

@ -38,18 +38,24 @@ public class GridReveal : MonoBehaviour
}
else if (MovDir >= 0) { //Moving Right
Rows[Index].SetActive(false);//Deactivates Leftmost
if (Index != (Rows.Length - 1) - ROSCount) {//Prevents OfB error
if (Index <= (Rows.Length - 1) - ROSCount) {//Prevents OfB error
Rows[Index + ROSCount].SetActive(true);//Activates Rightmost
Index++;
}
}
else if (MovDir <= 0) { //Moving Left
Rows[Index].SetActive(true);//Activates Rightmost
if (Index != 0) {//Prevents OfB error
Rows[Index + ROSCount].SetActive(false);//Deactivates Leftmost
Rows[Index].SetActive(true);//Activates Leftmost
if (Index >= 0) {//Prevents OfB error
Rows[Index + ROSCount].SetActive(false);//Deactivates Rightmost
Index--;
}
}
if(Index > ((Rows.Length - 1) - ROSCount)) {
Index = (Rows.Length - 1) - ROSCount;
}
if(Index < 0) {
Index = 0;
}
}
//Mov Dir tells if the King is moving left (-1) right (1) or not at all (0)

View File

@ -16,13 +16,13 @@ public class Hail : MonoBehaviour
hail = GetComponent<Rigidbody>();//Gets the rigidbody attached to the bolder
ShadTemp = Instantiate(shadow);//Creates the shadow
ShadTemp.transform.position = new Vector3(hail.transform.position.x, 0, hail.transform.position.z);//Sets it properly directly under the hail
ShadTemp.transform.position = new Vector3(hail.transform.position.x, 0, hail.transform.position.z);//Sets it properly directly under the hail //TODO find ground and set it's y ocordingly
ShadTemp.transform.localScale = new Vector3(ShadStSz, 0, ShadStSz);//Scales it to the proper start size
m = (hail.transform.localScale.x - ShadStSz) / 30;//Find the proper rate of growth
m = (hail.transform.localScale.x - ShadStSz) / 100;//Find the proper rate of growth
}
void FixedUpdate() {
float y = m * (hail.transform.position.y-30) + ShadStSz;//Find the proper current size
float y = m * (hail.transform.position.y-100) + ShadStSz;//Find the proper current size
ShadTemp.transform.localScale = new Vector3(y, 0, y);//Scales the shadow to that size
Destruction();//Sees if it needs to destroy both
}

View File

@ -5,11 +5,11 @@ using UnityEngine;
public class HailArea : MonoBehaviour
{
// Update is called once per frame
public float Xmax = 15f;
public float Xmin = -15f;
private float Xmax = 15f;
private float Xmin = -15f;
public float Zmax = -85f;
public float Zmin = -115f;
private float Zmax = -85f;
private float Zmin = -115f;
public GameObject Hail;
@ -24,7 +24,7 @@ public class HailArea : MonoBehaviour
float radius = diameter / 2.0f;
//Random pos X Xmax-radius -> Xmin+radius
//Random pos Z Zmax-radius -> Zmin+radius
Vector3 position = new Vector3(Random.Range(Xmin + radius, Xmax - radius), 30, Random.Range(Zmin + radius, Zmax - radius));
Vector3 position = new Vector3(Random.Range(Xmin + radius, Xmax - radius), 100, Random.Range(Zmin + radius, Zmax - radius)); //TODO find ground and set y occordingly
SpawnHail(diameter, position);
}
@ -40,4 +40,11 @@ public class HailArea : MonoBehaviour
HailTemp.transform.position = pos;
HailTemp.transform.localScale = new Vector3(size, size, size);
}
public void SetArea(float LeftBound, float RightBound, float TopBound, float BottomBound) {
Xmin = LeftBound;
Xmax = RightBound;
Zmax = TopBound;
Zmin = BottomBound;
}
}

View File

@ -11,7 +11,7 @@ public class KingMove : MonoBehaviour
public GameObject Grid;
// Update is called once per frame
void Update() {
float translation = Input.GetAxis("HorizontalCam") * speed;
float translation = Input.GetAxis("KingMove") * speed;
// Make it move 10 meters per second instead of 10 meters per frame...
translation *= Time.deltaTime;

View File

@ -23,19 +23,23 @@ public class KingPlace : MonoBehaviour
public GameObject Thunderstorm;
//Is called when the King clicks on the Thunderstorm button
public void OnThundClicked() {
//TODO Spawn thunderstorms on the players
}
public GameObject Block;
public GameObject Hail;
public GameObject HailSprite;
public GameObject HailObject;
public GameObject Slime;
public GameObject Grid;
private GameObject Place;
private GameObject PlaceTemp;
private bool Placing = false;
private GameObject HailCorner;
private GameObject SlimeDir;
private bool FirstPlacing = false;
private bool HailPlacing = false;
private bool SlimePlacing = false;
private int BoxSize = 20;
private void PlaceObject(int ID) {
//Switch statement, ID-0 = Block,ID-1 = Hail,ID-2 = Slime
@ -44,7 +48,7 @@ public class KingPlace : MonoBehaviour
Place = Block;
break;
case 1:
Place = Hail;
Place = HailSprite;
break;
case 2:
Place = Slime;
@ -56,55 +60,64 @@ public class KingPlace : MonoBehaviour
Grid.GetComponent<GridReveal>().GridSwitch(true);
//The player can then see where the object will be placed, reletive to the Grid
Placing = true;
FirstPlacing = true;
}
[SerializeField] private Camera KingCam;
[SerializeField] private LayerMask LayerMask;
private void FixedUpdate() {
if (Placing == true) {
private void FixedUpdate() { //TODO Canceling out an input
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)) {
PlaceTemp.transform.position = RayCastHit.point;
}
if (Input.GetMouseButtonDown(0)) {//Reads the player clicking the left mouse button again
if (Input.GetMouseButtonDown(0)) {//Reads the player clicking the left mouse button
FindGridBox();
}
}
if (HailPlacing == 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))
{
HailCorner.transform.position = RayCastHit.point;
}
if (Input.GetMouseButtonUp(0)) {//Reads the player clicking the left mouse button again
CreateHail();
}
}
if (SlimePlacing == true) {
//TODO draw arrow in direction of slime move
//TODO CreateSlime function?
}
}
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
float y = ((PlaceTemp.transform.position.z) - 906) / -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
int z = (Box * -BoxSize) + 906;//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();
GridCheck(RowNumb, Box, ref FirstPlacing);//Makes sure the Box is a valid position
if (Place == Slime) {//If Object is Hail or Slime set the respective Placing value to true so it can launch into the secondary placing function
SlimePlacing = true;
}
else if (Place == Hail && HailPlacing == false) {
HailPlc();
else if (Place == HailSprite) {
Grid.GetComponent<GridReveal>().GridSwitch(true);
HailPlacing = true;
HailCorner = Instantiate(Place);
}
}
private void GridCheck(int Row, int Box) {
private void GridCheck(int Row, int Box, ref bool Placing) {
GameObject RowTrue;
GameObject BoxTrue;
RowTrue = Grid.transform.Find("Row" + Row).gameObject;
if(RowTrue != null) {
BoxTrue = RowTrue.transform.Find("GridChunk(0," + Box + ")").gameObject;
BoxTrue = RowTrue.transform.Find("GridChunk" + Box).gameObject;
if(BoxTrue != null) {
Grid.GetComponent<GridReveal>().GridSwitch(false); //Switch off the grid
Placing = false;//Stop placing
@ -112,14 +125,21 @@ public class KingPlace : MonoBehaviour
}
}
private void SlimePlc() {
Grid.GetComponent<GridReveal>().GridSwitch(true);
SlimePlacing = true;
}
private void HailPlc() {
Grid.GetComponent<GridReveal>().GridSwitch(true);
SlimePlacing = true;
private void CreateHail() {//TODO make sure it makes a box/actually make the Hail Area
float i = ((HailCorner.transform.position.x) - 101) / -BoxSize; //Finds the Row the cursor is in
int RowNumb = (int)i; //Rounds it down
float y = ((HailCorner.transform.position.z) - 906) / -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) + 906;//Sets its Z to the Z of the Box
HailCorner.transform.position = new Vector3(x, HailCorner.transform.position.y, z);//fully snaps it to the grid
GridCheck(RowNumb, Box, ref HailPlacing);//Makes sure the Box is a valid position
//Instanciate HailArea based on PlaceTemp = Top Left and HailCorner = Bottom Right
if (HailPlacing == false) {
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);
}
}
}

View File

@ -27,7 +27,7 @@ public class Slime : MonoBehaviour
GooTrail.transform.parent = Folder.transform;
GooTimer = 0;
}
//attempt to move forward (Raycast for objects, how to make sure it didn't fall off a cliff?)
//attempt to move forward(Raycast for objects, how to make sure it didn't fall off a cliff?)
if (transform.position.z >= StartPos || transform.position.z <= EndPos) {//Rough way of keeping turning it around when it reaches an end
MoveDir = -MoveDir;
}

View File

@ -0,0 +1,30 @@
using UnityEngine;
using UnityEditor;
public class RenameChildren : EditorWindow
{
private static readonly Vector2Int size = new Vector2Int(250, 100);
private string childrenPrefix;
private int startIndex;
[MenuItem("GameObject/Rename children")]
public static void ShowWindow()
{
EditorWindow window = GetWindow<RenameChildren>();
window.minSize = size;
window.maxSize = size;
}
private void OnGUI()
{
childrenPrefix = EditorGUILayout.TextField("Children prefix", childrenPrefix);
startIndex = EditorGUILayout.IntField("Start index", startIndex);
if (GUILayout.Button("Rename children"))
{
GameObject[] selectedObjects = Selection.gameObjects;
for (int objectI = 0; objectI < selectedObjects.Length; objectI++)
{
Transform selectedObjectT = selectedObjects[objectI].transform;
for (int childI = 0, i = startIndex; childI < selectedObjectT.childCount; childI++) selectedObjectT.GetChild(childI).name = $"{childrenPrefix}{i++}";
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a8434936019ab2641ac090dafefbeb3d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -150,13 +150,13 @@ InputManager:
axis: 2
joyNum: 0
- serializedVersion: 3
m_Name: HorizontalCam
m_Name: KingMove
descriptiveName:
descriptiveNegativeName:
negativeButton: left
positiveButton: right
altNegativeButton:
altPositiveButton:
negativeButton: a
positiveButton: d
altNegativeButton: left
altPositiveButton: right
gravity: 3
dead: 0.001
sensitivity: 3