예제 #1
0
    public override void LoadState(ItemState state)
    {
        PlateState pState = state as PlateState;

        HoldingMeal = GetItemManager().ItemList[pState.mealID] as Meal;
        IsSubmitted = pState.IsSubmitted;
    }
예제 #2
0
    public override AIState ApplyAction(AIState currentState)
    {
        AIState cloneState = base.ApplyAction(currentState);

        int heldItemID = cloneState.CurrentPlayerState.Drop();

        PlateState plate = (cloneState.ItemStateList[heldItemID] as PlateState);
        MealState  meal  = cloneState.ItemStateList[plate.mealID] as MealState;

        //Removing the meal from the plate
        //foreach (int ingredientID in meal.ContainedIngredientIDs)
        //{
        //    IngredientState iState = currentState.ItemStateList[ingredientID] as IngredientState;
        //    iState.IsInMeal = false;
        //    iState.
        //}
        //meal.ContainedIngredientIDs.RemoveAll(x => true);
        //meal.cookDuration = 0;

        // S.C. Do not remove meal from plate. We just give up the plate entirely.
        plate.IsSubmitted = true;

        //Debug.Log("Potentially score the meal submission here?");

        return(cloneState);
    }
예제 #3
0
    public void InitializePlate(GameManager gameManager)
    {
        _gameManager = gameManager;
        state        = PlateState.Prepare;
        reciepeList.ingredientsList = null;
        lumpiaMinigameUserInterface = FindObjectOfType <LumpiaMinigameUserInterface>();

        SetupPlate();
    }
예제 #4
0
    public override void OnStopInput()
    {
        base.OnStopInput();

        if (_state == PlateState.Ready)
        {
            _state = PlateState.Drop;
        }
    }
예제 #5
0
    public override string ToString(AIState currentState)
    {
        int heldItemID = currentState.CurrentPlayerState.HoldingItemID;

        PlateState plate = (currentState.ItemStateList[heldItemID] as PlateState);
        MealState  meal  = currentState.ItemStateList[plate.mealID] as MealState;

        return("Submitting meal " + meal);
    }
예제 #6
0
    public void Deactivate()
    {
        if (state != PlateState.DEACTIVATED && !standingOn)
        {
            GetComponent <Animator>().SetTrigger("Deactivate");
        }

        activated = false;
        state     = PlateState.DEACTIVATED;     // !!!
    }
예제 #7
0
    public IEnumerator CloseAnimation(float delay)
    {
        yield return(new WaitForSeconds(delay));

        anim.SetBool("IsClosing", true);
        plateState = PlateState.Closing;
        yield return(new WaitForSeconds(anim.GetCurrentAnimatorStateInfo(0).length));

        anim.SetBool("IsClosing", false);
        plateState = PlateState.Close;
    }
예제 #8
0
    public override void Reset()
    {
        if (!_isHold)
        {
            base.Reset();

            if (_anim != null)
            {
                _anim.SetBool("isbroke", false);
            }

            _state = PlateState.Ready;
        }
    }
예제 #9
0
    private void Start()
    {
        EventManager.GetInstance().AddListener(ConfigContext.PlateEvent, OnPlate);

        PlatePoint = this.transform.Find("LockPoint");

        GroundPoint = GameObject.Find("GroundPoint").transform;

        _state = PlateState.Ready;

        _anim = this.gameObject.GetComponent <Animator>();

        _isHold = false;
    }
예제 #10
0
    public void Consume()
    {
        plateState = PlateState.Dirty;

        dirtyPlate.SetActive(true);
        infecteParticle.Stop(true, ParticleSystemStopBehavior.StopEmitting);
        for (int i = 0; i < food.Length; i++)
        {
            food[i].SetActive(false);
        }
        for (int i = 0; i < garbage.Length; i++)
        {
            garbage[i].SetActive(false);
        }
    }
