Example #1
0
    //profit counter for the game
    public void Profit(FoodSO food, float time)
    {
        if (food.foodName == "Curry Fish Head")
        {
            rate += (0.2f * time);
        }
        else if (food.foodName == "Laksa")
        {
            rate += (0.05f * time);
        }
        else if (food.foodName == "Mee Siam")
        {
            rate += (0.05f * time);
        }
        else if (food.foodName == "Otah")
        {
            rate += (0.1f * time);
        }

        switching          = true;
        rateBar.fillAmount = rate;
        Total_Rate();
        HighScore.Instance.overall += food.cost;
        money.text = HighScore.Instance.overall.ToString();
    }
Example #2
0
    /// <summary>
    /// Selects the food the player chooses as the food to be cooked
    /// </summary>
    /// <param name="foodSO"></param>
    public void ChooseFood(FoodSO foodSO)
    {
        //Debug.Log("Choosing food");

        if (selectedFood)
        {
            return;
        }

        selectedFood = foodSO;
        OpenCloseCanvas(true);
        OpenCloseFoodMenu(false);
        OpenCloseIngredients(true);

        // Do other stuff which happens when a food is selected
        foreach (IngredientSO ingredient in foodSO.ingredientList)
        {
            GameObject prefab          = Instantiate(ingredientDisplayPrefab, ingredientPanel);
            Image      ingredientImage = prefab.GetComponent <Image>();
            ingredientImage.sprite = ingredient.sprite;
            ingredientDisplayList.Add(ingredientImage);
        }

        //RadialMenu radialMenu = ingredientPanel.parent.gameObject.GetComponentInChildren<RadialMenu>();
        //if (radialMenu.currentFood)
        //    radialMenu.ChangeColor(radialMenu.currentFood);

        ResizeCanvas(2.9f, 1.2f * Mathf.CeilToInt(foodSO.ingredientList.Count) / 2 + 0.5f);
    }
Example #3
0
    /// <summary>
    /// Drops currently held food, Change Sprite back to Hand, Reset references to cooking appliance and food.
    /// </summary>
    /// <param name="item"> The Item to Drop. </param>
    public void DropItem(GameObject item)
    {
        // Change Ingredient Sprite back to Hand Sprite
        background.sprite = defaultSprite;

        // If item is Null, do not do anything
        if (item == null)
        {
            return;
        }

        // Disable highlight on selected ingredient
        var o = item.GetComponentsInChildren <Outline>();

        foreach (var oL in o)
        {
            oL.selected = false;
            oL.color    = 0;
        }

        if (item == cookingAppliance)
        {
            // Reset Food
            cookingAppliance = null;
            foodSO           = null;
        }
    }
Example #4
0
    public static void CreateFood()
    {
        FoodSO asset = CreateInstance <FoodSO>();

        AssetDatabase.CreateAsset(asset, "Assets/Foods/food.asset");
        AssetDatabase.SaveAssets();

        EditorUtility.FocusProjectWindow();

        Selection.activeObject = asset;
    }
Example #5
0
    /// <summary>
    /// Order food based on parameter.
    /// </summary>
    /// <param name="food"> The food to order. </param>
    public void OrderFood(FoodSO food)
    {
        // Show Food Bubble Image
        GameObject canvas = transform.GetChild(0).gameObject;

        canvas.SetActive(true);
        clockHand = canvas.transform.GetChild(3).gameObject;
        canvas.transform.GetChild(4).GetComponent <Image>().sprite         = food.sprite;
        canvas.transform.GetChild(4).GetComponent <Image>().preserveAspect = true;

        // Set Ordered Food
        foodOrdered = food;
        orderedFood = true;
    }
Example #6
0
    /// <summary>
    /// Deactivates this GameObject and Reset its data for later use through The Object Pool.
    /// </summary>
    public void Destroy()
    {
        gameObject.SetActive(false);

        timerImage.fillAmount = 1f;
        movementSpeed         = 2.5f;
        reachedTarget         = false;
        orderedFood           = false;
        foodOrdered           = null;
        fighting       = false;
        othersFighting = false;
        leaving        = false;
        player         = null;
        timer          = 0f;
        clockHand      = null;
        leavingState   = LeavingStates.phase1;
        fightPositions = (FightPositions)customerId;
        dodge          = false;
    }
