//============================================= //создать новую фигуру на базе фигуры из очереди (взять из нее каркас и типы камней) //queueFigura - каркас + типы квадратов (без графики) public void Create_Figura(OneQueueFigura queueFigura, Transform parent) { carcas_type = queueFigura.carcas_type; carcas = queueFigura.carcas; //myUtils.console_log(carcas_type, carcas); //создание фигуры по центру плашки Vector2 min = new Vector2((float)carcas.getMinD(0), (float)carcas.getMinD(1)); Vector2 pt_center = new Vector2((float)GameConstants.AREA_WIDTH / 2f, -min.y + (float)GameConstants.AREA_VISUAL_HEIGHT); for (int i = 0; i < carcas.numPoints; i++) { int type = queueFigura.squaresList[i].type; float dx = GameConstants.AREA_START.x + ((float)carcas.coords[i, 0] + pt_center.x + 0.5f) * GameConstants.AREA_SQUARE_SIZE.x; float dy = GameConstants.AREA_START.y + ((float)carcas.coords[i, 1] + pt_center.y + 0.5f) * GameConstants.AREA_SQUARE_SIZE.y; OneSquare square = myUtils.create_OneSquare(new Vector3(dx, dy, 0f), parent, GameConstants.AREA_SQUARE_SCALE, type, GameConstants.sANIM_BASE); squaresList.Add(square); } coords = new Vector2Int( Mathf.RoundToInt(pt_center.x), Mathf.RoundToInt(pt_center.y) ); delta = new Vector2(0f, 0f); last_move_time = 0f; rotate_index = 0; flagFastSpeed = false; figure_area_acept_time = 0; anti_click_space_first_frame = true; }
//============================================= // конструктор public void Create_Queue_Figura(CarcasType type, Transform parent) { carcas_type = type; carcas = FiguraCarcasesList.get_Carcas_byType(carcas_type); // создание плашки DestroyGraphicsObjects(); plashka = (GameObject)Instantiate(Resources.Load(GameConstants.PREFAB_PLASHKA), parent); //, parent plashka.transform.SetParent(parent); plashka.transform.localPosition = new Vector3(0f, 0f, 0f); //localPosition GameConstants.QUEUE_ITEM_HEIGHT / 2f plashka.GetComponent <SpriteRenderer>().maskInteraction = SpriteMaskInteraction.VisibleInsideMask; //plashka.transform.localScale = GameConstants.PLASHKA_SCALE; //Animator anim = prefab.GetComponent<Animator>(); //anim.runtimeAnimatorController = (RuntimeAnimatorController)Instantiate(Resources.Load(animation)) as RuntimeAnimatorController; //anim.Play("Idle"); //создание фигуры по центру плашки Vector2 min = new Vector2((float)carcas.getMinD(0), (float)carcas.getMinD(1)); Vector2 size = new Vector2((float)carcas.getMaxD(0) - min.x + 1f, (float)carcas.getMaxD(1) - min.y + 1f); //Ширина плашки = 5 x Ширина квадрата , поэтому crd = Xn-Xmin - FIGURA_WIDTH/2 + 1/2 //Высота плашки = 3.9 x Высоты квадрата for (int i = 0; i < carcas.numPoints; i++) { float dx = (0.5f - min.x - size.x / 2f + (float)carcas.coords[i, 0]) * GameConstants.QUEUE_SQUARE_SIZE.x; //f - maxwidth float dy = (0.45f - min.y - size.y / 2f + (float)carcas.coords[i, 1]) * GameConstants.QUEUE_SQUARE_SIZE.y; //myUtils.console_log(dx, dy); OneSquare square = myUtils.create_OneSquare(new Vector3(dx, dy, 0f), plashka.transform, GameConstants.QUEUE_SQUARE_SCALE, -1, GameConstants.sANIM_BASE); squaresList.Add(square); } //plashka.transform.localPosition = plashka.transform.localPosition + new Vector3(0f, GameConstants.QUEUE_ITEM_HEIGHT/2f, 0f); //localPosition }
private void Awake() { gameArea = FindObjectOfType <GameArea>(); // GetComponent gameController = FindObjectOfType <GameController>(); // GetComponent carcas_type = CarcasType.empty; carcas = null; squaresList = new List <OneSquare>(); }
//========================================= //добавить случайную фигуру в конец очереди public void Add_Random_Figura() { CarcasType carcase_type = FiguraCarcasesList.get_RandomCarcasType(); //myUtils.console_log("random carcase_type =", carcase_type); Vector3 crd = new Vector3(0f, -top_point_y - GameConstants.QUEUE_START.y - (float)figures_Queue.Count * GameConstants.QUEUE_ITEM_HEIGHT, 0f); OneQueueFigura qfigura = new OneQueueFigura(); Transform parent = GameObject.FindGameObjectWithTag("queue_figures").GetComponent <Transform>(); qfigura.Create_Queue_Figura(carcase_type, parent); qfigura.MoveTo(crd); figures_Queue.Add(qfigura); }
//============================================= //удалить квадраты фигуры public void delete_Figura() { if (squaresList.Count > 0) { while (squaresList.Count > 0) { Destroy(squaresList[0].brick); squaresList.RemoveAt(0); } } carcas_type = CarcasType.empty; }
//получить каркас фигуры по ключу с данной ротацией (0..3 = 0,90,180,270) public static FiguraCarcas get_Carcas_byType(CarcasType key, int rotate = 0) { rotate = rotate % 4; FiguraCarcas baseCarcas = null; List <FiguraCarcas> carcas = new List <FiguraCarcas>(); //myUtils.console_log("figura key =", key); switch (key) { case CarcasType.skoba_l: baseCarcas = new FiguraCarcas(4, new int[4, 2] { { -1, 1 }, { -1, 0 }, { 0, 0 }, { 1, 0 } }); break; case CarcasType.skoba_r: baseCarcas = new FiguraCarcas(4, new int[4, 2] { { -1, 0 }, { 0, 0 }, { 1, 0 }, { 1, 1 }, }); break; case CarcasType.zigzag_l: baseCarcas = new FiguraCarcas(4, new int[4, 2] { { -1, -1 }, { 0, -1 }, { 0, 0 }, { 1, 0 } }); break; case CarcasType.zigzag_r: baseCarcas = new FiguraCarcas(4, new int[4, 2] { { -1, 1 }, { 0, 1 }, { 0, 0 }, { 1, 0 } }); break; case CarcasType.halfcros: baseCarcas = new FiguraCarcas(4, new int[4, 2] { { -1, 0 }, { 0, 0 }, { 1, 0 }, { 0, 1 } }); break; case CarcasType.line_h: baseCarcas = new FiguraCarcas(4, new int[4, 2] { { -1, 0 }, { 0, 0 }, { 1, 0 }, { 2, 0 } }); break; case CarcasType.sector: baseCarcas = new FiguraCarcas(4, new int[4, 2] { { -1, -1 }, { 0, 0 }, { 1, 0 }, { 2, -1 } }); break; case CarcasType.duga_l: baseCarcas = new FiguraCarcas(4, new int[4, 2] { { -1, -1 }, { 0, 0 }, { 1, 0 }, { 2, 0 } }); break; case CarcasType.duga_r: baseCarcas = new FiguraCarcas(4, new int[4, 2] { { -1, 1 }, { 0, 0 }, { 1, 0 }, { 2, 0 } }); break; case CarcasType.circle: baseCarcas = new FiguraCarcas(4, new int[4, 2] { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } }); break; case CarcasType.check_l: baseCarcas = new FiguraCarcas(4, new int[4, 2] { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 2, 1 } }); break; case CarcasType.check_r: baseCarcas = new FiguraCarcas(4, new int[4, 2] { { 1, 0 }, { 0, -1 }, { -1, 0 }, { -2, 1 } }); break; case CarcasType.lomanaya: baseCarcas = new FiguraCarcas(4, new int[4, 2] { { 1, 0 }, { 0, -1 }, { -1, 0 }, { -2, -1 } }); break; case CarcasType.square: default: carcas.Add(new FiguraCarcas(4, new int[4, 2] { { 0, 1 }, { 0, 0 }, { -1, 0 }, { -1, 1 } })); carcas.Add(new FiguraCarcas(4, new int[4, 2] { { 0, 0 }, { -1, 0 }, { -1, 1 }, { 0, 1 } })); carcas.Add(new FiguraCarcas(4, new int[4, 2] { { -1, 0 }, { -1, 1 }, { 0, 1 }, { 0, 0 } })); carcas.Add(new FiguraCarcas(4, new int[4, 2] { { -1, 1 }, { 0, 1 }, { 0, 0 }, { -1, 0 } })); break; } if (key != CarcasType.square) { carcas.Add(baseCarcas); baseCarcas = RotateCarcas(baseCarcas, GameConstants.DIR_RIGHT); carcas.Add(baseCarcas); baseCarcas = RotateCarcas(baseCarcas, GameConstants.DIR_RIGHT); carcas.Add(baseCarcas); baseCarcas = RotateCarcas(baseCarcas, GameConstants.DIR_RIGHT); carcas.Add(baseCarcas); } return(carcas[rotate]); }
public CarcaseChance(int _c, CarcasType _t) { chance = _c; type = _t; }