예제 #11
0
    public override AIState ApplyAction(AIState currentState)
    {
        AIState cloneState = base.ApplyAction(currentState);

        int heldItemID = cloneState.CurrentPlayerState.HoldingItemID;

        MealState meal1;

        if (cloneState.ItemStateList[heldItemID].MyItemType == ItemType.POT)
        {
            PotState pot = (cloneState.ItemStateList[heldItemID] as PotState);
            meal1 = (cloneState.ItemStateList[pot.mealID] as MealState);
        }
        else
        {
            PlateState plate = (cloneState.ItemStateList[heldItemID] as PlateState);
            meal1 = (cloneState.ItemStateList[plate.mealID] as MealState);
        }

        //Transferring/combining it with the other meal
        if (cloneState.ItemStateList[id].MyItemType == ItemType.POT)
        {
            PotState  pot   = cloneState.ItemStateList[id] as PotState;
            MealState meal2 = cloneState.ItemStateList[pot.mealID] as MealState;

            int cookDuration = CombineCookDurations(meal1, meal2);
            meal2.cookDuration = cookDuration;

            meal2.ContainedIngredientIDs.AddRange(meal1.ContainedIngredientIDs);

            meal1.ContainedIngredientIDs.RemoveAll(x => true);
            meal1.cookDuration = 0;
        }
        else
        {
            PlateState plate = cloneState.ItemStateList[id] as PlateState;
            MealState  meal2 = cloneState.ItemStateList[plate.mealID] as MealState;

            int cookDuration = CombineCookDurations(meal1, meal2);
            meal2.cookDuration = cookDuration;

            meal2.ContainedIngredientIDs.AddRange(meal1.ContainedIngredientIDs);
            meal1.ContainedIngredientIDs.RemoveAll(x => true);
            meal1.cookDuration = 0;
        }

        return(cloneState);
    }
예제 #12
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (_state == PlateState.Drop)
        {
            if (collision.gameObject.name == "man_hand")
            {
                _state = PlateState.Hold;

                _anim.SetBool("ishold", true);

                this.transform.parent = collision.gameObject.transform;

                this.transform.localPosition = Vector3.zero;

                _isHold = true;
            }
        }
    }
예제 #13
0
    public void Cook()
    {
        if (plateState == PlateState.Clean)
        {
            if (Random.value > 0.85f)
            {
                plateState = PlateState.Garbage;

                garbage[Random.Range(0, garbage.Length)].SetActive(true);
                infecteParticle.Play(true);
            }
            else
            {
                plateState = PlateState.Full;

                food[Random.Range(0, food.Length)].SetActive(true);
            }
        }
    }
예제 #14
0
    public override void StopUpdate(float dt)
    {
        base.ActiveUpdate(dt);

        switch (_state)
        {
        case PlateState.Drop:
        {
            this.transform.position += DropSpeed * DropDir * dt;

            if (this.transform.position.y < GroundPoint.position.y)
            {
                _state = PlateState.Broke;

                _anim.SetBool("isbroke", true);
            }
        }
        break;
        }
    }
예제 #15
0
    public bool IsGoal(AIState currentState)
    {
        // This function needs to be fast...
        // Assumes only Mushrooms and Onions
        bool[] plateUsed = new bool[currentState.PlateStateIndexList.Count];
        int[,] mealIngredientCounts = currentState.GetMealIngredientCounts();
        foreach (List <int> count in IngredientCountsPerRecipe)
        {
            bool found = false;
            for (int plateIndex = 0; plateIndex < currentState.PlateStateIndexList.Count; ++plateIndex)
            {
                int        plateID = currentState.PlateStateIndexList[plateIndex];
                PlateState plate   = currentState.ItemStateList[plateID] as PlateState;
                if (plate.IsSubmitted && !plateUsed[plateIndex])
                {
                    int holdingMealIndex = currentState.PlateToMeal[plateIndex];
                    int onionCount       = mealIngredientCounts[holdingMealIndex, (int)IngredientType.ONION];
                    int mushroomCount    = mealIngredientCounts[holdingMealIndex, (int)IngredientType.MUSHROOM];

                    MealState meal = currentState.ItemStateList[plate.mealID] as MealState;

                    if (meal.IsCooked() &&
                        !meal.IsBurnt() &&
                        onionCount == count[(int)IngredientType.ONION] &&
                        mushroomCount == count[(int)IngredientType.MUSHROOM])
                    {
                        found = true;
                        plateUsed[plateIndex] = true;
                        break;
                    }
                }
            }

            if (!found)
            {
                return(false);
            }
        }

        return(true);
    }
