(ns advent.screens.rooms.outside-jail (:require [advent.screens.rooms :as rooms] [advent.actions :as actions] [advent.screens.items :as items] [advent.utils :as utils] [clojure.zip :as zip] [play-clj.core :refer :all] [play-clj.ui :refer :all] [play-clj.utils :refer :all] [play-clj.g2d :refer :all])) (defn make-night [entities] (-> entities (assoc-in [:room :entities :guard] (get-in entities [:room :guard])))) (defn make [screen] (let [fountain (utils/make-anim "outside-jail/fountain.png" [42 50] 0.2 (range 3)) guard-sheet (texture! (texture "inside-cafeteria/ladder-guard.png") :split 37 87) guard-stand (animation 0.1 [(aget guard-sheet 0 0)]) guard-talk (animation 0.2 (for [i [0 0 0 0 1 0 0 1]] (aget guard-sheet 0 i))) guard-sleep (utils/make-anim "outside-jail/guard-sleep.png" [43 67] 0.1 (range 4))] (rooms/make :music :town-2 :interactions {:down-dir {:box [30 0 227 20] :script (actions/get-script entities (actions/walk-to entities :ego [159 5]) (actions/walk-straight-to entities :ego [159 -20]) (actions/transition-background entities :inside-castle [79 145] ) (actions/walk-to entities :ego [159 74])) :cursor :down} :door {:box [22 42 46 124] :script (actions/get-script entities (if (= :night (get-in @entities [:state :time])) (actions/talk entities :ego "I do NOT want to go back in there!") (do (actions/walk-to entities :ego [50 46]) (actions/talk entities :warden "NO VISITORS!"))))} :window {:box [62 175 80 212] :script (actions/get-script entities (actions/talk entities :ego "I wonder if anyone is prisoner up there?"))} :sign {:box [5 173 61 199] :script (actions/get-script entities (actions/talk entities :ego "J.A.I.L. Jail. Can't you read?"))} :my-house {:box [89 128 118 179] :script (actions/get-script entities (actions/talk entities :ego "That's my house. I'd rather play outside."))} :sherrif-house {:box [138 143 160 168] :script (actions/get-script entities (actions/do-dialogue entities :ego "That's the Sherrif's house." :ego "He hates me." :ego "All because I threw a rock through his window." :ego "Or windows." :ego "What's the big deal?"))} :mchulk-house {:box [223 137 282 172] :script (actions/get-script entities (actions/do-dialogue entities :ego "That's Captain McHulk's house!" :ego "He's the mightiest knight in all of Remington." :ego "If only I could be as strong as him one day." ))}} :layers {:day [(assoc (texture "outside-jail/background.png") :x 0 :y 0 :baseline 0)] :night [(assoc (texture "outside-jail/background-dark.png") :x 0 :y 0 :baseline 0)]} :entities {:fountain (assoc (animation->texture screen fountain) :x 150 :y 126 :baseline 114 :anim fountain :anim-start 0 :script (actions/get-script entities (actions/walk-to entities :ego [151 119] :face :right) (actions/play-animation entities :ego :reach) (actions/do-dialogue entities :ego "Ahh, life-giving water." :ego "I feel strength." :ego "And renewal!"))) :warden {:object nil :x 36 :y 86 :width 10 :height 10 :talk-color (color 0.9 0.3 0.9 1.0)}} :guard (assoc (animation->texture screen guard-stand) :x 70 :y 55 :baseline 185 :stand guard-stand :talk guard-talk :sleep guard-sleep) :collision "outside-jail/collision.png" :scale-fn (utils/scaler-fn-with-baseline 40 0.001 1.3) :start-pos [145 15] :apply-state (fn [entities] (as-> entities entities (if (= :night (get-in entities [:state :time])) (make-night entities) entities) (if (get-in entities [:state :dropped-ball?]) (update-in entities [:room :entities :guard] #(actions/start-animation % :sleep)) entities))))))