First release: Galaxy Buster!

Hey guys!
I started this course with no coding / unity experience, but I’m pretty happy with the results so far.
Click here to play!



I was able to create a time-bonus feature, which gives you more points the faster you beat the level.
I scripted some of the TMPro text to change color via hue in realtime.
And I made my own sound effects!

I could’ve kept going with features but I wanted to move on with the course.
I’m curious if anyone has feedback on some of my code!
Here’s the gameStatus script which has most of the custom code in it:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class GameStatus : MonoBehaviour
{
    // configuration parameters
    [Range(-.5f, 5f)] [SerializeField] float gameSpeed = 1f;
    [Range(1, 300)] [SerializeField] int pointsPerBlockDestroyed = 100;
    [SerializeField] bool isAutoPlayEnabled;
    [SerializeField] bool cursorOverride;


    // hue cycle parameters
    [SerializeField] float hueScrollRate = .05f;
    // static required by HSVtoRGB method
    static float mHue = .2f;
    static float mSat = .71f;
    static float mVal = 1f;


    //score parmeters
    [SerializeField] TextMeshProUGUI scoreText;
    [SerializeField] TextMeshProUGUI bonusText;
    [SerializeField] int currentScore = 0;
    public int timeBasedPoints;


    //timer variables
    [SerializeField] TextMeshProUGUI roundTimer;
    int timeBonusLimit = 60;

    private void Awake()
    {
        int gameStatusCount = FindObjectsOfType<GameStatus>().Length;
        if(gameStatusCount > 1)
        {
            gameObject.SetActive(false);
            Destroy(gameObject);
        }    
        else
        {
            DontDestroyOnLoad(gameObject);
        }
    }

    private void Start()
    {
        scoreText.text = currentScore.ToString();
        Cursor.visible = cursorOverride;
    }

    // Update is called once per frame
    void Update()
    {
        Time.timeScale = gameSpeed;
        ColorCycle();
        roundTimer.text = Time.timeSinceLevelLoad.ToString("0#");
    }


    // Methods


    // points from blocks broken
    public void AddToScore()
    {
        currentScore += pointsPerBlockDestroyed;
        scoreText.text = currentScore.ToString();
    }

    // points from completing levels fast
    public void TimeScore()
    {
        if(Time.timeSinceLevelLoad < timeBonusLimit)
        {
            timeBasedPoints = (timeBonusLimit*100) - (int)Time.timeSinceLevelLoad * 100;
            currentScore += timeBasedPoints;
            scoreText.text = currentScore.ToString();

            bonusText.text = $"+{timeBasedPoints}";
            Invoke("ScoreHide", 2.5f);
        }
    }

    // stops DontDestroyOnLoad loop + resets point
    public void ResetGame()
    {
        Destroy(gameObject);
    }


    // cycles faceColor on TMProUI elemenets
    public void ColorCycle()
    {
        Color color = Color.HSVToRGB(mHue, mSat, mVal);

        // elements to apply to
        scoreText.faceColor = color;
        roundTimer.faceColor = color;

        // controls cycle speed
        mHue += hueScrollRate * Time.deltaTime;

        // restarts the cycle
        if(mHue >=1f)
        {
            mHue = .01f;
        }
    }

    void ScoreHide()
    {
        bonusText.text = "";
    }

    public bool IsAutoPlayEnabled()
    {
        return isAutoPlayEnabled;
    }

}

Privacy & Terms