MVC shop project for software architecture, in Unity.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

27 lines
1.0 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// This component basically associates a model with a gameobject. This allows to know its location in the world
/// (2D or 3D!) for fancy effects, or allows a view to switch between different models as it sees fit.
/// The actual model can be anything from a buymodel to an inventorymodel
/// </summary>
public abstract class ModelComponent : MonoBehaviour, IModelContainer
{
public ShopModel Model { get => model; }
//[SerializeField] private ItemFactory factory;
[SerializeField] protected InventoryComponent inventory;
protected ShopModel model;
private void Awake()
{
Debug.Assert(inventory != null,"Inventory not assigned!",this);
CreateModel(); // Of course, a generic model component can't select which type of model to use. So we use polymorphism!
model.inventory = inventory.Inventory;
//factory.PopulateInventory(model.inventory);
}
protected abstract void CreateModel();
}