Paid by Mushroom

Paid by Mushroom is a resource gathering game where you play as a witch who needs to collect various mushrooms and other resources from the woods to concoct a potion and then sell it to the villagers in need. Use the money you get from selling the potion to pay your house credit and live peacefully.

This project is still ongoing, so all the stuff that I show here is highly subject to change. I have been working on it in my spare time as a side project. I have finished making some mechanics for the game, such as wand mechanics, environment damage mechanics, inventory systems, etc. The details of these mechanics will be shown below. I will update this page in the future if I make any progress on the project.

Wand Mechanic

Wand mechanics is the main combat and also puzzle solving for the player. For now, there are only two types of wands, fire and wind. In future, I plan to make more wands to make player can solve more various types of puzzles and fight various types of enemies. Below is the snippet of code how I implement fireball from fire wand in game.

private async void Start()
{
    await UniTask.Delay(3000, cancellationToken: _cancellationTokenSource.Token);

    Destroy(gameObject);
}

private void Update()
{
    transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
}

private void OnCollisionEnter(Collision collision)
{
    if (!collision.gameObject.CompareTag("Player"))
    {
        if (collision.gameObject.GetComponent<IBurnable>() != null)
        {
            collision.gameObject.GetComponent<IBurnable>().GetBurn();

            Instantiate(hitEffect, transform.position, Quaternion.identity);

            Destroy(gameObject);
        }
        else
        {
            Instantiate(hitEffect, transform.position, Quaternion.identity);

            Destroy(gameObject);
        }
    }
}

To move the fireball, I modify the transform for the fireball to move forward. I also use UniTask to determine the duration of the object. The fireball only moves forward and detects the IBurnable interface when it collides with something. I also plan to use object pooling for the fireball to improve its performance. I will update the snippet code when there is any change.

Environment Damage Mechanic

The spell that the player uses can also damage a certain type of environment. For example, the thorn that got touched by a fireball will get burned, and the thorn that is near the burned thorn will also get burned. Below is a snippet of code showing how I implement the burned thorn.

public async UniTask GetBurn()
{
    HasBurned = true;

    fireEffect.SetActive(true);

    await UniTask.Delay(2000, cancellationToken: _cancellationTokenSource.Token);

    foreach (var r in rays)
    {
        RaycastHit hit;

        if (Physics.Raycast(r, out hit, 1.5f))
        {
            if (hit.transform.GetComponent<IBurnable>() != null)
            {
                if (!hit.transform.GetComponent<IBurnable>().HasBurned)
                {
                    await hit.transform.GetComponent<IBurnable>().GetBurn();
                }
            }
        }
    }

    await UniTask.Delay(4000, cancellationToken: _cancellationTokenSource.Token);

    Instantiate(smokeEndEffect, transform.position, Quaternion.identity);

    Destroy(gameObject);
}

The GetBurn method is part of the IBurnable Interface. So when the fireball hits the thorn, it will call the GetBurn method via the IBurnable interface. I use a ray to detect the thorn that is near the burned thorn. The ray will check the left, right, front, and back sides of the burned thorn and then call the GetBurn method for that thorn.

Inventory System

When players interact with collectible items, such as mushrooms, they will store them in their inventory. I made the inventory using ScriptableObject. In Inventory UI, the code will get data from the item that is stored in Inventory SO and will show the item sprite and amount of the item. I also made the item types using SO to make it easier if I wanted to make multiple types of items. In the future, I will make the concoct mechanic and check the player’s inventory to see if they have the item needed to make the potion that they want to concoct. I will update the visual again if there is any change in the future.