more progress
This commit is contained in:
@@ -541,7 +541,7 @@
|
||||
(defn remove-item [entities item]
|
||||
(run-action entities
|
||||
(begin [this screen entities]
|
||||
(screen! @(resolve 'advent.screens.scene/hud) :on-remove-item :item item)
|
||||
(screen! @(resolve 'advent.screens.scene/hud) :on-remove-item :item ((:all-items entities) item))
|
||||
(-> entities
|
||||
(update-in [:state :inventory] #(remove (partial = item) %))
|
||||
(assoc-in [:cursor :current] :main)))
|
||||
|
||||
@@ -172,7 +172,7 @@
|
||||
(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 :portrait))
|
||||
|
||||
(defn has-to-return-teddy? [entities]
|
||||
(and (actions/has-item? entities :teddy)
|
||||
|
||||
@@ -1464,6 +1464,31 @@ void main ()
|
||||
(assoc-in [:inv-fsm :state-data] state-data)
|
||||
(assoc-in [:inv-fsm :transition-steps] transitions)))
|
||||
|
||||
(defn appear-transition [item hide-or-show in-or-out]
|
||||
(reify ITransition
|
||||
(start-transition [this screen entities]
|
||||
(let [fade-tween (if (= :hide hide-or-show)
|
||||
(tween/tween :appear-item screen [:selected-item :opacity] 1.0 0.0 0.5 :ease tween/ease-in-out-quadratic)
|
||||
(tween/tween :appear-item screen [:selected-item :opacity] 0.0 1.0 0.5 :ease tween/ease-in-out-quadratic))
|
||||
move-tween (condp = in-or-out
|
||||
:out
|
||||
(tween/tween :appear-item-y screen [:selected-item :y] 30 35 0.5 :ease tween/ease-in-out-quadratic)
|
||||
|
||||
:in
|
||||
(tween/tween :appear-item-y screen [:selected-item :y] 35 30 0.5 :ease tween/ease-in-out-quadratic)
|
||||
|
||||
:none
|
||||
(tween/tween :appear-item-y screen [:selected-item :y] 35 35 0.5 :ease tween/ease-in-out-quadratic))]
|
||||
(-> entities
|
||||
(assoc :selected-item
|
||||
(assoc (texture (aget (get-in entities [:all-items]) 0 (.indexOf utils/+all-cursors+ (:cursor item))))
|
||||
:x 300 :y 40 :baseline 9000 :opacity 0.0
|
||||
:item item))
|
||||
(assoc-in [:tweens :appear-item] fade-tween)
|
||||
(assoc-in [:tweens :appear-item-y] move-tween))))
|
||||
(transition-done? [this screen entities]
|
||||
(not (get-in entities [:tweens :appear-item])))))
|
||||
|
||||
(defmethod transition-hud [:none :open]
|
||||
[screen entities state state-data]
|
||||
(accept-state entities state state-data
|
||||
@@ -1507,25 +1532,53 @@ void main ()
|
||||
|
||||
(defmethod transition-hud [:open :selected]
|
||||
[screen entities state state-data]
|
||||
|
||||
(accept-state entities state state-data
|
||||
[(reify ITransition
|
||||
(start-transition [this screen entities]
|
||||
(-> entities
|
||||
(assoc :selected-item
|
||||
(assoc (texture (aget (get-in entities [:all-items]) 0 (.indexOf utils/+all-cursors+ (:cursor state-data))))
|
||||
:x 300 :y 40 :baseline 9000 :opacity 0.0
|
||||
:item state-data))
|
||||
(assoc-in [:tweens :appear-item]
|
||||
(tween/tween :appear-item screen [:selected-item :opacity] 0.0 1.0 0.5 :ease tween/ease-in-out-quadratic))
|
||||
(assoc-in [:tweens :appear-item-y]
|
||||
(tween/tween :appear-item-y screen [:selected-item :y] 30 35 0.5 :ease tween/ease-in-out-quadratic))))
|
||||
(transition-done? [this screen entities]
|
||||
(not (get-in entities [:tweens :appear-item]))))]))
|
||||
[(appear-transition state-data :show :out)]))
|
||||
|
||||
(defmethod transition-hud [:selected :none]
|
||||
[screen entities state state-data]
|
||||
(accept-state entities state state-data))
|
||||
(accept-state entities state state-data
|
||||
[(reify ITransition
|
||||
(start-transition [this screen entities]
|
||||
(screen! scene :on-click-inventory)
|
||||
(update-in [:inventory] (fn [i] (actions/start-animation screen i :closing))))
|
||||
(transition-done? [this screen entities] true))
|
||||
(appear-transition state-data :hide :in)
|
||||
|
||||
(reify ITransition
|
||||
(start-transition [this screen entities]
|
||||
(-> entities
|
||||
(update-in [:inventory] (fn [i] (actions/start-animation screen i :default)))
|
||||
(dissoc :selected-item)))
|
||||
(transition-done? [this screen entities]
|
||||
true))]))
|
||||
|
||||
(defmethod transition-hud [:selected :remove]
|
||||
[screen entities state state-data]
|
||||
(let [current-item (get-in entities [:inv-fsm :state-data])
|
||||
transitions (if (= state-data current-item )
|
||||
[(appear-transition state-data :hide :none)
|
||||
(reify ITransition
|
||||
(start-transition [this screen entities]
|
||||
(-> entities
|
||||
(dissoc :selected-item)))
|
||||
(transition-done? [this screen entities]
|
||||
true))]
|
||||
[(appear-transition current-item :hide :in)
|
||||
(appear-transition state-data :hide :out)
|
||||
(reify ITransition
|
||||
(start-transition [this screen entities]
|
||||
(-> entities
|
||||
(dissoc :selected-item)))
|
||||
(transition-done? [this screen entities]
|
||||
true))])]
|
||||
(accept-state entities state state-data
|
||||
transitions)))
|
||||
|
||||
(defmethod transition-hud [:remove :selected]
|
||||
[screen entities state state-data]
|
||||
(accept-state entities state state-data
|
||||
[(appear-transition state-data :show :out)]))
|
||||
|
||||
(defmethod transition-hud [:none :aquiring]
|
||||
[screen entities state state-data]
|
||||
@@ -1546,7 +1599,7 @@ void main ()
|
||||
(defn fsm-busy? [entities]
|
||||
(seq (get-in entities [:inv-fsm :transition-steps])))
|
||||
|
||||
(defn process-fsm [screen { {:keys [transition-steps current-transition] [next-state next-state-data] :pending-states [next-transition & remaining-transitions] :transition-steps} :inv-fsm :as entities}]
|
||||
(defn process-fsm [screen { {:keys [transition-steps current-transition] [[next-state next-state-data] & pending-states] :pending-states [next-transition & remaining-transitions] :transition-steps} :inv-fsm :as entities}]
|
||||
(cond
|
||||
(and current-transition (transition-done? current-transition screen entities))
|
||||
(-> entities
|
||||
@@ -1561,7 +1614,8 @@ void main ()
|
||||
(assoc-in [:inv-fsm :transition-steps] remaining-transitions))
|
||||
|
||||
next-state
|
||||
(transition-hud screen entities next-state next-state-data)
|
||||
(-> (transition-hud screen entities next-state next-state-data)
|
||||
(assoc-in [:inv-fsm :pending-states] pending-states))
|
||||
|
||||
:else
|
||||
nil))
|
||||
@@ -1776,7 +1830,7 @@ void main ()
|
||||
(as-> entities entities
|
||||
(update-in entities [:inventory] assoc :r 0.75 :g 0.75 :b 0.75)
|
||||
(grow-hud screen entities :inventory false)))
|
||||
entities (if (:selected-item entities)
|
||||
entities (if (= :selected (get-in entities [:inv-fsm :state]))
|
||||
(if hud-interactable?
|
||||
(as-> entities entities
|
||||
(update-in entities [:selected-item] assoc :r 1.0 :g 1.0 :b 1.0 ))
|
||||
@@ -1816,17 +1870,15 @@ void main ()
|
||||
|
||||
:on-remove-item
|
||||
(fn [{:keys [item] :as screen} [ entities]]
|
||||
|
||||
#_(when (= (:value item) (get-in entities [:selected-item :value]))
|
||||
(transition-hud screen entities :remove-item)))
|
||||
|
||||
(-> entities
|
||||
(update-in [:inv-fsm :pending-states] conj [:remove item])
|
||||
(update-in [:inv-fsm] (fn [{:keys [state state-data] :as fsm}]
|
||||
(update-in fsm [:pending-states] conj [state state-data])))))
|
||||
|
||||
:on-return-item
|
||||
(fn [screen [ entities]]
|
||||
(if (hud-interactable?)
|
||||
nil
|
||||
|
||||
#_(transition-hud screen entities :returning-item)))
|
||||
(transition-hud screen entities :none :in)))
|
||||
|
||||
|
||||
:on-start-script
|
||||
@@ -1886,9 +1938,8 @@ void main ()
|
||||
((:mouse-in? (:inventory entities)) x y)
|
||||
|
||||
(if (:selected-item entities)
|
||||
entities
|
||||
#_(transition-hud screen entities :returning-item)
|
||||
(doto (transition-hud screen entities :open nil) println))
|
||||
(transition-hud screen entities :none :in)
|
||||
(transition-hud screen entities :open nil))
|
||||
|
||||
(utils/intersects? (:close entities) [x y])
|
||||
(screen! scene :on-menu)
|
||||
|
||||
Reference in New Issue
Block a user