sheep hoarding.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
[advent.screens.rooms.inside-castle :as inside-castle]
|
||||
[advent.actions :as actions]
|
||||
[advent.tween :as tween]
|
||||
[advent.steam :as steam]
|
||||
[advent.utils :as utils]
|
||||
[clojure.zip :as zip]
|
||||
[clojure.string :as str]
|
||||
@@ -57,7 +58,7 @@
|
||||
ego-sheep-loc))
|
||||
|
||||
(defn is-sheep-close? [entities]
|
||||
(< (dist-to-sheep entities) 45))
|
||||
(< (dist-to-sheep entities) 50))
|
||||
|
||||
(defn is-ready-for-slingshot [entities]
|
||||
(and (actions/has-obtained? entities :broken-clock)
|
||||
@@ -65,8 +66,17 @@
|
||||
(actions/has-obtained? entities :money)
|
||||
(not (actions/has-item? entities :money))))
|
||||
|
||||
(defn set-sheep-anim [screen entities]
|
||||
(if-let [wool-count (get-in entities [:state :wool-count])]
|
||||
(update-in entities
|
||||
[:room :entities :sheep]
|
||||
#(actions/start-animation screen %
|
||||
(get % [:stand wool-count])))
|
||||
|
||||
entities))
|
||||
|
||||
(defn walk-to-sheep [entities]
|
||||
(actions/walk-to entities :ego [119 134] :skip-type :end))
|
||||
(actions/walk-to entities :ego [118 131] :skip-type :end))
|
||||
|
||||
(defn magic [entities]
|
||||
(actions/run-action entities
|
||||
@@ -592,8 +602,11 @@
|
||||
(let [sheep-stand-sheet (texture! (utils/get-texture "outsidehouse/sheep-anim.png") :split 33 21)
|
||||
sheep-walk-sheet (texture! (utils/get-texture "outsidehouse/sheep-walk.png") :split 33 21)
|
||||
lamb-walk-sheet (texture! (utils/get-texture "outsidehouse/lamb-walk.png") :split 27 28)
|
||||
sheep-stand (animation 0.15 (for [i (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 9 10 (repeat 25 11) (repeat 15 12)])]
|
||||
sheep-stand (animation 0.15 (for [i (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 2 1 (repeat 25 11) (repeat 15 12)])]
|
||||
(aget sheep-stand-sheet 0 i)))
|
||||
sheep-1 (utils/make-anim "outsidehouse/sheep-1.png" [33 21] 0.15 (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 2 1 (repeat 25 0) (repeat 15 9)]))
|
||||
sheep-2 (utils/make-anim "outsidehouse/sheep-2.png" [33 21] 0.15 (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 2 1 (repeat 25 0) (repeat 15 9)]))
|
||||
sheep-3 (utils/make-anim "outsidehouse/sheep-3.png" [33 21] 0.15 (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 2 1 (repeat 25 0) (repeat 15 9)]))
|
||||
door (utils/make-anim "outsidehouse/door.png" [24 58] 0.15 (flatten [(range 4) 3 3 3 3 3 3 3]))
|
||||
sheep-walk (animation 0.05 (for [i (range 6)]
|
||||
(aget sheep-walk-sheet 0 i)))
|
||||
@@ -668,6 +681,9 @@
|
||||
(assoc (utils/get-texture "outsidehouse/fg2.png") :x (- 320 55) :y 0 :baseline 1000 :parallax 1.5)]}
|
||||
:entities {:sheep (actions/start-animation screen
|
||||
(assoc (animation->texture screen sheep-stand) :x 38 :y 160 :baseline 80
|
||||
[:stand 1] sheep-1
|
||||
[:stand 2] sheep-2
|
||||
[:stand 3] sheep-3
|
||||
:scale-x (scaler [38 160])
|
||||
:scale-y (scaler [38 160])
|
||||
:box [38 160 71 181]
|
||||
@@ -679,6 +695,15 @@
|
||||
(if (is-sheep-close? @entities)
|
||||
(do (walk-to-sheep entities)
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(actions/update-state entities #(assoc % :wool-count (inc (or (:wool-count %) 0))))
|
||||
(when (= 3 (doto (get-in @entities [:state :wool-count]) println))
|
||||
(steam/set-achievement "SHEEP_HORDER"))
|
||||
|
||||
(actions/update-entities entities #(update-in
|
||||
% [:room :entities :sheep]
|
||||
(fn [s]
|
||||
(let [which (get-in % [:state :wool-count])]
|
||||
(assoc s :anim (get s [:stand which]))))))
|
||||
(actions/give entities :wool)
|
||||
(actions/talk entities :ego "I guess her wool is shedding.")
|
||||
)
|
||||
@@ -700,7 +725,7 @@
|
||||
:carrot (actions/get-script entities
|
||||
(walk-to-sheep entities)
|
||||
(actions/talk entities :ego "Come on, girl, get the carrot!")
|
||||
(actions/walk-straight-to entities :sheep [90 138] :update-baseline? false)
|
||||
(actions/walk-straight-to entities :sheep [85 138] :update-baseline? false)
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(actions/remove-item entities :carrot)
|
||||
(actions/update-state entities (fn [s] (assoc s :coaxed-sheep? true)))
|
||||
@@ -826,10 +851,11 @@
|
||||
(utils/fast-forward-particle (get-in entities [:room :entities :outside-particles]))
|
||||
(as-> entities entities
|
||||
(if (get-in entities [:state :coaxed-sheep?])
|
||||
(let [scale ((get-in entities [:room :scale-fn]) [90 138])]
|
||||
(update-in entities [:room :entities :sheep] #(assoc % :x 90 :y 138 :baseline 40 :scale-x scale :scale-y scale)))
|
||||
(let [scale ((get-in entities [:room :scale-fn]) [85 138])]
|
||||
(update-in entities [:room :entities :sheep] #(assoc % :x 85 :y 138 :baseline 40 :scale-x scale :scale-y scale)))
|
||||
entities)
|
||||
(if (= :night (get-in entities [:state :time]))
|
||||
(make-night screen entities)
|
||||
entities)))
|
||||
entities)
|
||||
(set-sheep-anim screen entities)))
|
||||
:start-pos [30 80])))
|
||||
|
||||
Reference in New Issue
Block a user