David Liu

Slime Buddy

About the Game

Slime Buddy is a casual game about a green slime that has recently moved into its home. The player can control the slime in order to pick up objects, or may interact with objects directly themselves. The game has a 'black box', where objects can be combined in order to make different objects. Players will need to explore and experiment with all these different interactions in order to help the slime to the next room.

Developed from September 2019 to October 2019.

Role in Development

  • Manager: Dennis Slavinsky
  • Designer: Chase Slattery
  • Programmers: David Liu, Billy Bowden, Jonathan Mura

I am mainly a programmer for this project, while assisting with the design. I developed the interactions with the water gun in respect to the slime and the environment. The water gun shoots cube particles, which will bounce off of objects and the slime. After watering the slime for a few seconds, the slime's shader color slowly turns blue. I also worked on a secret interaction, where there are three hidden buttons in the environment. A hidden event occurs when all three are pressed. I also helped with the finishing touches of the game by fixing bugs and polishing the main mechanics.

Script Examples

Inventory.csPlayerController.csSquirtGun.csIInteractable.cs
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Inventory : MonoBehaviour {

    // Fields
    [HideInInspector]
    public List prefabs;
    public GameObject buttonPrefab;
    public GameObject content;
    public int spawnDistance = 3;
    public float buttonHeight;

    private int currentIndex;
    public PlayerController playerController;
    private List buttons;

    // Runs before start
    void Start()
    {
        buttons = new List();

        // Determine how much space is needed in the scroll window's Content
        buttonHeight = buttonPrefab.GetComponent().sizeDelta.y + 10;
        float totalHeight = buttonHeight * (prefabs.Count + 1) + 10;
        content.GetComponent().sizeDelta = new Vector2(0, totalHeight);
      
        GameObject anchorButton = Instantiate(buttonPrefab, content.transform);
        anchorButton.transform.localScale = Vector3.one;
        anchorButton.transform.localPosition = new Vector3(0, - buttonHeight / 2 - 10, 0);
        
        anchorButton.GetComponentInChildren().text = "Anchor Slime";
        
        ButtonData anchorData = anchorButton.GetComponent();

        anchorData.parentInventory = this;
        anchorData.isSelected = false;
        anchorData.index = 0;

        buttons.Add(anchorData);
        
        for (int i = 0; i < prefabs.Count; i++)
        {
            GameObject spawnedButton = Instantiate(buttonPrefab, content.transform);
            spawnedButton.transform.localScale = Vector3.one;
            spawnedButton.transform.localPosition = new Vector3(0, - buttonHeight * (i + 1) - buttonHeight / 2 - 10, 0);

            if (prefabs[i].image && prefabs[i].prefab)
            {
                spawnedButton.GetComponent().sprite = prefabs[i].image;
                spawnedButton.GetComponentInChildren().enabled = false;
            }
            else
            {
                spawnedButton.GetComponentInChildren().text = prefabs[i].prefab.name;
            }

            ButtonData data = spawnedButton.GetComponent();
            Debug.Log(data);

            data.parentInventory = this;
            data.isSelected = false;
            data.index = (i + 1);
            data.objectData = prefabs[i].prefab;

            buttons.Add(data);
        }
    }

    public void ButtonPressed(ButtonData data)
    {
        // If the pressed button is selected, then despawn the selected
        if (data.isSelected)
        {
            data.isSelected = false;
            data.GetComponentInChildren().color = Color.white;
            playerController.currentlyEquipped = null;
            playerController.anchoring = false;
            currentIndex = -1;
            return;
        }
        
        if (currentIndex >= 0)
        {
            playerController.currentlyEquipped = null;
            buttons[currentIndex].isSelected = false;
            buttons[currentIndex].GetComponentInChildren().color = Color.white;
            playerController.anchoring = false;
            currentIndex = -1;
        }

        data.isSelected = true;
        currentIndex = data.index;
      
        if (currentIndex == 0)
            playerController.anchoring = true;
        else
            playerController.currentlyEquipped = data.objectData;

        data.GetComponentInChildren().color = Color.grey;
    }

    public void UIPointerEnter()
    {
        playerController.enabled = false;
    }

    public void UIPointerExit()
    {
        playerController.enabled = true;
    }
}

[System.Serializable]
public struct InventoryItem
{
    public GameObject prefab;
    public Sprite image;
}