Squashed commit of the following:
commit1e4ffae4f6Author: bance <90307762+bance23@users.noreply.github.com> Date: Sat May 13 14:23:47 2023 +0200 proba athozas veszelyes commit0297a2cb78Merge:604088e31b9214Author: bance <90307762+bance23@users.noreply.github.com> Date: Sat May 13 14:09:48 2023 +0200 Merge branch 'master' of https://github.com/playmaker1210/PuzzleColorBall commit31b9214f35Merge:184d2e889976bbAuthor: Playmaker1210 <hatvanitamas09@gmail.com> Date: Mon May 8 14:42:34 2023 +0200 Merge https://github.com/playmaker1210/PuzzleColorBall commit184d2e84daAuthor: Playmaker1210 <hatvanitamas09@gmail.com> Date: Mon May 8 14:41:59 2023 +0200 server mukodik commit89976bbcf8Author: playmaker1210 <75033623+playmaker1210@users.noreply.github.com> Date: Fri May 5 12:49:28 2023 +0200 Update README.md commit250cc0ffeeAuthor: playmaker1210 <75033623+playmaker1210@users.noreply.github.com> Date: Fri May 5 12:49:01 2023 +0200 Create README.md commit2f0ae77e35Author: playmaker1210 <hatvanitamas09@gmail.com> Date: Thu May 4 12:56:56 2023 +0200 update commitb94c80b293Author: Playmaker1210 <hatvanitamas09@gmail.com> Date: Tue May 2 13:46:38 2023 +0200 coin db working commit25d792e0fdAuthor: playmaker1210 <hatvanitamas09@gmail.com> Date: Sat Apr 29 17:07:23 2023 +0200 update
This commit is contained in:
@@ -7,9 +7,11 @@ public class GroundController : MonoBehaviour
|
||||
private GameObject[] ground;
|
||||
public GameObject[] loadFrom;
|
||||
public GameObject[] sideObjects;
|
||||
public GameObject[] sideObjectsSpawned;
|
||||
public Material[] materials;
|
||||
public int materialIndex = 0;
|
||||
public float groundMoveSpeed = 10f;
|
||||
private Vector3 lastSideObjectPos = new Vector3(0,0,0);
|
||||
|
||||
//private CollectibleSpawner cs;
|
||||
|
||||
@@ -18,7 +20,7 @@ public class GroundController : MonoBehaviour
|
||||
|
||||
//Loading modules
|
||||
loadFrom = LoadPrefabs("Prefabs/Modulok");
|
||||
sideObjects = LoadPrefabs("Models/World Objects/World 1");
|
||||
sideObjects = LoadPrefabs("Prefabs/WorldObjects/World1/");
|
||||
Debug.Log("loadFrom length: " + loadFrom.Length);
|
||||
Debug.Log("sideObjects Length: " + sideObjects.Length);
|
||||
|
||||
@@ -33,15 +35,27 @@ public class GroundController : MonoBehaviour
|
||||
|
||||
private void Update() {
|
||||
ground = GameObject.FindGameObjectsWithTag("Ground"); //torles miatt ujra le kell kerni a ground objecteket
|
||||
OrderGroundArrayByZ(); //rendezzuk z szerint hogy sorba legyenek
|
||||
sideObjectsSpawned = GameObject.FindGameObjectsWithTag("SideObject");
|
||||
|
||||
OrderArrayByZ(ground); //rendezzuk z szerint a talajt
|
||||
OrderArrayByZ(sideObjectsSpawned);
|
||||
|
||||
if(sideObjectsSpawned.Length > 0){
|
||||
lastSideObjectPos = sideObjectsSpawned[sideObjectsSpawned.Length-1].transform.position;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ground.Length; i++){ //ground objecteket mozgatja
|
||||
ground[i].transform.position = ground[i].transform.position + new Vector3(0,0, -groundMoveSpeed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < sideObjectsSpawned.Length; i++){
|
||||
sideObjectsSpawned[i].transform.position = sideObjectsSpawned[i].transform.position + new Vector3(0,0, -groundMoveSpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
//uj ground letrehozas
|
||||
if(ground[ground.Length-1].transform.position.z <= 120){
|
||||
CreateNewGround();
|
||||
CreateNewSideObjects(false);
|
||||
|
||||
ground = GameObject.FindGameObjectsWithTag("Ground");
|
||||
|
||||
@@ -79,6 +93,23 @@ public class GroundController : MonoBehaviour
|
||||
return arr;
|
||||
}
|
||||
|
||||
private void CreateNewSideObjects(bool isLeftSide){
|
||||
int random = UnityEngine.Random.Range(0, sideObjects.Length);
|
||||
|
||||
GameObject inst = sideObjects[random];
|
||||
Vector3 pos = new Vector3(0,0,0);
|
||||
|
||||
if(inst.name == "haz1" && !isLeftSide){
|
||||
pos = new Vector3(4,0,0); //check pos in editor TODO!!
|
||||
}else if(inst.name == "haz2"){
|
||||
pos = new Vector3(9,0,0);
|
||||
}
|
||||
|
||||
if(isLeftSide) pos.x = -pos.x;
|
||||
|
||||
Instantiate(inst, lastSideObjectPos + pos, ground[0].transform.rotation);
|
||||
}
|
||||
|
||||
public void changeMaterialIndex(){
|
||||
|
||||
int materialteszt;
|
||||
@@ -113,14 +144,14 @@ public class GroundController : MonoBehaviour
|
||||
return false; //nem torolheto
|
||||
}
|
||||
|
||||
private void OrderGroundArrayByZ(){
|
||||
private void OrderArrayByZ(GameObject[] array){
|
||||
GameObject csere;
|
||||
for (int i = 0; i < ground.Length; i++){
|
||||
for (int i = 0; i < array.Length; i++){
|
||||
for(int j = 0; j < i; j++){
|
||||
if(ground[j].transform.position.z > ground[j+1].transform.position.z){
|
||||
csere = ground[j];
|
||||
ground[j] = ground[j+1];
|
||||
ground[j+1] = csere;
|
||||
if(array[j].transform.position.z > array[j+1].transform.position.z){
|
||||
csere = array[j];
|
||||
array[j] = array[j+1];
|
||||
array[j+1] = csere;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user