← Back

Elemental tower defense

Elemental Tower Defense gameplay

Overview

Elemental Tower Defense is my first tower defense game, where you need to defend your base against skeleton enemies with your elemental towers. Such as a fire tower that fires rapidly or an ice tower that slows the enemy down.

Reflection

This was my first tower defense project that I created at school with help from classmates and AI. I struggled most with starting scripts and structuring my code properly. It was also difficult to make my game good replayability wise.

What I Used

C#
Unity
Git

Features

• Wave system
• Music
• Different towers
• Tower sell mechanic

Development Sheet

Enemy system gif
void Update()
{
    if (isPlacingTower)
    {
        FollowMouseWithTower();

        if (Input.GetMouseButtonDown(0))
        {
            Tower tower = currentTower.GetComponent();
            tower.isPlaced = true;

            PlaceTower();
        }
    }
}

Tower placement

With left mouse button you can place towers around the map up to 7 towers.

  • tower follows mouse until placed
  • Limit of 7 towers
  • Can place everywhere
Attack system gif
public void SellTower()
private void SellTowers()
{
    foreach (Transform t in towerList)
    {
        currency.AddMoney(50);
        Destroy(t.gameObject); 
    }
    towerList.Clear();
    placement.towerAmount = 0; 
}

Tower sell

The towers sell mechanic lets players sell all their towers at once for currency

  • Sells all towers at once
  • Low currency return
  • strategic button to use
Wave system gif
    void Start()
    {
        m_CurrencyText.text = "$: " + Money.ToString();
    }

    void Update()
    {
        
    }

    public void AddMoney(int money)
    {
        Money += money;
        m_CurrencyText.text = "$: " + Money.ToString();

    }

    public void RemoveMoney(int money) 
    {
        Money -= money;
        m_CurrencyText.text = "$: " + Money.ToString();
}

Currency System

The currency system lets players earn money by killing enemies to buy new towers.

  • can buy different towers
  • 50$ with each kill
  • Improves replayability

GitHub: github.com/Flyboyace/BO-tower-defense

Project Type: Tower defense game

Genre: TD

Engine: Unity

Role: Solo Dev

Status: Done