//音频
using UnityEngine;
using System.Collections;public class GameController:MonoBehaviour
{
private AudioClip baoshi_sound;
private AudioClip jump_sound;
private AudioClip dead_sound;
private AudioSource soundSource;
private static GameController instance = null;
public AudioSource soundMgr;
public static GameController Instance
{
get
{
return instance;
}
}
void Awake()
{
instance = this;
soundSource = gameObject.GetComponent<AudioSource>();
baoshi_sound = Resources.Load("Sounds/baoshi_eat") as AudioClip;
dead_sound = Resources.Load("Sounds/dead") as AudioClip;
jump_sound = Resources.Load("Sounds/jump") as AudioClip;
}
public void Playbaoshi_sound()
{
soundSource.clip = baoshi_sound;
soundSource.Play();
}
public void Playdead_sound()
{
soundSource.clip = dead_sound;
soundSource.Play();
}
public void Playjump_sound()
{
soundSource.clip = jump_sound;
soundSource.Play();
}
}
//panel切换
using UnityEngine;
using System.Collections;
public class Panel_start : MonoBehaviour
{
public GameObject panel_start;
public GameObject panel_main;
void Start ()
{
}
void Update ()
{
}
public void OnClick()
{
panel_start.SetActive(false);
panel_main.SetActive(true);
Application.LoadLevel(0);
}
}
//模拟屏幕控制
using UnityEngine;
using System.Collections;
public class HUDLayer : MonoBehaviour
{
public Vector2 zhongli = new Vector2(0, -20);
public Vector2 click = new Vector2(0, 12);
public Vector2 tap = new Vector2(0, 20);
public Rigidbody2D body;
public bool start = false;
public float speed = 0.09f;
bool StartCountTime = false;
float totalTime;
int speed_y = 1;
//public Animation Jump;
public GameObject Role_Jump;
public GameController jumpSource;
public void OnPointerDown()
{
StartCountTime = true;
}
public void OnPointerUp()
{
StartCountTime = false;
if (totalTime < 0.15&&speed_y==0)
{
body.velocity = click;
//animation["Jump"].speed = 0;
body.transform.Find("role_run").GetComponent<Animator>().speed = 0;
jumpSource.Playjump_sound();
}
totalTime = 0;
}
void Start ()
{
jumpSource = GameObject.Find("SourceManger").GetComponent<GameController>();
}
void Update ()
{
float a=speed + PlayerPrefs.GetInt("floors_num")*0.0005f;
if (PlayerPrefs.GetInt("stop") == 1)
{
a = 0;
click = new Vector2(0, 0);
tap = new Vector2(0, 0);
}
if (body.velocity.y < 0.2 && body.velocity.y > -0.2)
{
speed_y = 0;
}
else
{
speed_y = 1;
}
body.AddForce(zhongli);
body.transform.Translate(a, 0, 0);
if (StartCountTime)
{
totalTime += Time.deltaTime;
if (0.2 > totalTime && totalTime > 0.15 &&speed_y=&