item interactions are beginning to form.
This commit is contained in:
@@ -79,7 +79,7 @@
|
||||
[i (assoc (label text (style :label font (color :white))) :x 30 :y (* 30 i))]))
|
||||
(assoc :state {:object nil :callback callback :choices choices}))))
|
||||
|
||||
:on-touch-down (fn [screen [entities]]
|
||||
:on-touch-up (fn [screen [entities]]
|
||||
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
||||
(when (seq entities)
|
||||
(when (< y (* 30 (dec (count entities))))
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
InputMultiplexer InputProcessor Net Preferences Screen]))
|
||||
|
||||
|
||||
(defn close [entities]
|
||||
(run! @(resolve 'advent.screens.scene/scene) :on-reactivate)
|
||||
(-> entities
|
||||
(assoc :shown? false)
|
||||
(assoc :start-showing? false)))
|
||||
|
||||
|
||||
(defscreen inventory-screen
|
||||
:on-show
|
||||
@@ -74,17 +80,21 @@
|
||||
(assoc entities :highlighted-item (:item selected-entity))
|
||||
(assoc entities :highlighted-item nil))))
|
||||
|
||||
:on-touch-down (fn [screen [entities]]
|
||||
:on-touch-up (fn [screen [entities]]
|
||||
(when (:shown? entities)
|
||||
|
||||
(let [{:keys [highlighted-item]} entities]
|
||||
(let [{:keys [highlighted-item]} entities
|
||||
room-entities (-> @(resolve 'advent.screens.scene/scene)
|
||||
:entities
|
||||
deref
|
||||
first)
|
||||
current-cursor (get-in room-entities [:cursor :current])]
|
||||
(if highlighted-item
|
||||
(run! @(resolve 'advent.screens.scene/scene) :on-chose-item :item highlighted-item)
|
||||
(do
|
||||
(run! @(resolve 'advent.screens.scene/scene) :on-reactivate)
|
||||
(-> entities
|
||||
(assoc :shown? false)
|
||||
(assoc :start-showing? false)))))))
|
||||
(if (= :main current-cursor)
|
||||
(run! @(resolve 'advent.screens.scene/scene) :on-chose-item :item highlighted-item)
|
||||
(when-let [interaction-script ((or (:scripts highlighted-item) (constantly nil)) current-cursor)]
|
||||
(interaction-script room-entities)
|
||||
(close entities)))
|
||||
(close entities)))))
|
||||
|
||||
:on-resize (fn [screen entities]
|
||||
(height! screen 960)
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
(ns advent.screens.items)
|
||||
(ns advent.screens.items
|
||||
(:require [advent.actions :as actions]))
|
||||
|
||||
(def wool {:name "Wool" :value :wool :cursor :wool})
|
||||
(def mushrooms {:name "Mushrooms" :value :mushrooms :cursor :mushrooms})
|
||||
(def carrot {:name "Carrot" :value :carrot :cursor :carrot})
|
||||
|
||||
(def flask-1 {:name "Flask" :value :flask-1 :cursor :flask})
|
||||
(def flask-1-with-milk {:name "Flask with milk" :value :flask-1-with-milk :cursor :flask-with-contents})
|
||||
(def flask-1-with-mushrooms {:name "Flask with mushrooms" :value :flask-1-with-mushrooms :cursor :flask-with-contents})
|
||||
(def flask-1-with-milk-mushrooms {:name "Flask with cream of mushrooms soup" :value :flask-1-with-milk-mushrooms :cursor :flask-with-contents})
|
||||
(def flask-1-with-cream-of-mushroom {:name "Flask with cream of mushrooms soup" :value :flask-1-with-cream-of-mushroom :cursor :flask-with-contents})
|
||||
|
||||
(def flask-1-with-milk {:name "Flask with milk" :value :flask-1-with-milk :cursor :flask-with-contents
|
||||
:scripts {mushrooms (actions/get-script entities
|
||||
(actions/remove-item entities flask-1-with-milk)
|
||||
(actions/give entities flask-1-with-cream-of-mushroom)
|
||||
(actions/talk entities :ego "It's just like cream of mushroom soup."))}})
|
||||
|
||||
(def flask-1-strength {:name "Strength potion" :value :flask-1-strength :cursor :flask-with-contents})
|
||||
(def flask-1 {:name "Flask" :value :flask-1 :cursor :flask
|
||||
:scripts {mushrooms (actions/get-script entities
|
||||
(actions/remove-item entities flask-1)
|
||||
(actions/give entities flask-1-with-mushrooms)
|
||||
(actions/talk entities :ego "I'll just put a few of these in here."))}})
|
||||
|
||||
@@ -163,7 +163,6 @@
|
||||
:box [38 160 71 181]
|
||||
:script (actions/get-script
|
||||
entities
|
||||
|
||||
|
||||
(if (actions/has-item? @entities items/wool)
|
||||
(actions/talk entities :ego "The sheep has given me enough wool.")
|
||||
|
||||
@@ -187,7 +187,7 @@
|
||||
(assoc-in entities [:cursor :override] (:cursor mouse-override))
|
||||
(assoc-in entities [:cursor :override] nil)))))
|
||||
|
||||
:on-touch-down (fn [screen [entities]]
|
||||
:on-touch-up (fn [screen [entities]]
|
||||
(when (get-in entities [:state :active?])
|
||||
(if (= (button-code :right)
|
||||
(:button screen))
|
||||
|
||||
Reference in New Issue
Block a user