Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* BEGIN SCRIPT "PlayerMovement.cs" */
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerMovement : MonoBehaviour {
- public float acceleration = 1f;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- if (Input.GetKey (KeyCode.W)) {
- this.GetComponent<Rigidbody> ().AddForce (new Vector3 (0, 0, acceleration));
- }
- if (Input.GetKey (KeyCode.S)) {
- this.GetComponent<Rigidbody> ().AddForce (new Vector3 (0, 0, -acceleration));
- }
- if (Input.GetKey (KeyCode.D)) {
- this.GetComponent<Rigidbody> ().AddForce (new Vector3 (acceleration, 0, 0));
- }
- if (Input.GetKey (KeyCode.A)) {
- this.GetComponent<Rigidbody> ().AddForce (new Vector3 (-acceleration, 0, 0));
- }
- gameObject.transform.rotation = new Quaternion (gameObject.transform.rotation.x + 1, 0, 0, 0);
- }
- }
- /* END SCRIPT */
- /* BEGIN SCRIPT "MatchPlayer.cs" */
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class MatchPlayer : MonoBehaviour {
- public GameObject player;
- public Vector3 defaultPos = new Vector3(-18, 20, -18);
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- gameObject.transform.position = player.transform.position + defaultPos;
- }
- }
- /* END SCRIPT */
- /* BEGIN SCRIPT "Cheese.cs" */
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class Cheese : MonoBehaviour {
- public Text scoreboard;
- private int score = 0;
- private bool started = false;
- private int time = 5;
- private Vector3[] locations = {
- new Vector3(7.5f,0f,7.5f), new Vector3(7.5f,0f,-7.5f), new Vector3(-7.5f,0f,7.5f), new Vector3(-7.5f,0f,-7.5f), new Vector3(0f,0f,0f), new Vector3(7.5f,0f,0f), new Vector3(-7.5f,0f,0f), new Vector3(0f,0f,7.5f), new Vector3(0f,0f,-7.5f)
- };
- private Vector3 last = new Vector3(-7.5f,0f,7.5f);
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- }
- void IGUpdate(){
- time--;
- scoreboard.text = "Time: " + time + "\n" + "Score: " + score;
- if (time <= 0) {
- scoreboard.text = "You lose.";
- Invoke("Close",3f);
- }
- }
- void Close(){
- Debug.Log ("Quit");
- Application.Quit ();
- }
- void OnTriggerEnter(){
- if (!started) {
- InvokeRepeating ("IGUpdate", 0f, 1f);
- started = true;
- }
- score++;
- time = 6;
- Vector3 newLocation = new Vector3(0, 0, 0);
- bool goodLocation = false;
- int safety = 0;
- while (!goodLocation && (safety < 100)) {
- newLocation = locations [Random.Range (0, 9)];
- if (newLocation != last) {
- goodLocation = true;
- }
- }
- transform.position = newLocation;
- last = newLocation;
- }
- }
- /* END SCRIPT */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement