Вы находитесь на странице: 1из 3

var theTextComponent : UI.

Text;
var theTextComponent2 : UI.Text;
var theTextComponent3 : UI.Text;
private var stars = 50;
private var health = 100;
private var poison = 50;
private var gravitydown = -10;
private var gravityup = 4;
private var jetpack = false;
private var fuel = 30;

function Update ()
{
theTextComponent.text = "icecream: " + stars.ToString();;
theTextComponent2.text = "health: " + health.ToString();;
theTextComponent3.text = "fuel: " + fuel.ToString();;
if(health <= 0)\
{
Application.LoadLevel("gameover");
}
if (Input.GetKey("w") && jetpack == true)
{
GetComponent.<Rigidbody2D>().gravityScale = gravitydown;
fuel -= Time.deltaTime;\
\}\
\
if (Input.GetKeyUp("w") )\
\{\
GetComponent.<Rigidbody2D>().gravityScale = gravityup;\
\}\
\
if(fuel <= 0)\
\{ \
jetpack = false;\
GetComponent.<Rigidbody2D>().gravityScale = gravityup;\
\}\
\
\}\
\

\
function OnTriggerEnter2D (other: Collider2D) \
\{\
if (other.gameObject.tag == "larry")\
\{\
health -= 100;\
Destroy(other.gameObject);\
\}\
\
if (other.gameObject.tag == "healthpickup")\
\{\
health += 30000;\
Destroy(other.gameObject);\
\}\
\
if (other.gameObject.tag == "jetpack")\
\{\
jetpack = true;\
Destroy(other.gameObject);\
\}\
\}\
\
\
\
\
/*\
if (Input.GetKeyDown("w"))\
\{\
\
\}\
*/\
\
\
\
\
\
\
\
\
}

camera follows

using UnityEngine;
using System.Collections;
public class CameraFollowScript : MonoBehaviour {
public GameObject focus;
public float tempTranslationSpeed;
// Use this for initialization
void Start () {
transform.parent = null;
}
// Update is called once per frame
void FixedUpdate () {
transform.Translate ((focus.transform.position - transform.position) *
tempTranslationSpeed);
transform.position = new Vector3 (transform.position.x, transform.position.y,
-10f);
}
}

Вам также может понравиться