Exemple #1
0
    void ResetFood()
    {
        Bounds stageBounds = stageArea.bounds;

        foreach (GameObject food in foods)
        {
            Vector3 position = new Vector3(
                UnityEngine.Random.Range(stageBounds.min.x, stageBounds.max.x),
                UnityEngine.Random.Range(stageBounds.min.y, stageBounds.max.y),
                0
                );

            Quaternion rotation = Quaternion.AngleAxis(UnityEngine.Random.Range(0, 360), Vector3.forward);

            food.transform.position = position;
            food.transform.rotation = rotation;

            FoodCtrl foodCtrl = food.GetComponent <FoodCtrl>();
            foodCtrl.Initialize();
        }
    }
Exemple #2
0
 public void SyncFoods(FoodState[] foodList)
 {
     for (int i = 0; i < foodList.Length; i++)
     {
         FoodState food = foodList[i];
         if (!m_allFoods.ContainsKey(food.guid))
         {
             TableFoodPos tFood = TableManager.instance.GetPropertiesById <TableFoodPos>(food.tableId);
             GameObject   go    = (GameObject)Object.Instantiate(Resources.Load(tFood.modelPath));
             FoodCtrl     _ctrl = go.GetComponent <FoodCtrl>();
             if (_ctrl == null)
             {
                 _ctrl = go.AddComponent <FoodCtrl>();
             }
             _ctrl.name = "Food_" + food.guid;
             _ctrl.guid = food.guid;
             m_allFoods.Add(food.guid, _ctrl);
         }
         m_allFoods[food.guid].Sync(food);
     }
 }
Exemple #3
0
 public override void CreateInit()
 {
     foodCtrl = transform.Find("Node/Foods").GetComponent <FoodCtrl>();
     InitEvent();
 }