Add sound effects to example analyser
This commit is contained in:
@@ -15,6 +15,7 @@ import Dodge.Default
|
||||
--import Dodge.Room.RoadBlock
|
||||
import Dodge.Placement.Instance
|
||||
import Dodge.Placement.Shift
|
||||
import Dodge.SoundLogic
|
||||
--import Dodge.Default.Room
|
||||
--import Dodge.Item.Weapon.BulletGuns
|
||||
--import Dodge.Item.Weapon.Utility
|
||||
@@ -66,11 +67,11 @@ analyser' starts sucs fails afters upf pslight psmc = extTrigLitPos pslight $ \t
|
||||
, _termTitle = "ANALYSER"
|
||||
}
|
||||
)
|
||||
(\mc -> upf mc . (triggers . ix (fromJust $ _plMID tp) .~ const (_mcSensorToggle mc))
|
||||
(\mc -> upf mc . (triggers . ix (fromJust $ _plMID tp) .~ const (_sensToggle $ _mcSensor mc))
|
||||
)
|
||||
simpleline str = TerminalLineDisplay {_tlPause = 0, _tlString = const (str,white)}
|
||||
testline' mcid = TerminalLineDisplay 0 (testline mcid)
|
||||
testline mcid w = case w ^? machines . ix mcid . mcSensorToggle of
|
||||
testline mcid w = case w ^? machines . ix mcid . mcSensor . sensToggle of
|
||||
Just True -> (sucs,green)
|
||||
_ -> (fails,red)
|
||||
updatebuttonname = plType . putButton . btText .~ "ANALYSER"
|
||||
@@ -88,8 +89,9 @@ analyser starts sucs fails afters upf pslight psmc = extTrigLitPos pslight $ \tp
|
||||
Just $ psPtCont psmc
|
||||
(PutMachine aquamarine (reverse $ square 10) defaultMachine
|
||||
{ _mcDraw = const . noPic . colorSH aquamarine . upperPrismPoly 25 $ square 10
|
||||
, _mcUpdate = \mc -> (triggers . ix (fromJust $ _plMID tp) .~ const (_mcSensorToggle mc))
|
||||
, _mcUpdate = \mc -> (triggers . ix (fromJust $ _plMID tp) .~ const (_sensToggle $ _mcSensor mc))
|
||||
. upf mc
|
||||
, _mcSensor = SensorCloseToggle NotClose False
|
||||
}
|
||||
) $ \anmc -> Just
|
||||
$ plSpot .~ shiftRelativeToPS (V2 20 0) (_plSpot anmc)
|
||||
@@ -104,15 +106,26 @@ analyser starts sucs fails afters upf pslight psmc = extTrigLitPos pslight $ \tp
|
||||
where
|
||||
simpleline str = TerminalLineDisplay {_tlPause = 0, _tlString = const (str,white)}
|
||||
testline' mcid = TerminalLineDisplay 0 (testline mcid)
|
||||
testline mcid w = case w ^? machines . ix mcid . mcSensorToggle of
|
||||
testline mcid w = case w ^? machines . ix mcid . mcSensor . sensToggle of
|
||||
Just True -> (sucs,green)
|
||||
_ -> (fails,red)
|
||||
updatebuttontext = plType . putButton . btText .~ "ANALYSER"
|
||||
|
||||
testYourHealth :: Int -> Machine -> World -> World
|
||||
testYourHealth hp mc w
|
||||
| _crHP ycr >= hp && dist (_crPos ycr) (_mcPos mc) < 40
|
||||
= w & machines . ix (_mcID mc) . mcSensorToggle .~ True
|
||||
| otherwise = w
|
||||
testYourHealth hp mc w = case (_sensCloseToggle sens
|
||||
, _sensToggle sens
|
||||
, _crHP ycr >= hp
|
||||
, dist (_crPos ycr) (_mcPos mc) < 40) of
|
||||
(_,True,_,_) -> w
|
||||
(_,False,True,True) -> w
|
||||
& machines . ix (_mcID mc) . mcSensor . sensToggle .~ True
|
||||
& playsound dededaS
|
||||
& machines . ix (_mcID mc) . mcSensor . sensCloseToggle .~ IsClose
|
||||
(NotClose,_,False,True) -> w & playsound dededumS
|
||||
& machines . ix (_mcID mc) . mcSensor . sensCloseToggle .~ IsClose
|
||||
(_,_,_,False) -> w & machines . ix (_mcID mc) . mcSensor . sensCloseToggle .~ NotClose
|
||||
_ -> w
|
||||
where
|
||||
playsound sid = soundContinue (MachineAltSound (_mcID mc)) (_mcPos mc) sid Nothing
|
||||
ycr = you w
|
||||
sens = _mcSensor mc
|
||||
|
||||
@@ -26,6 +26,7 @@ damageSensor dt wdth upf ps = pContID ps (PutLS $ lsPosCol (V3 0 0 30) 0.1)
|
||||
$ \gw -> (,) gw $ PutMachine yellow (reverse $ square wdth) defaultMachine
|
||||
{ _mcDraw = sensorSPic wdth $ _sensorCoding (_gParams gw) M.! dt
|
||||
, _mcUpdate = \mc -> upf mc . sensorUpdate dt mc
|
||||
, _mcSensor = SensorToggleAmount False 0
|
||||
, _mcLSs = [lsid]
|
||||
}
|
||||
|
||||
@@ -36,10 +37,10 @@ sensorUpdate :: DamageType -> Machine -> World -> World
|
||||
sensorUpdate damF mc w = w & machines . ix mcid %~ upmc
|
||||
& lightSources . ix lsid %~ upls
|
||||
where
|
||||
upmc = ( mcSensorAmount %~ \x' -> min 1000 (max 0 (x' - 5 + newSense)) )
|
||||
upmc = ( mcSensor . sensAmount %~ \x' -> min 1000 (max 0 (x' - 5 + newSense)) )
|
||||
. ( mcHP -~ sum dam )
|
||||
. (mcDamage .~ [])
|
||||
x = _mcSensorAmount mc
|
||||
x = _sensAmount $ _mcSensor mc
|
||||
mcid = _mcID mc
|
||||
lsid = head (_mcLSs mc)
|
||||
(senseData,dam) = partitionEithers $ map (damageUsing damF) $ _mcDamage mc
|
||||
|
||||
@@ -29,6 +29,7 @@ putTerminal' col mcf = ps0PushPS (PutButton thebutton)
|
||||
{ _mcDraw = noPic . colorSH col . terminalShape
|
||||
, _mcHP = 100
|
||||
, _mcUpdate = mcf (fromJust $ _plMID pl)
|
||||
, _mcSensor = SensorCloseToggle NotClose False
|
||||
})
|
||||
$ const Nothing
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user