This commit is contained in:
2023-02-09 17:11:37 +05:30
commit 6682748554
98 changed files with 10835 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.U2D;
public class LevelGenerator : MonoBehaviour
{
public static LevelGenerator instance { get; private set; }
public SpriteShapeController spriteShapeController;
public int LevelCount = 1000;
public float groundLevel = -5.5f;
public float maxHeight = 5;
public Vector2 minDiff, maxDiff;
public Vector3[] points {get; private set;}
void Start()
{
spriteShapeController.spline.Clear();
points = new Vector3[LevelCount+1];
for(int i=0; i < LevelCount; i++){
if(i ==0){
points[i] = new Vector3(0,groundLevel);
spriteShapeController.spline.InsertPointAt(i, points[i]);
continue;
}
Vector3 addition = new Vector3(Random.Range(minDiff.x, maxDiff.x), Random.Range(minDiff.y, maxDiff.y));
float newX = points[i-1].x + addition.x;
float newY = points[i-1].y + addition.y;
while(newY < groundLevel){
newY += Mathf.Abs(addition.y);
}
while(newY > maxHeight){
newY -= Mathf.Abs(addition.y);
}
points[i] = new Vector3(newX, newY);
spriteShapeController.spline.InsertPointAt(i, points[i]);
}
points[LevelCount] = new Vector3(points[LevelCount-1].x, groundLevel);
spriteShapeController.spline.InsertPointAt(LevelCount, points[LevelCount]);
}
void Update()
{
}
}

View File

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