Shadow Bots

In this lesson, you’re going to shake off the rust and become reacquainted with Unity3D and the video game design pipeline.

2D Static Platformer

In the latest version of unity, you’re given the option to load various assets into your project from the Window > Asset Store panel. In the link below, you’ll download a very simple version of the Shadowbots project featured below. Your task is to examine how the current game works and then mod it into your own unique playing experience. Below, you will also find a series of scripts that you can add to the game to enhance playability.

Shadow Mots


Your goal is to make your game both challenging, fun, and different than your peers. Be creative, feel free to try new things, and use each other as resources.

Scripts

/* 
=================================================
FlyScript.cs 
=================================================
*/
using UnityEngine;
using System.Collections;

public class FlyScript : MonoBehaviour  {
	
	private bool dirRight = true;
	public float speed = 3.0f;
	
	void Update () {
		transform.Translate (Vector2.right * speed * Time.deltaTime);
	}
}


/* 
=================================================
Destroy.cs
=================================================
*/
using UnityEngine;
using System.Collections;

public class Destroy : MonoBehaviour {

	void OnCollisionEnter2D (Collision2D col)
	{
		Destroy(gameObject);
	}
}

/* 
=================================================
LevelLoader.cs
=================================================
*/
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class LevelLoader : MonoBehaviour {

	public string Level = "Level_02"; 

	private void OnCollisionEnter2D(Collision2D collision)
	{
		if (collision.gameObject.CompareTag("Player"))
			SceneManager.LoadScene(Level);
	}
}

/* 
=================================================
myTimer.cs
=================================================
*/


using UnityEngine;
using System.Collections;
using UnityEngine.UI; //very important
using UnityEngine.SceneManagement; //also very important

public class myTimer : MonoBehaviour {

	public float myCoolTimer = 99;
	private Text timerText;

	// Use this for initialization
	void Start () {
		timerText = GetComponent();
	}

	// Update is called once per frame
	void Update () {
		myCoolTimer -= Time.deltaTime;
		timerText.text = "Time: " + myCoolTimer.ToString ("f0");
		if (myCoolTimer < 0) {
			SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
		};
	}
}


/* 
=================================================
CameraScript.cs
=================================================
*/
using UnityEngine;
using System.Collections;

public class CameraScript : MonoBehaviour {
	
	public GameObject player;
	
	// Update is called once per frame
	void Update () {
		
		this.gameObject.transform.position = new Vector3(player.gameObject.transform.position.x,this.gameObject.transform.position.y,this.gameObject.transform.position.z);
		
	}
}

/* 
=================================================
Fading.cs
=================================================
*/
using UnityEngine;
using System.Collections;

public class Fading : MonoBehaviour {

	public Texture2D fadeOutTexture;	// the texture that will overlay the screen, This can be a black image or a loading graphic
	public float fadeSpeed = 0.8f;		//the fading speed

	private int drawDepth = -1000;		// the texture's order in the draw hierarchy: a low number means it renders on top
	private float alpha = 1.0f;			// the texture's alpha value between 0 and 1
	private int fadeDir = -1;				// the direction to fade: in = -1 or out = 1;

	void OnGUI() {
		// fade out/in the alpha value using a direction, a speed and Time.deltatime to conver the operation to seconds
		alpha += fadeDir * fadeSpeed 	* Time.deltaTime;
		// force (clamp) the number between 0 and 1 because GUI.color uses alpha values between 0 and 1;
		alpha = Mathf.Clamp01(alpha);

		// set color of our GUI (in this class our texture). All color values remain the same&amp; the Almoha is set to the alpha variable
		GUI.color = new Color (GUI.color.r, GUI.color.g, GUI.color.b, alpha);		// set the alpha value
		GUI.depth = drawDepth;														// make sure the black texture render on top (draw last)
		GUI.DrawTexture ( new Rect (0, 0, Screen.width, Screen.height), fadeOutTexture ); // draw the texture to fit the entire screen area
	}

	// sets fadeDir to the direction parameter making the scene fade in if -1 and out if 1
	public float BeginFade (int direction){
		fadeDir = direction;
		return (fadeSpeed);		// return the fadeSpeed variable so it's easy to time the Application.LoadLevel
	}
}