fixed inventory and junk.
This commit is contained in:
@@ -62,42 +62,34 @@
|
|||||||
|
|
||||||
(defn left-click [screen entities]
|
(defn left-click [screen entities]
|
||||||
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
||||||
(cond
|
(let [interaction (first (filter #((:mouse-in? %) entities x y)
|
||||||
((:mouse-in? (:inventory entities)) x y)
|
(get-in entities [:room :interactions])))
|
||||||
(click-inventory screen entities)
|
interacting-entity (first (sort-by (comp - :baseline) (filter #(and (:mouse-in? %)
|
||||||
(utils/intersects? (:close entities) [x y])
|
(:get-script %)
|
||||||
(assoc-in entities [:tweens :fade-out] (tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0 :finish #(do (set-screen! @(resolve 'advent.core/advent) @(resolve 'advent.screens.title/title-screen))
|
((:mouse-in? %) entities x y))
|
||||||
%)))
|
(vals (get-in entities [:room :entities])))))
|
||||||
|
current-action (get-in entities [:actions :current])
|
||||||
|
|
||||||
|
;; TODO - hacky way of resetting queue
|
||||||
|
entities (if (and current-action (actions/can-skip? current-action screen entities))
|
||||||
|
(let [terminated-entities (actions/terminate current-action screen entities)]
|
||||||
|
(do (put! (actions/get-channel current-action) terminated-entities)
|
||||||
|
(-> terminated-entities
|
||||||
|
(assoc-in [:actions :current] nil)
|
||||||
|
(assoc-in [:actions :started?] false))))
|
||||||
|
entities)]
|
||||||
|
|
||||||
:else
|
(if (get-in entities [:actions :script-running?])
|
||||||
(let [interaction (first (filter #((:mouse-in? %) entities x y)
|
entities
|
||||||
(get-in entities [:room :interactions])))
|
((or (when interacting-entity
|
||||||
interacting-entity (first (sort-by (comp - :baseline) (filter #(and (:mouse-in? %)
|
((:get-script interacting-entity) (get-in entities [:cursor :current]) [x y]))
|
||||||
(:get-script %)
|
(when interaction
|
||||||
((:mouse-in? %) entities x y))
|
((:get-script interaction) (or (when (:cursor interaction) :main)
|
||||||
(vals (get-in entities [:room :entities])))))
|
(get-in entities [:cursor :current]))
|
||||||
current-action (get-in entities [:actions :current])
|
[x y]))
|
||||||
|
|
||||||
;; TODO - hacky way of resetting queue
|
((:get-script default-interaction) (get-in entities [:cursor :current]) [x y])) entities))
|
||||||
entities (if (and current-action (actions/can-skip? current-action screen entities))
|
entities)))
|
||||||
(let [terminated-entities (actions/terminate current-action screen entities)]
|
|
||||||
(do (put! (actions/get-channel current-action) terminated-entities)
|
|
||||||
(-> terminated-entities
|
|
||||||
(assoc-in [:actions :current] nil)
|
|
||||||
(assoc-in [:actions :started?] false))))
|
|
||||||
entities)]
|
|
||||||
|
|
||||||
(if (get-in entities [:actions :script-running?])
|
|
||||||
entities
|
|
||||||
((or (when interacting-entity
|
|
||||||
((:get-script interacting-entity) (get-in entities [:cursor :current]) [x y]))
|
|
||||||
(when interaction
|
|
||||||
((:get-script interaction) (or (when (:cursor interaction) :main)
|
|
||||||
(get-in entities [:cursor :current]))
|
|
||||||
[x y]))
|
|
||||||
|
|
||||||
((:get-script default-interaction) (get-in entities [:cursor :current]) [x y])) entities))
|
|
||||||
entities))))
|
|
||||||
|
|
||||||
(defn drink-blergh [entities]
|
(defn drink-blergh [entities]
|
||||||
(actions/walk-straight-to entities :ego [205 45])
|
(actions/walk-straight-to entities :ego [205 45])
|
||||||
@@ -441,8 +433,6 @@
|
|||||||
:value 0.0}
|
:value 0.0}
|
||||||
:music-override {:object nil
|
:music-override {:object nil
|
||||||
:value nil}
|
:value nil}
|
||||||
:close (assoc (texture "close.png") :x 304 :y 224 :width 16 :height 16 :baseline 9000)
|
|
||||||
|
|
||||||
:cursor {:id "cursor"
|
:cursor {:id "cursor"
|
||||||
:current :main
|
:current :main
|
||||||
:last :main
|
:last :main
|
||||||
@@ -452,10 +442,7 @@
|
|||||||
:fade-in-music (tween/tween :fade-in-music screen [:volume :value] 0.0 1.0 1.5 :ease tween/ease-in-cubic)}
|
:fade-in-music (tween/tween :fade-in-music screen [:volume :value] 0.0 1.0 1.5 :ease tween/ease-in-cubic)}
|
||||||
:all-items (assoc items/items :object nil)
|
:all-items (assoc items/items :object nil)
|
||||||
:room (as-> (get rooms (:last-room (get-state))) room
|
:room (as-> (get rooms (:last-room (get-state))) room
|
||||||
(assoc-in room [:entities :ego] (get-ego screen (:start-pos room) ((:scale-fn room) (:start-pos room)))))
|
(assoc-in room [:entities :ego] (get-ego screen (:start-pos room) ((:scale-fn room) (:start-pos room)))))}]
|
||||||
:inventory (assoc (texture "inventory.png") :x 278 :y 0 :baseline 9000
|
|
||||||
:mouse-in? (zone/box 278 0 320 42))
|
|
||||||
:fps (assoc (label "0" (color :white) ) :x 5 :baseline 0)}]
|
|
||||||
(music! (utils/get-current-music entities) :set-volume (get-in entities [:volume :value]))
|
(music! (utils/get-current-music entities) :set-volume (get-in entities [:volume :value]))
|
||||||
|
|
||||||
(utils/play-sound (get-in entities [:musics (actions/get-music (get-in entities [:room :music]) (get-in entities [:state :time]))]))
|
(utils/play-sound (get-in entities [:musics (actions/get-music (get-in entities [:room :music]) (get-in entities [:state :time]))]))
|
||||||
@@ -513,11 +500,7 @@
|
|||||||
(doseq [m (vals (get-in entities [:musics]))]
|
(doseq [m (vals (get-in entities [:musics]))]
|
||||||
(when m
|
(when m
|
||||||
(music! m :set-volume (get-in entities [:volume :value]))))
|
(music! m :set-volume (get-in entities [:volume :value]))))
|
||||||
|
|
||||||
|
|
||||||
(label! (:fps entities) :set-text (str (game :fps)))
|
|
||||||
(render! screen (sort-by :baseline all-entities))
|
(render! screen (sort-by :baseline all-entities))
|
||||||
(render! screen [(:fps entities)])
|
|
||||||
entities))
|
entities))
|
||||||
|
|
||||||
:on-resize (fn [screen entities]
|
:on-resize (fn [screen entities]
|
||||||
@@ -552,6 +535,47 @@
|
|||||||
:on-chose-item (fn [{:keys [item]} [entities]]
|
:on-chose-item (fn [{:keys [item]} [entities]]
|
||||||
(assoc-in entities [:cursor :current] item))
|
(assoc-in entities [:cursor :current] item))
|
||||||
|
|
||||||
|
:on-show-inventory (fn [screen [entities]]
|
||||||
|
(click-inventory screen entities))
|
||||||
|
:on-close (fn [screen [entities]]
|
||||||
|
(assoc-in entities [:tweens :fade-out] (tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0 :finish #(do (set-screen! @(resolve 'advent.core/advent) @(resolve 'advent.screens.title/title-screen))
|
||||||
|
%))))
|
||||||
|
|
||||||
:on-start-script (fn [{:keys [script]} [entities]]
|
:on-start-script (fn [{:keys [script]} [entities]]
|
||||||
(script entities)
|
(script entities)
|
||||||
entities))
|
entities))
|
||||||
|
|
||||||
|
(defscreen hud
|
||||||
|
:on-show
|
||||||
|
(fn [screen entities]
|
||||||
|
(let [screen (assoc screen :total-time 0)]
|
||||||
|
(update! screen :renderer (stage) :camera (orthographic))
|
||||||
|
{:close (assoc (texture "close.png") :x 304 :y 224 :width 16 :height 16 :baseline 9000)
|
||||||
|
:inventory (assoc (texture "inventory.png") :x 278 :y 0 :baseline 9000
|
||||||
|
:mouse-in? (zone/box 278 0 320 42))
|
||||||
|
:fps (assoc (label "0" (color :white) ) :x 5 :baseline 0)}))
|
||||||
|
|
||||||
|
:on-render
|
||||||
|
(fn [screen [entities]]
|
||||||
|
(label! (:fps entities) :set-text (str (game :fps)))
|
||||||
|
(render! screen [(:fps entities) (:inventory entities) (:close entities)])
|
||||||
|
entities)
|
||||||
|
|
||||||
|
:on-resize
|
||||||
|
(fn [screen entities]
|
||||||
|
(size! screen 320 240))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:on-touch-up
|
||||||
|
(fn [screen [entities]]
|
||||||
|
(if (= (button-code :left) (:button screen))
|
||||||
|
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
||||||
|
(cond ((:mouse-in? (:inventory entities)) x y)
|
||||||
|
(screen! scene :on-show-inventory)
|
||||||
|
|
||||||
|
(utils/intersects? (:close entities) [x y])
|
||||||
|
(screen! scene :on-menu)
|
||||||
|
|
||||||
|
:else
|
||||||
|
nil)))))
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0
|
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0
|
||||||
:finish (fn [entities]
|
:finish (fn [entities]
|
||||||
(utils/stop-sound (:music entities))
|
(utils/stop-sound (:music entities))
|
||||||
(set-screen! @(resolve 'advent.core/advent) scene/scene dialogue/talking-screen dialogue/choice-screen inventory/inventory-screen safe/safe-screen)
|
(set-screen! @(resolve 'advent.core/advent) scene/scene scene/hud dialogue/talking-screen dialogue/choice-screen inventory/inventory-screen safe/safe-screen )
|
||||||
entities)
|
entities)
|
||||||
:ease tween/ease-in-cubic))
|
:ease tween/ease-in-cubic))
|
||||||
(assoc-in [:tweens :fade-out-music]
|
(assoc-in [:tweens :fade-out-music]
|
||||||
|
|||||||
Reference in New Issue
Block a user