Example #7
0
    /// <summary>
    /// This is called when the player has finished cooking and the appliance is ready to be used again.
    /// </summary>
    public void NewFood()
    {
        isCooking             = false;
        isDone                = false;
        timer                 = 0;
        cleanTimer            = 0;
        ingredients           = new List <IngredientSO>();
        ingredientDisplayList = new List <Image>();
        selectedFood          = null;

        OpenCloseCanvas(false);
        OpenCloseDoneDisplay(false);
        OpenCloseFoodMenu(false);
        OpenCloseIngredients(false);
        OpenCloseTimer(false);
        OpenCloseHint(false);

        particleSystem.SetActive(false);
        ShowProcess(false);
    }
Example #8
0
    private void DrawFood()
    {
        //Show Icons GUI
        table.OrderGui.ShowIcons();
        for (int i = 0; i < table.SittingCustomers.numberOfCustomers; i++)
        {
            // Draw food
            FoodSO randomFood = OrdersManager.GetRandomFood();

            // Show food Icon
            table.OrderGui.AddIcon(color, randomFood.icon, i);

            // Spawn food in kitchen
            Food food = new Food();
            food.color      = color;
            food.orderId    = id;
            food.customerId = i;
            food.prefab     = randomFood.prefab;
            FoodSpawner.Singleton.OrderFood(food);
        }
    }
Example #9
0
    public void ChangeColor(FoodSO foodSO)
    {
        List <Sprite> sprites = foodSO.ingredientList.Select(x => x.sprite).ToList();

        for (int i = 1; i < transform.childCount; i++)
        {
            if (sprites.Contains(transform.GetChild(i).GetChild(0).GetComponent <Image>().sprite))
            {
                Button     button = transform.GetChild(i).GetComponent <Button>();
                ColorBlock cb     = button.colors;
                cb.highlightedColor = Color.green - Color.white * 0.3f;
                button.colors       = cb;
            }
            else
            {
                Button     button = transform.GetChild(i).GetComponent <Button>();
                ColorBlock cb     = button.colors;
                cb.highlightedColor = Color.red - Color.white * 0.3f;
                button.colors       = cb;
            }
        }
    }
Example #10
0
 public void Close()
 {
     currentAppliance.NewFood();
     currentAppliance = null;
     currentFood      = null;
 }
Example #11
0
 public Food(FoodSO foodData) : base(new Item(foodData.itemID, foodData.itemName, 0), foodData.isStackable, foodData.itemSprite)
 {
 }
