Beispiel #1
0
    public void Load()
    {
        LoadIngredients();
        ClearUI();
        Util.ClearConsole();

        if (self == null)
        {
            self = this;
        }

        switch (databaseSource)
        {
        case RecipeSource.MEALDB:
            recipeSystem = new MealDBRecipeSystem(this, loadedIngredients, CueAnimate);
            break;

        default:
        case RecipeSource.OFFLINE:
            break;
        }
        if (recipeSystem == null)
        {
            NotifyOfflineError();
            return;
        }
        else
        {
            recipeSystem.LoadBase();
        }

        recipes = recipeSystem.loadedRecipes;
    }
Beispiel #2
0
    private IEnumerator FetchRecipe()
    {
        UnityWebRequest www = UnityWebRequest.Get(MAIN_LINK + "random.php");

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            var txt   = www.downloadHandler.text;
            var fetch = new RecipeFetch(txt.Substring(txt.IndexOf("idMeal") + 9, 5));

            //Avoid two of the same recipes
            if (usedIDs.Contains(fetch.id))
            {
                host.StopCoroutine(FetchRecipe());
                host.StartCoroutine(FetchRecipe());
                yield return(null);
            }

            UnityWebRequest wwwSub = UnityWebRequest.Get(MAIN_LINK + "lookup.php?i=" + fetch.id);
            yield return(wwwSub.SendWebRequest());

            if (wwwSub.isNetworkError || wwwSub.isHttpError)
            {
                Debug.Log(wwwSub.error);
            }
            else
            {
                var subText = wwwSub.downloadHandler.text;
                subText = subText.Substring(10, subText.Length - 12);
                //Debug.Log(subText);
                var recipe = JsonUtility.FromJson <Recipe>(subText);
                recipe = FilterRecipe(ref recipe);

                loadedRecipes.Add(recipe);
                var UI = RecipeSystem.GenerateRecipeUI(recipe);

                Debug.Log(FilterInstructions(ref recipe.strInstructions));

                GenerateIngredientImages(ref recipe, UI.ingredientIMG);
                usedIDs.Add(fetch.id);
                //if(loadedRecipes.Count < RecipeSystem.MAX_LOADED_RECIPES) yield break;
                onLoadFinished();
            }
        }
    }
Beispiel #3
0
    void Update()
    {
        if (OnMainMenu)
        {
            return;
        }
        if (Input.GetKeyDown(KeyCode.Escape) && !RecipeSystem.IsShowing())
        {
            if (showMenu)
            {
                exitButton.Set();
            }
            else
            {
                SoundManager.PLAY_SOUND("Scroll", 1, 1.5f);
            }

            showMenu = !showMenu;
            for (int i = 0; i < transform.childCount; i++)
            {
                transform.GetChild(i).gameObject.SetActive(showMenu);
            }
            MenuOn = showMenu;
            if (player != null)
            {
                player.mouseLook.enabled = !showMenu;
            }
            if (showMenu)
            {
                Cursor.lockState = CursorLockMode.None;
            }
            else
            {
                Cursor.visible = false;
                if (player != null && player.controller != null)
                {
                    player.controller.enabled = true;
                }
            }
        }
        ApplyBaseSettings();
    }
Beispiel #4
0
    void Update()
    {
        if (playerCam != null)
        {
            playerCam.orthographicSize = CamHeight;
        }

        //Tutorial
        time += Time.deltaTime;
        if (time > 1 && !extend.finished && sprint.finished)
        {
            TutorialManager.SetTutorial(extend, gameObject.transform.position + new Vector3(250, -100, 0));
        }

        if (RecipeSystem.IsShowing())
        {
            holdExtendView = false;
        }

        if (Input.GetKey(KeyCode.M) && !RecipeSystem.IsShowing())
        {
            holdExtendDelay += Time.deltaTime;
            holdExtendView   = holdExtendDelay > 0.5f & show;
            if (holdExtendView)
            {
                TutorialManager.FinishTutorial(extend);
            }
        }
        if (Input.GetKeyUp(KeyCode.M) && !RecipeSystem.IsShowing())
        {
            holdExtendDelay = 0;
            if (!holdExtendView)
            {
                ToggleMap();
            }
            holdExtendView = false;
        }

        title.text = "<color=" + (show ? "#dfdfa4" : "maroon") + ">M</color>ap";

        if (turn > 0)
        {
            turn -= rollDownSpeed;
        }
        else if (turn < 0)
        {
            turn += rollDownSpeed;
        }

        if (holdExtendView)
        {
            CamHeight               = Mathf.Lerp(CamHeight, 70f, Time.deltaTime * 2f);
            transform.position      = Vector3.Lerp(transform.position, new Vector3(Screen.width / 2f, Screen.height + 10 + GetWobble(), transform.localPosition.z), Time.deltaTime * 2f);
            transform.localScale    = Vector3.Lerp(transform.localScale, 1.75f * new Vector3(baseScale.x + GetWobble(1, 0.02f) - 0.1f - (show ? -0.1f : 0.1f), baseScale.y + GetWobble(1, 0.02f) - 0.1f - (show ? -0.1f : 0.1f), 1), Time.deltaTime * 2f);
            transform.localRotation = Quaternion.Euler(transform.localEulerAngles.x, transform.localEulerAngles.y, Mathf.LerpAngle(transform.localEulerAngles.z, turn, Time.deltaTime * 3.5f));
        }
        else
        {
            CamHeight = Mathf.Lerp(CamHeight, BaseCam, Time.deltaTime * 2f);
            transform.localPosition = Vector3.Lerp(transform.localPosition, new Vector3(basePos.x, basePos.y + GetWobble(), transform.localPosition.z), Time.deltaTime * 2f);
            transform.localScale    = Vector3.Lerp(transform.localScale, new Vector3(baseScale.x + GetWobble(1, 0.02f) - 0.1f - (show ? -0.1f : 0.1f), baseScale.y + GetWobble(1, 0.02f) - 0.1f - (show ? -0.1f : 0.1f), 1), Time.deltaTime * 2f);
            transform.localRotation = Quaternion.Euler(transform.localEulerAngles.x, transform.localEulerAngles.y, Mathf.LerpAngle(transform.localEulerAngles.z, turn, Time.deltaTime * 3.5f));
        }

        Vector3 targetScale, targetPos;

        if (show)
        {
            targetPos   = baseBottomPos;
            targetScale = baseBottomScale;
        }
        else
        {
            targetPos   = new Vector3(0, -160, 0);
            targetScale = new Vector3(1, 0.25f, 1);
        }
        bottom.transform.localPosition = Vector3.Lerp(bottom.transform.localPosition, targetPos, Time.deltaTime * 3);
        bottom.transform.localScale    = Vector3.Lerp(bottom.transform.localScale, targetScale, Time.deltaTime * 5);
    }