public override bool Use(Cell selected, GameManager gameManager) { Cell cell = selected; Figurine oldFigurine = cell.Selected; IReadOnlyList <Cell> cells = SearchFigurines(selected, gameManager.Cells); if (cells.Count > 0) { cells = cells.Where(x => (x.Selected.Data != selected.Selected)).ToList(); if (cells.Count > 0) { FigurineData[] datas = cells.OrderBy(x => - x.Selected.Data.Significance).Select(x => x.Selected.Data).ToArray(); for (int indexData = 0; indexData < datas.Length; indexData++) { FigurineData data = datas[indexData]; for (int indexInteraction = 0; indexInteraction < conditionForExecutions.Length; indexInteraction++) { FigurineInteractions conditionForExecution = conditionForExecutions[indexInteraction]; if (data.Interactions.Contains(conditionForExecution) == true) { Figurine figurine = Figurine.Create(prefab, cell.GetComponent <RectTransform>(), data) as Figurine; cell.Selected = figurine; if (conditionForExecution.CheckingUse(selected, gameManager) == true) { figurine.GetComponent <ControlDrag>().Interaction = false; for (int index = 0; index < data.Interactions.Length; index++) { FigurineInteractions interaction = data.Interactions[index]; if (interaction.ActivateOnDrop == true) { interaction.Use(selected, gameManager); } } oldFigurine.Destroy(); return(true); } else { Destroy(figurine.gameObject); cell.Selected = oldFigurine; } } } } } } notCompleted.Use(selected, gameManager); return(true); }
/// <summary> /// Обновить ячейку (Обновляеться на дочерний объект child) /// </summary> /// <param name="selected">Ячейка где находиться фигурка</param> /// <param name="gameManager"></param> /// <param name="prefab"></param> protected void UpgradeFigurine(Cell selected, GameManager gameManager, Figurine prefab) { if (selected.Selected.Data.Child != null) { Cell cell = selected; Figurine figurine = Figurine.Create(prefab, cell.GetComponent <RectTransform>(), selected.Selected.Data.Child) as Figurine; cell.Selected = figurine; figurine.GetComponent <ControlDrag>().Interaction = false; for (int index = 0; index < figurine.Data.Interactions.Length; index++) { FigurineInteractions interaction = figurine.Data.Interactions[index]; if (interaction.ActivateOnDrop == true) { interaction.Use(selected, gameManager); } } } }