protected void AddedThingsFixed1x2Or2x1(List <DataIndex> dataIndices, ThingFull thingFull, int indexGridBlock) { //if (thingFull.TypeThing== TypeThing.Type1x2) //{ // thingFull.SetBack(IconManager.GetRandomSprite1x2()); //} //if (thingFull.TypeThing==TypeThing.Type2x1) //{ // thingFull.SetBack(IconManager.GetRandomSprite2x1()); //} thingFull.Init(gridBlocks[indexGridBlock]); Vector2 Center = Vector2.zero; for (int i = 0; i < dataIndices.Count; i++) { thingFull.GridBlock.gridCells[dataIndices[i].indexI, dataIndices[i].indexJ].SetOccupied(thingFull.thingCells[i]); thingFull.GridBlock.gridCells[dataIndices[i].indexI, dataIndices[i].indexJ].SetNonDelete(); Center += thingFull.GridBlock .gridCells[dataIndices[i].indexI, dataIndices[i].indexJ] .Coordinates; } thingFull.SetFix(); thingFull.transform.SetParent(thingFull.GridBlock.transform); thingFull.transform.localPosition = Center / dataIndices.Count; thingFull.transform.localScale = Vector3.one; }
protected override void OneThingsInCases1x2(int indexGridBlock = 0, string str = default) { rnd = Random.Range(0, 2); if (str == default) { str = (rnd % 2 == 0) ? "100100" : "001001"; } for (int i = 0; i < str.Length; i++) { I = Mathf.CeilToInt(i / 3); J = i % 3; if (str[i] == '1') { //print($"str[{i}] -> [{I},{J}] ->GridBlock{indexGridBlock}"); dataCellTmp.Add(new DataIndex(I, J)); } } ThingFull thingFull = Instantiate(poolThings.DictionaryThings[TypeThing.Type1x2]); AddedThingsFixed1x2Or2x1(dataCellTmp, thingFull, indexGridBlock); dataCellTmp.Clear(); }
protected void AppendByTypeInListPack(TypeThing typeThing, int count = 1) { for (int i = 0; i < count; i++) { ThingFull thingFull = Instantiate(poolThings.DictionaryThings[typeThing]); //switch (typeThing) //{ // case TypeThing.Type1x1: // thingFull.SetBack(IconManager.GetRandomSprite1x1()); // break; // case TypeThing.Type1x2: // thingFull.SetBack(IconManager.GetRandomSprite1x2()); // break; // case TypeThing.Type2x1: // thingFull.SetBack(IconManager.GetRandomSprite2x1()); // break; // case TypeThing.Other: // break; // default: // break; //} poolThings.AddToListPack(thingFull); } }
private void InitDictionary() { foreach (TypeThing typeThing in (TypeThing[])System.Enum.GetValues(typeof(TypeThing))) { ThingFull thingFull = ListPoolInstance.Find(item => item.name.Contains(typeThing.ToString().Substring(4))); DictionaryThings.Add(typeThing, thingFull); } }
public void AddToListPack(ThingFull thingFull) { ListPoolSelectedPack.Add(thingFull); thingFull.transform.SetParent(transform); thingFull.GetComponent <ThingDragNDrop>().SetTransformParentDef(transform); thingFull.transform.localScale = Vector3.one; }
protected override void OneThingsInCases1x1(int indexGridBlock = 0, string str = default, bool isRandom = true) { if (str == default) { str = GenerateStr("00000", 6, "1"); } for (int i = 0; i < str.Length; i++) { I = Mathf.CeilToInt(i / 3); J = i % 3; if (isRandom) { indexGridBlock = i % gridBlocks.Count; if (i % gridBlocks.Count == 0) { if (str[i] == '1') { //print($"str[{i}] -> [{I},{J}] ->GridBlock{indexGridBlock}"); ThingFull thingFull = Instantiate(poolThings.DictionaryThings[TypeThing.Type1x1]); AddedThingsFixed1x1(I, J, thingFull, indexGridBlock); } } else { if (str[i] == '1') { //print($"str[{i}] -> [{(I + 1) % 2},{J}] ->GridBlock{indexGridBlock}"); ThingFull thingFull = Instantiate(poolThings.DictionaryThings[TypeThing.Type1x1]); AddedThingsFixed1x1((I + 1) % 2, J, thingFull, indexGridBlock); } } } else { if (str[i] == '1') { //print($"str[{i}] -> [{I},{J}] ->GridBlock{indexGridBlock}"); ThingFull thingFull = Instantiate(poolThings.DictionaryThings[TypeThing.Type1x1]); AddedThingsFixed1x1(I, J, thingFull, indexGridBlock); } } } }
public void AddThisToGrid(ThingFull thingFull) { float x = 0; float y = 0; //TODO // 1x1, 1x2,2x1 this if (thingFull.TypeThing != TypeThing.Type1x2L) { for (int i = 0; i < thingFull.thingCells.Count; i++) { x += thingFull.thingCells[i].CenterInGrids.x; y += thingFull.thingCells[i].CenterInGrids.y; gridCells[(int)thingFull.thingCells[i].dataCell.Coordinates.x, (int)thingFull.thingCells[i].dataCell.Coordinates.y] .SetOccupied(thingFull.thingCells[i]); } thingFull.transform.SetParent(gameObject.transform); thingFull.transform.localPosition = new Vector3(x / thingFull.thingCells.Count, y / thingFull.thingCells.Count, 0); } //TODO // 1x2L if (thingFull.TypeThing == TypeThing.Type1x2L) { for (int i = 1; i < thingFull.thingCells.Count; i++) { x += thingFull.thingCells[i].CenterInGrids.x; y += thingFull.thingCells[i].CenterInGrids.y; gridCells[(int)thingFull.thingCells[i].dataCell.Coordinates.x, (int)thingFull.thingCells[i].dataCell.Coordinates.y] .SetOccupied(thingFull.thingCells[i]); } thingFull.transform.SetParent(gameObject.transform); thingFull.transform.localPosition = new Vector3(x / 2, y / 2, 0); } if (!ListAddedThings.Any(item => item == thingFull)) { ListAddedThings.Add(thingFull); } thingFull.transform.localScale = Vector3.one; }
protected override void OneThingsInCases2x1(int indexGridBlock, string str) { for (int i = 0; i < str.Length; i++) { I = Mathf.CeilToInt(i / 4); J = i % 4; if (str[i] == '1') { //print($"str[{i}] -> [{I},{J}] ->GridBlock{indexGridBlock}"); dataCellTmp.Add(new DataIndex(I, J)); } } ThingFull thingFull = Instantiate(poolThings.DictionaryThings[TypeThing.Type2x1]); AddedThingsFixed1x2Or2x1(dataCellTmp, thingFull, indexGridBlock); dataCellTmp.Clear(); }
protected void AddedThingsFixed1x1(int indexI, int indexJ, ThingFull thingFull, int indexGridBlock) { //TODO //thingFull.SetBack(IconManager.GetRandomSprite1x1()); thingFull.Init(gridBlocks[indexGridBlock]); thingFull.GridBlock.gridCells[indexI, indexJ].SetOccupied(thingFull.thingCells[0]); thingFull.GridBlock.gridCells[indexI, indexJ].SetNonDelete(); thingFull.SetFix(); thingFull.transform.SetParent(thingFull.GridBlock.transform); thingFull.transform.localPosition = thingFull.GridBlock .gridCells[indexI, indexJ] .Coordinates; thingFull.transform.localScale = Vector3.one; }
public void RemoveToListPack(ThingFull thingFull) { ListPoolSelectedPack.Remove(thingFull); }