Esempio n. 1
0
        /// <summary>
        /// Create a game asset view
        /// </summary>
        /// <param name="asset"></param>
        /// <returns>A view that doesn't have a link to the model.  The caller needs to link this subsequently</returns>
        public GameAssetView CreateGameAssetView(AbstractGameAsset asset)
        {
            GameAssetView v   = null;
            FieldView     fv  = m_fieldViews[asset.Field.Uuid];
            Vector3       pos = fv.RootPart.AbsolutePosition;

            if (asset.Type == AbstractGameAssetType.Factory)
            {
                v = new FactoryView(m_controller, m_scene, asset, m_itemStoreView);
            }
            else if (asset.Type == AbstractGameAssetType.Houses)
            {
                v = new HousesView(m_controller, m_scene, asset, m_itemStoreView);
            }
            else if (asset.Type == AbstractGameAssetType.Crops)
            {
                v = new CropsView(m_controller, m_scene, asset, m_itemStoreView);
            }
            else
            {
                throw new Exception(string.Format("Unrecognized asset type {0} at position {1}", asset.Type, pos));
            }

            fv.Close();
            m_fieldViews.Remove(asset.Field.Uuid);

            v.Initialize(pos);

            return(v);
        }
Esempio n. 2
0
        /// <summary>
        /// Create a game asset view
        /// </summary>
        /// <param name="asset"></param>
        /// <returns>A view that doesn't have a link to the model.  The caller needs to link this subsequently</returns>
        public GameAssetView CreateGameAssetView(AbstractGameAsset asset)
        {
            GameAssetView v = null;
            FieldView fv = m_fieldViews[asset.Field.Uuid];
            Vector3 pos = fv.RootPart.AbsolutePosition;

            if (asset.Type == AbstractGameAssetType.Factory)
                v = new FactoryView(m_controller, m_scene, asset, m_itemStoreView);
            else if (asset.Type == AbstractGameAssetType.Houses)
                v = new HousesView(m_controller, m_scene, asset, m_itemStoreView);
            else if (asset.Type == AbstractGameAssetType.Crops)
                v = new CropsView(m_controller, m_scene, asset, m_itemStoreView);
            else
                throw new Exception(string.Format("Unrecognized asset type {0} at position {1}", asset.Type, pos));

            fv.Close();
            m_fieldViews.Remove(asset.Field.Uuid);

            v.Initialize(pos);

            return v;
        }