var facingRight : boolean = true;
var grounded: boolean;
var groundCheck:Transform;
var player:Transform;
var groundRadius:float = .2;
var isGround:LayerMask;
var vSpeed:float;
var can: CannonScript;
var projectile: GameObject;
function Start () {
animator = GetComponent(“Animator”);
var can : CannonScript = gameObject.GetComponent(CannonScript);
animator.SetBool(“IsIdle”,true);
scoreText.guiText.text = ((“You Have “) + health + (” health”));
}
// if(Input.GetKeyDown(“space”)){
// health -= 10;
// scoreText.guiText.text = ((“You Have “) + health + (” health”));
// }
//
//
function FixedUpdate () {
grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, isGround);
speed = Input.GetAxis(“Horizontal”);
if(speed !=0){
animator.SetBool(“IsIdle”,false);
rigidbody2D.velocity = new Vector2(maxSpeed * speed, rigidbody2D.velocity.y);
}
else if(speed ==0){
animator.SetBool(“IsIdle”,true);
}
if(speed > 0 && !facingRight){
Flip();
}
else if(speed < 0 && facingRight){
Flip();
}
}
function Update (){
if(grounded && Input.GetKeyDown(“space”)){
rigidbody2D.AddForce(new Vector2(0,1200));
//anim.Play(“WarriorJump”);
}
if(health <= 0){
rigidbody2D.velocity = new Vector2(0, rigidbody2D.velocity.y);
animator.Play(“BallerinaDie”);
Application.LoadLevel(“Lose”);
}
}
function Flip() {
facingRight = !facingRight;
var theScale:Vector2 = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
function HealthSubtract() {
print(“function called”);
health -=10;
scoreText.guiText.text = ((“You Have “) + health + (” health”));
}
/*function OnCollisionEnter2D(coll: Collision2D) {
if (coll.gameObject.tag == “Projectile”)
projectile = gameObject.FindWithTag(“Projectile”);
audio.PlayOneShot(splat);
print(“collision”);
health -= 10;
scoreText.guiText.text = ((“You Have “) + health + (” health”));
projectile.SetActive(false);
print(“destroyed”);
}*/