Salvager



CREDITS;


Lucan Monks – Scripting/Game Design/Story Concepts
Danijel Piperac – Level Design/Game Design

Stina Flödstrom – Art Director/Models
Joaquim Larsen – Characters Models
Carl Palacios – Environments
Patrik Ånberg – Lord Animator
Kx_Kx – Musician extraordinaire!

SUMMARY


The challenge was to make a vertical slice of a tower defense game in just 7 weeks using the Unity Engine. We created a game where, instead of vast landscapes, the player must make their way through a dilapidated hospital over-run with crazed cyborgs. A story would unfold as the player went from room to room, revealing a dark and complex story that you don’t usually get with TD games. We also included a “fort building” mechanic, where the player can drag the furniture around to barricade themselves from the enemy.

After the project was over, this was how our game looked, pretty close to how it was expected and we were very pleased with the results.
DOWNLOAD A DEMO HERE!

WHAT I DID ON THIS PROJECT;


Scripting tasks included;

  • Camera controls.
  • Player movement.
  • Collecting items.
  • Spending currency.
  • Placing Turrets.
  • Turret automation.
  • Targeting an enemy.
  • Destroying furniture.
  • Gui functions.

I also came up with the original concept and story plot, and even provided some enemy concept art to speed up the process.

EXAMPLE CODE


What this piece of code does is send information that is detected by the turrets to and from any enemies within it’s range. This information is used to create a list that checks when the enemy has exited the turrets firing range or is killed, and then deletes it from the list so that the turret will no longer shoot at it, and instead search for the next enemy on the list. If there isn’t an enemy in the list, the turret stops firing.

public List <GameObject> TARGETLIST;
public List <GameObject> ENEMIESLIST;
public Transform TURRETEYES; 
public GameObject PROJECTILE;
public GameObject[] MUZZLES;
public GameObject MUZZLEFLASH;
public float TURNSPEED; 
public float DETECTRANGE;
public float RELOADTIME;
private float NEXTFIRETIME; 
private Quaternion DESIREDROTATION;
private float ANGLE;
private Vector3 TARGETDIRECTION;
Code_LM_Enemy CODECHECK;
public bool ELECTRIC = false; 
public GameObject ELBASE;
public GameObject ELTARGET;
public ParticleRenderer SPARKULA;

 void Start () 

 {
    TARGETLIST = new List<GameObject>();
    ENEMIESLIST = new List<GameObject>();

    if (ELECTRIC)
    {
       GetComponent<ParticleRenderer>().enabled = false;
    }
 }

 void Update () 

 {
    if (TARGETLIST.Count != 0)
    {
       if (TARGETLIST[0].gameObject == null)
       {
          TARGETLIST.Remove(TARGETLIST[0]);
       }
       else
       {
          CODECHECK = TARGETLIST[0].gameObject.GetComponent<Code_LM_Enemy>();

          if (CODECHECK.DEADYET)
          {
             TARGETLIST[0].gameObject.GetComponent<Code_LM_Enemy>().REMOVETURRETS();
          }
          else
          {
             if (!ELECTRIC)
             {
                TURRETEYES.LookAt(TARGETLIST[0].transform.position);
                DESIREDROTATION = TURRETEYES.rotation;

                if(TARGETLIST[0].gameObject.GetComponent<Code_LM_Enemy>().ENEMYTYPE == 2)
                {
                   DESIREDROTATION.x = 0;
                   DESIREDROTATION.z = 0;
                }

                TARGETDIRECTION = TARGETLIST[0].transform.position - transform.position;
                ANGLE = Vector3.Angle(TARGETDIRECTION,transform.forward);
                transform.rotation = Quaternion.Lerp(transform.rotation, DESIREDROTATION, Time.deltaTime*TURNSPEED);

                if (ANGLE > -DETECTRANGE && ANGLE < DETECTRANGE)
                {
                   Vector3 FORWARD = transform.TransformDirection(Vector3.forward);
                   RaycastHit HIT; 
                   Debug.DrawRay(transform.position, FORWARD*10, Color.white);

                   if ( Physics.Raycast(transform.position, FORWARD, out HIT ))
                   {
                      if (HIT.collider.transform.tag == "ENEMY")
                      {
                         if (Time.time >= NEXTFIRETIME)
                         {
                            NEXTFIRETIME = Time.time + RELOADTIME;
                            foreach (GameObject MUZZLE in MUZZLES)
                            {
                               Instantiate(MUZZLEFLASH, MUZZLE.transform.position, MUZZLE.transform.rotation);
                               Instantiate(PROJECTILE, MUZZLE.transform.position, MUZZLE.transform.rotation);
                            }
                         }
                      }
                   }
                }
             }
             else
             {
                ELTARGET.transform.position = TARGETLIST[0].gameObject.transform.position;
                SPARKULA = GetComponent<ParticleRenderer>();

                if (SPARKULA.enabled != true)
                {
                   SPARKULA.enabled = true;
                }
             }
          }
       }
    }
 }

 void OnTriggerEnter(Collider OBJECT)
 {
    if (OBJECT.transform.tag == "ENEMY")
    {
       TARGETLIST.Add(OBJECT.gameObject);
       OBJECT.gameObject.GetComponent<Code_LM_Enemy>().SPOTTED(gameObject);
    }
 }

 void OnTriggerExit(Collider OBJECTEXIT)
 {
    if (OBJECTEXIT.transform.tag == "ENEMY")
    {
       OBJECTEXIT.gameObject.GetComponent<Code_LM_Enemy>().REMOVETURRETS();
       TARGETLIST.Remove(OBJECTEXIT.gameObject);
    }
 }

 public void REMOVEENEMY (GameObject DELETEME)
 {
    TARGETLIST.Remove(DELETEME);
    DELETEME.gameObject.GetComponent<Code_LM_Enemy>().CHECKDEATH();
    if (ELECTRIC)
    {
       GetComponent<ParticleRenderer>().enabled = false;
       ELTARGET.transform.position = transform.position;
    }
 }
 public void ADDTHIS (GameObject INCOMING)
 {
    ENEMIESLIST.Add(INCOMING);
 }

 public void REMOVETHIS (GameObject INCOMING2)
 {
    ENEMIESLIST.Remove(INCOMING2);
    INCOMING2.gameObject.GetComponent<Code_LM_EnemyAttack>().REMOVED( gameObject );
 }

}
 
credit