public Caravel_Lantern(CaravelInterface newShip) : base(newShip) { //currently uses new keyword, but because Plating is a unity MonoBehavior, throws console a warning (not sure how to fix) Lanterns newLanterns = new Lanterns(); newLanterns.AddLanterns(); }
/* * //Currently Redacted, changing functionality of ship adds unfoseen issues, WIP * void AddFunctionality() * { * foreach (Perk p in PerkList) * { * if (p.state) * { * AddFunction(p); * } * } * return; * } * * void AddFunction(Perk p) * { * switch (p.ToggleName) * { * case "PlatingToggle": * Debug.Log("Adding bonus HP"); * GetComponent<Health>().MaxHealthChange(150f); * break; * case "SailsToggle": * Debug.Log("Increasing Engine Power"); * // * break; * case "LanternToggle": * // * break; * default: * Debug.Log("Unknown perk request"); * break; * } * return; * } */ //Attributes and their corresponding decorator functions void AddAttribute(Perk p) { switch (p.ToggleName) { case "PlatingToggle": Debug.Log("CM: Adding Plating"); Ship = new Caravel_Plating(Ship); break; case "SailsToggle": Debug.Log("CM: Adding Sails"); Ship = new Caravel_Sails(Ship); break; case "LanternToggle": Debug.Log("CM: Adding Lantern"); Ship = new Caravel_Lantern(Ship); break; default: Debug.Log("Unknown perk request"); break; } return; }
CaravelInterface Ship; //decorator pattern interface void Awake() { Ship = new PlainShip(); //using decorator, basic concrete plain ship component Debug.Log("Caravel maker here: reading from perks and setting components"); InitializePerkListItems(); InitilizeStates(); SetComponents(Ship); return; }
void SetComponents(CaravelInterface Ship) { foreach (Perk p in PerkList) { if (p.state) { AddAttribute(p); } } return; }
Caretaker BabySitter; //memento pattern caretaker void Start() { Ship = new PlainShip(); Origin = new Originator(); //-- Initialize buttons, listeners, and the perk items, perk toggle states, set onscreen toggles to false InitializeButtons(); InitializeButtonListeners(); InitializePerkListItems(); InitilizeStates(); SetTogglesFalse(); //-- Set the Originator's states to the current states read from file, create a memento of these states if user wishes to undo Origin.State = (GenerateStateString()); BabySitter = new Caretaker(); BabySitter.Memento = Origin.CreateMemento(); }
public ShipDecorator(CaravelInterface newShip) { temp = newShip; }