This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function coinToss(weighted) | |
local w = weighted or 50 | |
return math.random() <= w/100 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
public var pickupValue : int = 5; | |
function OnTriggerEnter2D(other : Collider2D) | |
{ | |
var gObj : GameObject = other.gameObject; | |
var clip : AudioClip; | |
if (gObj.CompareTag("Player")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
function OnMouseDown () | |
{ | |
if (gameObject.transform.position.y > -2 && gameObject.transform.position.y < 4) | |
{ | |
GameData.numGrabbed++; | |
GameData.DisplayScore(); | |
Destroy(gameObject); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
public var hitTag : string = "Ground"; | |
function OnCollisionEnter2D (other : Collision2D) | |
{ | |
if (other.gameObject.CompareTag(hitTag)) | |
{ | |
GameData.numMissed++; | |
GameData.DisplayScore(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
public var gObj : GameObject; | |
function Start () { | |
InvokeRepeating("CreateRandom", 0, 4); | |
} | |
function CreateRandom () | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
// access from other scripts like GameData.numGrabbed++ | |
static var numGrabbed : int = 0; | |
static var numMissed : int = 0; | |
static function DisplayScore () { | |
Debug.Log("Grabbed: " + numGrabbed + " Missed: " + numMissed); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
public var rocket : GameObject; // object to push | |
public var xSpeed : float = 0; // horizontal speed | |
public var ySpeed : float = 400; // vertical speed | |
private var rb2D : Rigidbody2D; | |
function Start () | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
public var liveTime : float = 0.5f; // how long to wait before ditching the explosion | |
public var killWithTag : String = "Enemy"; // kills these tagged objects in the blast radius | |
function Start () | |
{ | |
Invoke("DeleteMe", liveTime); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
public var layerName : String = "Foreground"; // the layer in which the particle should be placed | |
public var orderInLayer : int = -1; // -1 to go behind the parent object, 1 to go in front of it | |
public var destroyAfterTime : float = 0; | |
private var pSys : ParticleSystem; | |
function Start () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
public var speed : int; | |
function Start () | |
{ | |
var newSpeed : Vector2; | |
newSpeed.x = speed; | |
newSpeed.y = 0; | |
OlderNewer