(ns advent.screens.rooms.castle-gate (: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) (defn walk-to-frankie [entities] (actions/walk-to entities :ego [268 61] :face :left)) (defn drop-walkie-talkie [entities] (actions/talk entities :ego "I'll drop one of these off in here.") (actions/walk-to entities :ego [155 64]) (actions/walk-straight-to entities :ego [106 18] :face :left) (actions/play-animation entities :ego :squat) (actions/remove-item entities :walkie-talkies) (actions/give entities :walkie-talkie) (actions/walk-straight-to entities :ego [155 64])) (defn present-frankie-choices [entities] (actions/present-choices entities {:choices ["Please, Frankie. Give me my stuff back!" {:run #(do (actions/respond entities % :frankie "Not a chance, Dipstick." :frankie "Burglers like us gotta eat too, you know." :ego "But it's a matter of life and death! Georgia McGorgeous is counting on me!" ) (actions/in-love entities) (actions/respond entities % :frankie "Georgia's going steady with me now, Dipstick.") (actions/play-animation entities :frankie :laugh) (actions/do-dialogue entities :frankie "You'd be better off if you just packed your bags and left town." :frankie "Ain't that right boys?") (actions/play-animation entities :frankie :glance)) :choices actions/previous-choices} "You guys are nothing but a bunch of crooks!" {:run #(do (actions/respond entities % :frankie "Oh please." :frankie "Like you're so different." :frankie "Am I right boys?") (actions/play-animation entities :frankie :glance) (actions/do-dialogue entities :frankie "We steal gold, diamonds, and relic slingshots." :frankie "And you steal teddy bears.") (actions/play-animation entities :frankie :laugh)) :choices actions/previous-choices} "Where is your secret stash?" {:run #(do (actions/respond entities % :frankie "Like I'd ever tell you, Dipstick.") (actions/play-animation entities :frankie :laugh) (actions/do-dialogue entities :frankie "That's only for people in the 'Super secret cool club'!")) :choices actions/previous-choices} "Nevermind." {:run #(actions/respond entities % :frankie "Come back when you've got some good valuables.")}]})) (defn make-frankie [screen] (let [stand (utils/make-anim "castle-gate/frankie.png" [48 35] 0.19 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]) talk (utils/make-anim "castle-gate/frankie.png" [48 35] 0.2 [2 0 2 0 2 0 2 0 0 1 0]) laugh (utils/make-anim "castle-gate/frankie.png" [48 35] 0.1 [1 3 4 3 4 3 4 3 4 3 4 3 4 1 0]) glance (utils/make-anim "castle-gate/frankie.png" [48 35] 0.25 [0 6 0 6 5 5 5 6 7 7 7 6 ])] (assoc (animation->texture screen stand) :x 215 :y 90 :baseline 150 :anim stand :anim-start 0 :night-profile :sprite :scale-x 1.4 :scale-y 1.4 :talk-color (color 0.6 0.2 0.6 1.0) :talk talk :stand stand :laugh laugh :glance glance :script (actions/get-script entities (walk-to-frankie entities) (actions/talk entities :ego "Listen, Frankie...") (present-frankie-choices entities)) :scripts {:walkie-talkies (actions/get-script entities (actions/do-dialogue entities :frankie "Tin cans? What do I need walkie talkies for?"))}))) (defn make-goon-1 [screen] (let [stand (utils/make-anim "castle-gate/goon-1.png" [12 33] 0.21 [0 0 0 0 0 0 0 0 0 1])] (assoc (animation->texture screen stand) :x 244 :y 102 :baseline 138 :scale-x 1.4 :scale-y 1.4 :night-profile :sprite :anim stand :anim-start 0 :stand stand))) (defn make-goon-2 [screen] (let [stand (utils/make-anim "castle-gate/goon-2.png" [12 32] 0.175 [0 0 0 0 0 0 0 0 0 0 0 0 0 1])] (assoc (animation->texture screen stand) :x 208 :y 102 :baseline 138 :scale-x 1.4 :scale-y 1.4 :anim stand :night-profile :sprite :anim-start 0 :stand stand))) (defn attempt-walking-through-gate [entities] (actions/walk-to entities :ego [157 83]) (actions/transition-background entities :inside-castle [280 145]) (actions/walk-to entities :ego [245 90])) (defn make [screen] (let [throw-walkie (utils/make-anim "castle-gate/throw-walkie.png" [205 136] 0.1 (flatten [(repeat 55 0) (range 9) (repeat 55 8)])) walkie-visible (animation 1.0 [(last (utils/split-texture "castle-gate/throw-walkie.png" [205 136] (range 9)))]) walkie-invisible (animation 1.0 [(first (utils/split-texture "castle-gate/throw-walkie.png" [205 136] (range 9)))])] (rooms/make :music {:day :town-2 :night :night} :interactions {:right-dir {:box [300 40 320 83] :script (actions/get-script entities (actions/walk-to entities :ego [301 46] :face :right) (actions/walk-straight-to entities :ego [340 40]) (actions/transition-background entities :outside-castle [82 180]) (actions/walk-to entities :ego [129 148])) :cursor :right} :left-dir {:box [105 93 169 212] :script (actions/get-script entities (attempt-walking-through-gate entities)) :cursor :left} :big-tree {:box [20 10 82 235] :scripts {:walkie-talkies (actions/get-script entities (drop-walkie-talkie entities))}} :window {:box [192 157 215 215] :script (actions/get-script entities (actions/talk entities :ego "That's a big window!")) :scripts {:walkie-talkies (actions/get-script entities (actions/walk-to entities :ego [285 71]) (actions/walk-straight-to entities :ego [308 105] :face :left) (actions/add-entity entities :walkie-talkies (actions/start-animation (get-in @entities [:room :walkie-talkies]) :walkie-invisible)) (actions/begin-animation entities :walkie-talkies :throw-walkie) (actions/play-animation entities :ego :throw) (actions/remove-item entities :walkie-talkies) (actions/begin-animation entities :walkie-talkies :stand) (Thread/sleep 2000) (actions/walk-straight-to entities :ego [285 71]))}}} :layers {:day [(assoc (texture "castle-gate/background.png") :x 0 :y 0 :baseline 0)] :night [(assoc (texture "castle-gate/background.png") :x 0 :y 0 :baseline 0)]} :entities {:frankie (make-frankie screen) :goon-1 (make-goon-1 screen) :goon-2 (make-goon-2 screen) } :walkie-talkies (rooms/make-entity :walkie-talkies (assoc (animation->texture screen walkie-visible) :x 104 :y 88 :baseline 130 :night-profile :sprite :throw-walkie throw-walkie :stand walkie-visible :walkie-invisible walkie-invisible :anim-start 0 :anim walkie-visible)) :collision "castle-gate/collision.png" :scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.30) :apply-state (fn [_ entities] (as-> entities entities (if (= :night (get-in entities [:state :time])) (make-night entities) entities) (if (and (not (actions/has-item? entities :walkie-talkies)) (actions/has-obtained? entities :walkie-talkies)) (assoc-in entities [:room :entities :walkie-talkies] (get-in entities [:room :walkie-talkies])) entities))) :start-pos [300 45])))