示例#1
0
    private void Interaction()
    {
        Collider2D collider = Physics2D.OverlapCircle(transform.position, .5f, checkableLayer);

        if (collider != null)
        {
            string s = collider.tag;
            switch (s)
            {
            case "Plate":
                if (player.inventory.Count > 0 && player.inventory[0].typeOfVegetable != VegetableType.Combo)
                {
                    collider.GetComponent <Vegetable>().GetVegetable(player.inventory[0]);
                    player.RemoveVegetable();
                }
                break;

            case "Vegetable":
                VegetableType vtype = collider.GetComponent <Vegetable>().typeOfVegetable;
                Vegetable     vege  = player.inventory.Find(v => v.typeOfVegetable == vtype);
                player.inventory.Remove(vege);
                break;

            case "CuttingBoard":
                CuttingBoard cb = collider.GetComponent <CuttingBoard>();
                if (cb.vegePlate.vegetablesOnPlate.Count != 0)
                {
                    player.AddToVegePlate(cb.vegePlate);
                    cb.ClearVegePlate();
                }
                break;

            case "Trash":
                player.RemoveVegePlate();
                GameManager.Instance.PointDistribution(player, -50);
                break;

            default:
                break;
            }
        }
    }
示例#2
0
    /// <summary>
    /// 触れている調理器具からスクリプト取得
    /// </summary>
    /// <param name="obj"></param>
    private void ChangeTouchCookware(GameObject obj)
    {
        if (obj == _TouchCookware)
        {
            return;
        }

        _TouchCookware = obj;

        if (b_TouchPot)
        {
            _TouchPotScript = _TouchCookware.GetComponent <Pot>();
        }
        if (b_TouchFPan)
        {
            _TouchFryingPanScript = _TouchCookware.GetComponent <FryingPan>();
        }
        if (b_TouchCB)
        {
            _TouchCutScript = _TouchCookware.GetComponent <CuttingBoard>();
        }
    }
