Files
gitea-docker/desktop/src-common/advent/screens/rooms/inside_stash.clj
Bryce Covert 66b446c16c blurbs.
2015-11-04 21:43:47 -08:00

103 lines
5.8 KiB
Clojure

(ns advent.screens.rooms.inside-stash
(:require [advent.screens.rooms :as rooms]
[advent.screens.items :as items]
[advent.actions :as actions]
[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 bust-chest [entities]
(if (get-in @entities [:state :broke-lock?])
(do
(actions/talk entities :ego "I already bust it open."))
(do
(actions/talk entities :ego "Let's see if this can pry this puppy open.")
(actions/walk-straight-to entities :ego [152 95] :face :right)
(actions/play-animation entities :ego :crowbar)
(actions/remove-entity entities :lid)
(actions/update-state entities #(assoc % :broke-lock? true))
(actions/talk entities :ego "Got it!"))))
(defn explore-chest [entities]
(cond
(actions/has-item? entities :slingshot)
(do (actions/walk-to entities :ego [152 95] :face :right)
(actions/talk entities :ego "It's empty now."))
(get-in @entities [:state :broke-lock?])
(do
(actions/walk-to entities :ego [152 95] :face :right)
(actions/talk entities :ego "Let's see what's inside now.")
(actions/play-animation entities :ego :reach)
(actions/do-dialogue entities
:ego "Yes! I got my stuff back!"
:ego "Including the Slinger's shot!")
(actions/give entities :flask-1-strength)
(actions/give entities :medal)
(actions/give entities :trophy)
(actions/give entities :slingshot))
:else
(do
(actions/walk-to entities :ego [152 95] :face :right)
(actions/talk entities :ego "Maybe my stuff is in here...")
(actions/play-animation entities :ego :reach)
(actions/talk entities :ego "It's locked tight!"))))
(defn make [screen]
(let [candle-flame (utils/make-anim "inside-stash/candle.png" [4 4] 0.1 (range 4))
candle-aura (utils/make-anim "inside-house/candle-aura.png" [27 27] 0.2 [0 1 2 3 2 1] )
]
(rooms/make :music {:day :secret-hideout :night :secret-hideout}
:name "Inside stash"
:interactions
{:left-dir {:box [91 60 125 140]
:script (actions/get-script
entities
(actions/walk-straight-to entities :ego [118 96])
(actions/transition-background entities :outside-jail [200 97])
(actions/walk-straight-to entities :ego [167 100]))
:cursor :left}
:candle {:box [160 130 170 140]
:script (actions/get-script
entities
(actions/talk entities :ego "Just a candle."))
:scripts {:note-1 (actions/get-script entities
(actions/talk entities :ego "Why would I want to burn Gandarf's note?"))
:note-2 (actions/get-script entities
(actions/talk entities :ego "Why would I want to burn Gandarf's note?"))
:recipe (actions/get-script entities
(actions/walk-to entities :ego [152 95] :face :right)
(actions/play-animation entities :ego :reach)
(actions/remove-item entities :recipe)
(actions/give entities :ash)
(actions/talk entities :ego "It burned up into ash."))
:default (actions/get-script entities
(actions/talk entities :ego "Momma always told me not to play with fire."))}}
:chest {:box [151 107 180 124]
:script (actions/get-script entities (explore-chest entities))
:scripts {:sword (actions/get-script entities (actions/talk entities :ego "There's not enough room to swing my sword here."))
:crowbar (actions/get-script entities
(bust-chest entities))}}}
:layers [(assoc (utils/get-texture "inside-stash/background.png") :x 0 :y 0 :baseline 0 :night-profile :none)]
:entities {:lid (assoc (utils/get-texture "inside-stash/lid.png")
:x 156 :y 116 :baseline 125 :night-profile :none)
:candle-flame (assoc (animation->texture screen candle-flame)
:x 165 :y 135 :baseline 1
:anim candle-flame
:anim-start 0
:night-profile :none)
:candle-aura (assoc (animation->texture screen candle-aura) :x 166 :y 138 :baseline 2 :additive? true :origin-x 13 :origin-y 13 :opacity 0.5 :anim candle-aura :anim-start 0 :night-profile :none)
}
:collision "inside-stash/collision.png"
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00)
:start-pos [143 96]
:apply-state (fn [_ entities]
(if (get-in entities [:state :broke-lock?])
(update-in entities [:room :entities] #(dissoc % :lid))
entities)))))