예제 #16
0
    public override bool isValid(AIState currentState)
    {
        if (currentState.CurrentPlayerState.HandsFree())
        {
            return(false);
        }
        else
        {
            int heldItemID = currentState.CurrentPlayerState.HoldingItemID;

            if (currentState.ItemStateList[heldItemID].MyItemType != ItemType.PLATE)
            {
                return(false);
            }
            else
            {
                PlateState plate = (currentState.ItemStateList[heldItemID] as PlateState);
                return((currentState.ItemStateList[plate.mealID] as MealState).IsSpawned() &&
                       (currentState.ItemStateList[plate.mealID] as MealState).IsCooked());
            }
        }
    }
예제 #17
0
    public override bool Equals(object obj)
    {
        if (obj == null)
        {
            return(false);
        }

        if (this == obj)
        {
            return(true);
        }

        PlateState otherState = obj as PlateState;

        if (obj == null)
        {
            return(false);
        }

        return(this.ID == otherState.ID &&
               this.mealID == otherState.mealID &&
               this.IsSubmitted == otherState.IsSubmitted);
    }
예제 #18
0
    public override AIState ApplyAction(AIState currentState)
    {
        AIState cloneState = base.ApplyAction(currentState);

        int droppedItemID = cloneState.CurrentPlayerState.Drop();

        if (cloneState.ItemStateList[id].MyItemType == ItemType.TABLE)
        {
            TableSpace table = cloneState.ItemStateList[id] as TableSpace;
            table.ItemIDOnTable = droppedItemID;
        }
        if (cloneState.ItemStateList[id].MyItemType == ItemType.BOARD)
        {
            BoardState board = cloneState.ItemStateList[id] as BoardState;
            board.HoldingItemID = droppedItemID;
        }
        if (cloneState.ItemStateList[id].MyItemType == ItemType.POT)
        {
            PotState  pot  = cloneState.ItemStateList[id] as PotState;
            MealState meal = cloneState.ItemStateList[pot.mealID] as MealState;

            (cloneState.ItemStateList[droppedItemID] as IngredientState).IsInMeal = true;

            meal.ContainedIngredientIDs.Add(droppedItemID);
            meal.cookDuration = Mathf.Min(meal.cookDuration, (meal.ContainedIngredientIDs.Count - 1) * MealState.COOK_TIME_PER_INGREDIENT);
        }
        if (cloneState.ItemStateList[id].MyItemType == ItemType.PLATE)
        {
            PlateState plate = cloneState.ItemStateList[id] as PlateState;
            MealState  meal  = cloneState.ItemStateList[plate.mealID] as MealState;

            (cloneState.ItemStateList[droppedItemID] as IngredientState).IsInMeal = true;
            meal.ContainedIngredientIDs.Add(droppedItemID);
            meal.cookDuration = Mathf.Min(meal.cookDuration, (meal.ContainedIngredientIDs.Count - 1) * MealState.COOK_TIME_PER_INGREDIENT);
        }
        return(cloneState);
    }
예제 #19
0
 // Use this for initialization
 void Start()
 {
     currentPlateState = new EmptyPlate(this);
 }
예제 #20
0
 // State changing method to be called by each state
 public void SetPlateState(PlateState plateState)
 {
     this.currentPlateState = plateState;
 }
예제 #21
0
 public void Activate()
 {
     GetComponent <Animator>().SetTrigger("Activate");
     activated = true;
     state     = PlateState.ACTIVATED;
 }
