Space Fishing Game
Tech Stack: Unity 2023, Visual Studio, Maya/Blender, Substance Painter, Gitlab
The Assignment
My Role
Here are some more of my tasks:
Code Highlights
private List<float> DistToObjects(List<Interactable> list)
{
List<float> dists = new();
for (int i = 0; i < list.Count; i++)
{
dists.Add(Vector3.Distance(transform.position, list[i].transform.position));
}
for (int i = 0; i < dists.Count; i++)
{
if (dists[i] > floatRadius)
{
list[i].inRadius = false;
list[i].inRadiusEvent.Invoke();
list.Remove(list[i]);
dists.Remove(dists[i]);
}
}
return dists;
}
Explanation:
This code defines a method DistToObjects that takes a list of objects (interactable) as a parameter and calculates the distances between the current object (with this script) and each object in the provided list.
The method calculates distances between the current object and a list of interactable objects, updates their "inRadius" status, triggers events, and removes objects that are beyond a specified radius.
private void CheckWhichZone()
{
for (int i = 0; i < zones.Count; i++)
{
if (zones[i].bounds.Contains(player.transform.position))
{
playerZoneLocation[i] = true;
playerRef.currentZone = zones[i];
}
else
{
playerZoneLocation[i] = false;
}
}
}
private bool CheckIfZoneUnlocked()
{
//als de zone waar de speler in zit niet unlocked is
var zone = playerRef.currentZone;
int currentZoneIndex = zones.IndexOf(zone);
for (int i = 0; i < playerZoneLocation.Length; i++)
{
if (playerZoneLocation[i] == true && zones[currentZoneIndex].GetComponent<Zone>().unlocked == true)
{
return true;
}
}
return false;
}
Explanation:
CheckWhichZone() iterates through a list of zones to determine if the player is inside any of them. If a zone contains the player‘s position, it sets a corresponding flag in an array to true and updates the player‘s current zone.
CheckIfZoneUnlocked() checks if the current zone where the player is located is unlocked. It examines the flags set in the array during the previous method and verifies if the associated zone is unlocked. If both conditions are met, it returns true; otherwise, it returns false.