Commit b8bf6cad authored by Mitchie Maluschnig's avatar Mitchie Maluschnig
Browse files

added some scalability to trapeze generation

parent eae17825
......@@ -574,7 +574,11 @@ MonoBehaviour:
AvgXSepparation: 10
XDifference: 0.8
YRange: 6.08
maxYrange: 20
maxDificulty: 100
maxXProgression: 30
minXProgression: 5
maxYProgression: 0
minYProgression: 0
--- !u!4 &141131300
Transform:
m_ObjectHideFlags: 0
......@@ -2243,7 +2247,7 @@ Rigidbody2D:
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_CollisionDetection: 1
m_Constraints: 0
--- !u!212 &2089978959
SpriteRenderer:
......
......@@ -9,15 +9,20 @@ public class GenerateTrapezes : MonoBehaviour {
public float AvgXSepparation = 10;
public float XDifference = 0.8f;
public float YRange = 2;
public float maxYrange = 10;
private GameObject player;
private Transform playerHands;
private Transform[] initialTrapezes = new Transform[3];
private Transform[] currentTrapezeInLevel = new Transform[3];
private int numTrapezes;
public int maxDificulty = 100;
public float maxXProgression = 30;
public float minXProgression = 5;
public float maxYProgression = 0;
public float minYProgression = 0;
// Use this for initialization
void Start () {
......@@ -30,15 +35,16 @@ public class GenerateTrapezes : MonoBehaviour {
//next 3 trapezes
Vector3 newTrapeze = firstTrapeze.position;
newTrapeze.x += AvgXSepparation;
newTrapeze.y += -YRange * 2;
//top
newTrapeze.y += YRange * 2;
initialTrapezes[0] = Instantiate(trapeze, newTrapeze, Quaternion.identity).transform;
currentTrapezeInLevel[0] = initialTrapezes[0];
newTrapeze.y += YRange * 2;
//middle
newTrapeze.y += -YRange * 2;
initialTrapezes[1] = Instantiate(trapeze, newTrapeze, Quaternion.identity).transform;
currentTrapezeInLevel[1] = initialTrapezes[1];
newTrapeze.y += YRange * 2;
//bottom
newTrapeze.y += -YRange * 2;
initialTrapezes[2] = Instantiate(trapeze, newTrapeze, Quaternion.identity).transform;
currentTrapezeInLevel[2] = initialTrapezes[2];
......@@ -47,17 +53,14 @@ public class GenerateTrapezes : MonoBehaviour {
// Update is called once per frame
void Update () {
//for (int i = 0; i < currentTrapezeInLevel.Length; i++) {
// if (currentTrapezeInLevel[i].position.x <= playerHands.position.x + 2 * AvgXSepparation) {
// Vector3 newTrapeze = currentTrapezeInLevel[i].position;
// newTrapeze.x += AvgXSepparation;
// newTrapeze.y = Mathf.Clamp(Random.Range(newTrapeze.y - YRange, newTrapeze.y + YRange),initialTrapezes[i].position.y - maxYrange, initialTrapezes[i].position.y + maxYrange);
//trapezeGeneration();
ScalingTrapezeGeneration();
// currentTrapezeInLevel[i] = Instantiate(trapeze, newTrapeze, Quaternion.identity).transform;
// }
//}
}
//second way
private void trapezeGeneration() {
//non-Scaling trapeze Generation
for (int i = 0; i < currentTrapezeInLevel.Length; i++) {
if (currentTrapezeInLevel[i].position.x <= playerHands.position.x + 2 * AvgXSepparation/*use camera stuff maybe*/) {
Vector3 newTrapeze = initialTrapezes[i].position;
......@@ -67,7 +70,42 @@ public class GenerateTrapezes : MonoBehaviour {
currentTrapezeInLevel[i] = Instantiate(trapeze, newTrapeze, Quaternion.identity).transform;
}
}
}
private void ScalingTrapezeGeneration() {
//Scaling trapeze Generation
print(numTrapezes / 3);
float progression = (numTrapezes / 3) / (float)maxDificulty;
if (progression > 1) progression = 1;
float XScaler = 0;
float YScaler = 0;
XScaler += Random.Range(minXProgression, maxXProgression) * progression;
for (int i = 0; i < currentTrapezeInLevel.Length; i++) {
if (currentTrapezeInLevel[i].position.x <= playerHands.position.x + 2 * AvgXSepparation/*use camera stuff maybe*/) {
if (i == 0) {
//top tier
YScaler += Random.Range(minYProgression, maxYProgression) * progression;
} else if (i == 2) {
//middle tier
} else {
//bottom tier
YScaler -= Random.Range(minYProgression, maxYProgression) * progression;
}
Vector3 newTrapeze = initialTrapezes[i].position;
newTrapeze.x = currentTrapezeInLevel[i].position.x + Random.Range(AvgXSepparation * XDifference, AvgXSepparation / XDifference);
newTrapeze.y = Random.Range(newTrapeze.y - YRange, newTrapeze.y + YRange);
//apply scaling
newTrapeze.x += XScaler;
newTrapeze.y += YScaler;
print("X " + XScaler + "Y " + YScaler);
currentTrapezeInLevel[i] = Instantiate(trapeze, newTrapeze, Quaternion.identity).transform;
numTrapezes++;
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment