示例#1
0
    // Main decision maker
    void CheckAction(MY_GAME_INPUTS gi)
    {
        if (m_model == null)
        {
            return;
        }

        // Only allow action when stopped
        if (m_state != PLAYER_STATE.IDLE)
        {
            return;
        }

        // No model
        if (m_model == null)
        {
            return;
        }

        // User is calling for an action - Find the context and trigger it
        if (gi.trigger1)
        {
            // Always stop
            FullStop();

            if (m_focusTrashCan != null)
            {
                Main.AUDIO_PutDown();
                ClearIngredients();
                return;
            }
            // If I have an ingredien, either drop it or put it on the table
            if (m_ingredients.Count >= cm_MAX_INGREDIENTS)
            {
                // If I have an ingredient no table, drop it
                if (m_focusChoppingTable != null)
                {
                    // If I have an ingredient and a table, drop it on the table
                    m_focusChoppingTable.AddIngredients(m_ingredients);

                    ClearIngredients();
                }
                else
                {
                    Main.AUDIO_Wrong();
                    Main.SendFloater(m_model.transform.position + Vector3.up, 3.0f, ("Inventory Full"));
                }
            }
            // Can carry more ingredients
            else
            {
                if (m_focusIngredient != null)
                {
                    ChangeState(PLAYER_STATE.TRANSFER);
                }
                else
                {
                    // Start chopping with a table full of ingredients)
                    if (m_ingredients.Count < 1 && m_focusChoppingTable != null && m_focusChoppingTable.HasIngredients())
                    {
                        ChangeState(PLAYER_STATE.CHOPPING);
                    }
                    else
                    {
                        if (m_focusChoppingTable != null)
                        {
                            m_focusChoppingTable.AddIngredients(m_ingredients);
                            ClearIngredients();
                        }
                    }
                }
            }
        }
    }