Orbo's Adventure is a game a classmate and I made for our Game Development class project at NSCC. We were inspired by many games such as Banjo-Kazooie, Super Mario 3D World, Pac-Man World, and Super Mario World.
For this project, I primarily worked on the code and various other tasks, while my classmate worked on the art and the sound. This project was quite a big undertaking as my classmate and I had to learn how to use Unity to understand what we were doing to make this project work the way we wanted it to.
I needed to learn a lot about coding in C# to make all the features we wanted in the game, including coding a dialogue box with scrolling text, a simple enemy AI, and PlayerPrefs to keep information between scenes.
I used Unity Engine, C#, Trello, Aseprite, Probuilder, and Microsoft Word during production.
The only assets from the Unity Asset Store used in this project were the trees and other foliage. There were some pieces of code I obtained from tutorials, such as a majority of the dialogue system code (Dialogue YouTube Tutorial) and a majority of the enemy AI state machine code (AI YouTube Tutorial).
Screenshots
Code Snippets
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ActivateLevel : MonoBehaviour
{
public GameObject nextLevel;
public GameObject nextLevelPath;
private bool waitForPress;
public string sceneName;
public GameObject player;
public GameObject levelBeaten;
public GameObject levelNotBeaten;
public bool isBeaten;
public GameObject buttonPrompt;
public string levelLastCompleted;
public string playerPrefLevelName;
public LevelSelectManager theLevelSelector;
// Start is called before the first frame update
void Start()
{
buttonPrompt.SetActive(false);
levelLastCompleted = PlayerPrefs.GetString("lastLevelCompleted");
isBeaten = GetBool(playerPrefLevelName);
theLevelSelector = FindObjectOfType<LevelSelectManager>();
if (levelLastCompleted == sceneName)
{
player.transform.position = SetPlayerPosition();
}
if (isBeaten)
{
EnableLevelComplete();
ActivateNextLevel();
}
else
{
LevelUncomplete();
}
}
// Update is called once per frame
void Update()
{
if (waitForPress && Input.GetKeyDown(KeyCode.E))
{
theLevelSelector.EnterLevel(sceneName);
}
}
private void OnTriggerEnter(Collider other)
{
buttonPrompt.SetActive(true);
waitForPress = true;
return;
}
private void OnTriggerExit(Collider other)
{
buttonPrompt.SetActive(false);
if (other.name == "OrboExpo2")
{
waitForPress = false;
}
}
public void EnableLevelComplete()
{
levelBeaten.SetActive(true);
levelNotBeaten.SetActive(false);
}
public void LevelUncomplete()
{
levelBeaten.SetActive(false);
levelNotBeaten.SetActive(true);
}
private bool GetBool(string key)
{
return PlayerPrefs.GetInt(key) == 1;
}
public void ActivateNextLevel()
{
nextLevel.SetActive(true);
nextLevelPath.SetActive(true);
}
public Vector3 SetPlayerPosition()
{
Vector3 playerPosition = levelBeaten.transform.position;
playerPosition.y = 2.9f;
return playerPosition;
}
}
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PickupController : MonoBehaviour
{
public int numberOfPickups;
public AudioSource audioSource;
public AudioClip clip;
public string levelName;
public int optionalPickups;
public string levelNameCompletedKey;
public bool winOnTalk;
public GameObject continueButton;
public TextMeshProUGUI countText;
public GameObject winTextObject;
private int count;
// Start is called before the first frame update
void Start()
{
GetComponent<AudioSource>();
PlayerPrefs.SetInt(levelName, 0);
numberOfPickups = CountPickups();
Time.timeScale = 1f;
SetCountText();
count = 0;
winTextObject.SetActive(false);
continueButton.SetActive(false);
}
// Update is called once per frame
void SetCountText()
{
int pickupsLeft = numberOfPickups - count;
countText.text = "x " + count.ToString() + "/" + numberOfPickups;
if (PlayerPrefs.GetInt(levelName) >= numberOfPickups)
{
if (winOnTalk)
{
return;
}
else
{
winTextObject.SetActive(true);
continueButton.SetActive(true);
Time.timeScale = 0f;
SetBool(levelNameCompletedKey, true);
PlayerPrefs.SetString("lastLevelCompleted", levelName);
}
}
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("PickUp"))
{
audioSource.PlayOneShot(clip);
other.gameObject.SetActive(false);
count = count + 1;
PlayerPrefs.SetInt(levelName, PlayerPrefs.GetInt(levelName) + 1);
SetCountText();
}
}
public void SetBool(string key, bool value)
{
PlayerPrefs.SetInt(key, value ? 1 : 0);
}
public int CountPickups()
{
return GameObject.FindGameObjectsWithTag("PickUp").Count() - optionalPickups;
}
}