private GameObject InitDataPattern(int nIndex, bool bIsSpecial) { ColorType colorType = (!bIsSpecial) ? this.GetRandomColor() : ColorType.SPECIAL_COLOR; PatternScript.Type eType = (PatternScript.Type)((!bIsSpecial) ? UnityEngine.Random.Range(0, 6) : 6); Color colorUI = (!bIsSpecial) ? this._listColorUI[(int)colorType] : Color.white; GameObject gameObject = this.CreatePattern(eType, nIndex, colorType, colorUI, bIsSpecial); //gameObject.name = "Pattern " + this._nCountPattern; //this._nCountPattern++; return(gameObject); }
private GameObject CreatePattern(PatternScript.Type eType, int nIndex, ColorType eColor, Color colorUI, bool bIsSpecial) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/Pattern")); gameObject.transform.SetParent(this.transform); // this._panelPattern); gameObject.transform.localScale = Vector3.one; if (bIsSpecial) { gameObject.transform.position = this._specialPatternManager.transform.position; } else { gameObject.transform.localPosition = new Vector2(0f, 0f); } gameObject.GetComponent <PatternScript>().CreatePattern(nIndex, eType, eColor, colorUI); return(gameObject); }
public List <PosMap> CheckHexa(List <CellModel> listHint, CellModel[,] mapData, PatternScript.Type eType) { List <PosMap> list = new List <PosMap>(); int count = listHint.Count; if (count == 0 || eType == PatternScript.Type.SPECIAL) { return(list); } this._mapData = mapData; for (int i = 0; i < count; i++) { PosMap posInMap = listHint[i].PosInMap; CellType type = listHint[i].Type; if (type != CellType.UP) { if (type == CellType.DOWN) { List <PosMap> listTemp = this.CheckCellDown_1(posInMap, listHint[i].Color); this.SumaryListCheckHexa(list, listTemp); listTemp = this.CheckCellDown_2(posInMap, listHint[i].Color); this.SumaryListCheckHexa(list, listTemp); listTemp = this.CheckCellDown_3(posInMap, listHint[i].Color); this.SumaryListCheckHexa(list, listTemp); } } else { List <PosMap> listTemp = this.CheckCellUp_1(posInMap, listHint[i].Color); this.SumaryListCheckHexa(list, listTemp); listTemp = this.CheckCellUp_2(posInMap, listHint[i].Color); this.SumaryListCheckHexa(list, listTemp); listTemp = this.CheckCellUp_3(posInMap, listHint[i].Color); this.SumaryListCheckHexa(list, listTemp); } } return(list); }
public void Import(SavePatterModel savePattern, List <Color> listColorUI) { this._eTypePattern = savePattern.TypePattern; this._eColor = savePattern.Color; this._nIndexInPanel = savePattern.IndexInPanel; this._nCountClick = savePattern.CountClick; int num = 0; int num2 = 0; this._nIndexPositionCenter = 0; switch (this._eTypePattern) { case PatternScript.Type.ONE_TRIANGLE: num = 1; num2 = 1; this._nNumberTriangle = 1; this._map[1, 0] = CellType.UP; this._bOneLine = true; this._nFinalIndex = 0; break; case PatternScript.Type.TWO_TRIANGLE: num = 1; num2 = 2; this._nNumberTriangle = 2; this._map[1, 0] = CellType.DOWN; this._map[1, 1] = CellType.UP; this._bOneLine = true; this._nFinalIndex = 1; break; case PatternScript.Type.THREE_TRIANGLE: num = 1; num2 = 3; this._nNumberTriangle = 3; this._map[1, 0] = CellType.UP; this._map[1, 1] = CellType.DOWN; this._map[1, 2] = CellType.UP; this._bOneLine = true; this._nFinalIndex = 2; break; case PatternScript.Type.FOUR_TRIANGLE_1: num = 2; num2 = 3; this._nNumberTriangle = 4; this._map[1, 0] = CellType.UP; this._map[1, 1] = CellType.DOWN; this._map[1, 2] = CellType.UP; this._map[0, 2] = CellType.DOWN; this._bOneLine = false; this._nFinalIndex = 3; break; case PatternScript.Type.FOUR_TRIANGLE_2: num = 2; num2 = 3; this._nNumberTriangle = 4; this._map[0, 0] = CellType.UP; this._map[0, 1] = CellType.DOWN; this._map[0, 2] = CellType.UP; this._map[1, 1] = CellType.UP; this._bOneLine = false; this._nFinalIndex = 3; this._nIndexPositionCenter = 1; break; case PatternScript.Type.FIVE_TRIANGLE: num = 2; num2 = 3; this._nNumberTriangle = 5; this._map[1, 0] = CellType.UP; this._map[1, 1] = CellType.DOWN; this._map[1, 2] = CellType.UP; this._map[0, 2] = CellType.DOWN; this._map[0, 1] = CellType.UP; this._bOneLine = false; this._nFinalIndex = 4; break; case PatternScript.Type.SPECIAL: num = 2; num2 = 3; this._nNumberTriangle = 6; this._map[1, 0] = CellType.UP; this._map[1, 1] = CellType.DOWN; this._map[1, 2] = CellType.UP; this._map[0, 2] = CellType.DOWN; this._map[0, 1] = CellType.UP; this._map[0, 0] = CellType.DOWN; this._bOneLine = false; this._nFinalIndex = 5; break; } this._nWidthPattern = Constant.CELL_SIZE_WIDTH + (Constant.RANGE_X + Constant.CELL_SIZE_WIDTH / 2) * (num2 - 1); this._nHeightPattern = Constant.CELL_SIZE_HEIGHT * num; this._nHeightPattern = ((num != 1) ? (this._nHeightPattern + Constant.RANGE_Y) : this._nHeightPattern); base.GetComponent <RectTransform>().sizeDelta = new Vector2((float)this._nWidthPattern, (float)this._nHeightPattern); Color colorUI = (this._eColor != ColorType.SPECIAL_COLOR) ? listColorUI[(int)this._eColor] : UnityEngine.Color.white; this.DrawMap(colorUI); base.GetComponent <RectTransform>().sizeDelta = new Vector2((float)(this._nWidthPattern + 50), (float)(this._nHeightPattern + 50)); if (this._eColor == ColorType.SPECIAL_COLOR) { this.UpdateColorSpecial(listColorUI); } if (this._eTypePattern == PatternScript.Type.ONE_TRIANGLE || this._eTypePattern == PatternScript.Type.FOUR_TRIANGLE_2) { base.GetComponent <RectTransform>().pivot = new Vector2(0.5f, 0.3f); } base.transform.localScale = new Vector3(0.95f, 0.95f, 1f); this.RotateWithCountClick(this._nCountClick); }
public void CreatePattern(int nIndexInPanel, PatternScript.Type eTypePattern, ColorType eColor, Color colorUI) { this._nIndexInPanel = nIndexInPanel; this._eTypePattern = eTypePattern; this._eColor = eColor; int num = 0; int num2 = 0; this._nIndexPositionCenter = 0; switch (this._eTypePattern) { case PatternScript.Type.ONE_TRIANGLE: num = 1; num2 = 1; this._nNumberTriangle = 1; this._map[1, 0] = CellType.UP; this._bOneLine = true; this._nFinalIndex = 0; break; case PatternScript.Type.TWO_TRIANGLE: num = 1; num2 = 2; this._nNumberTriangle = 2; this._map[1, 0] = CellType.DOWN; this._map[1, 1] = CellType.UP; this._bOneLine = true; this._nFinalIndex = 1; break; case PatternScript.Type.THREE_TRIANGLE: num = 1; num2 = 3; this._nNumberTriangle = 3; this._map[1, 0] = CellType.UP; this._map[1, 1] = CellType.DOWN; this._map[1, 2] = CellType.UP; this._bOneLine = true; this._nFinalIndex = 2; break; case PatternScript.Type.FOUR_TRIANGLE_1: num = 2; num2 = 3; this._nNumberTriangle = 4; this._map[1, 0] = CellType.UP; this._map[1, 1] = CellType.DOWN; this._map[1, 2] = CellType.UP; this._map[0, 2] = CellType.DOWN; this._bOneLine = false; this._nFinalIndex = 3; break; case PatternScript.Type.FOUR_TRIANGLE_2: num = 2; num2 = 3; this._nNumberTriangle = 4; this._map[0, 0] = CellType.UP; this._map[0, 1] = CellType.DOWN; this._map[0, 2] = CellType.UP; this._map[1, 1] = CellType.UP; this._bOneLine = false; this._nFinalIndex = 3; this._nIndexPositionCenter = 1; break; case PatternScript.Type.FIVE_TRIANGLE: num = 2; num2 = 3; this._nNumberTriangle = 5; this._map[1, 0] = CellType.UP; this._map[1, 1] = CellType.DOWN; this._map[1, 2] = CellType.UP; this._map[0, 2] = CellType.DOWN; this._map[0, 1] = CellType.UP; this._bOneLine = false; this._nFinalIndex = 4; break; case PatternScript.Type.SPECIAL: num = 2; num2 = 3; this._nNumberTriangle = 6; this._map[1, 0] = CellType.UP; this._map[1, 1] = CellType.DOWN; this._map[1, 2] = CellType.UP; this._map[0, 2] = CellType.DOWN; this._map[0, 1] = CellType.UP; this._map[0, 0] = CellType.DOWN; this._bOneLine = false; this._nFinalIndex = 5; break; } this._nWidthPattern = Constant.CELL_SIZE_WIDTH + (Constant.RANGE_X + Constant.CELL_SIZE_WIDTH / 2) * (num2 - 1); this._nHeightPattern = Constant.CELL_SIZE_HEIGHT * num; this._nHeightPattern = ((num != 1) ? (this._nHeightPattern + Constant.RANGE_Y) : this._nHeightPattern); base.GetComponent <RectTransform>().sizeDelta = new Vector2((float)this._nWidthPattern, (float)this._nHeightPattern); this.DrawMap(colorUI); base.GetComponent <RectTransform>().sizeDelta = new Vector2((float)(this._nWidthPattern + 50), (float)(this._nHeightPattern + 50)); if (this._eTypePattern == PatternScript.Type.ONE_TRIANGLE || this._eTypePattern == PatternScript.Type.FOUR_TRIANGLE_2) { base.GetComponent <RectTransform>().pivot = new Vector2(0.5f, 0.3f); } base.transform.localScale = new Vector3(0.95f, 0.95f, 1f); }