Initial commit

This commit is contained in:
Mausham
2025-12-10 18:02:47 -08:00
commit 1014b82c22
251 changed files with 32297 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
using System;
using UnityEngine;
using VContainer;
public class Platform : MonoBehaviour
{
private Transform playerTransform;
[Inject] private PlatformPool pool;
[Inject] private PlatformManager manager;
[Inject] private IInputReader inputReader;
void Start()
{
playerTransform = GameObject.FindGameObjectWithTag("Player").transform;
}
void Update()
{
if((playerTransform.position.y-transform.position.y)<-5)
{
pool.ReturnToPool(this.gameObject);
manager.BuildPlatform();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 67c2916908f5f5e4b80dc9c59b8b1592

View File

@@ -0,0 +1,38 @@
using UnityEngine;
using VContainer;
public class PlatformManager : MonoBehaviour
{
private GameObject currentPlatfrom;
[Inject] private PlatformPool pool;
private int yPos=0;
void Start()
{
ShowInitialPlatforms();
}
public void ShowInitialPlatforms()
{
foreach(var platfrom in pool.platformPool)
{
platfrom.gameObject.SetActive(true);
platfrom.transform.position = new Vector3(0,yPos,0);
yPos--;
}
}
public void BuildPlatform()
{
currentPlatfrom = pool.GetPlatformFromPool();
if(currentPlatfrom!=null)
{
currentPlatfrom.transform.position = new Vector3(0,yPos,0);
currentPlatfrom.SetActive(true);
yPos--;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5581fca74af43824995a825437415c12

View File

@@ -0,0 +1,52 @@
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine;
using VContainer;
using VContainer.Unity;
public class PlatformPool : MonoBehaviour
{
public List<GameObject> platformPool = new List<GameObject>();
public int amountToPool=10;
public GameObject[] platformPrefab;
public GameObject PlatformContainer; //parent
[Inject] private IObjectResolver container;
void Awake()
{
for(int i=0; i<amountToPool;i++)
{
GameObject obj = Instantiate(platformPrefab[Random.Range(0,platformPrefab.Length)]);
obj.SetActive(false);
obj.transform.SetParent(PlatformContainer.transform);
container.InjectGameObject(obj);
platformPool.Add(obj);
}
}
public GameObject GetPlatformFromPool()
{
for(int i=0;i<platformPool.Count;i++)
{
if(!platformPool[i].activeInHierarchy)
{
return platformPool[i];
}
}
GameObject newObj = Instantiate(platformPrefab[Random.Range(0,platformPrefab.Length)]);
platformPool.Add(newObj);
newObj.transform.SetParent(PlatformContainer.transform);
container.InjectGameObject(newObj);
return newObj;
}
public void ReturnToPool(GameObject obj)
{
obj.SetActive(false);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2d775e1dfaaa1884088214bc3e182dfa