Make View and Model consistent authored by Karikó Csongor Csanád's avatar Karikó Csongor Csanád
...@@ -26,8 +26,10 @@ package Model.Common { ...@@ -26,8 +26,10 @@ package Model.Common {
} }
interface IDisplayable { interface IDisplayable {
+ IsVisible() : bool
+ GetPosition() : Vector2 + GetPosition() : Vector2
+ GetVisible() : bool + GetModelObjectHandle() : ModelObjectHandle
+ GetState() : int
} }
interface ITickable { interface ITickable {
...@@ -39,6 +41,11 @@ package Model.Common { ...@@ -39,6 +41,11 @@ package Model.Common {
+ GetActions() : IEnumerable<Action> + GetActions() : IEnumerable<Action>
} }
interface IBuilder {
+ CanBuild(IMapObjectBlueprint, Orientation) : bool
+ Build(IMapObjectBlueprint, Orientation) : (IDisplayable, IInspectable)
}
class Singleton<T> <<Singleton>> { class Singleton<T> <<Singleton>> {
- {static} instance : T - {static} instance : T
- Singleton() - Singleton()
...@@ -47,12 +54,20 @@ package Model.Common { ...@@ -47,12 +54,20 @@ package Model.Common {
class Simulation <<Singleton>> { class Simulation <<Singleton>> {
- people : Person[] - people : Person[]
- map : Map
- park : Park
- Simulation() - Simulation()
+ Create(SimulationConfig)
+ GetPark() : IInspectable
+ GetBuilder() : IBuilder
+ Tick() : IEnumerable<(IDisplayable, IInspectable)>
} }
Simulation --|> Singleton Simulation --|> Singleton
Simulation --> Park Simulation --> Park
Simulation --> MaintenanceDispatcher Simulation --> MaintenanceDispatcher
class Park <<Singleton>> { class Park <<Singleton>> {
- balance : int - balance : int
- entryFee : int - entryFee : int
...@@ -67,7 +82,9 @@ package Model.Common { ...@@ -67,7 +82,9 @@ package Model.Common {
+ ModifyBalance(int) + ModifyBalance(int)
+ AddBuilding(Building) + AddBuilding(Building)
+ SetEntryFee(int) + SetEntryFee(int)
+ Tick()
} }
Park implements ITickable
Park --|> Singleton Park --|> Singleton
Park --|> IInspectable Park --|> IInspectable
...@@ -133,8 +150,8 @@ package Model.Map { ...@@ -133,8 +150,8 @@ package Model.Map {
class Map { class Map {
+ Map(Vector2) + Map(Vector2)
+ CanBuild(IMapObjectBlueprint) : bool + CanBuild(IMapObjectBlueprint, Orientation) : bool
+ Build(IMapObjectBlueprint) + Build(IMapObjectBlueprint, Orientation) : (IDisplayable, IInspectable)
} }
Map *- "*" Cell Map *- "*" Cell
Map *-- "1" NavigationGraph Map *-- "1" NavigationGraph
...@@ -317,37 +334,44 @@ package Model.Landscape { ...@@ -317,37 +334,44 @@ package Model.Landscape {
``` ```
**View**
```plantuml ```plantuml
@startuml View @startuml View
skinparam classAttributeIconSize 0 skinparam classAttributeIconSize 0
left to right direction left to right direction
class Model.Simulation { class Model.Simulation {
+ Simulation(SimulationConfig) - people : Person[]
+ GetCompany() : IInspectable - map : Map
- park : Park
- Simulation()
+ Create(SimulationConfig)
+ GetPark() : IInspectable
+ GetBuilder() : IBuilder + GetBuilder() : IBuilder
+ Tick() : List<(IDisplayable, IInspectable)> // list of new visitors / staff + Tick() : IEnumerable<(IDisplayable, IInspectable)>
} }
interface Model.IBuilder { interface Model.IBuilder {
+ IsPlacementAllowed(IMapObjectBlueprint, Orientation) : bool + CanBuild(IMapObjectBlueprint, Orientation) : bool
+ Place(IMapObjectBlueprint, Orientation) : (IDisplayable, IInspectable) + Build(IMapObjectBlueprint, Orientation) : (IDisplayable, IInspectable)
} }
interface Model.IInspectable { interface Model.IInspectable {
+ GetModelObjectRef() : ModelObjectRef + GetProperties() : IEnumerable<Property>
+ GetProperties() : List<Property>() + GetActions() : IEnumerable<Action>
} }
interface Model.IDisplayable { interface Model.IDisplayable {
+ IsAlive() : bool
+ IsVisible() : bool + IsVisible() : bool
+ GetPosition() : Vector2 + GetPosition() : Vector2
+ GetModelObjectHandle() : ModelObjectHandle
+ GetState() : int + GetState() : int
} }
class Model.ModelObjectHandle {
+ IsValid() : bool
}
/' END OF MODEL '/ /' END OF MODEL '/
UnityEngine.MonoBehaviour <|-- View.SingletonMonobehaviour UnityEngine.MonoBehaviour <|-- View.SingletonMonobehaviour
... ...
......