26 changed files with 324 additions and 13 deletions
@ -0,0 +1,8 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 5baa559c09c7aa84db8dbacf122bf34d |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,17 @@ |
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: af86c7c2268eed441b882ced845365f4, type: 3} |
|||
m_Name: BetterSword |
|||
m_EditorClassIdentifier: |
|||
Name: Good Sword |
|||
Description: Better than the Noob Sword |
|||
sprite: {fileID: -4063295180217184869, guid: b00993d063fbc4a87983115070f6145c, type: 3} |
|||
@ -0,0 +1,8 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 8ec316abfe61e4b43862dd2c75f0f792 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 11400000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,17 @@ |
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: af86c7c2268eed441b882ced845365f4, type: 3} |
|||
m_Name: SomeSword |
|||
m_EditorClassIdentifier: |
|||
Name: Noob Sword |
|||
Description: This sword is for noobs |
|||
sprite: {fileID: -6229739577819397656, guid: b00993d063fbc4a87983115070f6145c, type: 3} |
|||
@ -0,0 +1,8 @@ |
|||
fileFormatVersion: 2 |
|||
guid: b0a77491a8b600245b47aa33287d7585 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 11400000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,16 @@ |
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 3145dd14dac0cf84a909862b61ec2893, type: 3} |
|||
m_Name: StandardShop |
|||
m_EditorClassIdentifier: |
|||
Money: 10000 |
|||
PriceModifier: 1.1 |
|||
@ -0,0 +1,8 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 366ca79a0c4a2df4fac53ddd28f65f1a |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 11400000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,27 @@ |
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: d4a440686e1eaa042a9d58081a9b8dbe, type: 3} |
|||
m_Name: StandardShopInventory |
|||
m_EditorClassIdentifier: |
|||
Items: |
|||
- {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} |
|||
- {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} |
|||
- {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} |
|||
- {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} |
|||
- {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} |
|||
- {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} |
|||
- {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} |
|||
- {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} |
|||
- {fileID: 11400000, guid: 8ec316abfe61e4b43862dd2c75f0f792, type: 2} |
|||
- {fileID: 11400000, guid: 8ec316abfe61e4b43862dd2c75f0f792, type: 2} |
|||
- {fileID: 11400000, guid: 8ec316abfe61e4b43862dd2c75f0f792, type: 2} |
|||
- {fileID: 11400000, guid: 8ec316abfe61e4b43862dd2c75f0f792, type: 2} |
|||
@ -0,0 +1,8 @@ |
|||
fileFormatVersion: 2 |
|||
guid: d16c0801001245545908f8b001145a3d |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 11400000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,6 @@ |
|||
/// <summary>
|
|||
/// Just makes sure implementations have an accessible reference to a shop model. Could be an inventory of course.
|
|||
/// </summary>
|
|||
public interface IModelContainer{ |
|||
ShopModel Model { get; } |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
fileFormatVersion: 2 |
|||
guid: bac32d122ed6934498d1bbe6e2fbabc3 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,25 @@ |
|||
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; |
|||
|
|||
protected ShopModel model; |
|||
|
|||
private void Awake() |
|||
{ |
|||
Debug.Assert(factory != null,"Item factory not assigned!",this); |
|||
CreateModel(); // Of course, a generic model component can't select which type of model to use. So we use polymorphism!
|
|||
factory.PopulateModel(model); |
|||
} |
|||
|
|||
protected abstract void CreateModel(); |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 1abae9da667453942bb6221fd22826ee |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,13 @@ |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class ShopModelComponent : ModelComponent |
|||
{ |
|||
[SerializeField] private ShopObject shop; |
|||
protected override void CreateModel() |
|||
{ |
|||
Debug.Assert(shop != null,"Shop model initial object never assigned!",this); |
|||
model = new BuyModel(shop); |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
fileFormatVersion: 2 |
|||
guid: be8c4b332c72a3c4b85013b334ebde3a |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,10 @@ |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
/// <summary>
|
|||
/// An item factory is simply meant to procedurally (or pre-scripted) populate a shop model.
|
|||
/// </summary>
|
|||
public abstract class ItemFactory : ScriptableObject |
|||
{ |
|||
public abstract void PopulateModel(ShopModel model); |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 46c010061a3c73145bc36b2b3efac6df |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,13 @@ |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
/// <summary>
|
|||
/// This represents anything needed to construct one item with pre-scripted information
|
|||
/// </summary>
|
|||
[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor
|
|||
public class ScriptedItem : ScriptableObject |
|||
{ |
|||
public string Name; |
|||
public string Description; |
|||
public Sprite sprite; |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
fileFormatVersion: 2 |
|||
guid: af86c7c2268eed441b882ced845365f4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,15 @@ |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
/// <summary>
|
|||
/// This item factory literally just takes a handcrafted list of items and populates the model with that!
|
|||
/// </summary>
|
|||
[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor
|
|||
public class ScriptedItemFactory : ItemFactory |
|||
{ |
|||
public List<ScriptedItem> Items; |
|||
public override void PopulateModel(ShopModel model) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
fileFormatVersion: 2 |
|||
guid: d4a440686e1eaa042a9d58081a9b8dbe |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,14 @@ |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
/// <summary>
|
|||
/// This shop object allows us to script which kind of stuff a shop starts out with. Models are meant to be created
|
|||
/// by using the appropriate unity component, which requires a shopobject to be able to which kind of money and other
|
|||
/// things specific to a shop they start with.
|
|||
/// </summary>
|
|||
[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor
|
|||
public class ShopObject : ScriptableObject |
|||
{ |
|||
public int Money; |
|||
public float PriceModifier; // How much more expensive than retail price does this shop sell stuff?
|
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 3145dd14dac0cf84a909862b61ec2893 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
Loading…
Reference in new issue