// Update is called once per frame
    void Update()
    {
        if (!Application.isEditor)
        {
            Destroy(this);
            return;
        }

        // if topping has changed, instantiate new prefab
        if (lastTopping != bMapTile.topping)
        {
            // remove old children objects
            List <GameObject> children = new List <GameObject>();
            for (int i = 0; i < transform.childCount; i++)
            {
                children.Add(transform.GetChild(i).gameObject);
            }
            foreach (GameObject go in children)
            {
                DestroyImmediate(go);
            }

            // spawn prefab if there is any
            if (bMapTile.topping != BMapTile.ToppingType.NONE)
            {
                bMapTile.UpdateTopping();
                Debug.Log(prefabPath + bMapTile.mapTile.topping.prefabName);
                bMapTile.SpawnTopping();
            }

            lastTopping = bMapTile.topping;
        }
    }
Beispiel #2
0
    void HandleToppingSpawned(object sender, EventArgs args)
    {
        ToppingSpawnEvent e        = args as ToppingSpawnEvent;
        BMapTile          bMapTile = GetBMapTile(e.target.mapTile);

        bMapTile.SpawnTopping();
        EventProxyManager.FireEvent(this, new EventDoneEvent());
    }