Example #12
0
    private void NuitrackManager_onHandsTrackerUpdate(nuitrack.HandTrackerData handTrackerData)
    {
        active = false;
        press  = false;

        // Set Hand Pointer Data if can detect hand
        if (handTrackerData != null)
        {
            nuitrack.UserHands userHands = handTrackerData.GetUserHandsByID(CurrentUserTracker.CurrentUser);

            if (userHands != null)
            {
                if (currentHand == Hands.right && userHands.RightHand != null)
                {
                    baseRect.anchoredPosition = new Vector2(userHands.RightHand.Value.X * Screen.width, -userHands.RightHand.Value.Y * Screen.height);
                    active = true;
                    press  = userHands.RightHand.Value.Click;
                }
                else if (currentHand == Hands.left && userHands.LeftHand != null)
                {
                    baseRect.anchoredPosition = new Vector2(userHands.LeftHand.Value.X * Screen.width, -userHands.LeftHand.Value.Y * Screen.height);
                    active = true;
                    press  = userHands.LeftHand.Value.Click;
                }
            }
        }

        // Show Image
        background.enabled = active;

        if (active)
        {
            // Change back to Hand Sprite if not holding food
            if (!foodSO)
            {
                background.sprite = defaultSprite;
            }
        }
        else
        {
            // Do not do anything if not active
            return;
        }

        // Raycast from Screen Space to World Space
        var pointOnScreenPosition = (Vector2)cam.WorldToScreenPoint(transform.position);

        eventData.delta    = pointOnScreenPosition - eventData.position;
        eventData.position = pointOnScreenPosition;

        raycastResults.Clear();
        EventSystem.current.RaycastAll(eventData, raycastResults);

        Button newButton = null;

        for (int i = 0; i < raycastResults.Count && newButton == null; i++)
        {
            newButton = raycastResults[i].gameObject.GetComponent <Button>();
        }

        if (newButton != selectedButton)
        {
            // When current selected button is not previous sselected button
            if (selectedButton != null)
            {
                selectedButton.OnPointerExit(eventData);

                // Reset Hand Timer, Frame and Flower
                handElapsedTime       = 0f;
                timerImage.fillAmount = 0f;
                timerImage2.gameObject.SetActive(false);
                angle = -(timerImage.fillAmount * 360f + 90f) * Mathf.Deg2Rad;
                var offset = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)) * radius;
                timerImage2.transform.localPosition = new Vector3(offset.x, offset.y, 0f);

                // If previous selected button is Ingredient Panel, stop zooming
                if (selectedButton.GetComponent <IngredientPanel>())
                {
                    selectedButton.GetComponent <IngredientPanel>().Zoomasaurus(false);
                }

                // If any of the cooking appliance's hover hint is active, close it
                if (LevelManager.Instance.cookingAppliances.Any(x => x.hoverHint.activeSelf))
                {
                    foreach (var app in LevelManager.Instance.cookingAppliances)
                    {
                        if (app.hoverHint.activeSelf)
                        {
                            app.OpenCloseHint(false);
                            app.OpenCloseCanvas(false);
                        }
                    }
                }
            }

            // Updates selected buttpon
            selectedButton = newButton;

            if (selectedButton != null)
            {
                selectedButton.OnPointerEnter(eventData);

                // If selected button is Ingredient Panel, start zooming
                if (selectedButton.GetComponent <IngredientPanel>())
                {
                    selectedButton.GetComponent <IngredientPanel>().Zoomasaurus(true);
                }
            }
        }
        else if (selectedButton != null)
        {
            // Runs timer
            handElapsedTime += Time.deltaTime;

            // Reduce fillAmount of Timer Filler Image(visual feedback) over waitTiming
            timerImage.fillAmount += (1f / handTimer) * Time.deltaTime;

            // Shows Flower Image and Move it in a circle
            timerImage2.gameObject.SetActive(true);
            angle = -(timerImage.fillAmount * 360f + 90f) * Mathf.Deg2Rad;
            var offset = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)) * radius;
            timerImage2.transform.localPosition = new Vector3(offset.x, offset.y, 0f);

            #region Highlight Code
            // If previously got hit other object
            if (hitTransform)
            {
                // Disable highlight for hit object and its children
                var o = hitTransform.GetComponentsInChildren <Outline>();
                foreach (var oL in o)
                {
                    if (!oL.selected)
                    {
                        oL.enabled = false;
                    }
                }
            }

            // When the game is not paused, menus not active and selected button is not pause nor guide image
            if (PauseManager.Instance != null && !PauseManager.Instance.isPaused && !foodListPanel.activeSelf && !ingredientListPanel.activeSelf &&
                selectedButton.name != "Pause" && selectedButton.name != "GuideImage")
            {
                // If selecting Cooking Appliance(Frying Pan, Pot 1, Pot 2)
                if (LevelManager.Instance.cookingAppliances.Any(x => x.gameObject.GetInstanceID() == selectedButton.transform.parent.parent.gameObject.GetInstanceID()))
                {
                    var something = LevelManager.Instance.cookingAppliances.Where(x => x.gameObject.GetInstanceID() == selectedButton.transform.parent.parent.gameObject.GetInstanceID()).ToList();

                    if (something.Count != 1)
                    {
                        return;
                    }

                    var app = something[0].GetComponent <CookingAppliance>();

                    app.OpenCloseHint(true);
                    app.OpenCloseCanvas(true);
                }
                // When Carrying food
                else if (foodSO)
                {
                    // If selecting customer
                    if (CustomerSpawner.Instance.customerDic.Any(x => x.Value.gameObject.GetInstanceID() == selectedButton.transform.parent.parent.gameObject.GetInstanceID()))
                    {
                        var something = CustomerSpawner.Instance.customerDic.Where(x => x.Value.gameObject.GetInstanceID() == selectedButton.transform.parent.parent.gameObject.GetInstanceID()).ToList();

                        if (something.Count != 1)
                        {
                            return;
                        }

                        var customer = something[0].Value.GetComponent <Customer>();

                        hitTransform = customer.transform;
                        ShowOutline(customer.gameObject);
                    }
                }
            }
            #endregion Highlight Code

            // When hand timer reach limit
            if (handElapsedTime >= handTimer)
            {
                // Reset Hand Timer, Frame, and Flower image
                handElapsedTime       = 0f;
                timerImage.fillAmount = 0f;
                timerImage2.gameObject.SetActive(false);
                angle = -(timerImage.fillAmount * 360f + 90f) * Mathf.Deg2Rad;
                var offset1 = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)) * radius;
                timerImage2.transform.localPosition = new Vector3(offset1.x, offset1.y, 0f);

                selectedButton.OnPointerClick(eventData);

                // When the game is not paused, menus not active and selected button is not pause
                if (PauseManager.Instance != null && !PauseManager.Instance.isPaused && !foodListPanel.activeSelf && !ingredientListPanel.activeSelf &&
                    selectedButton.name != "Pause")
                {
                    // Do not do anything if haven't finish guiding about intro and order
                    if (selectedButton.name == "GuideImage")
                    {
                        if (!selectedButton.GetComponent <Guide>().finishedIntro || !selectedButton.GetComponent <Guide>().finishedOrder)
                        {
                            return;
                        }
                    }

                    // If selecting Cooking Appliance(Frying Pan, Pot 1, Pot 2)
                    else if (LevelManager.Instance.cookingAppliances.Any(x => x.gameObject.GetInstanceID() == selectedButton.transform.parent.parent.gameObject.GetInstanceID()))
                    {
                        var something = LevelManager.Instance.cookingAppliances.Where(x => x.gameObject.GetInstanceID() == selectedButton.transform.parent.parent.gameObject.GetInstanceID()).ToList();

                        if (something.Count != 1)
                        {
                            return;
                        }

                        var app = something[0].GetComponent <CookingAppliance>();

                        // Haven't done cooking food
                        if (!app.isDone)
                        {
                            // Open up Food list to choose "food to cook"
                            app.OpenCloseFoodMenu(true);

                            // If the game is in Tutorial Scene and Guide Image is not active
                            if (Menu_Manager.Instance.Tutorial_Mode && !Guide.Instance.gameObject.activeSelf)
                            {
                                // If haven't guide cook, start guiding
                                if (!Guide.Instance.CheckIfGuidedCook())
                                {
                                    Guide.Instance.Show();
                                }
                            }
                        }
                        // Done cooking food
                        else
                        {
                            // If previously selected another cooking Appliance
                            if (cookingAppliance)
                            {
                                DropItem(cookingAppliance);
                            }

                            // Select food and store it for serving customer
                            cookingAppliance = app.gameObject;
                            foodSO           = app.TakeFood();

                            // Allow interactions with customer when holding food
                            foreach (var pair in CustomerSpawner.Instance.customerDic)
                            {
                                pair.Value.AllowHover(true);
                            }

                            // Change Hand Sprite to Food Sprite
                            background.sprite = foodSO.sprite;
                        }
                    }
                    // When Carrying food
                    else if (foodSO)
                    {
                        // If selecting customer
                        if (CustomerSpawner.Instance.customerDic.Any(x => x.Value.gameObject.GetInstanceID() == selectedButton.transform.parent.parent.gameObject.GetInstanceID()))
                        {
                            var something = CustomerSpawner.Instance.customerDic.Where(x => x.Value.gameObject.GetInstanceID() == selectedButton.transform.parent.parent.gameObject.GetInstanceID()).ToList();

                            if (something.Count != 1)
                            {
                                return;
                            }

                            var customer = something[0].Value.GetComponent <Customer>();

                            // When customer is not fighting
                            if (!customer.fighting)
                            {
                                // Serve Correct
                                if (foodSO == customer.foodOrdered)
                                {
                                    // Set customer's animations and sound effect
                                    customer.SetAnim(customer.idle, false);
                                    customer.SetAnim(customer.happy, true);
                                    customer.SetClip(Audio_Manager.Instance.audioDictionary["Coin Drop"]);

                                    // Served correct food, Add Score
                                    Score.Instance.Profit(customer.foodOrdered, customer.timerImage.fillAmount);

                                    // Customer leaves
                                    customer.Leave();
                                }
                                // Serve Wrong
                                else
                                {
                                    // Set customer's animations
                                    customer.SetAnim(customer.idle, false);
                                    customer.SetAnim(customer.angry, true);

                                    // Served wrong food, Decrease Rate
                                    Score.Instance.rate -= 0.1f;
                                    customer.fighting    = true;

                                    foreach (CookingAppliance appliance in LevelManager.Instance.cookingAppliances)
                                    {
                                        if (!appliance.isDone)
                                        {
                                            appliance.NewFood();
                                        }
                                    }

                                    customer.player = Player.Instance.transform;

                                    // If the game is in Tutorial Scene
                                    if (Guide.Instance != null)
                                    {
                                        Guide.Instance.gameObject.SetActive(true);
                                    }
                                }

                                // Disable interactions with customer
                                foreach (var pair in CustomerSpawner.Instance.customerDic)
                                {
                                    pair.Value.AllowHover(false);
                                }

                                // Reset cooking Appliance status
                                CookingAppliance app = cookingAppliance.GetComponent <CookingAppliance>();
                                app.NewFood();

                                // Drop food
                                DropItem(cookingAppliance);
                            }
                        }
                    }
                }
            }
        }
        else
        {
            // Disable highlight for every objects that have outline
            var ol = FindObjectsOfType <Outline>();
            foreach (var oL in ol)
            {
                if (!oL.selected)
                {
                    oL.enabled = false;
                }
            }
        }

        // If any customer is fighting with player
        if (CustomerSpawner.Instance.customerDic.Any(x => x.Value.fighting == true))
        {
            // If the game is in Pause Status, do not do anything
            if (PauseManager.Instance != null && PauseManager.Instance.isPaused)
            {
                return;
            }

            var something = CustomerSpawner.Instance.customerDic.Where(x => x.Value.fighting == true).ToList();

            foreach (var pair in something)
            {
                var customer = pair.Value.GetComponent <Customer>();

                // Set player transform for customer to have a target to shoot at
                if (!customer.player)
                {
                    customer.player = Player.Instance.transform;
                }
            }

            // If menus are inactive and player is performing Grab Gesture
            if (!foodListPanel.activeSelf && !ingredientListPanel.activeSelf && press)
            {
                // Runs timer
                shootingElapsedTime += Time.deltaTime;

                // When timer reach limit
                if (shootingElapsedTime >= shootingTimer)
                {
                    // Reset timer
                    shootingElapsedTime = 0f;

                    // Shoot bullet towards hand icon
                    GameObject Projectile = ObjectPool.Instance.GetPooledObject(ProjectilePrefab);

                    // If projectile is not Null
                    if (!Projectile)
                    {
                        return;
                    }

                    // Initialise position and direction of projectile
                    Projectile.transform.position = transform.position;
                    Projectile.GetComponent <Projectile>().dir = (transform.position - cam.transform.position).normalized;
                }
            }
        }
    }