BUSHIDO BOATS

bb-gameplay-optimized

Bushido Boats was developed entirely in C# in Unity over the 2017 winter holiday.

Developed for Minimalistic Jam 2 in a public GitHub repository.

TECH: Unity 5 | C# | WebGL | Paint.Net | Excel | Trello | Toggl

I implemented Player functionality in multiple components to increase cohesion and leverage modularity to my advantage. It was important for my code to be highly adaptive to change during the jam.

Readability was essential, as I would need to quickly recall functionality to make progress during a busy winter holiday.

High Cohesion Player Controller(s)

My PlayerAimController class handles player functionality of reticles and projectiles. Utilising the PlayerMovementController, a dedicated component I wrote to assemble information of respective player’s controller inputs at the start of a frame, prevented  needless repeated calling of Input class functions each frame. It also improved readability at no extra cost.

public class PlayerAimController : MonoBehaviour
{
    public GameObject aimReticle;
    private PlayerMovementController moveController;
    private SpriteRenderer reticleSpriteRenderer;
    private PlayerController playerController;
    
    void Awake()
    {
        playerController = GetComponent<PlayerController>();
        moveController = GetComponent<PlayerMovementController>();
        reticleSpriteRenderer = aimReticle.GetComponentInChildren<SpriteRenderer>();
        reticleSpriteRenderer.enabled = false;
    }

    void Update ()
    {
        if (playerController.inputAim)
        {
            reticleSpriteRenderer.enabled = true; // Show Reticle
            float zRot = Mathf.Atan2(playerController.axisInputDirection.x, -playerController.axisInputDirection.y) * Mathf.Rad2Deg;            
        } else
        {
            reticleSpriteRenderer.enabled = false; // Hide Reticle
        }

        // Is there actual axis input?
        if (playerController.axisInputDirection != Vector2.zero) 
        {
            aimReticle.transform.rotation = Quaternion.Euler(new Vector3(0, 0, zRot - 90f));
        }
 
        if (playerController.inputFire && playerController.axisInputDirection != Vector2.zero)
        {
             FireProjectile();
        }
    }

    private void FireProjectile()
    {
        GameObject projectile = Instantiate(playerController.prefabPayload, transform.position, aimReticle.transform.rotation);
        ProjectileController projectileController = projectile.GetComponent<ProjectileController>();
        projectileController.shooter = this.gameObject;
        projectileController.direction = playerController.axisInputDirection;
        projectileController.Launch();
        playerController.timeSinceFiring = 0;
    }
}

Writing PlayerMovementController also ensured I would obtain an individual player’s controller inputs, therefore immediately supporting a greater number of players.