C# | Unity | Team | Game jam
Time: 18 september 2023 - 20 september 2023
C# | Unity | Team | Game jam
Time: 18 september 2023 - 20 september 2023
In a high-pressure 72-hour game jam, I served as the solo developer, managing scene creation, script development, and post-jam bug fixes. Despite the challenges, I successfully delivered a polished and functional game, demonstrating my ability to thrive under pressure and independently produce a complete project. Following this, I invite you to explore "Goopy," our 2.5D game, reminiscent of the beloved Plants vs. Zombies series.
Norah (Artist)
Tijmen (Artist)
Yesse (Developer)
Lola (Artist)
Originally assigned to another developer, I assumed responsibility for a crucial script during a high-pressure game jam. This script played a pivotal role in creating grids, managing unit placement, and instantiating grids within the game world. Despite tight time constraints, I successfully completed this essential task, ensuring the project's success during the game jam. While the code may not be pristine due to time pressure, it proved effective in delivering the desired functionality.
using System;
using UnityEngine;
using UnityEngine.Serialization;
public class ObjectInstantiation : MonoBehaviour
{
public Transform originalGrid;
public Transform mirroredGrid;
public GameObject emptySpacePrefab;
public GameObject lastSelectedUnit;
public Vector3 gridCellSize = new Vector3(1.5f, 1f, 1.3f);
public int numRows = 9;
public int numColumns = 5; /
public float gridSpacing = 0.1f;
private UnitSelectionManager _unitSelection;
private int _unitPrice;
private bool CheckEnoughMoney()
{
switch (lastSelectedUnit.name)
{
case "Shooter Unit":
_unitPrice = 100;
break;
case "Armory Unit":
_unitPrice = 75;
break;
case "Resourcing Unit":
_unitPrice = 50;
break;
default:
return false;
}
return CurrencySingleton.Instance.playerCurrency >= _unitPrice;
}
private void Awake()
{
_unitSelection = FindObjectOfType<UnitSelectionManager>();
}
private void Start()
{
CreateGrid(originalGrid);
CreateMirroredGrid(originalGrid, mirroredGrid);
}
private void CreateGrid(Transform grid)
{
Vector3 startPosition = transform.position - new Vector3
((numColumns - 1) * (gridCellSize.x + gridSpacing) / 2f, 0f, (numRows - 1) * (gridCellSize.z + gridSpacing) / 2f);
for (int row = 0; row < numRows; row++)
{
for (int column = 0; column < numColumns; column++)
{
Vector3 position = startPosition + new Vector3
(column * (gridCellSize.x + gridSpacing), 0f, row * (gridCellSize.z + gridSpacing));
Instantiate(emptySpacePrefab, position, Quaternion.identity, grid);
}
}
}
private void CreateMirroredGrid(Transform original, Transform mirrored)
{
foreach (Transform child in original)
{
Vector3 originalPosition = child.position;
// Calculate he mirrored position with an offset on the positive X-axis
Vector3 mirroredPosition = new Vector3(-originalPosition.x + 0.33f, originalPosition.y, originalPosition.z);
// Instantiate an empty space at the modified mirrored position in the mirrored grid only
Instantiate(emptySpacePrefab, mirroredPosition, Quaternion.identity, mirrored);
}
}
private Vector3 IsGridEmpty()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
if (hit.transform.CompareTag("EmptySpace"))
{
return hit.transform.position;
}
}
return Vector3.zero; // Replace with your default position
}
private void PlaceObject()
{
if (lastSelectedUnit == null)
return;
Vector3 emptySpacePosition = IsGridEmpty();
// Check if the returned position is not the default position
if (emptySpacePosition != Vector3.zero && CheckEnoughMoney())
{
// Adjust the position offset
Vector3 MirroredUnitPosition = emptySpacePosition + new Vector3(-0.45f, 0.67f, 0f);
Vector3 unitPosition = emptySpacePosition + new Vector3(0.35f, 0.67f, 0f);
CurrencySingleton.Instance.SubtractCurrency(_unitPrice);
GameObject instantiatedUnitOriginal = Instantiate(lastSelectedUnit, unitPosition, Quaternion.Euler(0f, 90f, 0f), originalGrid);
Vector3 mirroredUnitPosition = new Vector3(-MirroredUnitPosition.x, MirroredUnitPosition.y, MirroredUnitPosition.z);
GameObject instantiatedUnitMirrored = Instantiate(lastSelectedUnit, mirroredUnitPosition, Quaternion.Euler(0f, 90f, 0f), mirroredGrid);
SoundManager.Instance.PlayOneShot("placing_unit");
}
else
{
Debug.Log("Not enough money to place this unit.");
}
}
private void Update()
{
lastSelectedUnit = _unitSelection.GetSelectedUnit();
if (Input.GetMouseButtonDown(0))
{
PlaceObject();
}
}
}