Ah, i see:
This is the GameManager:
using UnityEngine;
using System.Collections;
public class GameManager: MonoBehaviour
{
private AudioSource sound;
private GameObject Door;
private bool won;
private bool death;
public GUIStyle guiStyle;
public string NextLevel;
public int totalCoin;
public int foundCoin;
public AudioClip DestroySound;
public AudioClip WonSound;
public AudioClip CoinSound;
public AudioClip SpeedBoosterSound;
public AudioClip JumpBoosterSound;
public AudioClip TeleporterSound;
public AudioClip BallJumpSound;
public AudioClip BallHitGroundSound;
public AudioClip BallRollSlowSound;
public AudioClip BallRollFastSound;
void Start ()
{
Time.timeScale = 1.0f;
totalCoin = GameObject.FindGameObjectsWithTag("Coin").Length;
Door = GameObject.Find("Door");
sound = GetComponent<AudioSource>();
}
void Updata()
{
if (Input.GetKey (KeyCode.X))
{
Application.LoadLevel("Main_Menu");
}
}
void OnGUI ()
{
if (GUI.Button(new Rect(10, Screen.height - 25, 50, 20), "Menu"))
{
Application.LoadLevel("Main_Menu");
}
if (won)
{
GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 150, 100, 20), "You Won", guiStyle);
if(NextLevel != "Main_Menu")
{
if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 130, 100, 20), "Next Level"))
{
Application.LoadLevel(NextLevel);
}
}
if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 105, 100, 20), "Menu"))
{
Time.timeScale = 1f;
Application.LoadLevel("Main_Menu");
}
}
else if (death)
{
GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 150, 100, 20), "You're Dead", guiStyle);
if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 130, 100, 20), "Try Again"))
{
Application.LoadLevel(Application.loadedLevelName);
}
if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 105, 100, 20), "Menu"))
{
Application.LoadLevel("Main_Menu");
}
}
GUI.Label(new Rect(10, 10, 500, 20), "Found Coins: "+foundCoin+"/"+totalCoin, guiStyle);
}
public void FoundCoin()
{
audio.clip = CoinSound;
audio.Play();
foundCoin++;
if (foundCoin >= totalCoin)
{
Door.GetComponent<Door>().FindAllCoin = true;
}
}
public void SpeedBooster()
{
audio.clip = SpeedBoosterSound;
audio.Play();
}
public void BallRollSlow()
{
audio.clip = BallRollSlowSound;
audio.loop = true;
// audio.PlayOneShot();
audio.Play();
}
public void BallRollFast()
{
audio.clip = BallRollFastSound;
// audio.PlayOneShot();
audio.loop = true;
audio.Play();
}
public void JumpBooster()
{
audio.clip = JumpBoosterSound;
audio.Play();
}
public void BallJump()
{
audio.clip = BallJumpSound;
audio.Play();
}
public void BallHitGround()
{
audio.clip = BallHitGroundSound;
audio.Play();
}
public void Teleporter()
{
audio.clip = TeleporterSound;
audio.Play();
}
public void Won()
{
audio.clip = WonSound;
audio.Play();
Time.timeScale = 0f;
won = true;
}
public void Death()
{
audio.clip = DestroySound;
audio.Play();
death = true;
}
}
This is the PlayerScript:
using UnityEngine;
using System.Collections;
public class PlayerControl : MonoBehaviour
{
private GameObject moveJoy;
private GameObject _GameManager;
public Vector3 movement;
public float moveSpeed = 6.0f;
public float jumpSpeed = 5.0f;
public float drag = 3;
private bool canJump = true;
//public AudioClip BallRollSlowSound;
//public float height;
void Start()
{
moveJoy = GameObject.Find("LeftJoystick");
_GameManager = GameObject.Find("_GameManager");
// height = collider.bounds.extents.y + 0.2f; //Landi
}
void Update ()
{
Vector3 forward = Camera.main.transform.TransformDirection(Vector3.forward);
forward.y = 0;
forward = forward.normalized;
Vector3 forwardForce = new Vector3();
if (Application.platform == RuntimePlatform.Android)
{
float tmpSpeed = moveJoy.GetComponent<Joystick>().position.y;
forwardForce = forward * tmpSpeed * 1f * moveSpeed;
}
else
{
forwardForce = forward * Input.GetAxis("Vertical") * moveSpeed;
}
rigidbody.AddForce(forwardForce);
Vector3 right= Camera.main.transform.TransformDirection(Vector3.right);
right.y = 0;
right = right.normalized;
Vector3 rightForce = new Vector3();
if (Application.platform == RuntimePlatform.Android)
{
float tmpSpeed = moveJoy.GetComponent<Joystick>().position.x;
rightForce = right * tmpSpeed * 0.8f * moveSpeed;
}
else
{
rightForce= right * Input.GetAxis("Horizontal") * moveSpeed;
}
rigidbody.AddForce(rightForce);
if (canJump Input.GetKeyDown(KeyCode.Space))
{
rigidbody.AddForce(Vector3.up * jumpSpeed * 100);
canJump = false;
_GameManager.GetComponent<GameManager>().BallJump();
}
if (rigidbody.velocity.magnitude > 0.5 /* Physics.Raycast(transform.position, Vector3.down, height) gameObject.tag == "Untagged"*/)
{
_GameManager.GetComponent<GameManager>().BallRollSlow();
}
if (rigidbody.velocity.magnitude > 4.5 /* Physics.Raycast(transform.position, Vector3.down, height) gameObject.tag == "Untagged"*/)
{
_GameManager.GetComponent<GameManager>().BallRollFast();
}
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Destroy")
{
_GameManager.GetComponent<GameManager>().Death();
Destroy(gameObject);
}
else if (other.tag == "Coin")
{
Destroy(other.gameObject);
_GameManager.GetComponent<GameManager>().FoundCoin();
}
else if (other.tag == "SpeedBooster")
{
movement = new Vector3(0,0,0);
_GameManager.GetComponent<GameManager>().SpeedBooster();
}
else if (other.tag == "JumpBooster")
{
movement = new Vector3(0,0,0);
_GameManager.GetComponent<GameManager>().JumpBooster();
}
else if (other.tag == "Teleporter")
{
movement = new Vector3(0,0,0);
_GameManager.GetComponent<GameManager>().Teleporter();
}
}
void OnCollisionEnter(Collision collision)
{
if (!canJump)
{
canJump = true;
_GameManager.GetComponent<GameManager>().BallHitGround();
}
}
void OnGUI()
{
GUI.Label(new Rect(300,10,100,100),"X: " + moveJoy.GetComponent<Joystick>().position.x.ToString());
GUI.Label(new Rect(300,30,100,100),"Y: " + moveJoy.GetComponent<Joystick>().position.y.ToString());
}
}
My Idea was, that i do not post to much useless info, sry.
But now, it should be good and enough info.