Randomise enemies and floor items
This commit is contained in:
@@ -6,13 +6,17 @@ module Dodge.Room.Procedural
|
||||
, roomRectAutoLinks
|
||||
, testRoom
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Room.Data
|
||||
import Dodge.Room.Placement
|
||||
import Dodge.Room.Link
|
||||
import Dodge.Item.Consumable
|
||||
import Dodge.Item.Weapon
|
||||
import Dodge.RandomHelp
|
||||
import Dodge.LevelGen
|
||||
import Dodge.LevelGen.Data
|
||||
import Dodge.Creature
|
||||
import Dodge.Default
|
||||
import Geometry
|
||||
|
||||
import Data.List (nub,nubBy,sortBy)
|
||||
@@ -199,12 +203,29 @@ fillNothingPlacement pst r =
|
||||
replaceNothingWith x (ps:pss) = ps : replaceNothingWith x pss
|
||||
replaceNothingWith _ [] = []
|
||||
|
||||
fillNothingPlacements :: [PSType] -> Room -> Room
|
||||
fillNothingPlacements pst r = foldr fillNothingPlacement r pst
|
||||
|
||||
shufflePlacements :: RandomGen g => Room -> State g Room
|
||||
shufflePlacements r = do
|
||||
newPSs <- shuffle $ _rmPS r
|
||||
return $ r & rmPS .~ newPSs
|
||||
|
||||
putDefaultFlIt :: Item -> PSType
|
||||
putDefaultFlIt itm = PutFlIt $ defaultFlIt { _flItRot = 0, _flIt = itm }
|
||||
|
||||
testRoom :: RandomGen g => State g Room
|
||||
testRoom = do
|
||||
corners <- replicateM 4 . join $ takeOne [fourthWall 100, fourthCornerWall 100]
|
||||
-- corners <- replicateM 4 (fourthCornerWall 100)
|
||||
randomiseAllLinks
|
||||
. fillNothingPlacement (PutCrit chaseCrit)
|
||||
nItms <- state $ randomR (1,2)
|
||||
itms <- takeN nItms $ fmap putDefaultFlIt $ [autoRadar,autoSonar,remoteLauncher,jetPack,blinkGun] ++ replicate 5 (medkit 500)
|
||||
nCrits <- state $ randomR (1,3)
|
||||
crits <- takeN nCrits $ fmap PutCrit $ [spreadGunCrit,pistolCrit,autoCrit,armourChaseCrit]
|
||||
++ replicate 20 chaseCrit
|
||||
randomiseAllLinks =<<
|
||||
( fmap (fillNothingPlacements $ crits ++ itms)
|
||||
. shufflePlacements
|
||||
. foldr1 combineRooms
|
||||
$ zipWith (\r a -> shiftRoomBy ((0,0),a) r) corners [0,pi/2,pi,3*pi/2]
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user