side object update, portal spawn rules

This commit is contained in:
2023-05-16 14:27:55 +02:00
parent 45b782894c
commit b0bfd2f034
21 changed files with 10401 additions and 6440 deletions

View File

@@ -12,6 +12,10 @@ public class GroundController : MonoBehaviour
public int materialIndex = 0;
public float groundMoveSpeed = 10f;
private Vector3 lastSideObjectPos = new Vector3(0, 0, 0);
[SerializeField] GameObject portalModul;
[SerializeField] private int groundCounter = 0;
[SerializeField] private int portalSpawnNumber = 15; //ennyi modulonkent spawnoljon portalt
//private CollectibleSpawner cs;
@@ -51,8 +55,7 @@ public class GroundController : MonoBehaviour
OrderArrayByZ(sideObjectsSpawned);
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);
{ //ground objecteket mozgatja
Move(ground[i]);
}
@@ -62,26 +65,26 @@ public class GroundController : MonoBehaviour
Move(sideObjectsSpawned[i]);
}
if (sideObjectsSpawned[sideObjectsSpawned.Length - 1].transform.position.z < 145)
{
CreateNewSideObjects(false);
CreateNewSideObjects(true);
}
//uj ground letrehozas
if (ground[ground.Length - 1].transform.position.z <= 120)
{
CreateNewGround();
for (int k = 0; k < 3; k++)
{
CreateNewSideObjects(false);
CreateNewSideObjects(true);
if(groundCounter == portalSpawnNumber){
CreateNewGround(true);
groundCounter = 0; //ne menjen a vegtelensegig a counter
}else{
CreateNewGround();
}
ground = GameObject.FindGameObjectsWithTag("Ground");
for (int i = 0; i < ground.Length; i++)
{
/*foreach (GameObject child in ground[i].transform){
if (child.name == "Lane1" || child.name == "Lane2" || child.name == "Lane3"){
Debug.Log(child.name + " " + transform.gameObject.name);
}
}*/
Transform[] lanes = new Transform[3];
lanes[0] = ground[i].transform.Find("Lane1");
lanes[1] = ground[i].transform.Find("Lane2");
@@ -94,13 +97,6 @@ public class GroundController : MonoBehaviour
}
}
//ellenorzi hogy torolheto e az object || mar nem szukseges mert van egy trigger box
/*foreach (var item in ground){
if(CheckGroundToDestroy(item)){
Destroy(item);
}
}*/
//cs.SpawnCoin();
}
@@ -119,41 +115,46 @@ public class GroundController : MonoBehaviour
{
if (item.transform.position.x < 0 && isLeftSide)
{
side.Add(item); //ball oldal
side.Add(item); //bal oldal
}
else
else if (item.transform.position.x > 0 && !isLeftSide)
{
side.Add(item); //jobb oldal
}
}
int random = UnityEngine.Random.Range(0, sideObjects.Length);
random = 0; //csak debug
int random = UnityEngine.Random.Range(0, sideObjects.Length); //random sorsolasa a modulhoz
//random = 0; //csak debug
GameObject inst = sideObjects[random];
GameObject inst = sideObjects[random]; //random modul object eltarolas
//remake to get width
Vector3 offset = new Vector3(0, 0, 10f);
Vector3 offset = new Vector3(0, 0, 0);
if (sideObjectsSpawned.Length > 0)
if (side.Count > 0)
{
if (sideObjectsSpawned[sideObjectsSpawned.Length - 1].gameObject.name.Contains("haz1")) //haz1Clone
offset = new Vector3(0, 0, 10f); //TODO adjust
else if (sideObjectsSpawned[sideObjectsSpawned.Length - 1].gameObject.name.Contains("haz2"))
if (side[side.Count - 1].gameObject.name.Contains("haz1")) //haz1Clone
offset = new Vector3(0, 0, 15f); //TODO adjust
else if (side[side.Count - 1].gameObject.name.Contains("haz2"))
offset = new Vector3(0, 0, 20f); //TODO adjust
}
//
Vector3 pos = new Vector3(9f, 0, 0);
Vector3 pos = new Vector3(9f, -5f, -10f);
Quaternion rotation = inst.transform.rotation;
if (sideObjectsSpawned.Length > 0)
pos = sideObjectsSpawned[sideObjectsSpawned.Length - 1].transform.position + offset;
if (side.Count > 0)
//pos = sideObjectsSpawned[sideObjectsSpawned.Length - 1].transform.position + offset;
pos = side[side.Count - 1].transform.position + offset;
else
pos = pos + offset;
if (isLeftSide) pos.x = -pos.x;
Instantiate(inst, pos, inst.transform.rotation);
if (isLeftSide && pos.x > 0) //x negativ hogy a bal oldalra keruljon
pos.x = -pos.x;
Instantiate(inst, pos, rotation);
sideObjectsSpawned = GameObject.FindGameObjectsWithTag("SideObject");
OrderArrayByZ(sideObjectsSpawned);
@@ -164,10 +165,11 @@ public class GroundController : MonoBehaviour
int materialteszt;
bool teszteljtovabb = true;
while (teszteljtovabb == true)
while (teszteljtovabb)
{
materialteszt = UnityEngine.Random.Range(0, materials.Length);
Debug.Log(materialteszt);
if (materialteszt == materialIndex)
{
@@ -211,10 +213,20 @@ public class GroundController : MonoBehaviour
}
}
private void CreateNewGround()
private void CreateNewGround(bool portalModulSpawn = false)
{
int random = UnityEngine.Random.Range(0, loadFrom.Length);
GameObject inst;
if(!portalModulSpawn)
inst = loadFrom[random];
else
inst = portalModul;
//egy modullal elobb tolt be, annak az iranyanak megfeleloen, +80 a ket modul hossza
Instantiate(loadFrom[random], new Vector3(0, 0, ground[ground.Length - 1].transform.position.z + 40), ground[ground.Length - 1].transform.rotation);
Instantiate(inst, new Vector3(0, 0, ground[ground.Length - 1].transform.position.z + 40), ground[ground.Length - 1].transform.rotation);
groundCounter++;
}
}

