106 lines
3.2 KiB
C#
106 lines
3.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using ZXKFramework;
|
|
|
|
public class LeftVer : UIBase
|
|
{
|
|
public override string GroupName => "LeftVer";
|
|
|
|
public override string Name => "LeftVer";
|
|
|
|
public Button[] buts;
|
|
GameManager gameManager;
|
|
GameModel gameModel;
|
|
string[] StringSplit(string str) {
|
|
string[] ret = str.Split('|');
|
|
return ret;
|
|
}
|
|
|
|
Sprite True;
|
|
Sprite False;
|
|
|
|
public void changeState(int n) {
|
|
if (n > buts.Length) return ;
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
buts[i].image.sprite = True;
|
|
}
|
|
for (int i = n; i < buts.Length; i++) {
|
|
buts[i].image.sprite = False;
|
|
}
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (buts == null || buts.Length <= 0) buts = gameObject.GetComponentsInChildren<Button>();
|
|
if (!True) True = Resources.Load<Sprite>("UI/True");
|
|
if (!False) False = Resources.Load<Sprite>("UI/false");
|
|
|
|
//changeState(0);
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
gameModel = MVC.GetModel<GameModel>();
|
|
|
|
//buts = gameObject.GetComponentsInChildren<Button>();
|
|
//True = Resources.Load<Sprite>("UI/True");
|
|
//False = Resources.Load<Sprite>("UI/false");
|
|
|
|
foreach (Button but in buts) {
|
|
but.onClick.AddListener(()=>{
|
|
|
|
|
|
gameManager = GameManager.Instance;
|
|
|
|
int end = int.Parse(but.name);
|
|
int n = gameModel.excelData.allOrderDragData.Count;
|
|
|
|
changeState(end);
|
|
|
|
string[] unBombs = { };
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
if (gameModel.excelData.allOrderDragData[i].orderID < end - 1)
|
|
{
|
|
unBombs = unBombs.Concat(StringSplit(gameModel.excelData.allOrderDragData[i].dragGameName)).ToArray();
|
|
}
|
|
}
|
|
|
|
n = gameManager.allMouseMove.Count;
|
|
List<string> unBomb = unBombs.ToList();
|
|
for (int i = 0; i < n; i++) {
|
|
MouseMoveObj fd = gameManager.allMouseMove[i];
|
|
Collider col = gameManager.allOutLine[i];
|
|
if (unBomb.IndexOf(fd.name) != -1)
|
|
{
|
|
//Debug.Log("unbomb : " + fd.name);
|
|
fd.enabled = false;
|
|
fd.GetComponent<Collider>().enabled = false;
|
|
col.enabled = false;
|
|
OrderDragManager.Instance.AddDragGame(fd.name, fd.transform.localPosition);
|
|
gameManager.MergeAdsorb(fd.name);
|
|
|
|
}
|
|
else
|
|
{
|
|
fd.enabled = true;
|
|
fd.GetComponent<Collider>().enabled = true;
|
|
col.enabled = true;
|
|
OrderDragManager.Instance.ReturnToStartPos(fd.gameObject);
|
|
|
|
}
|
|
}
|
|
|
|
OrderDragManager.Instance.InitDragOrder(end - 1);
|
|
Debug.Log(end - 1);
|
|
});
|
|
}
|
|
}
|
|
|
|
}
|