예제 #22
0
 private void StartActivating()
 {
     GetComponent <Animator>().SetTrigger("StartActivating");
     state = PlateState.ACTIVATING;
 }
예제 #23
0
    /// <summary>
    /// Used to get all of the valid actions for the current state
    /// </summary>
    /// <returns></returns>
    public List <Action> GetValidActions(AIState state)
    {
        List <Action> validActions = new List <Action>();

        //Waiting around
        validActions.Add(new IdleAction());

        //Things you can do when your hands are free
        if (state.CurrentPlayerState.HandsFree())
        {
            //Spawning items
            foreach (IngredientType type in System.Enum.GetValues(typeof(IngredientType)))
            {
                SpawnAction spawnAction = new SpawnAction(type);
                if (spawnAction.isValid(state))
                {
                    validActions.Add(spawnAction);
                }
            }

            PickUpAction pickupAction;
            //Picking up everything
            //Ingredients
            foreach (int ingredientID in state.IngredientStateIndexList)
            {
                IngredientState ingredient = state.ItemStateList[ingredientID] as IngredientState;
                if (ingredient.IsSpawned && !ingredient.IsInMeal)
                {
                    pickupAction = new PickUpAction(ingredient.ID);
                    validActions.Add(pickupAction);
                }
            }

            //Pots
            foreach (int potID in state.PotStateIndexList)
            {
                PotState pot = state.ItemStateList[potID] as PotState;
                pickupAction = new PickUpAction(pot.ID);
                validActions.Add(pickupAction);
            }

            //Plates
            foreach (int plateID in state.PlateStateIndexList)
            {
                PlateState plate = state.ItemStateList[plateID] as PlateState;
                pickupAction = new PickUpAction(plate.ID);
                validActions.Add(pickupAction);
            }

            PrepareAction prepAction;
            foreach (int boardID in state.BoardStateIndexList)
            {
                BoardState bState = state.ItemStateList[boardID] as BoardState;
                if (!bState.IsFree())
                {
                    IngredientState iState = state.ItemStateList[bState.HoldingItemID] as IngredientState;
                    if (iState != null && !iState.IsPrepared)
                    {
                        prepAction = new PrepareAction(boardID);
                        validActions.Add(prepAction);
                    }
                }
            }
        }

        //Things you can do when you have something in hand
        else
        {
            DropOffAction  dropoffAction;
            TransferAction transferAction;
            ItemState      itemState = state.ItemStateList[state.CurrentPlayerState.HoldingItemID];
            ItemType       type      = itemState.MyItemType;

            if (type == ItemType.INGREDIENT)
            {
                //Putting things on the table
                foreach (int tableID in state.TableStateIndexList)
                {
                    TableSpace table = state.ItemStateList[tableID] as TableSpace;
                    if (table.IsFree())
                    {
                        dropoffAction = new DropOffAction(table.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                //Moving ingredients to a cutting board
                foreach (int boardID in state.BoardStateIndexList)
                {
                    BoardState board = state.ItemStateList[boardID] as BoardState;
                    if (board.IsFree())
                    {
                        dropoffAction = new DropOffAction(board.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                if ((itemState as IngredientState).IsPrepared)
                {
                    //Moving ingredients to a pot
                    foreach (int potID in state.PotStateIndexList)
                    {
                        PotState  pot  = state.ItemStateList[potID] as PotState;
                        MealState meal = state.ItemStateList[pot.mealID] as MealState;
                        if (meal.MealSize() + 1 <= PotState.MAX_ITEMS_PER_POT && !meal.IsBurnt())
                        {
                            dropoffAction = new DropOffAction(pot.ID);
                            validActions.Add(dropoffAction);
                        }
                    }

                    //Moving ingredients to a plate
                    foreach (int plateID in state.PlateStateIndexList)
                    {
                        PlateState plate = state.ItemStateList[plateID] as PlateState;
                        MealState  meal  = state.ItemStateList[plate.mealID] as MealState;
                        if (!plate.IsSubmitted && !meal.IsBurnt())
                        {
                            dropoffAction = new DropOffAction(plate.ID);
                            validActions.Add(dropoffAction);
                        }
                    }
                }
            }

            if (type == ItemType.POT)
            {
                PotState  pot  = itemState as PotState;
                MealState meal = state.ItemStateList[pot.mealID] as MealState;

                //Putting the pot on the table
                foreach (int tableID in state.TableStateIndexList)
                {
                    TableSpace table = state.ItemStateList[tableID] as TableSpace;
                    if (table.IsFree())
                    {
                        dropoffAction = new DropOffAction(table.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                //Moving meal to a pot
                transferAction = new TransferAction(Item.NOTHING_ID);
                foreach (int potID in state.PotStateIndexList)
                {
                    transferAction.id = potID;
                    if (transferAction.isValid(state))
                    {
                        validActions.Add(transferAction);
                        transferAction = new TransferAction(Item.NOTHING_ID);
                    }
                }

                //Moving the meal to another plate
                foreach (int plateID in state.PlateStateIndexList)
                {
                    transferAction.id = plateID;
                    if (transferAction.isValid(state))
                    {
                        validActions.Add(transferAction);
                        transferAction = new TransferAction(Item.NOTHING_ID);
                    }
                }
            }

            if (type == ItemType.PLATE)
            {
                PlateState plate = itemState as PlateState;

                //Putting things on the table
                foreach (int tableID in state.TableStateIndexList)
                {
                    TableSpace table = state.ItemStateList[tableID] as TableSpace;
                    if (table.IsFree())
                    {
                        dropoffAction = new DropOffAction(table.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                //If the plate is non-empty
                MealState heldMeal = state.ItemStateList[plate.mealID] as MealState;
                if (heldMeal.IsSpawned())
                {
                    //Submitting the meal
                    if (heldMeal.IsCooked())
                    {
                        SubmitOrderAction submitAction = new SubmitOrderAction();
                        validActions.Add(submitAction);
                    }

                    //Moving meal to a pot
                    transferAction = new TransferAction(Item.NOTHING_ID);
                    foreach (int potID in state.PotStateIndexList)
                    {
                        transferAction.id = potID;
                        if (transferAction.isValid(state))
                        {
                            validActions.Add(transferAction);
                            transferAction = new TransferAction(Item.NOTHING_ID);
                        }
                    }

                    //Moving the meal to another plate
                    foreach (int plateID in state.PlateStateIndexList)
                    {
                        transferAction.id = plateID;
                        if (transferAction.isValid(state))
                        {
                            validActions.Add(transferAction);
                            transferAction = new TransferAction(Item.NOTHING_ID);
                        }
                    }
                }
            }
        }


        return(validActions);
    }
예제 #24
0
    public float GetHeuristic(AIState state)
    {
        if (state.Heuristic >= 0)
        {
            return(state.Heuristic);
        }

        if (HeuristicPerIngredient == null)
        {
            Init(state);
        }
        else
        {
            for (int i = 0; i < HeuristicPerIngredient.Count; ++i)
            {
                HeuristicPerIngredient[i].Clear();
            }
        }

        foreach (int ingredientID in state.IngredientStateIndexList)
        {
            IngredientState iState = state.ItemStateList[ingredientID] as IngredientState;
            HeuristicPerIngredient[(int)iState.ingredientType].Add(IngredientHeuristic(iState));
        }

        int ingredientHeuristicSum = 0;

        for (int i = 0; i < HeuristicPerIngredient.Count; ++i)
        {
            HeuristicPerIngredient[i].Sort();
            ingredientHeuristicSum += HeuristicPerIngredient[i].Take(CountOfEachIngredient[i]).Sum();
        }

        int cooktimeHeuristic  = 0;
        int submittedHeuristic = 0;

        int[,] mealIngredientCounts = state.GetMealIngredientCounts();
        for (int goalIndex = 0; goalIndex < Goal.GoalRecipes.Count; ++goalIndex)
        {
            int        neededCookTime  = Goal.GoalRecipes[goalIndex].Count * MealState.COOK_TIME_PER_INGREDIENT + 1;
            int        minGoalCookTime = neededCookTime;
            bool       submitted       = false;
            List <int> goalRecipe      = Goal.IngredientCountsPerRecipe[goalIndex];
            for (int mealListIndex = 0; mealListIndex < state.MealStateIndexList.Count; ++mealListIndex)
            {
                MealState meal = state.ItemStateList[state.MealStateIndexList[mealListIndex]] as MealState;
                if (!meal.IsSpawned())
                {
                    continue;
                }

                int onionCount    = mealIngredientCounts[mealListIndex, (int)IngredientType.ONION];
                int mushroomCount = mealIngredientCounts[mealListIndex, (int)IngredientType.MUSHROOM];
                if (meal.IsBurnt() ||
                    onionCount > goalRecipe[(int)IngredientType.ONION] ||
                    mushroomCount > goalRecipe[(int)IngredientType.MUSHROOM])
                {
                    continue;
                }

                // Found qualifying meal.
                bool foundPlate = false;

                // Is there a plate holding this meal...?
                foreach (int plateID in state.PlateStateIndexList)
                {
                    PlateState plate = state.ItemStateList[plateID] as PlateState;
                    if (plate.mealID != meal.ID)
                    {
                        continue;
                    }

                    foundPlate = true;
                    if (plate.IsSubmitted)
                    {
                        // Check if the meal completely matches
                        if (meal.IsCooked() &&
                            onionCount == goalRecipe[(int)IngredientType.ONION] &&
                            mushroomCount == goalRecipe[(int)IngredientType.MUSHROOM])
                        {
                            // Good job.
                            submitted       = true;
                            minGoalCookTime = 0;
                        }
                        else
                        {
                            // Submitted meal that doesn't match the recipe or is uncooked
                            // skip.
                        }
                    }
                    else
                    {
                        // Qualifying meal on a plate that hasn't been submitted.
                        int currentCookDuration = Mathf.Min(meal.cookDuration, meal.ContainedIngredientIDs.Count * MealState.COOK_TIME_PER_INGREDIENT + 1);
                        int remainingCookTime   = Mathf.Max(0, neededCookTime - currentCookDuration);
                        minGoalCookTime = Mathf.Min(minGoalCookTime, remainingCookTime);
                    }
                    break;
                }

                if (!foundPlate)
                {
                    // Meal is in a pot.
                    int currentCookDuration = Mathf.Min(meal.cookDuration, meal.ContainedIngredientIDs.Count * MealState.COOK_TIME_PER_INGREDIENT + 1);
                    int remainingCookTime   = Mathf.Max(0, neededCookTime - currentCookDuration);
                    minGoalCookTime = Mathf.Min(minGoalCookTime, remainingCookTime);
                }
            }

            //cooktimeHeuristic = Mathf.Max(cooktimeHeuristic, minGoalCookTime);
            cooktimeHeuristic  += minGoalCookTime;
            submittedHeuristic += submitted ? 0 : 1;
        }

        //state.Heuristic = Mathf.Max(ingredientHeuristicSum + submittedHeuristic, cooktimeHeuristic);
        //state.Heuristic = ingredientHeuristicSum + submittedHeuristic;
        float parallelism = Mathf.Min(Goal.GoalRecipes.Count, state.PotStateIndexList.Count);

        state.Heuristic = ingredientHeuristicSum + (cooktimeHeuristic / parallelism) + submittedHeuristic;
        return(state.Heuristic);
    }
예제 #25
0
    public override bool isValid(AIState currentState)
    {
        if (currentState.CurrentPlayerState.HandsFree())
        {
            return(false);
        }
        else
        {
            int droppedItemID = currentState.CurrentPlayerState.HoldingItemID;

            if (currentState.ItemStateList[droppedItemID].MyItemType == ItemType.MEAL ||
                currentState.ItemStateList[droppedItemID].MyItemType == ItemType.TABLE ||
                currentState.ItemStateList[droppedItemID].MyItemType == ItemType.BOARD)
            {
                return(false);
            }


            if (currentState.ItemStateList[id].MyItemType == ItemType.TABLE)
            {
                TableSpace table = currentState.ItemStateList[id] as TableSpace;
                return(table.IsFree());
            }
            else if (currentState.ItemStateList[id].MyItemType == ItemType.BOARD)
            {
                BoardState board = currentState.ItemStateList[id] as BoardState;
                return((currentState.ItemStateList[droppedItemID].MyItemType == ItemType.INGREDIENT) &&
                       board.IsFree());
            }
            else if (currentState.ItemStateList[id].MyItemType == ItemType.POT)
            {
                if (currentState.ItemStateList[droppedItemID].MyItemType != ItemType.INGREDIENT)
                {
                    return(false);
                }
                else
                {
                    if ((currentState.ItemStateList[droppedItemID] as IngredientState).IsPrepared &&
                        (currentState.ItemStateList[droppedItemID] as IngredientState).IsSpawned)
                    {
                        PotState  pot  = currentState.ItemStateList[id] as PotState;
                        MealState meal = currentState.ItemStateList[pot.mealID] as MealState;
                        return(meal.MealSize() + 1 <= PotState.MAX_ITEMS_PER_POT && !meal.IsBurnt());
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else if (currentState.ItemStateList[id].MyItemType == ItemType.PLATE)
            {
                if (currentState.ItemStateList[droppedItemID].MyItemType != ItemType.INGREDIENT)
                {
                    return(false);
                }
                else
                {
                    PlateState plate = currentState.ItemStateList[id] as PlateState;
                    MealState  meal  = currentState.ItemStateList[plate.mealID] as MealState;
                    return((currentState.ItemStateList[droppedItemID] as IngredientState).IsPrepared &&
                           (currentState.ItemStateList[droppedItemID] as IngredientState).IsSpawned &&
                           !plate.IsSubmitted &&
                           !meal.IsBurnt());
                }
            }
            else
            {
                return(false);
            }
        }
    }
예제 #26
0
    public override bool isValid(AIState currentState)
    {
        if (currentState.CurrentPlayerState.HandsFree())
        {
            return(false);
        }

        int droppedItemID = currentState.CurrentPlayerState.HoldingItemID;

        if (droppedItemID == id)
        {
            return(false);
        }

        ItemState droppedItem = currentState.ItemStateList[droppedItemID];

        if (!(droppedItem.MyItemType == ItemType.POT || droppedItem.MyItemType == ItemType.PLATE))
        {
            return(false);
        }

        ItemState receivingItem = currentState.ItemStateList[id];

        if (!(receivingItem.MyItemType == ItemType.POT || receivingItem.MyItemType == ItemType.PLATE))
        {
            return(false);
        }

        MealState transferredMeal;

        if (droppedItem.MyItemType == ItemType.POT)
        {
            PotState pot = (droppedItem as PotState);
            transferredMeal = (currentState.ItemStateList[pot.mealID] as MealState);
        }
        else
        {
            PlateState plate = (droppedItem as PlateState);
            if (plate.IsSubmitted)
            {
                return(false);
            }

            transferredMeal = (currentState.ItemStateList[plate.mealID] as MealState);
        }

        if (!transferredMeal.IsSpawned() || transferredMeal.IsBurnt())
        {
            return(false);
        }

        if (receivingItem.MyItemType == ItemType.POT)
        {
            PotState  pot1  = receivingItem as PotState;
            MealState meal1 = currentState.ItemStateList[pot1.mealID] as MealState;

            return(meal1.MealSize() + transferredMeal.MealSize() <= PotState.MAX_ITEMS_PER_POT &&
                   !meal1.IsBurnt());
        }
        else
        {
            PlateState plate1 = receivingItem as PlateState;
            MealState  meal1  = currentState.ItemStateList[plate1.mealID] as MealState;

            return(!plate1.IsSubmitted &&
                   !meal1.IsBurnt());
        }
    }