using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class scriptCameraController : MonoBehaviour {
public GameObject player; //introduces variables
private Vector3 offset;
public bool RotateAroundPlayer = false;
public float RotSpeed = 5.0f;
public Transform Player;
// Use this for initialization
void Start () {
offset = transform.position - player.transform.position; //setting the offset for the camera to follow the player
}
// Update is called once per frame
void Update () {
/*if (Input.GetMouseButton (1)) { //dectects if im attempting to rotate
RotateAroundPlayer = true;
} else {
RotateAroundPlayer = false;
} */
}
void LateUpdate () {
transform.position = player.transform.position + offset; //camera follows player
if (RotateAroundPlayer) { //used to allow the player to rotate camera (it worked) but it wasnt needed
Quaternion camTurnAngle = Quaternion.AngleAxis (Input.GetAxis ("Mouse X") * RotSpeed, Vector3.up);
offset = camTurnAngle * offset;
transform.LookAt (Player);
}
}
}
using System.Collections.Generic;
using UnityEngine;
public class scriptCameraController : MonoBehaviour {
public GameObject player; //introduces variables
private Vector3 offset;
public bool RotateAroundPlayer = false;
public float RotSpeed = 5.0f;
public Transform Player;
// Use this for initialization
void Start () {
offset = transform.position - player.transform.position; //setting the offset for the camera to follow the player
}
// Update is called once per frame
void Update () {
/*if (Input.GetMouseButton (1)) { //dectects if im attempting to rotate
RotateAroundPlayer = true;
} else {
RotateAroundPlayer = false;
} */
}
void LateUpdate () {
transform.position = player.transform.position + offset; //camera follows player
if (RotateAroundPlayer) { //used to allow the player to rotate camera (it worked) but it wasnt needed
Quaternion camTurnAngle = Quaternion.AngleAxis (Input.GetAxis ("Mouse X") * RotSpeed, Vector3.up);
offset = camTurnAngle * offset;
transform.LookAt (Player);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class scriptController : MonoBehaviour {
public float speed; //introducing variables
private Rigidbody rb;
bool level2 = false;
bool level3 = false;
bool level4 = false;
bool level5 = false;
public float timer;
bool startTime = true;
public float Lvlforce;
bool level3start = true;
bool level4start = true;
bool level5start = true;
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody> (); //getting the rigidbody
}
// Update is called once per frame
void Update () {
if (transform.position.y <= -10) { //the safety net so you dont fall forever
Vector3 position = new Vector3 (0, 5, 0);
transform.position = position;
}
if (level2 && startTime) { //at the start of level 2
GameObject levelUp2 = GameObject.Find ("Lvl2"); //destroying the level up coin
Destroy (levelUp2.gameObject);
startTime = false; //starting the timer
InvokeRepeating ("Countdown", 1, 1);
}
if (level3) { //sets the wind for each level
Lvlforce = 1;
if (level4) {
Lvlforce = 3;
if (level5) {
Lvlforce = 5;
}
}
}
if (level3 && level3start) { //at the start of level 3
GameObject levelUp3 = GameObject.Find ("Lvl3"); //destroying the level up coin
Destroy (levelUp3.gameObject);
level3start = false;
}
if (level4 && level4start) { //at the start of level 4
GameObject levelUp4 = GameObject.Find ("Lvl4"); //destroying the level up coin
Destroy (levelUp4.gameObject);
level4start = false;
}
if (level5 && level5start) { //at the start of level 5
GameObject levelUp5 = GameObject.Find ("Lvl5"); //destroying the level up coin
Destroy (levelUp5.gameObject);
level5start = false;
}
}
void FixedUpdate () {
//transform.position = transform.position + Camera.main.transform.forward * 20 * Time.deltaTime;
float moveHorizontal = Input.GetAxis ("Horizontal"); //controls
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
if (level3) { //wind effect
Vector3 windy = new Vector3 (-1f, 0, 0);
rb.AddForce (windy * Lvlforce);
}
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag ("Pick Up")) //detecting pickups
{
Destroy (other.transform.gameObject); //destroying them
}
if (other.gameObject.CompareTag ("Lvl2")) //detecting levelups
{
level2 = true; //changing difficulty
Vector3 position = new Vector3 (0, 5, 0); //teleporting to start
transform.position = position;
Destroy (other.transform.gameObject); //destroying levelups
}
if (other.gameObject.CompareTag ("Lvl3"))
{
level3 = true;
Vector3 position = new Vector3 (0, 5, 0);
transform.position = position;
Destroy (other.transform.gameObject);
}
if (other.gameObject.CompareTag ("Lvl4"))
{
level4 = true;
Vector3 position = new Vector3 (0, 5, 0);
transform.position = position;
Destroy (other.transform.gameObject);
}
if (other.gameObject.CompareTag ("Lvl5"))
{
level5 = true;
Vector3 position = new Vector3 (0, 5, 0);
transform.position = position;
Destroy (other.transform.gameObject);
}
if (other.gameObject.CompareTag ("Win
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class scriptController : MonoBehaviour {
public float speed; //introducing variables
private Rigidbody rb;
bool level2 = false;
bool level3 = false;
bool level4 = false;
bool level5 = false;
public float timer;
bool startTime = true;
public float Lvlforce;
bool level3start = true;
bool level4start = true;
bool level5start = true;
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody> (); //getting the rigidbody
}
// Update is called once per frame
void Update () {
if (transform.position.y <= -10) { //the safety net so you dont fall forever
Vector3 position = new Vector3 (0, 5, 0);
transform.position = position;
}
if (level2 && startTime) { //at the start of level 2
GameObject levelUp2 = GameObject.Find ("Lvl2"); //destroying the level up coin
Destroy (levelUp2.gameObject);
startTime = false; //starting the timer
InvokeRepeating ("Countdown", 1, 1);
}
if (level3) { //sets the wind for each level
Lvlforce = 1;
if (level4) {
Lvlforce = 3;
if (level5) {
Lvlforce = 5;
}
}
}
if (level3 && level3start) { //at the start of level 3
GameObject levelUp3 = GameObject.Find ("Lvl3"); //destroying the level up coin
Destroy (levelUp3.gameObject);
level3start = false;
}
if (level4 && level4start) { //at the start of level 4
GameObject levelUp4 = GameObject.Find ("Lvl4"); //destroying the level up coin
Destroy (levelUp4.gameObject);
level4start = false;
}
if (level5 && level5start) { //at the start of level 5
GameObject levelUp5 = GameObject.Find ("Lvl5"); //destroying the level up coin
Destroy (levelUp5.gameObject);
level5start = false;
}
}
void FixedUpdate () {
//transform.position = transform.position + Camera.main.transform.forward * 20 * Time.deltaTime;
float moveHorizontal = Input.GetAxis ("Horizontal"); //controls
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
if (level3) { //wind effect
Vector3 windy = new Vector3 (-1f, 0, 0);
rb.AddForce (windy * Lvlforce);
}
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag ("Pick Up")) //detecting pickups
{
Destroy (other.transform.gameObject); //destroying them
}
if (other.gameObject.CompareTag ("Lvl2")) //detecting levelups
{
level2 = true; //changing difficulty
Vector3 position = new Vector3 (0, 5, 0); //teleporting to start
transform.position = position;
Destroy (other.transform.gameObject); //destroying levelups
}
if (other.gameObject.CompareTag ("Lvl3"))
{
level3 = true;
Vector3 position = new Vector3 (0, 5, 0);
transform.position = position;
Destroy (other.transform.gameObject);
}
if (other.gameObject.CompareTag ("Lvl4"))
{
level4 = true;
Vector3 position = new Vector3 (0, 5, 0);
transform.position = position;
Destroy (other.transform.gameObject);
}
if (other.gameObject.CompareTag ("Lvl5"))
{
level5 = true;
Vector3 position = new Vector3 (0, 5, 0);
transform.position = position;
Destroy (other.transform.gameObject);
}
if (other.gameObject.CompareTag ("Win
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class scriptPickup : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Rotate (new Vector3 (15, 30, 45) * Time.deltaTime); //rotates object
}
}
using System.Collections.Generic;
using UnityEngine;
public class scriptPickup : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Rotate (new Vector3 (15, 30, 45) * Time.deltaTime); //rotates object
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class scriptMainMenu : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI () {
if (GUI.Button (new Rect (10, 10, 100, 20), "Start Game")) { //makes buttons
SceneManager.LoadScene ("sceneLevel1");
}
if (GUI.Button (new Rect (10, 30, 100, 20), "Exit Game")) {
Application.Quit ();
}
}
}
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class scriptMainMenu : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI () {
if (GUI.Button (new Rect (10, 10, 100, 20), "Start Game")) { //makes buttons
SceneManager.LoadScene ("sceneLevel1");
}
if (GUI.Button (new Rect (10, 30, 100, 20), "Exit Game")) {
Application.Quit ();
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class scriptWin : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI () {
if (GUI.Button (new Rect (10, 10, 100, 20), "Main Menu")) { //makes buttons
SceneManager.LoadScene ("sceneMainMenu");
}
}
}
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class scriptWin : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI () {
if (GUI.Button (new Rect (10, 10, 100, 20), "Main Menu")) { //makes buttons
SceneManager.LoadScene ("sceneMainMenu");
}
}
}