Exemplo n.º 1
0
 private void Create(ObjectForPlacementData data)
 {
     if (data is FigurineData)
     {
         Figurine figurine = Figurine.Create(prefabFigurine, content, data as FigurineData) as Figurine;
         CreateFigurine?.Invoke(figurine);
     }
     else if (data is SubjectData)
     {
         Subject subject = Subject.Create(prefabSubject, content, data as SubjectData) as Subject;
         CreateSubject?.Invoke(subject);
     }
 }
Exemplo n.º 2
0
    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);
    }
Exemplo n.º 3
0
 /// <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);
             }
         }
     }
 }
Exemplo n.º 4
0
    /// <param name="parent">Default use own parent</param>
    public void Create(ObjectForPlacementData data, RectTransform parent = null)
    {
        if (parent == null)
        {
            parent = content;
        }

        if (data is FigurineData)
        {
            Figurine figurine = Figurine.Create(prefabFigurine, parent, data as FigurineData) as Figurine;
            figurine.name = indefecator;
            CreateFigurine?.Invoke(figurine);
        }
        else if (data is SubjectData)
        {
            Subject subject = Subject.Create(prefabSubject, parent, data as SubjectData) as Subject;
            subject.name = indefecator;
            CreateSubject?.Invoke(subject);
        }
    }