View File

@@ -13,12 +13,9 @@ public class DatabaseData : MonoBehaviour
public PlayerList players; //jatekos adatok
public HighScoreTableDataContainer htdc; //itt van a tomb
public HighScoreTable hst; //high score table ui
private StreamWriter writer;
public string jsondata; //json szoveg
private CoinCounter coinc;
public string jsondata; //json szoveg
public ulong coins = 0;
@@ -47,7 +44,7 @@ public class DatabaseData : MonoBehaviour
url = "nodejs.dszcbaross.edu.hu:" + PORT.ToString();
}*/
url = "nodejs.dszcbaross.edu.hu:" + PORT.ToString();
//url = "nodejs.dszcbaross.edu.hu:" + PORT.ToString();
Debug.Log("<color=pink>url: </color>" + url);
}

View File

@@ -16,7 +16,7 @@ public class jatekmanager : MonoBehaviour
public static event Action<GameState> OnGameStateChanged;
//gameobjectek,gombok,scriptek
public GameObject playButton;
public GameObject playGomb;
public GameObject garazs;
public GameObject homeGomb;
public GameObject settingsGomb;
@@ -96,6 +96,7 @@ public class jatekmanager : MonoBehaviour
homeGomb.SetActive(true);
settingsGomb.SetActive(true);
shopGomb.SetActive(true);
goLeftButton.SetActive(false);
jumpButton.SetActive(false);
goRightButton.SetActive(false);
@@ -107,6 +108,7 @@ public class jatekmanager : MonoBehaviour
{
//deactivate buttons
StartCoroutine(TimerHome());
playGomb.SetActive(true);
GetComponent<GroundController>().enabled = false;
GetComponent<PlayerController>().enabled = false;
goLeftButton.SetActive(false);
@@ -120,32 +122,36 @@ public class jatekmanager : MonoBehaviour
IEnumerator TimerHome()
{
yield return new WaitForSecondsRealtime(2);
playButton.SetActive(true);
}
public void ChangeToSettings()
{
UpdateGameState(GameState.Settings);
playGomb.SetActive(false);
}
private async void HandleSettings()
{
playButton.SetActive(false);
playGomb.SetActive(false);
goLeftButton.SetActive(false);
jumpButton.SetActive(false);
goRightButton.SetActive(false);
scoreText.gameObject.SetActive(false);
timerText.gameObject.SetActive(false);
playGomb.SetActive(false);
}
public void ChangeToShop()
{
UpdateGameState(GameState.Shop);
}
private async void HandleShop()
{
playButton.SetActive(false);
playGomb.SetActive(false);
goLeftButton.SetActive(false);
jumpButton.SetActive(false);
goRightButton.SetActive(false);
@@ -158,31 +164,37 @@ public class jatekmanager : MonoBehaviour
homeGomb.SetActive(false);
settingsGomb.SetActive(false);
shopGomb.SetActive(false);
playButton.SetActive(false);
playGomb.SetActive(false);
UpdateGameState(GameState.Game);
}
IEnumerator TimerGame()
{
yield return new WaitForSecondsRealtime(1);
garazs.SetActive(false);
}
private async void HandleGame()
{
StartCoroutine(TimerGame());
GetComponent <GroundController> ().enabled = true;
GetComponent <PlayerController>().enabled = true;
goLeftButton.SetActive(true);
jumpButton.SetActive(true);
goRightButton.SetActive(true);
scoreText.gameObject.SetActive(true);
timerText.gameObject.SetActive(true);
playButton.SetActive(false);
timerText.gameObject.SetActive(true);;
timer.playTime.Start();
}
public void ChangeToMeghaltal()
@@ -205,7 +217,7 @@ public class jatekmanager : MonoBehaviour
SceneUIManager.LoadScene(1); //HighScore scene
/*playButton.SetActive(false);
/*
homeGomb.SetActive(true);
GetComponent<GroundController>().enabled = false;
GetComponent<PlayerController>().enabled = false;

View File

@@ -13,7 +13,9 @@ public class portal : MonoBehaviour
private void OnTriggerEnter(Collider other)
{
gc.changeMaterialIndex();
if(other.gameObject.tag.Equals("Player")){
gc.changeMaterialIndex();
}
}
}