This commit is contained in:
Bryce Covert
2016-08-01 18:36:05 -07:00
parent 9139a37119
commit 0a3b10b221
11 changed files with 96 additions and 64 deletions

View File

@@ -53,6 +53,6 @@
:warn-on-reflection true}
}
:aot [advent.core.desktop-launcher]
:aot [advent.core.desktop-launcher advent.tryitout]
:main advent.core.desktop-launcher)

View File

@@ -538,10 +538,11 @@
(defn update-state [entities f]
(update-entities entities #(update-in % [:state] f)))
(defn remove-item [entities item]
(defn remove-item [entities item & {:keys [quiet?] :or {quiet? false}}]
(run-action entities
(begin [this screen entities]
(screen! @(resolve 'advent.screens.scene/hud) :on-remove-item :item ((:all-items entities) item))
(when-not quiet?
(screen! @(resolve 'advent.screens.scene/hud) :on-remove-item :item ((:all-items entities) item)))
(-> entities
(update-in [:state :inventory] #(remove (partial = item) %))))

View File

@@ -17,9 +17,9 @@
InputMultiplexer InputProcessor Net Preferences Screen]))
(defn close [screen entities]
(defn close [screen entities script-started?]
(log/info "closing inventory")
(screen! @(resolve 'advent.screens.scene/scene) :on-reactivate)
(screen! @(resolve 'advent.screens.scene/scene) :on-reactivate :script-started? script-started?)
(-> entities
(assoc-in [:tweens :fade-out] (tween/tween :fade-out screen [:opacity] 1.0 0.0 0.2 :ease tween/ease-out-cubic
:finish #(assoc % :shown? false)))))
@@ -44,8 +44,8 @@
(screen! @(resolve 'advent.screens.scene/scene) :on-chose-item :item highlighted-item)
(when-let [interaction-script ((or (:scripts highlighted-item) (constantly nil)) (:value current-cursor))]
(interaction-script room-entities)
(close screen entities)))
(close screen entities))))
(close screen entities true)))
(close screen entities false))))
(defn right-click [screen entities]
(let [{:keys [highlighted-item]} entities

View File

@@ -3,60 +3,60 @@
(def make-cat-toy
(actions/get-script entities
(actions/remove-item entities :stick)
(actions/remove-item entities :wool)
(actions/remove-item entities :stick :quiet? true)
(actions/remove-item entities :wool :quiet? true)
(actions/give entities :cat-toy)
(actions/talk entities :ego "It makes a little cat toy!")))
(defn make-cream-of-mushroom [entities]
(actions/remove-item entities :flask-1-with-mushrooms)
(actions/remove-item entities :flask-1-with-milk)
(actions/remove-item entities :mushrooms)
(actions/remove-item entities :flask-1-with-mushrooms :quiet? true)
(actions/remove-item entities :flask-1-with-milk :quiet? true)
(actions/remove-item entities :mushrooms :quiet? true)
(actions/give entities :flask-1-with-cream-of-mushroom)
(actions/talk entities :ego "It's just like cream of mushroom soup."))
(defn add-slobber []
(actions/get-script entities
(actions/remove-item entities :flask-1-with-cream-of-mushroom)
(actions/remove-item entities :slobber)
(actions/remove-item entities :flask-1-with-cream-of-mushroom :quiet? true)
(actions/remove-item entities :slobber :quiet? true)
(actions/give entities :flask-1-slobber)
(actions/talk entities :ego "I put the slobber in with the cream of mushroom.")))
(defn make-strength-potion []
(actions/get-script entities
(actions/remove-item entities :flask-1-slobber)
(actions/remove-item entities :mandrake)
(actions/remove-item entities :flask-1-slobber :quiet? true)
(actions/remove-item entities :mandrake :quiet? true)
(actions/give entities :flask-1-strength)
(actions/talk entities :ego "It's the completed strength potion!")
(actions/glad entities)))
(defn make-water-and-ash [entities]
(actions/remove-item entities :flask-water)
(actions/remove-item entities :ash)
(actions/remove-item entities :flask-water :quiet? true)
(actions/remove-item entities :ash :quiet? true)
(actions/give entities :flask-water-ash)
(actions/talk entities :ego "I added the ashes to the water."))
(defn make-water-and-flies [entities]
(actions/remove-item entities :flask-water)
(actions/remove-item entities :flies)
(actions/remove-item entities :flask-water :quiet? true)
(actions/remove-item entities :flies :quiet? true)
(actions/give entities :flask-water-flies)
(actions/talk entities :ego "I put those flies in the flask."))
(defn make-flies-ash [entities]
(actions/remove-item entities :flask-water)
(actions/remove-item entities :flask-water-ash)
(actions/remove-item entities :flask-water-flies)
(actions/remove-item entities :ash)
(actions/remove-item entities :flies)
(actions/remove-item entities :flask-water :quiet? true)
(actions/remove-item entities :flask-water-ash :quiet? true)
(actions/remove-item entities :flask-water-flies :quiet? true)
(actions/remove-item entities :ash :quiet? true)
(actions/remove-item entities :flies :quiet? true)
(actions/give entities :flask-flies-ash)
(actions/talk entities :ego "Now it's got the fountain water, flies, and the ashes in it."))
(defn make-finished-component [entities]
(actions/talk entities :ego "I'll just mix this up.")
(actions/remove-item entities :flask-flies-ash)
(actions/remove-item entities :feather)
(actions/remove-item entities :flask-flies-ash :quiet? true)
(actions/remove-item entities :feather :quiet? true)
(actions/play-animation entities :ego :reach)
(actions/give entities :spell-component)
(actions/talk entities :ego "It looks like it's ready!"))
@@ -64,8 +64,8 @@
(defn add-mushrooms-to-flask []
(actions/get-script entities
(if (actions/has-item? entities :recipe)
(do (actions/remove-item entities :flask-1)
(actions/remove-item entities :mushrooms)
(do (actions/remove-item entities :flask-1 :quiet? true)
(actions/remove-item entities :mushrooms :quiet? true)
(actions/give entities :flask-1-with-mushrooms)
(actions/talk entities :ego "I'll just put a few of these in here."))
(actions/talk entities :ego "I don't know if I could get them back out."))))

View File

@@ -12,8 +12,8 @@
: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 region) 0))
height (or height (if (instance? TextureRegion region ) (.getRegionHeight region) 0))
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)

View File

@@ -439,9 +439,9 @@
(actions/walk-straight-to entities :ego [180 100] :anim :jumping-straight :update-baseline? false :stop? false :speed 2.0)
(actions/walk-straight-to entities :ego [190 30] :anim :jumping-straight :update-baseline? false :stop? false :speed 3.0)
(actions/walk-straight-to entities :ego [200 -80] :anim :jumping-straight :update-baseline? false :stop? false :speed 8.0)
(actions/remove-item entities :dream-sword)
(actions/remove-item entities :broom)
(actions/remove-item entities :shovel)
(actions/remove-item entities :dream-sword :quiet? true)
(actions/remove-item entities :broom :quiet? true)
(actions/remove-item entities :shovel :quiet? true)
(actions/transition-background entities :inside-castle [92 150] :time 8.0)
(actions/resume-camera entities)
(actions/walk-straight-to entities :ego [79 145] :stop? false)

View File

@@ -262,10 +262,16 @@
:frankie "And some gold..."
:frankie "And what's this?")
(actions/play-animation entities :frankie :reach)
(actions/remove-item entities :slingshot)
(actions/remove-item entities :medal)
(actions/remove-item entities :trophy)
(actions/do-dialogue entities
:frankie "The Slinger's Shot?"
:ego "No, not the Slinger's Shot!"
:frankie "Looks like we hit the jackpot tonight, boys!")
(actions/remove-item entities :flask-1-strength)
(frankie-comment-on-item entities)
(actions/update-state entities #(assoc % :bubba-gone? true))
(actions/do-dialogue entities
@@ -278,10 +284,6 @@
:frankie "Before we decide to take all of your stuff."
:ego "But I need that slingshot!"
:frankie "Too bad. Move along.")
(actions/remove-item entities :flask-1-strength)
(actions/remove-item entities :medal)
(actions/remove-item entities :trophy)
(actions/remove-item entities :slingshot)
(actions/walk-to entities :ego [181 79])
(actions/do-dialogue entities

View File

@@ -121,7 +121,7 @@
(actions/play-animation entities :ego :reach-stop :stop? true)
(actions/remove-item entities :slingshot)
(actions/remove-item entities :slingshot :quiet? true )
(actions/give entities :magic-slingshot)
(actions/do-dialogue entities :ego "It worked!")
@@ -751,7 +751,7 @@
(if (is-sheep-close? @entities)
(do (walk-to-sheep entities)
(actions/play-animation entities :ego :milk)
(actions/remove-item entities :flask-1)
(actions/remove-item entities :flask-1 :quiet? true)
(actions/give entities :flask-1-with-milk)
(actions/talk entities :ego "Sheep's milk.")
)

View File

@@ -213,7 +213,7 @@
:scripts {:flask-2 (actions/get-script entities
(actions/walk-to entities :ego [151 119] :face :right)
(actions/play-animation entities :ego :reach)
(actions/remove-item entities :flask-2)
(actions/remove-item entities :flask-2 :quiet? true)
(actions/give entities :flask-water)
(actions/talk entities :ego "Filled up with water, just as Gandarf wanted."))}}}
:layers {:day [(assoc (utils/get-texture "outside-jail/background.png") :x 0 :y 0 :baseline 0)

View File

@@ -1048,16 +1048,14 @@ void main ()
(defn get-rendered [entities e]
(as-> e e
(merge e
(when (#{:night :sunrise} (get-in entities [:state :time]))
(get-in entities [:time-profiles (:night-profile e :default)]))
)
(when (and (not= (:time e) (get-in entities [:state :time]))
(#{:night :sunrise} (get-in entities [:state :time])))
(assoc (get-in entities [:time-profiles (:night-profile e :default)])
:time (get-in entities [:state :time]))))
(if (:offset-y e)
(assoc e :y (+ (:y e) (:offset-y e)))
e)))
(defn mouse-moved [{:keys [input-x input-y viewport] :as screen} [entities]]
(utils/update-override screen (assoc-in entities [:cursor :last-pos] [input-x input-y])))
@@ -1365,8 +1363,8 @@ void main ()
:on-deactivate (fn [screen [entities]]
(assoc-in entities [:state :active?] false))
:on-reactivate (fn [screen [entities]]
(screen! hud :on-reactivate :cursor (get-in entities [:cursor :current]))
:on-reactivate (fn [{:keys [script-started?] :as screen} [entities]]
(screen! hud :on-reactivate :cursor (get-in entities [:cursor :current]) :script-started? script-started?)
(-> entities
(assoc-in [:state :active?] true)
(assoc-in [:cursor :current] :main)))
@@ -1571,7 +1569,7 @@ void main ()
(start-transition [this screen entities]
(update-in entities [:inventory] (fn [i] (actions/start-animation screen i :closing))))
(transition-done? [this screen entities] true))
(appear-transition state-data :hide :in)
(appear-transition (or state-data (get-in entities [:inv-fsm :state-data])) :hide :in)
(reify ITransition
(start-transition [this screen entities]
@@ -1609,6 +1607,29 @@ void main ()
(accept-state entities state state-data
[(appear-transition state-data :show :out)]))
(defmethod transition-hud [:none :remove]
[screen entities state state-data]
(accept-state entities state state-data
[(reify ITransition
(start-transition [this screen entities]
(update-in entities [:inventory] (fn [i] (actions/start-animation screen i :open))))
(transition-done? [this screen entities]
(animation! (get-in entities [:inventory :anim])
:is-animation-finished
(- (:total-time screen) (get-in entities [:inventory :anim-start])))))
(appear-transition state-data :show :out)
(reify ITransition
(start-transition [this screen entities]
(update-in entities [:inventory] (fn [i] (actions/start-animation screen i :closing))))
(transition-done? [this screen entities] true))
(appear-transition state-data :hide :far-out)
(reify ITransition
(start-transition [this screen entities]
(dissoc entities :selected-item))
(transition-done? [this screen entities]
true))]))
(defmethod transition-hud [:remove :none]
[screen entities state state-data]
(accept-state entities state state-data
@@ -1809,19 +1830,23 @@ void main ()
:on-return-item
(fn [screen [ entities]]
(if (hud-interactable?)
(transition-hud screen entities :none (get-in entities [:inv-fsm :state-data]))))
(-> entities
(update-in [:inv-fsm :pending-states] conj [:none (get-in entities [:inv-fsm :state-data])]))))
:on-start-script
(fn [_ [entities]]
(assoc-in entities [:already-saved?] false))
(println "here")
(-> entities
(update-in [:inv-fsm :pending-states] conj [:none nil])
(assoc-in [:already-saved?] false)))
:on-reactivate
(fn [{:keys [cursor] :as screen} [entities]]
(fn [{:keys [cursor script-started?] :as screen} [entities]]
(let [selected-item? (and (:value cursor)
(:cursor cursor))]
(if selected-item?
(if (and (not script-started?) selected-item?)
(transition-hud screen entities :selected cursor)
(transition-hud screen entities :none nil))))

View File

@@ -24,16 +24,20 @@
(dec (* t (- t 2))))
start)))))
(defn ease-in-out-quintic [t start delta duration]
(let [t (/ t (/ duration 2))]
(if (< t 1)
(+ (* (/ delta 2)
t t t t t)
start)
(let [t (- t 2)]
(+ (* (/ (- delta) 2)
(- (* t t t t) 2))
start)))))
(defn ease-in-out-quintic ^double [^double t ^double start ^double delta ^double duration]
(binding [*unchecked-math* true]
(let [t (/ t (/ duration (double 2.0)))]
(if (< t (double 1))
(let [result (+ (* (/ delta (double 2.0))
t t t t t) start)]
result)
(let [t (- t (double 2.0))
result (+ (* (/ (- delta) (double 2.0))
(- (* t t t t) (double 2.0)))
start)]
result
)))))
(defn ease-out-quadratic [t start delta duration]
(let [t (/ t duration)]