From 766757b2ccffdd63cf7bcd7500b79a24965f21b2 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Sat, 27 Dec 2014 12:52:21 -0800 Subject: [PATCH] opening the cell. --- desktop/src-common/advent/actions.clj | 17 ++++++++++------- .../advent/screens/rooms/inside_jail.clj | 19 ++++++++++++++----- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index 6ec8dd35..27bac2d4 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -99,13 +99,16 @@ (or (get-in entity [(:facing entity) anim]) (get entity anim)))) -(defn start-animation [screen entity anim] - (let [new-anim (find-animation entity anim)] - (if (and anim (not= new-anim (:anim entity))) - (assoc entity - :anim new-anim - :anim-start (:total-time screen)) - entity))) +(defn start-animation + ([entity anim] + (start-animation {:total-time 0} entity anim)) + ([screen entity anim] + (let [new-anim (find-animation entity anim)] + (if (and anim (not= new-anim (:anim entity))) + (assoc entity + :anim new-anim + :anim-start (:total-time screen)) + entity)))) (defn stop [screen entities target-id & {:keys [face]}] (update-in entities [:room :entities target-id] (comp #(start-animation screen % :stand) (if face #(assoc % :facing face) identity)))) diff --git a/desktop/src-common/advent/screens/rooms/inside_jail.clj b/desktop/src-common/advent/screens/rooms/inside_jail.clj index e6277360..923ac313 100644 --- a/desktop/src-common/advent/screens/rooms/inside_jail.clj +++ b/desktop/src-common/advent/screens/rooms/inside_jail.clj @@ -86,7 +86,8 @@ (actions/play-animation entities :ego :squat) (actions/do-dialogue entities :ego "You know, in some games, you have to try multiple times." - :ego "I'm beginning to feel like this isn't that game."))) + :ego "But I have a feeling each time you click on this hay, I'm going to find nothing." + :ego "Maybe you should give it a rest."))) (actions/update-state entities #(assoc % :hay-searches (inc hay-searches))))) (defn make [screen] @@ -105,7 +106,11 @@ :script (actions/get-script entities (actions/walk-to entities :ego [174 80] :face :right) (actions/play-animation entities :ego :reach) - (actions/talk entities :ego "There's no helping it. It's locked."))} + (actions/talk entities :ego "There's no helping it. It's locked.")) + :scripts {:key (actions/get-script entities + (actions/walk-to entities :ego [174 80] :face :right) + (actions/play-animation entities :ego :reach) + (actions/talk entities :ego "Yes, that's it!"))}} :window {:box [98 110 118 140] :script (actions/get-script entities (actions/walk-to entities :ego [102 88] :face :right) @@ -152,6 +157,10 @@ :scale-fn (utils/scaler-fn-with-baseline 0 0.50 1.5) :start-pos [130 85] :apply-state (fn [entities] - (if (actions/has-item? entities :ball-n-chain) - (update-in entities [:room :entities] #(dissoc % :ball-n-chain)) - entities))))) + (as-> entities entities + (if (actions/has-item? entities :ball-n-chain) + (update-in entities [:room :entities] #(dissoc % :ball-n-chain)) + entities) + (if (get-in entities [:state :warden-sleeping?]) + (update-in entities [:room :entities :warden] #(actions/start-animation % :sleep)) + entities))))))