public void OnEnable() { coins = transform.Find("Coins").gameObject; obstacles = transform.Find("Obstacles").gameObject; scoreBoard = transform.GetComponentInChildren <TextMeshPro>(); player = transform.GetComponentInChildren <Player>(); spawnLine = transform.GetComponentInChildren <SpawnLine>(); floor = transform.Find("Floor").gameObject; spawnLineLocation = spawnLine.transform.position; spawnLineRotation = spawnLine.transform.rotation; }
public void defineType(SpawnLine mySpawnLine) { this.mySpawnLine = mySpawnLine; myVariables = BlocksControl.INSTANCE.getRandomVariables(); if (spriteRendererCache) { spriteRendererCache.sprite = myVariables.imagemBlock; } else { spriteRendererCache = GetComponent <SpriteRenderer>(); spriteRendererCache.sprite = myVariables.imagemBlock; } }
public void InterchangeLines(SpawnLine line1, SpawnLine line2) { if (line1 == line2) { return; } int index1 = Array.IndexOf(Lines, line1); int index2 = Array.IndexOf(Lines, line2); if (index1 == -1 || index2 == -1) { throw new CommonException("Lines are not contained within collection"); } Lines[index1] = line2; Lines[index2] = line1; }
public void OnEnable() { p = transform.GetComponentInChildren <Player>(); scoreBoard = transform.GetComponentInChildren <TextMeshPro>(); //for default obstacles = transform.Find("Obstacles").gameObject; spawnLine = transform.GetComponentInChildren <SpawnLine>(); floor = transform.Find("Floor").gameObject; spawnLineLocation = spawnLine.transform.position; spawnLineRotation = spawnLine.transform.rotation; //for cross obstaclesCross = transform.Find("ObstaclesCross").gameObject; spawnLineCross = transform.GetComponentInChildren <SpawnLineCross>(); floorCross = transform.Find("FloorCross").gameObject; spawnLineLocationCross = spawnLineCross.transform.position; spawnLineRotationCross = spawnLineCross.transform.rotation; }
private void LoadLine(Panel pnlLine, SpawnLine line) { pnlLine.SuspendLayout(); SuspendDrawing(pnlLine); BeginBinding(); try { pnlLine.Controls.Clear(); pnlLine.Tag = line; foreach (var item in line.Items) { AddSpawnItemButton(pnlLine, item); } } finally { pnlLine.ResumeLayout(); ResumeDrawing(pnlLine); EndBinding(); } }
public Level(Pack pack, bool isTemplate = false) { if (pack == null) { throw new ArgumentNullException("pack"); } if (!isTemplate && Pack.LevelTemplate == null) { throw new ArgumentException("Pack must have a template level."); } Pack = pack; Items = new List <LevelItem>(); Tasks = new List <Task>(); Lines = new SpawnLine[LineCount]; for (int i = 0; i < LineCount; ++i) { Lines[i] = new SpawnLine(); } Clear(isTemplate); }
private void pnlLine_DragDrop(object sender, DragEventArgs e) { var pnlLineTo = (Panel)sender; var pnlLineDragged = (Panel)e.Data.GetData(typeof(Panel)); var btnDragged = (SpawnItemButton)e.Data.GetData(typeof(SpawnItemButton)); if (btnDragged != null) { // перенос кнопки (SpawnItem) на другую панель (линию) var pnlLineFrom = btnDragged.Parent; var lineFrom = GetLine(pnlLineFrom); var lineTo = GetLine(pnlLineTo); pnlLineFrom.SuspendLayout(); pnlLineTo.SuspendLayout(); SuspendDrawing(pnlLineFrom); SuspendDrawing(pnlLineTo); try { pnlLineFrom.Controls.Remove(btnDragged); lineFrom.RemoveItem(btnDragged.Item); var pointInPnlTo = pnlLineTo.PointToClient(new Point(e.X, e.Y)); AddSpawnItem(pnlLineTo, GetNearButton(pnlLineTo, pointInPnlTo.X), true, btnDragged.Item); } finally { pnlLineFrom.ResumeLayout(); pnlLineTo.ResumeLayout(); ResumeDrawing(pnlLineFrom); ResumeDrawing(pnlLineTo); } } else if (pnlLineDragged != null) { // меняем панели местами через Drag/Drop SpawnLine lineTo = GetLine(pnlLineTo); SpawnLine lineDragged = GetLine(pnlLineDragged); pnlLines.SuspendLayout(); try { CurrentLevel.InterchangeLines(lineTo, lineDragged); int lineТоIndex = _linePanels.IndexOf(pnlLineTo); int lineDraggedIndex = _linePanels.IndexOf(pnlLineDragged); _linePanels[lineТоIndex] = pnlLineDragged; _linePanels[lineDraggedIndex] = pnlLineTo; int childToIndex = pnlLines.Controls.IndexOf(pnlLineTo); int childDraggedIndex = pnlLines.Controls.IndexOf(pnlLineDragged); pnlLines.Controls.SetChildIndex(pnlLineTo, childDraggedIndex); pnlLines.Controls.SetChildIndex(pnlLineDragged, childToIndex); } finally { pnlLines.ResumeLayout(); } } IsNeedSave = true; }