示例#3
0
    private void OnCollisionEnter(Collision collision)
    {
        GameObject go = collision.gameObject;

        if (go.gameObject.name != "Plane")
        {
            //Store chopped vegetables in case we recieve notification that they are ready to deliver to Customer
            if (go.name.Contains("Board") && go.name.Contains(p1))
            {
                CuttingBoard cb = go.GetComponent <CuttingBoard>();
                ingredients = cb.vegetablesChopped;
            }
            //Pickup a vegetable
            if (go.tag == "Vegetable")
            {
                if (vegetables.Count == 2)
                {
                    NotificationCenter.DefaultCenter.PostNotification(this, "UIPlateTooMany");
                }
                else
                {
                    vegetables.Add(go.name);
                    if (vegetables.Count == 1)
                    {
                        veg1.sprite = AssignVegetable(go.name);
                    }
                    else
                    {
                        veg2.sprite = AssignVegetable(go.name);
                    }
                }
            }
            //Check if we collided with a customer
            CheckCustomerCollision(go);
        }
    }
    // MOST OF THE INTERACTIONS HAPPEN HERE!! -----------------
    // while you are colliding with an item
    private void OnTriggerStay(Collider other)
    {
        //Debug.Log("PlayerAction is colliding with" + other.name);

        // collision with crates -----------------------------------
        if (other.gameObject.CompareTag("Crate"))
        {
            Crate crate = other.gameObject.GetComponent <Crate>();

            // if the player doesn't have an item and presses "J"
            if (!hasItem && Input.GetKeyDown(KeyCode.J))
            {
                // set item to the item from the crate
                SetItem(crate.ReturnItem());
            }
        }



        // using cutting board ---------------------------------------
        if (other.gameObject.CompareTag("CuttingBoard"))
        {
            CuttingBoard cuttingBoard = other.gameObject.GetComponent <CuttingBoard>();
            // if you have an item and the cutting board does not
            // OR
            // if you don't have an item but the cutting board does
            // AND
            // you're pressing down the "K" key
            if (hasItem && !cuttingBoard.hasItem && Input.GetKey(KeyCode.K) && currentItem.gameObject.CompareTag("FoodChoppable"))
            {
                Debug.Log("CURRENT ITEM NUMBER: " + currentItem.name);
                // give away item
                cuttingBoard.TakeInItem(currentItem);
                RemoveItem();
            }

            else if (!hasItem && cuttingBoard.hasItem && Input.GetKey(KeyCode.K))
            {
                // while the cutting is not done,
                if (!cuttingBoard.isCuttingDone)
                {
                    // cut
                    cuttingBoard.Cutting();
                    isChopping = true;
                }
            }

            if (!hasItem && cuttingBoard.isCuttingDone && Input.GetKeyDown(KeyCode.J))
            {
                SetItem(cuttingBoard.ReturnCuttedItem());
                cuttingBoard.ClearCuttingBoard();
            }
        }


        // Cooking with the Frying Pan -------------------------------------
        if (other.gameObject.CompareTag("FryingPan"))
        {
            FryingPan fryingPan = other.gameObject.GetComponent <FryingPan>();
            // if you have an item that can be cooked and the fryingPan is
            if (hasItem && !fryingPan.hasItem && Input.GetKeyDown(KeyCode.K) && currentItem.gameObject.CompareTag("FoodCookable"))
            {
                fryingPan.TakeInitem(currentItem);
                RemoveItem();
                fryingPan.CookFood();
            }

            if (!hasItem && fryingPan.isCooked && Input.GetKeyDown(KeyCode.J))
            {
                SetItem(fryingPan.ReturnCookedItem());
                fryingPan.ClearFryingPan();
            }
        }

        // Plate ----------------------------------------------------
        if (other.gameObject.CompareTag("Plate"))
        {
            Plate plate = other.gameObject.GetComponent <Plate>();
            // add item to plate
            if (hasItem && Input.GetKeyDown(KeyCode.K) && !currentItem.gameObject.CompareTag("Plate"))
            {
                plate.AddToPlate(currentItem);
                RemoveItem();
            }

            // pick up plate
            if (!hasItem && Input.GetKeyDown(KeyCode.J))
            {
                SetItem(plate.gameObject.GetComponent <Item>());
            }
        }

        // Service Window --------------------
        if (other.gameObject.CompareTag("ServiceWindow"))
        {
            ServiceWindow serviceWindow = other.gameObject.GetComponent <ServiceWindow>();

            if (hasItem && Input.GetKeyDown(KeyCode.K) && currentItem.gameObject.CompareTag("Plate"))
            {
                serviceWindow.GivePlateToWindow(currentItem.GetComponent <Plate>());
                // change plate position to x: -1     y: 3.3     z: -27
                RemoveItem();
            }
        }

        // Trash ----------------------------
        if (other.gameObject.CompareTag("Trash"))
        {
            Trash trash = other.gameObject.GetComponent <Trash>();



            if (hasItem && Input.GetKeyDown(KeyCode.K))
            {
                string tag = currentItem.gameObject.tag;
                trash.RemoveItem(currentItem);
                RemoveItem();
                if (tag == "Plate")
                {
                    CreateNewPlate();
                }
            }
        }
    }
 public CuttableOnCuttingBoardEvent(CuttingBoard cuttingBoard, CuttableFood food) : base(cuttingBoard)
 {
     board     = cuttingBoard;
     this.food = food;
 }
    // Use this for initialization
    void Start()
    {
        _dialogueComponents = GameObject.FindGameObjectWithTag("LevelManager").GetComponent <DialogueCompanyComponent>();

        _inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent <Inventory>();


        _cuttingBoard = GameObject.Find("CuttingBoard").GetComponent <CuttingBoard>();
        _meatGrinder  = GameObject.Find("MeatGrinder").GetComponent <MeatGrinder>();
        _grater       = GameObject.Find("Grater").GetComponent <Grater>();
        _pan          = GameObject.Find("Pan").GetComponent <Pan>();
        _stove        = GameObject.FindGameObjectWithTag("Stove").GetComponent <Stove>();

        _boxWithMeat  = GameObject.Find("BoxWithMeat").GetComponent <Repository>();
        _boxWithBread = GameObject.Find("BoxWithBread").GetComponent <Repository>();

        _stage = 0;

        _dialogues = new Dictionary <Stage, DialogueInfo>
        {
            {
                Stage.Begining, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan2",

                    NameText     = "Сестренка",
                    DialogueText =
                        "Доброе утро, братик! С сегодняшнего дня эта закусочная твоя, надеюсь ты сможешь о ней позаботиться. Давай попробуем сделать дедушкин сэндвич. Сходи на склад и достань мясо из коробки.",
                    NextBtnText     = "Ок",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.WaitForMeat;
                    }
                }
            },
            {
                Stage.WaitForMeat, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan2",

                    NameText        = "Сестренка",
                    DialogueText    = "Сейчас прижарь его на сковороде.",
                    NextBtnText     = "Хорошо",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.DropWholeRawMeatInStove;
                    }
                }
            },
            {
                Stage.TakeBreadBeforeMeat, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan",

                    NameText        = "Сестренка",
                    DialogueText    = "Это похоже на мясо? Мне кажется это хлеб. Возьми мясо из соседней коробки!",
                    NextBtnText     = "Угу",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.WaitForMeat;
                    }
                }
            },
            {
                Stage.DropWholeRawMeatInStove, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = false,
                    IsAnswer1BtnVisible = true,
                    IsAnswer2Visible    = true,
                    IsAnswer3Visible    = true,

                    AvatarPath = "Avatars/tyan2",

                    NameText           = "Сестренка",
                    DialogueText       = "Хорошо, теперь прожарь его до легкой корочки.",
                    Answer1Text        = "A что будет, если я его пережарю?",
                    Answer2Text        = "Как понять, что мясо готово?",
                    Answer3Text        = "Oкей",
                    Answer1BtnCallback = () =>
                    {
                        _stage = Stage.TalkAboutStateOfPreparing;
                        Close();
                    },
                    Answer2BtnCallback = () =>
                    {
                        _stage = Stage.TalkAboutCookingInStove;
                        Close();
                    },
                    Answer3BtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.WaitForWholeFriedMeat;
                    }
                }
            },
            {
                Stage.DropWholeRawMeatInAllAnotherPlaces, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan",

                    NameText     = "Сестренка",
                    DialogueText = "Я же сказала, положи мясо на сковороду!",

                    NextBtnText     = "Хорошо, хорошо...",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.DropWholeRawMeatInStove;
                        _meatGrinder.DeleteItem();
                        _cuttingBoard.DeleteItem();
                        _grater.DeleteItem();
                        _pan.DeleteItem();
                        _inventory.AddItem(Item.Name.Meat, Item.StateOfIncision.Whole, Item.StateOfPreparing.Raw, false);
                    }
                }
            },
            {
                Stage.DropWholeRawMeatInGarbage, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan",

                    NameText     = "Сестренка",
                    DialogueText = "Зачем ты выкинул кусок отличной вырезки в мусорку? Ты ебобо?! Иди и возьми новый кусок мяса!",

                    NextBtnText     = "Ой...",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _boxWithMeat.AddtoRepository(1, Item.Name.Meat);
                        _stage = Stage.WaitForMeat;
                    }
                }
            },
            {
                Stage.AgainTalkWhenDropWholeRawMeatInStove, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = false,
                    IsAnswer1BtnVisible = true,
                    IsAnswer2Visible    = true,
                    IsAnswer3Visible    = true,

                    AvatarPath = "Avatars/tyan2",

                    NameText           = "Сестренка",
                    DialogueText       = "Готов жарить мясо?",
                    Answer1Text        = "A что будет, если я его пережарю?",
                    Answer2Text        = "Как понять, что мясо готово?",
                    Answer3Text        = "Дыа",
                    Answer1BtnCallback = () =>
                    {
                        _stage = Stage.TalkAboutStateOfPreparing;
                        Close();
                    },
                    Answer2BtnCallback = () =>
                    {
                        _stage = Stage.TalkAboutCookingInStove;
                        Close();
                    },
                    Answer3BtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.WaitForWholeFriedMeat;
                    }
                }
            },
            {
                Stage.TalkAboutStateOfPreparing, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan",

                    NameText     = "Сестренка",
                    DialogueText = "Оно сгорит, глупенький! Что же оно ещё может сделать?!",

                    NextBtnText     = "Ладно, ладно...",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.AgainTalkWhenDropWholeRawMeatInStove;
                    }
                }
            },
            {
                Stage.TalkAboutCookingInStove, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan2",

                    NameText     = "Сестренка",
                    DialogueText = "Все просто! Когда мясо покраснеет, оно будет готово!",

                    NextBtnText     = "Окей",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.AgainTalkWhenDropWholeRawMeatInStove;
                    }
                }
            },

            {
                Stage.CreateBadMeat, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan",

                    NameText     = "Сестренка",
                    DialogueText = "Братик, ты испортил кусок отличного мяса! Постарайся так больше не делать.",

                    NextBtnText     = "Хорошо",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.WaitForWholeFriedMeat;
                    }
                }
            },

            {
                Stage.TakeBreadWhenCreateWholeFriedMeat, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan",

                    NameText     = "Сестренка",
                    DialogueText = "Положи этот кусок хлеба, сейчас он тебе ещё не нужен.",

                    NextBtnText     = "Хорошо",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.WaitForWholeFriedMeat;
                    }
                }
            },

            {
                Stage.WaitForWholeFriedMeat, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan2",

                    NameText     = "Сестренка",
                    DialogueText = "Отлично, а сейчас достань кусок хлеба из коробки.",

                    NextBtnText     = "Хорошо",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.WaitForBread;
                    }
                }
            },

            {
                Stage.TakeMeatBeforeBread, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan",

                    NameText     = "Сестренка",
                    DialogueText = "Я попросила взять тебя кусок хлеба, а ты взял ещё один кусок мяса. Зачем?",

                    NextBtnText     = "Оу...",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.WaitForBread;
                    }
                }
            },

            {
                Stage.WaitForBread, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan2",

                    NameText     = "Сестренка",
                    DialogueText = "Теперь просто сделай бутерброд на рабочем столе. Рецепт бутреброда можно посмотреть в книге рецептов. " +
                                   "(Рабочий стол работает по принципу положил в него нужные ингридиенты, нажал, получил продукт. Однако, если положить туда не те продукты, которые требуются, на выходе получишь что - то совсем иное...)",

                    NextBtnText     = "Хорошо",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.WaitForSandwich;
                    }
                }
            },

            {
                Stage.DoBadThing, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan",

                    NameText     = "Сестренка",
                    DialogueText =
                        "Не очень то похоже на сэндвич! Открой книгу рецептов, прочти её и попробуй снова! >_>",

                    NextBtnText     = "Хорошо",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.WaitForSandwich;
                    }
                }
            },

            {
                Stage.LostAll, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan",

                    NameText     = "Сестренка",
                    DialogueText =
                        "<_< Ты похерил всю еду на кухне! Фиговый из тебя повар, попробуй ещё раз. >_>",

                    NextBtnText     = "Хорошо",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.WaitForSandwich;
                    }
                }
            },

            {
                Stage.WaitForSandwich, new DialogueInfo
                {
                    IsChatPanelVisible  = true,
                    IsAvatarVisible     = true,
                    IsNextBtnVisible    = true,
                    IsAnswer1BtnVisible = false,
                    IsAnswer2Visible    = false,
                    IsAnswer3Visible    = false,

                    AvatarPath = "Avatars/tyan2",

                    NameText     = "Сестренка",
                    DialogueText = "Думаю ты справишься с покупателями в первые дни. Главное не забудь читать книгу рецептов в поисках новых рецептов!",

                    NextBtnText     = "Хорошо",
                    NextBtnCallback = () =>
                    {
                        Close();
                        _stage = Stage.WaitForDroppingSandwichToSister;
                    }
                }
            }
        };
    }