Пример #1
0
    void Update()
    {
        bar.set(5000f, pelanggan.kesabaran);
        //cek state
        switch (pelanggan.state)
        {
        case 0:
            //randomize pelanggan tersedia + pesanannya
            pelanggan = new Pelanggan("garong", "ikan goreng");
            break;

        case 1:
            render.color = new Color32(225, 80, 80, 0);
            //jalan ke antre.kalau belum sampai, jalan. kalau sudah ganti state 2
            if (transform.position.y > kursi.y)
            {
                rb.MovePosition(transform.position + new Vector3(0, -1) * speed * Time.deltaTime);
                skin.Play("Base Layer.walk_down");
            }
            else
            {
                pelanggan.state++;
                GameObject.FindWithTag("manajer").GetComponent <Ordermanager>().isAntrianGerak = false;
                skin.Play("Base Layer.down");
            }
            break;

        case 2:
            render.color = new Color32(225, 80, 80, 255);
            //kalau belum dapat kursi kurangi kesabaran, pergantian state ke state 3 ditangani player
            if (pelanggan.kesabaran > 0)
            {
                if (!UI_Controller.isPaused)
                {
                    pelanggan.kesabaran--;
                }
            }
            else
            {
                pelanggan.state = 5;
                LevelDesigner.kurangreputasi(1);
                GameObject.FindWithTag("manajer").GetComponent <Ordermanager>().keluarAntrian(noAntri);
            }

            break;

        case 3:
            render.color = new Color32(225, 80, 80, 0);
            skin.Play("Base Layer.right");
            //kalau belum dapat makanan kurangi kesabaran, pergantian state ke state 4 ditangani player
            if (pelanggan.kesabaran > 0)
            {
                if (!UI_Controller.isPaused)
                {
                    pelanggan.kesabaran--;
                }
            }
            else
            {
                pelanggan.state = 5;
                LevelDesigner.kurangreputasi(1);
                GameObject.FindWithTag("manajer").GetComponent <Ordermanager>().pulang(noKursi);
            }

            break;

        case 4:
            //tunggu 10 detik lalu ganti ke state 5 dan bayar makan
            if (waktumakan > 0)
            {
                if (!UI_Controller.isPaused)
                {
                    waktumakan--;
                }
            }
            else
            {
                if (warnamakanan.ToLower() == pelanggan.warna.ToLower())
                {
                    LevelDesigner.bayar(10);
                    LevelDesigner.tambahreputasi(2);
                }
                else
                {
                    LevelDesigner.bayar(5);
                    LevelDesigner.tambahreputasi(1);
                }
                pelanggan.state++;
                GameObject.FindWithTag("manajer").GetComponent <Ordermanager>().pulang(noKursi);
            }
            break;

        case 5:
            //kalau belum sampai, jalan. kalau sudah trigger pelanggan baru di order manager dan hancurkan objek
            if (transform.position.x > keluar.x)
            {
                skin.Play("Base Layer.left");
                rb.MovePosition(transform.position - new Vector3(1, 0) * speed * Time.deltaTime);
            }
            else if (transform.position.y < keluar.y)
            {
                skin.Play("Base Layer.walk_up");
                rb.MovePosition(transform.position + new Vector3(0, 1) * speed * Time.deltaTime);
            }
            else
            {
                Destroy(gameObject);
            }
            break;
        }
    }