(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "Cycle")
(use "Game")
(use "PV")
(use "Obj")
(script 34)


(local
    local0

)
(instance waves of List
    (properties)
)
(instance wave1 of Prop
    (properties)
)
(instance wave2 of Prop
    (properties)
)
(instance wave3 of Prop
    (properties)
)
(instance public Room34 of Rm
    (properties
        picture 34
    )

    (method (init)
        (if (global100)
            = picture 134
        )
        = north 31
        = east 35
        = west 33
        = horizon 80
        = global101 0
        = gHorizon horizon
        (send gEgo:edgeHit(0))
        (super:init())
        (self:setRegions(505 501 503 504))
        (wave1:
            view(661)
            isExtra(1)
            loop(2)
            cel(0)
            posn(66 111)
            setPri(0)
            ignoreActors()
            cycleSpeed(3)
            init()
        )
        (wave2:
            view(661)
            isExtra(1)
            loop(3)
            cel(0)
            posn(143 110)
            setPri(0)
            ignoreActors()
            cycleSpeed(3)
            init()
        )
        (wave3:
            view(661)
            isExtra(1)
            loop(4)
            cel(0)
            posn(214 108)
            setPri(0)
            ignoreActors()
            cycleSpeed(3)
            init()
        )
        (waves:add(wave1 wave2 wave3))
        (wave1:setScript(waveActions))
        (switch (gPicture)
            (case 31
                ((send gEgo:posn((send gEgo:x()) (+ horizon 2)))  )
            )
            (case 33
                ((send gEgo:posn(2 (send gEgo:y())))  )
            )
            (case 35
                ((send gEgo:posn(317 (send gEgo:y()))) )
            )
        )
        (send gEgo:
            xStep(2)
            yStep(1)
            init()
        )
    )


    (method (dispose)
        (waves:
            dispose()
            delete()
        )
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if ((== (send pEvent:type()) 128) and Said('look[<around][/room,island]'))
                (if (== (send gEgo:view()) 2)
                    Print(34 0)
                )(else
                    Print(34 1)
                )
            )(else
                0
            )
    )

)
(instance waveActions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (= local0 0 (while (< local0 (waves:size()))(send ((View:new())):
                        view((send ((waves:at(local0))):view()))
                        loop((send ((waves:at(local0))):loop()))
                        cel(0)
                        setPri(0)
                        ignoreActors()
                        x((send ((waves:at(local0))):x()))
                        y((send ((waves:at(local0))):y()))
                        init()
                        addToPic()
                        yourself()
                    )
 ++local0  ) = local0 0 (self:changeState(1))  )
            )
            (case 1
                ((send ((waves:at(local0))):
                    cel(0)
                    show()
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send ((waves:at(local0))):hide()) 
                (if (< local0 (- (waves:size()) 1))
                    ++local0
                )(else
                    = local0 0
                )
 (waveActions:changeState(1)) )
            )
        )
    )

)
