Ejemplo n.º 1
0
        public List<IngredientGridCell> ComputingPath(IngredientGrid grid)
        {
            List<IngredientGridCell> listIngredient = null;

            //--- Cherche les duos de pains dans la grille
            var breads = new Ingredient[] { Ingredient.Bread01, Ingredient.Bread02, Ingredient.Bread03 };

            Dictionary<Ingredient, List<IngredientGridCell>> dicBreadCells = new Dictionary<Ingredient, List<IngredientGridCell>>();

            for (int i = 0; i < breads.Length; i++)
            {
                dicBreadCells.Add(breads[i], new List<IngredientGridCell>());

                for (int j = 0; j < 2; j++)
                {
                    IngredientGridCell cell = FoundIngredient(breads[i], dicBreadCells[breads[i]], grid);
                    dicBreadCells[breads[i]].Add(cell);
                }
            }
            //---

            listIngredient = null;
            int bestScore = int.MinValue;

            //--- Calcul le chemin optimal parmis les 3 familles de pain
            foreach (Ingredient bread in dicBreadCells.Keys)
            {
                _listCellOpen = new List<AStarCell>();
                _listCellClose = new List<AStarCell>();
                ListCellPath = new List<IngredientGridCell>();
                int score = 0;

                List<IngredientGridCell> listBreadCells = CalcPath(dicBreadCells[bread][0], dicBreadCells[bread][1], ref score);
                //Debug.Log(bread.Name + " " + dicBreadCells[bread][0].m_xIndex + ";" + dicBreadCells[bread][0].m_yIndex +  " to " + dicBreadCells[bread][1].m_xIndex + ";" + dicBreadCells[bread][1].m_yIndex + " Score " + score);

                if (listIngredient == null || bestScore < score)
                {
                    bestScore = score;
                    listIngredient = listBreadCells;
                }
            }
            //---

            return listIngredient;
            //Debug.Log(this.name + " : " + bestScore);
        }
Ejemplo n.º 2
0
    public Ingredient Combine()
    {
        if (this.item1 == null || this.item2 == null)
        {
            return(null);
        }
        newItem = null;

        // logic to combine ingredients
        int tier = Mathf.Min(Mathf.Max(this.item1.data.tier, this.item2.data.tier), 4);
        List <Ingredient> nextTier = StaticData.Instance.IngredientTier(tier);

        if (this.item1.data.categories.Contains("Chicken") ||
            this.item2.data.categories.Contains("Chicken"))
        {
            newItem = nextTier[nextTier.Count - 1];
        }
        else
        {
            for (int i = 0; i < nextTier.Count; ++i)
            {
                if (nextTier[i].blueprint != null && nextTier[i].blueprint.Count == 2 &&
                    ((nextTier[i].blueprint[0] == this.item1.data.prefabName &&
                      nextTier[i].blueprint[1] == this.item2.data.prefabName) ||
                     (nextTier[i].blueprint[0] == this.item2.data.prefabName &&
                      nextTier[i].blueprint[1] == this.item1.data.prefabName)))
                {
                    newItem = nextTier[i];
                    break;
                }
            }
        }

        if (newItem == null)
        {
            newItem = nextTier[Random.Range(0, nextTier.Count)];
        }

        this.revealItemText.text = newItem.ingredientName;
        this.RemoveIngredient(item1);
        this.RemoveIngredient(item2);
        IngredientGrid.RefreshSelectedStates();
        return(newItem);
    }
Ejemplo n.º 3
0
    public void Clicked(int buttonType)
    {
        if (this.data == null)
        {
            return;
        }

        switch ((ButtonEvent)buttonType)
        {
        case ButtonEvent.BUTTON_GRID:
            combotron.AddIngredient(this.data);
            this.selectedObj.SetActive(combotron.IsSelected(this.data));
            break;

        case ButtonEvent.BUTTON_COMBO:
            combotron.RemoveIngredient(this);
            IngredientGrid.RefreshSelectedStates();
            break;

        case ButtonEvent.BUTTON_FINAL:
            gameplay.SetFinalIngredient(this.data);
            break;
        }
    }
Ejemplo n.º 4
0
        public IngredientGridCell FoundIngredient(Ingredient ingredient, List<IngredientGridCell> listAllreadyFound, IngredientGrid grid)
        {
            IngredientGridCell found = null;

            for (int x = 0; x < grid.HorizontalCells; x++)
            {
                for (int y = 0; y < grid.VerticalCells; y++)
                {
                    Ingredient cellIngredient = grid.m_cells[x, y].Ingredient;

                    if (cellIngredient != null && cellIngredient == ingredient && !listAllreadyFound.Contains(grid.m_cells[x, y]))
                    {
                        found = grid.m_cells[x, y];
                        return found;
                    }
                }
            }

            return found;
        }
Ejemplo n.º 5
0
 /************
  * Combotron
  ***********/
 public void AddItemToGrid()
 {
     IngredientGrid.AddIngredient(Combotron.newItem);
 }