From 86d1f7273da57ea1f853c699349c386eda067033 Mon Sep 17 00:00:00 2001 From: Remington Covert Date: Sun, 9 Nov 2014 10:29:27 -0800 Subject: [PATCH] can only open the safe when gandarf isn't around. --- .../advent/screens/rooms/inside_house.clj | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/desktop/src-common/advent/screens/rooms/inside_house.clj b/desktop/src-common/advent/screens/rooms/inside_house.clj index cfd9159a..3d46942d 100644 --- a/desktop/src-common/advent/screens/rooms/inside_house.clj +++ b/desktop/src-common/advent/screens/rooms/inside_house.clj @@ -9,6 +9,19 @@ [play-clj.utils :refer :all] [play-clj.g2d :refer :all])) +(defn do-wizard-dialogue [entities] + (actions/do-dialogue entities :wizard "What can I do for you boy?") + (actions/present-choices entities + {:choices [(when (= 3 (get-in @entities [:state :mints-eaten])) + "The antique shopkeeper needs more fire mints.") + {:run #(do (actions/respond entities % + :wizard "Already?" + :wizard "Ok, I'll deliver them myself. Don't touch anything while I'm gone.") + (actions/update-state entities (fn [s] (assoc s :mints-eaten 0))) + (actions/remove-entity entities :wizard))} + "Goodbye, Gandarf." + {:run #(actions/respond entities % :wizard "Goodbye, boy.")}]})) + (defn make [screen] (let [wizard-sheet (texture! (texture "wizard/talk.png") :split 20 46) wizard-stand (animation 0.2 (for [i (flatten [(repeat 10 0) 1])] @@ -24,19 +37,23 @@ :safe {:box [34 70 70 115] :script (actions/get-script entities (actions/walk-to entities :ego [59 65]) - (actions/play-animation entities :ego :squat) - (actions/give entities items/frog-legs) - (actions/talk entities :ego "I found some frog legs inside."))} + (if (get-in @entities [:room :entities :wizard]) + (actions/talk entities :wizard "Don't touch my MagiSafe!!") + (do + (actions/play-animation entities :ego :squat) + (actions/give entities items/frog-legs) + (actions/talk entities :ego "I found some frog legs inside."))))} } :layers [(assoc (texture "inside-house/background.png") :x 0 :y 0 :baseline 0) (assoc (texture "inside-house/desk.png") :x 0 :y 0 :baseline 200) (assoc (texture "inside-house/sillhoute.png") :x 0 :y 0 :baseline 240)] - :entities {:wizard (actions/start-animation screen (assoc (animation->texture (doto screen) wizard-stand) :x 228 :y 80 :baseline 160 :scale-x 1.75 :scale-y 1.75 + :entities {:wizard (actions/start-animation screen (assoc (animation->texture screen wizard-stand) :x 228 :y 80 :baseline 160 :scale-x 1.75 :scale-y 1.75 :left {:talk (utils/flip wizard-talk) :stand (utils/flip wizard-stand)} :right {:talk wizard-talk :stand wizard-stand} - :facing :left) + :facing :left + :script (actions/get-script entities (do-wizard-dialogue entities))) :stand) :flask (assoc (texture "inside-house/flask.png") :x 265 :y 80 :baseline 240