Skip to content
ldstrumpet edited this page Feb 26, 2015 · 18 revisions

#Controller API

##Data Controllers These controllers receive calls from Unity (clicks, keys, etc) and react by making necessary changes to the Model. Together, these classes should contain access to all Models.

####Data Management Controller

class DataManagementController
{
    CharacterController character;
    TimeController time;
}

####Scene Model Controller Handles character collision with scene borders (changing scenes or outer boundaries).

class SceneModelController
{
    SceneModel model;

    // Unity will send the scene to the controller so appropriate scene information can
    //   can be loaded into the model
    void ChangeScene(Scene);
}

####Character Controller Handles character Model changes including inventory and meters

class CharacterController
{
    CharacterModel model;

    // Passes these actions on to model
    void OnHour();
    void TakeDamage();
    double getDamage();
    
    void UseItem(); // tells InventoryController to use an item
    bool HasOnHand(Item); // checks for a specific Item in hand
}

####Time Controller Handles changes in time and has a list of ITimeAffected Controllers to call every hour

class TimeManagementController
{
    // These include Character Controller
    List<ITimeAffected> listeners; 
    
    // This value will change depending as the character moves or acts
    double time;  

    // value when the above variable "time" incurs the OnHour function 
    double const TIME_PER_HOUR;
    
    // Calls OnHour() for all listeners
    void OnHour();
    void AddTime(double);
}

####Interaction Controller Handles 'E' key press calls by checking area (colliders) for Interactable Environments (storage, trees, water, etc).

class InteractionController
{    
    // Checks for colliders in Transform area to interact with
    void OnEKeyPressed();
}

####NPC Controller Handles interaction between character and NPCs

####Inventory Controller Handles interaction between character and NPCs

class InteractionContoller
{
    // This dictionary will allow specific actions (ex: open the confirmation box for chopping down trees
    //   or opening a storage container in a house) 
    Dictionary <Collider, IAction> reactions;
    
    // This model will hold the current model showing and the item selected
    InventoryModel model;

    // These will handle checking for where the mouse is clicked on the inventory gui
    MousePressed()
    MouseReleased()
    
}
class GUIFrameController
{
    // This dictionary will allow specific actions based on which button on the GUI is pressed 
    Dictionary <string, IAction> reactions;    
    
   // Handles button action
   ButtonPressed(string);
}

##View Controllers These controllers listen for changes in the Model and react by informing Unity of necessary changes to the View.

####Character Movement Controller

class CharacterListener
{
    //When Character is changed, update character/inventory on screen.
    void OnCharacterChanged()
    {


    }

    void OnInventoryChanged(Inventory inventory)
    {

    }
}

####NPC Movement Controller

class NPCListener
{
    //When NPC is changed, update NPCs on screen.
    void OnNPCChanged()
}

####Meter View Controller

class MeterListener
{
    //When Meter changed, update Meters on screen.
    void OnMeterChanged(MeterList meters)
    {
       foreach(meter in meters)
          Update meter gui
    }
}

####GUI Controller

class GUIListener
{
    //When GUI is changed, update GUI on screen.
    void OnGUIChanged(GUIModel gui)
    {
       Currentgui.visable = false
       Newgui.visible = true
    }
}

####Environment Controller

class EnvironmentListener
{
    //When Environment is changed, update the environment
    void OnEnvironmentChanged(Environment environment) 
    {
      foreach (resource in environment.ResourceObjects)
         unity.changeimage(resource)
    }
}

####Scene Controller

class SceneListener
{
    //When Scene is changed, update scene.
    void OnSceneChanged(SceneModel scene) 
    {
       Unity.changescene(scene.currentscene)
    }
}

Clone this wiki locally