HKMBFZ/Assets/Scripts/Szz_Scripts/Shoot122Manager.cs

225 lines
5.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Shoot122Manager : MonoBehaviour
{
public static Shoot122Manager Instance { get; private set; }
public Animation animation_122;
//public GameObject rawImage_122;
public GameObject penguan;
public List<string> chooseShoot=new List<string>();
public Dictionary<string,int> choosedValue=new Dictionary<string,int>();
public Control3DModelBt ;
public bool isShootReady;
public RotationController Rotate122;
public Control3DModelBt autoBtn1;
public Control3DModelBt autoBtn2;
public Control3DModelBt usedOpen;
public bool diaoPaoOver = false;
public bool isCheck; //是否进行了装弹检测
public bool isShootClear; //是否已经全部发射完毕
public List<ShootMsg> shootMsgs = new List<ShootMsg>();
public Transform animationParent;
private void Awake()
{
Instance = this;
isShoot = false;
isShootReady = false;
allCount = 40;
isCheck = false;
isShootClear = false;
for (int i = 0; i <= 40; i++)
{
AddOrUpdate(i.ToString(), 0); //默认有弹
}
shotType = "20Km杀爆弹";
}
public bool isShoot;
// Start is called before the first frame update
private void Update()
{
if (autoBtn1.Get3DBtnState() && autoBtn2.Get3DBtnState() && usedOpen.Get3DBtnState())
{
isShootReady = true;
}
else {
isShootReady = false;
}
}
string shotType;
public void UpdateType(string value)
{
shotType = value;
}
public void AddOrUpdate(string key, int value)
{
if (choosedValue.ContainsKey(key))
{
// 键已存在,更新值
choosedValue[key] = value;
}
else
{
// 键不存在,添加新元素
choosedValue.Add(key, value);
}
if (GameObject.FindObjectOfType<PaoZhangMainPage>() != null)
{
FindObjectOfType<PaoZhangMainPage>().SetOneState(int.Parse(key), value);
}
}
public bool RemoveByKey(string key)
{
if (choosedValue.ContainsKey(key))
{
choosedValue.Remove(key);
return true; // 删除成功
}
return false; // key不存在删除失败
}
public int allCount; //当前装弹数量
public void Jifa()
{
if (isShoot|| !.isInit)
return;
//rawImage_122.SetActive(true);
AnimationModel.instance.Show122PZ();
isShoot = true;
animation_122.Play();
StartCoroutine(JiFaIe());
//for (int i = 0; i < chooseShoot.Count; i++)
//{
// //animationParent.Find(i.ToString()).GetComponent<Animation>().Play();
//}
}
IEnumerator JiFaIe()
{
for (int i = 0; i < chooseShoot.Count; i++)
{
if (choosedValue.ContainsKey(chooseShoot[i]))
{
animationParent.Find(chooseShoot[i]).GetComponent<Animation>().Play();
animationParent.Find(chooseShoot[i]).GetChild(0).GetChild(1).GetChild(0).gameObject.SetActive(true); //出现激发特效
yield return new WaitForSeconds(0.1f);
//RemoveByKey(chooseShoot[i].ToString());
if (GameObject.FindObjectOfType<PaoZhangMainPage>() != null)
{
FindObjectOfType<PaoZhangMainPage>().SetOneState(int.Parse( chooseShoot[i]), 3);
}
choosedValue.Remove(chooseShoot[i].ToString()); //从炮弹池中移除
}
}
FindObjectOfType<PaoZhangMainPage>().OnJiFaOver();
allCount -= chooseShoot.Count;
ShootMsg s=new ShootMsg();
s.shotCount = chooseShoot.Count;
s.shotTime = 0.5f;
s.shotType = shotType;
s.shotHigh = "0.5";
shootMsgs.Add(s);
if (allCount <= 0)
isShootClear = true;
else
isShoot = false;
chooseShoot.Clear();
}
public void DiaoPaoOver()
{
if (Manager122Base.instance != null)
Manager122Base.instance.Show122DwonMsg("高低到位,方位到位");
}
public LightState lianjieqileft;
public LightState lianjieqiRight;
/// <summary>
/// 控制左右连接器高亮
/// </summary>
/// <param name="state"></param>
public void LianJieQiState(bool state)
{
if (state)
{
lianjieqileft.OpenLight();
lianjieqiRight.OpenLight();
}
else
{
lianjieqileft.CloseLight();
lianjieqiRight.CloseLight();
}
}
public LightState leftLock;
public LightState rightLock;
public LightState ;
public LightState ;
/// <summary>
/// 模型上用炮按钮点击
/// </summary>
public void UseClick()
{
leftLock.OpenLight();
rightLock.OpenLight();
.OpenLight();
.OpenLight();
}
/// <summary>
/// 模型上收炮点击
/// </summary>
public void UnUseClick()
{
leftLock.OpenLight();
rightLock.OpenLight();
.CloseLight();
.CloseLight();
lianjieqileft.OpenLight();
lianjieqiRight.OpenLight();
}
}
public class ShootMsg
{
public int shotCount;
public string shotType;
public float shotTime;
public string shotHigh = "0";
}