Farms!
Farms is a school project (Project K.I.L.M.E.R.) in which I was the sole developer in my group (created in Year 1, Period 3). The game is inspired by Overcooked, where the objective is to complete orders in the shortest time possible. The goal is to work together with your partner to farm crops as quickly as possible. Several steps need to be completed before your crops can successfully grow.
Project Info:
Team members: Linde M & Samantha E
Project Time: First 1 period 3 (Until 11-05-2020)
Engine: Unity
Code Languages: C#
Farmland is also important because the game is fundamentally built around farming crops. The farmlands are used for various purposes, such as controlling birds and adjusting crop data to ensure the crops grow properly.
The farmland script isn't large; it manages the placement and pickup of crops and ensures that tools can be used effectively.
public void PlaceCropOnLand(GameObject Crop)
{
Crop.GetComponent().Play();
Crop.GetComponent().sortingOrder = 2;
Crop.transform.SetParent(transform);
Crop.transform.localPosition = new Vector2(0, 0);
}
The truck is a mechanic that interacts with many other mechanics. It needs to receive crop data, order data, and its own data so that it knows what tasks to perform.
if (TruckStatus == TruckState.OutOfScreen)
{
Orders.EnterScreen();
Ani.SetBool("ExitScreen", false);
Ani.SetBool("ScreenEnter", true);
TruckStatus = TruckState.OnScreen;
Horn.Play();
}
else if (TruckStatus == TruckState.OnScreen)
{
if (transform.childCount >= FindObjectOfType().AantalNodig + 1)
{
TruckTimer += Time.deltaTime;
if(TruckTimer >= 2.1f)
{
Ani.SetBool("ScreenEnter", false);
Ani.SetBool("ExitScreen", true);
Orders.LeaveScreen();
TruckStatus = TruckState.Leaving;
TruckTimer = 0;
}
}
}
Birds are those annoying creatures that attack your crops. This was intentional, so players would need to stay vigilant and sometimes make different choices to protect their crops.
The bird system works as follows: the more crops you have in your farmland, the more birds can spawn.
private void FixedUpdate()
{
if (Farm.transform.childCount == 1 && Flyback == false)
{
direction = farmCollider.bounds.center - transform.position;
direction.Normalize();
}
else
{
direction = SpawnPosition - (Vector2)transform.position;
direction.Normalize();
}
if (Farm.transform.childCount == 0 || Flyback == true)
{
if ((Vector2)transform.position == SpawnPosition)
{
Destroy(this.gameObject);
}
}
RaycastHit2D hit = Physics2D.Raycast(transform.position, direction, MaxRange, TargetLayer);
Movement = direction;
MoveEnemy(Movement);
}