public void MidclickPos(IndexOfList2D pos) { if (Singleton.GamePart.flipBoard[pos] == 1) { FlipAround(pos); } }
public void FlipAround(IndexOfList2D pos) { int flagCount = 0; flagMap.ChangeAround(pos.x, pos.y, (int aroundX, int aroundY, int get) => { if (get == 1) { flagCount++; } return(get); } ); if (Singleton.MainData.mineDatas[pos] == flagCount) { flagMap.ChangeAround(pos.x, pos.y, (int aroundX, int aroundY, int get) => { if (get != 1) { Singleton.GamePart.AreaClick(aroundX, aroundY); } return(get); } ); } }
void CreateNewGb(IndexOfList2D pos) { areaGbs[pos] = GameObject.Instantiate(originPrefab, transform); areaGbs[pos].transform.localPosition = AreaPosLocal(pos); areaGbs[pos].GetComponentInChildren <AreaView>().x = pos.x; areaGbs[pos].GetComponentInChildren <AreaView>().y = pos.y; }
public Area(IndexOfList2D _pos, ConnectedAreas _father) { Debug.Assert(_father != null); pos = _pos; neighbours = new List <Area>(8); father = _father; }
public void RclickPos(IndexOfList2D pos) { if (Singleton.GamePart.flipBoard[pos] != 1) { flagMap[pos] = 1 - flagMap[pos]; RefreshView(); } }
public T this[IndexOfList2D index] { get{ return(this[index.x, index.y]); } set{ this[index.x, index.y] = value; } }
public Area CreateOutside(IndexOfList2D pos, ConnectedAreas father) { Area area = new Area(pos, father); map[pos] = area; father.outsides.Add(area); return(area); }
public Area CreateNumber(IndexOfList2D pos, ConnectedAreas father) { Area area = new Area(pos, father); map[pos] = area; father.numbers.Add(area); return(area); }
public ChangeMap(IndexOfList2D _clickPos, Dictionary<ConnectedAreas, SearchForCa> _sfcas, PrecacTableBase _tableBase) { //Debug.Assert(_sfcas.Count != 0); clickPos = _clickPos; sfcas = _sfcas; mineData = Singleton.MainData.mineDatas; flipBoard = Singleton.GamePart.flipBoard; tableBase = _tableBase; }
public void ProcessAfterClick(IndexOfList2D clickPos) { if (isHappy) { if (clickAction != null) { clickAction.Invoke(clickPos); } } }
public static void DrawABeaultifulButton(IndexOfList2D pos, Color color, System.Action pushButton) { Handles.color = color; if (Handles.Button(Singleton.MainData.AreaPosWorld(pos), Quaternion.identity, 0.5f, 0.5f, Handles.CylinderHandleCap)) { if (pushButton != null) { pushButton(); } } }
public void CreateFlagGb(IndexOfList2D pos) { GameObject flagFather = GameObject.Find("Flags"); if (flagFather == null) { flagFather = new GameObject("Flags"); } var flagPrefab = Resources.Load <GameObject>("flag"); flagGbs[pos] = Instantiate(flagPrefab); flagGbs[pos].transform.parent = flagFather.transform; }
public void Flip(List <FlipNode> flipNodes) { foreach (var node in flipNodes) { var area = tableBase.map.GetArea(node.pos); if (area != null) { area.father.RemoveOutsides(area); } ConnectedAreas ca = tableBase.cas.CreateCa(); area = tableBase.map.CreateNumber(node.pos, ca); gamePart.flipBoard.ChangeAround(node.x, node.y, (int aroundX, int aroundY, int get) => { IndexOfList2D pos = new IndexOfList2D(aroundX, aroundY); Area neighbour = tableBase.map.GetArea(pos); if (get == 0) { if (neighbour == null) { neighbour = tableBase.map.CreateOutside(pos, ca); } else { tableBase.cas.MergeCas(neighbour.father, ca); ca = neighbour.father; } neighbour.neighbours.Add(area); area.neighbours.Add(neighbour); } return(get); } ); if (area.neighbours.Count == 0) { tableBase.map.RemovePos(area.pos); tableBase.cas.Remove(ca); } } problemsAndResults = new Dictionary <ConnectedAreas, SearchForCa>(); foreach (var ca in tableBase.cas.list) { problemsAndResults[ca] = new SearchForCa(ca); problemsAndResults[ca].Process(); } visualizedData(); if (afterPrecacAction != null) { afterPrecacAction(); } }
public void ReverseRandomInsideTarget(int count, IndexOfList2D exceptPos = null) { int setValue = -1 - insideTargetValue; List<IndexOfList2D> randomList = new List<IndexOfList2D>(insideTargets); if(exceptPos != null) { foreach(IndexOfList2D pos in randomList) { if(pos.x == exceptPos.x && pos.y == exceptPos.y) { randomList.Remove(pos); break; } } } for(int i = 0; i < count; i++) { IndexOfList2D randomPos = randomList[(int)(Random.value * randomList.Count)]; randomList.Remove(randomPos); result.Add(new SetMap(randomPos, setValue)); } }
public void AfterClick(IndexOfList2D clickPos) { if (precalculate.problemsAndResults != null && precalculate.tableBase != null) { foreach (var search in precalculate.problemsAndResults.Values) { if (!search.isDead) { return; } } changeMap = new ChangeMap(clickPos, precalculate.problemsAndResults, precalculate.tableBase); changeMap.Calculate(); List <SetMap> setMaps = changeMap.result; visualizedData(setMaps); changeMap.ChangeMineData(); } }
public void RandomGenerate(int randomGenerateCount) { int tempCount = randomGenerateCount; ResetMineData(); List <IndexOfList2D> positions = new List <IndexOfList2D>(); foreach (var pos in mineDatas.Positions()) { positions.Add(pos); } while (tempCount != 0) { int index = (int)(Random.value * positions.Count); IndexOfList2D pos = positions[index]; positions.Remove(pos); ReverseMineData(pos.x, pos.y); tempCount--; } }
public void RefreshView() { for (int i = 0; i < flagMap.XSize; i++) { for (int j = 0; j < flagGbs.YSize; j++) { var pos = new IndexOfList2D(i, j); if (flagMap[pos] == 0 && flagGbs[pos] != null) { Destroy(flagGbs[pos]); flagGbs[pos] = null; } else if (flagMap[pos] == 1 && flagGbs[pos] == null) { CreateFlagGb(pos); } if (flagGbs[pos] != null) { flagGbs[pos].transform.position = Singleton.MainData.AreaPosWorld(pos); } } } }
public SetMap(IndexOfList2D _pos, int _value) { pos = _pos; value = _value; }
public Area GetArea(IndexOfList2D pos) { return(map[pos]); }
public HCArea(int _value, IndexOfList2D _pos, List <HCArea> _neighbours) { pos = _pos; neighbours = _neighbours; value = _value; }
public bool Inside(IndexOfList2D index) { return(Inside(index.x, index.y)); }
public void RemovePos(IndexOfList2D pos) { map[pos] = null; }
public IndexOfList2D(IndexOfList2D other) { x = other.x; y = other.y; }
public Vector3 AreaPosLocal(IndexOfList2D pos) { return(AreaPosLocal(pos.x, pos.y)); }
public Vector3 AreaPosWorld(IndexOfList2D pos) { return(AreaPosWorld(pos.x, pos.y)); }
public void changeMineDataForHappy(IndexOfList2D clickPos) { List2DInt map = new List2DInt(Singleton.MainData.XSize, Singleton.MainData.YSize, 0); outsideUfas = new List <IndexOfList2D>(); insideUfas = new List <IndexOfList2D>(); foreach (var ufa in happyCheck.unFlipAreaList) { outsideUfas.Add(ufa.pos); } foreach (var pos in happyCheck.unFlipAreaInsideList) { if (pos.x != clickPos.x || pos.y != clickPos.y) { insideUfas.Add(pos); } } List <int> trueResult = null; var results = happyCheckStep.checkResults; int needPutMineCount = 0; if (map[clickPos] != -1) { if (results.Count > 0) { for (int i = 0; i < results.Count; i++) { needPutMineCount = Singleton.MainData.mineCount - results[i].Count; if (needPutMineCount <= insideUfas.Count) { trueResult = results[i]; break; } } } else { trueResult = new List <int>(); needPutMineCount = Singleton.MainData.mineCount; } } else { for (int i = 0; i < results.Count; i++) { var result = results[i]; bool flag = true; foreach (int index in result) { var ufa = happyCheckStep.GetUfa(index); if (ufa.pos.x == clickPos.x && ufa.pos.y == clickPos.y) { flag = false; break; } } if (flag) { trueResult = result; } } } if (trueResult == null) { return; } foreach (int index in trueResult) { var ufa = happyCheckStep.GetUfa(index); map[ufa.pos] = -1; } for (int i = 0; i < needPutMineCount; i++) { IndexOfList2D pos = insideUfas[(int)(Random.Range(0, insideUfas.Count))]; insideUfas.Remove(pos); map[pos] = -1; } watchList.list = map; var mainData = Singleton.MainData; foreach (var ufa in happyCheck.unFlipAreaList) { mainData.SetMineData(ufa.pos.x, ufa.pos.y, map[ufa.pos]); } foreach (var pos in happyCheck.unFlipAreaInsideList) { mainData.SetMineData(pos.x, pos.y, map[pos]); } }
public Area(Area other) { pos = new IndexOfList2D(other.pos); neighbours = new List <Area>(other.neighbours); }
public static void DrawABeaultifulLabel(IndexOfList2D pos, string text) { Handles.Label(Singleton.MainData.AreaPosWorld(pos), text); }