picking up the teddy and portait add and remove entities.
This commit is contained in:
@@ -10,18 +10,20 @@
|
||||
(merge entity
|
||||
{:id id
|
||||
:mouse-in? (fn [entities x y]
|
||||
(let [{entity-x :x entity-y :y width :width scale-x :scale-x scale-y :scale-y origin-x :origin-x origin-y :origin-y height :height region :object} (get-in entities [:room :entities id])
|
||||
|
||||
width (or width (if (instance? TextureRegion region ) (.getRegionWidth ^TextureRegion region) 0))
|
||||
height (or height (if (instance? TextureRegion region ) (.getRegionHeight ^TextureRegion region) 0))
|
||||
entity-x (- entity-x (* (or origin-x 0)
|
||||
(or scale-x 1)))
|
||||
entity-y (- entity-y (* (or origin-y 0)
|
||||
(or scale-y 1)))]
|
||||
|
||||
((zone/box entity-x entity-y
|
||||
(+ entity-x (* width (or scale-x 1)))
|
||||
(+ entity-y (* height (or scale-y 1)))) x y)))}
|
||||
(if-let [box (get-in entities [:room :entities id :box])]
|
||||
((apply zone/box box) x y)
|
||||
(let [{entity-x :x entity-y :y width :width scale-x :scale-x scale-y :scale-y origin-x :origin-x origin-y :origin-y height :height region :object} (get-in entities [:room :entities id])
|
||||
|
||||
width (or width (if (instance? TextureRegion region ) (.getRegionWidth ^TextureRegion region) 0))
|
||||
height (or height (if (instance? TextureRegion region ) (.getRegionHeight ^TextureRegion region) 0))
|
||||
entity-x (- entity-x (* (or origin-x 0)
|
||||
(or scale-x 1)))
|
||||
entity-y (- entity-y (* (or origin-y 0)
|
||||
(or scale-y 1)))]
|
||||
|
||||
((zone/box entity-x entity-y
|
||||
(+ entity-x (* width (or scale-x 1)))
|
||||
(+ entity-y (* height (or scale-y 1)))) x y))))}
|
||||
(when (or script scripts only-script)
|
||||
{:get-script (fn [cursor [x y]]
|
||||
(cond only-script
|
||||
|
||||
@@ -159,20 +159,25 @@
|
||||
(actions/walk-to entities :ego [143 58] :face :left)
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(actions/add-entity entities :portrait (get-in @entities [:room :portrait]))
|
||||
(actions/remove-item entities :portrait))
|
||||
(actions/remove-item entities :portrait)
|
||||
(actions/remove-entity entities :return-portrait)
|
||||
(actions/remove-entity entities :return-portrait-2))
|
||||
|
||||
(defn get-portrait [entities]
|
||||
(actions/walk-to entities :ego [140 58] :face :left)
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(actions/remove-entity entities :portrait)
|
||||
(actions/give entities :portrait)
|
||||
(actions/talk entities :ego "It's a portrait. There's something on the back but it's too dim to read."))
|
||||
(actions/talk entities :ego "It's a portrait. There's something on the back but it's too dim to read.")
|
||||
(actions/add-entity entities :return-portrait-2 (get-in @entities [:room :return-portrait-2]))
|
||||
(actions/add-entity entities :return-portrait (get-in @entities [:room :return-portrait])))
|
||||
|
||||
(defn return-teddy [entities]
|
||||
(actions/walk-to entities :ego [242 49] :face :right)
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(actions/add-entity entities :teddy (get-in @entities [:room :teddy]))
|
||||
(actions/remove-item entities :teddy))
|
||||
(actions/remove-item entities :teddy)
|
||||
(actions/remove-entity entities :return-teddy))
|
||||
|
||||
(defn has-to-return-teddy? [entities]
|
||||
(and (actions/has-item? entities :teddy)
|
||||
@@ -209,6 +214,7 @@
|
||||
:script (actions/get-script entities
|
||||
(actions/walk-to entities :ego [242 49] :face :right)
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(actions/add-entity entities :return-teddy (get-in @entities [:room :return-teddy]))
|
||||
(actions/give entities :teddy)
|
||||
(actions/remove-entity entities :teddy)
|
||||
(when (not (get-in @entities [:state :allowed-to-keep-teddy?]))
|
||||
@@ -223,6 +229,39 @@
|
||||
:fire-2 (utils/load-sound "inside-antique/fire-2.ogg")
|
||||
:fire-3 (utils/load-sound "inside-antique/fire-3.ogg")
|
||||
}
|
||||
:return-portrait (rooms/make-entity :return-portrait {:box [103 70 206 116]
|
||||
:label "Desk"
|
||||
:baseline 0
|
||||
:cursor :look
|
||||
:script (actions/get-script entities (actions/talk entities :ego "It's the shopkeep's desk."))
|
||||
:scripts {:portrait (actions/get-script entities
|
||||
(return-portrait entities))
|
||||
:teddy (actions/get-script entities
|
||||
(return-teddy entities))}})
|
||||
:return-portrait-2 (rooms/make-entity :return-portrait-2
|
||||
{:box [103 116 131 131]
|
||||
:label "Desk"
|
||||
:baseline 0
|
||||
:cursor :look
|
||||
:script (actions/get-script entities (if (actions/has-item? entities :portrait)
|
||||
(actions/talk entities :ego "The shopkeep's portrait used to sit there.")
|
||||
(get-portrait entities)
|
||||
|
||||
))
|
||||
:scripts {:portrait (actions/get-script entities
|
||||
(return-portrait entities))
|
||||
:teddy (actions/get-script entities
|
||||
(return-teddy entities))}})
|
||||
:return-teddy (rooms/make-entity :return-teddy {:box [227 90 301 105]
|
||||
:baseline 0
|
||||
:cursor :look
|
||||
:label "Shelf"
|
||||
:script (actions/get-script entities
|
||||
(actions/talk entities :ego "It's a shelf."))
|
||||
:scripts {:teddy (actions/get-script entities
|
||||
(return-teddy entities))
|
||||
:portrait (actions/get-script entities
|
||||
(return-portrait entities))}})
|
||||
:interactions
|
||||
{:right {:box [250 0 320 75]
|
||||
:cursor :right
|
||||
@@ -240,35 +279,9 @@
|
||||
(actions/walk-straight-to entities :ego [320 -5])
|
||||
(actions/transition-background entities :inside-castle [182 90])
|
||||
(actions/walk-to entities :ego [187 75]))}
|
||||
:return-portrait-2 {:box [103 116 131 131]
|
||||
:label "Desk"
|
||||
:cursor :look
|
||||
:script (actions/get-script entities (if (actions/has-item? entities :portrait)
|
||||
(actions/talk entities :ego "The shopkeep's portrait used to sit there.")
|
||||
(get-portrait entities)
|
||||
|
||||
))
|
||||
:scripts {:portrait (actions/get-script entities
|
||||
(return-portrait entities))
|
||||
:teddy (actions/get-script entities
|
||||
(return-teddy entities))}}
|
||||
:return-portrait {:box [103 70 206 116]
|
||||
:label "Desk"
|
||||
:cursor :look
|
||||
:script (actions/get-script entities (actions/talk entities :ego "It's the shopkeep's desk."))
|
||||
:scripts {:portrait (actions/get-script entities
|
||||
(return-portrait entities))
|
||||
:teddy (actions/get-script entities
|
||||
(return-teddy entities))}}
|
||||
:return-teddy {:box [227 90 301 105]
|
||||
:cursor :look
|
||||
:label "Shelf"
|
||||
:script (actions/get-script entities
|
||||
(actions/talk entities :ego "It's a shelf."))
|
||||
:scripts {:teddy (actions/get-script entities
|
||||
(return-teddy entities))
|
||||
:portrait (actions/get-script entities
|
||||
(return-portrait entities))}}
|
||||
|
||||
|
||||
|
||||
:window {:box [195 121 256 190]
|
||||
:label "Window"
|
||||
:cursor :hand
|
||||
@@ -455,6 +468,17 @@
|
||||
(update-in entities [:room :entities] #(dissoc % :teddy))
|
||||
entities)
|
||||
|
||||
(if (actions/has-item? entities :portrait)
|
||||
(update-in entities [:room :entities] assoc
|
||||
:return-portrait (get-in entities [:room :return-portrait])
|
||||
:return-portrait-2 (get-in entities [:room :return-portrait-2]))
|
||||
entities)
|
||||
|
||||
(if (actions/has-item? entities :teddy)
|
||||
(update-in entities [:room :entities] assoc
|
||||
:return-teddy (get-in entities [:room :return-teddy]))
|
||||
entities)
|
||||
|
||||
(update-in entities
|
||||
[:room :entities :bowl]
|
||||
(fn [b]
|
||||
|
||||
Reference in New Issue
Block a user