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,6 @@
using UnityEngine;
public interface IInputReader
{
Vector2 DragInput { get; }
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4fd243b30ced38840a3173920b99929f

View File

@@ -0,0 +1,26 @@
using UnityEngine;
using UnityEngine.InputSystem;
using static GameInputs;
public class InputReader : ScriptableObject, IInputReader, IPlayerActions
{
private GameInputs _inputActions;
public Vector2 DragInput { get; private set;}
void OnEnable()
{
if (_inputActions == null)
{
_inputActions = new GameInputs();
_inputActions.Player.SetCallbacks(this);
}
_inputActions.Enable();
}
public void OnDrag(InputAction.CallbackContext context)
{
DragInput = context.ReadValue<Vector2>();
Debug.Log(DragInput);
}
}

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b41ba7e7c457a844493479d95fe677f9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
using JetBrains.Annotations;
using UnityEngine;
using VContainer;
using VContainer.Unity;
public class GameLifeTimeScope : LifetimeScope
{
[SerializeField] private InputReader inputReader;
protected override void Configure(IContainerBuilder builder)
{
builder.RegisterComponentInHierarchy<PlatformPool>();
builder.RegisterComponentInHierarchy<JumpingBall>();
builder.RegisterComponentInHierarchy<PlatformManager>();
builder.RegisterComponent<IInputReader>(inputReader);
}
public void IsWorking()
{
Debug.Log("True");
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5f8d7d43c7f4a3d4d876897769dbf418

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f9b8db002cacc004caf00038e55a001f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 69ce4caca76952d48b6e1ee91464c551
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
using UnityEngine;
using VContainer;
public class JumpingBall : MonoBehaviour
{
public float jumpforce = 4f;
public Rigidbody BallRb;
void Start()
{
if(BallRb==null)
{
BallRb = GetComponent<Rigidbody>();
}
}
void OnCollisionEnter(Collision collision)
{
if(collision.collider.CompareTag("Platform"))
{
BallRb.linearVelocity = new Vector3(0, jumpforce, 0);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 747f7dce18fb6a548bafaf8388f331e4