Esempio n. 1
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.TryGetComponent(out SupplyTable supply))
     {
         if (supply == StartSupply)
         {
             if (foods.Count < SupplyCapacity)
             {
                 SupplyFood food = supply.Take();
                 if (food != null)
                 {
                     food.Grab(transform);
                     foods.Add(food);
                 }
             }
             else
             {
                 walkingToEnd = true;
             }
         }
         if (supply == EndSupply)
         {
             while (foods.Count > 0 && EndSupply.Drop(foods[foods.Count - 1]))
             {
                 foods.RemoveAt(foods.Count - 1);
             }
             if (foods.Count == 0)
             {
                 walkingToEnd = false;
             }
         }
     }
 }
Esempio n. 2
0
        public void CreateDataSupplyFood()
        {
            SupplyFood d1 = new SupplyFood("0", "Braised pork with eggs", "Non - vegetarian food", "Huỳnh Thanh Dương");
            SupplyFood d2 = new SupplyFood("1", "Pickled Scallion head", "Vegetarian food", "Lý Tiểu Long");

            listSupplyFood.Add(d1);
            listSupplyFood.Add(d2);
        }
Esempio n. 3
0
 public bool Drop(SupplyFood food)
 {
     if (supplies.Count >= MaxFood)
     {
         return(false);
     }
     supplies.Add(food);
     food.PutOnPlate(FindPlate(), this);
     return(true);
 }
Esempio n. 4
0
        private void listView1_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            ListView lsv = sender as ListView;

            if (lsv.SelectedItems.Count == 1)
            {
                ListViewItem item  = lsv.SelectedItems[0];
                int          index = Convert.ToInt32(item.Text);
                SupplyFoodSelected = (SupplyFood)SupplyProduct.listSupplyFood[index];
            }
        }
Esempio n. 5
0
    protected void CreateFood()
    {
        if (supplies.Count >= MaxFood)
        {
            return;
        }
        SupplyFood food = Instantiate(FoodPrefab);

        food.PutOnPlate(FindPlate(), this);
        supplies.Add(food);
    }
Esempio n. 6
0
    public SupplyFood Take()
    {
        if (supplies.Count == 0)
        {
            return(null);
        }
        int        end  = supplies.Count - 1;
        SupplyFood food = supplies[end];

        supplies.RemoveAt(end);
        return(food);
    }
Esempio n. 7
0
    // Start is called before the first frame update
    public void Init(SupplyFood Supply)
    {
        SpriteRenderer renderer = GetComponent <SpriteRenderer>();

        if (Supply != null)
        {
            renderer.sprite = Supply.SpriteRenderer.sprite;
        }
        else
        {
            renderer.sprite = Sprites[Random.Range(0, Sprites.Length)];
        }
        startPosition = transform.position;
    }
Esempio n. 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            ADD formAdd = new ADD();

            formAdd.ShowDialog();
            if (ADD.Food != null)
            {
                SupplyFood a = new SupplyFood(ADD.Food);

                if (string.IsNullOrEmpty(a.FoodWater.ToString()) || string.IsNullOrEmpty(a.CategoryFood.ToString()) || string.IsNullOrEmpty(a.Patient.ToString()))
                {
                }
                else
                {
                    listSupplyFood.Add(a);
                    MessageBox.Show("Add successful", "Notification");
                    LoadSupplyFood();
                }
            }
        }
    // Instanciates the food to be thrown, and throws it.
    private void ThrowFood()
    {
        SupplyFood foodSupply = null;

        if (RequireFoodToShoot)
        {
            foodSupply = supply.Take();
            if (foodSupply == null)
            {
                return;
            }
            foodSupply.Consume();
        }
        FoodImpact p = Instantiate(food, transform.position, Quaternion.identity);
        Collider2D projectileCollider = p.GetComponent <Collider2D>();

        Physics2D.IgnoreCollision(projectileCollider, fighterCollider);
        Vector3 direction = target.position - p.transform.position;

        p.GetComponent <Rigidbody2D>().velocity = direction.normalized * Speed;

        p.Init(foodSupply);
    }