jail scene coming together
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
(ns advent.screens.rooms.inside-jail
|
||||
(:require [advent.screens.rooms :as rooms]
|
||||
(:require [clojure.core.async :refer [chan]]
|
||||
[advent.screens.rooms :as rooms]
|
||||
[advent.actions :as actions]
|
||||
[advent.screens.items :as items]
|
||||
[advent.utils :as utils]
|
||||
@@ -30,6 +31,9 @@
|
||||
(actions/do-dialogue entities
|
||||
:ego "Hey!"
|
||||
:ego "All my possessions are in here!")
|
||||
(actions/update-state entities #(-> %
|
||||
(assoc :inventory (concat (:inventory %) (:chest-contents %)))
|
||||
(assoc :chest-contents [])))
|
||||
(when (not (actions/has-obtained? entities :rope))
|
||||
(actions/do-dialogue entities :ego "Looks like there's some rope in here too.")))
|
||||
|
||||
@@ -121,6 +125,11 @@
|
||||
:ego "Maybe you should give it a rest.")))
|
||||
(actions/update-state entities #(assoc % :hay-searches (inc hay-searches)))))
|
||||
|
||||
(defn go-to-jail [entities]
|
||||
(actions/update-state entities #(assoc % :chest-contents (remove #{:key} (:inventory %))))
|
||||
(actions/update-state entities #(assoc % :inventory []))
|
||||
(actions/update-state entities #(assoc % :opened-bars? false))
|
||||
(actions/transition-background entities :inside-jail [130 85]))
|
||||
|
||||
|
||||
(defn make [screen]
|
||||
@@ -152,10 +161,40 @@
|
||||
:script (actions/get-script entities
|
||||
(search-hay entities))}
|
||||
:chest {:box [194 62 228 99]
|
||||
:script (actions/get-script entities (touch-chest entities))}}
|
||||
:script (actions/get-script entities (touch-chest entities))}
|
||||
:door {:box [257 62 301 152]
|
||||
:cursor :down
|
||||
:script (actions/get-script entities
|
||||
(if (get-in @entities [:state :opened-bars?])
|
||||
(do
|
||||
(actions/walk-to entities :ego [279 57])
|
||||
(actions/transition-background entities :outside-jail [50 46] ))
|
||||
(actions/talk entities :ego "Do you really think I can walk down those steps while I'm locked up?")))}}
|
||||
:layers [(assoc (texture "inside-jail/background.png") :x 0 :y 0 :baseline 0)
|
||||
(assoc (texture "inside-jail/bars.png") :x 0 :y 0 :baseline 165)
|
||||
(assoc (texture "inside-jail/glow.png") :x 0 :y 0 :baseline 240)]
|
||||
:hotspots [{:box [121 40 258 44]
|
||||
:fn (fn [screen entities]
|
||||
|
||||
(let [is-walking? (#{(get-in entities [:room :entities :ego :left :walk])
|
||||
(get-in entities [:room :entities :ego :right :walk])} (get-in entities [:room :entities :ego :anim]))]
|
||||
(if is-walking?
|
||||
(let [entities (-> entities
|
||||
(update-in [:actions] #(assoc % :channel (chan) :current nil :started? false))
|
||||
(update-in [:room :entities :ego] #(actions/start-animation screen % :stand)))]
|
||||
((actions/get-script entities
|
||||
(actions/stop-walking entities :ego)
|
||||
(actions/do-dialogue entities
|
||||
:ego "*creak*"
|
||||
:ego "Oops!"
|
||||
:warden "Hey! What are you doing?"
|
||||
:warden "Get back in jail.")
|
||||
(go-to-jail entities)
|
||||
(actions/do-dialogue entities :warden "Now don't let me catch you trying to escape again.")
|
||||
(actions/play-animation entities :warden :fall-asleep :stop? false)
|
||||
(actions/begin-animation entities :warden :sleep)) entities)
|
||||
entities)
|
||||
entities)))}]
|
||||
:entities {:warden (assoc (texture "inside-jail/warden.png" )
|
||||
:x 40 :y 60 :baseline 166
|
||||
:stand warden-stand
|
||||
@@ -192,7 +231,7 @@
|
||||
:start-pos [130 85]
|
||||
:apply-state (fn [entities]
|
||||
(as-> entities entities
|
||||
(if (actions/has-item? entities :ball-n-chain)
|
||||
(if (actions/has-obtained? entities :ball-n-chain)
|
||||
(update-in entities [:room :entities] #(dissoc % :ball-n-chain))
|
||||
entities)
|
||||
(if (get-in entities [:state :warden-sleeping?])
|
||||
|
||||
Reference in New Issue
Block a user