using System.Collections;
public class StopBoss : MonoBehaviour
{
public UISprite slider;
public UIButton stopBoss;
public int count;
public UILabel countNum;
// public GameObject obj;
private bool stopBossStatus = false;
public GameObject Night_CorverBoss;
public GameObject Pig_CorverBoss;
public GameObject Rain_CorverBoss;
public GameObject Sun_CorverBoss;
void Start ()
{
UIEventListener.Get (stopBoss.gameObject).onClick = onStopBossBtn;
// obj = GameObject.FindWithTag ("SunBoss");
slider.fillAmount = 0f;
count = -1;
// countNum.text = count.ToString ();
//使用道具时
if (GameBuff.GetInstance ().StopBossBuffNum != 0) {
// count++;
count = GameBuff.GetInstance ().StopBossBuffNum;
stopBossStatus = true;
} else {
count++;
countNum.text = count.ToString ();
stopBoss.GetComponent<BoxCollider> ().enabled = true;
}
}
void Update ()
{
if (CarConfig.GetInstance ().isStopBoss) {
slider.fillAmount += 1 * 0.0128f;
CarConfig.GetInstance ().isStopBoss = false;
}
if (slider.fillAmount == 1f) {
count++;
countNum.text = count.ToString ();
slider.fillAmount = 0f;
}
//设置按钮为可用
if (count > 0) {
stopBoss.gameObject.GetComponent<BoxCollider> ().enabled = true;
}
countNum.text = count.ToString ();
}
//使用拦截道具
void onStopBossBtn (GameObject ob)
{
Debug.Log ("============================================按下拦截按钮============================================!");
//1、购买拦截道具
//2、吃到一定玉米获得拦截道具
if (count <= 0) {
count = 0;
} else {
if (stopBossStatus) {
StopBossType ();
// GameBuff.GetInstance ().StopBoss_status = false;
GameBuff.GetInstance ().StopBossBuffNum = 0;
stopBossStatus = false;
}
StopBossType ();
stopBoss.gameObject.GetComponent<BoxCollider> ().enabled = false;
CarConfig.GetInstance ().stopBossTimes++;
count--;
}
}
void StopBossType ()
{
switch (TempValue.GetInstance ().curLandType) {
case (int)Land_type.Dusk_land:
GameObject theGameObject = GameObject.FindWithTag ("SunBoss");
SunBoss sun = theGameObject.GetComponent<SunBoss> ();
//当按下拦截按钮的时候,实例化一个云,然后获取Boss的位置,将云的位置设置到Boss身上
GameObject sunObj = (GameObject)Instantiate (Sun_CorverBoss);
SunCloud sunCorverCloud = sunObj.GetComponent<SunCloud> ();
sunCorverCloud.Move ();
sun.SetBossCoveredStatus (true);
//实例化一个云之后,在CoverCloud中
GameObject.FindWithTag ("MainCamera").GetComponent<CameraFollowCar> ().SetCoverBoss ((int)Land_type.Dusk_land);
break;
case (int)Land_type.Night_land:
GameObject nightBoss = GameObject.FindWithTag ("NightFrost");
NightFrost frost = nightBoss.GetComponent<NightFrost> ();
//当按下拦截按钮的时候,实例化一个云,然后获取Boss的位置,将云的位置设置到Boss身上
GameObject frostObj = (GameObject)Instantiate (Night_CorverBoss);
NightCloud nightCorverCloud = frostObj.GetComponent<NightCloud> ();
nightCorverCloud.Move ();
frost.SetBossCoveredStatus (true);
GameObject.FindWithTag ("MainCamera").GetComponent<CameraFollowCar> ().SetCoverBoss ((int)Land_type.Night_land);
break;
case (int)Land_type.Ground_land:
GameObject groundBoss = GameObject.FindWithTag ("GroundPig");
GroundPig pig = groundBoss.GetComponent<GroundPig> ();
//当按下拦截按钮的时候,实例化一个云,然后获取Boss的位置,将云的位置设置到Boss身上
GameObject pigObj = (GameObject)Instantiate (Pig_CorverBoss);
Bullet bulletCorver = pigObj.GetComponent<Bullet> ();
bulletCorver.Move ();
pig.SetBossCoveredStatus (true);
GameObject.FindWithTag ("MainCamera").GetComponent<CameraFollowCar> ().SetCoverBoss ((int)Land_type.Ground_land);
break;
case (int)Land_type.Rain_land:
GameObject rainBoss = GameObject.FindWithTag ("RainClouds");
RainClouds rain = rainBoss.GetComponent<RainClouds> ();
//当按下拦截按钮的时候,实例化一个云,然后获取Boss的位置,将云的位置设置到Boss身上
GameObject rainObj = (GameObject)Instantiate (Rain_CorverBoss);
RainCloud rainCorverCloud = rainObj.GetComponent<RainCloud> ();
rainCorverCloud.Move ();
rain.SetBossCoveredStatus (true);
GameObject.FindWithTag ("MainCamera").GetComponent<CameraFollowCar> ().SetCoverBoss ((int)Land_type.Rain_land);
break;
default:
break;
}
}
}
using UnityEngine;
using System.Collections;
public class BtcAcc : MonoBehaviour {
public UISlider slider;
private GameObject car;
private bool isFly;
private float startFlytime;
void Start () {
slider.value = 0;
isFly = false;
startFlytime = ClientConstantConfigParseXML.GetValueById ("increaseFlyTime");
}
void Update () {
//TempValue.GetInstance().numToFlyModel
if (CarConfig.GetInstance ().isAccFly) {
// Debug.Log ("****************************************:" + Time.deltaTime);
slider.value += Time.deltaTime * 0.05f;
// slider.value += Time.deltaTime * 0.01f;
// slider.value += Time.time;
if (slider.value == 1f) {
// if (slider.value == startFlytime) {
isFly = true;
FlyCar (isFly);
}
} else {
slider.value = 0f;
}
}
void FlyCar(bool fly){
if(fly){
car = GameObject.FindGameObjectWithTag ("Player") as GameObject;
car.GetComponent<CarControlor> ().FlyModel (CarConfig.GetInstance ().FlyTime ());
Debug.Log ("*********************************************************测试飞行模式!" + GameBuff.GetInstance ().Fly_status);
slider.value = 0;
isFly = false;
}
}
}