Fish now jumps out of the fishing targets once in a while

This commit is contained in:
John 2015-05-30 14:57:43 +03:00 committed by Loudrob
parent a65952bb67
commit b5beee98a0
2 changed files with 13 additions and 23 deletions

View file

@ -7,6 +7,7 @@ from direct.fsm import ClassicFSM
from direct.fsm import State
from direct.directutil import Mopath
from toontown.toonbase import ToontownGlobals
from toontown.hood import FishAnimatedProp
from direct.actor import Actor
import FishingTargetGlobals
import random
@ -37,6 +38,8 @@ class DistributedFishingTarget(DistributedNode.DistributedNode):
self.bubbles = Bubbles.Bubbles(self, render)
self.bubbles.renderParent.setDepthWrite(0)
self.bubbles.start()
self.fish = FishAnimatedProp.FishAnimatedProp(self)
self.fish.enter()
DistributedNode.DistributedNode.generate(self)
def disable(self):
@ -45,6 +48,9 @@ class DistributedFishingTarget(DistributedNode.DistributedNode):
self.track = None
self.bubbles.destroy()
del self.bubbles
self.fish.exit()
self.fish.delete()
del self.fish
if self.pond:
self.pond.removeTarget(self)
self.pond = None
@ -84,4 +90,4 @@ class DistributedFishingTarget(DistributedNode.DistributedNode):
self.track.start()
def getRadius(self):
return self.radius
return self.radius

View file

@ -5,19 +5,13 @@ from toontown.effects.Splash import *
from toontown.effects.Ripples import *
import random
class FishAnimatedProp(AnimatedProp.AnimatedProp):
class FishAnimatedProp:
def __init__(self, node):
AnimatedProp.AnimatedProp.__init__(self, node)
parent = node.getParent()
self.fish = Actor.Actor(node, copy=0)
self.fish.reparentTo(parent)
self.fish.setTransform(node.getTransform())
node.clearMat()
self.fish.loadAnims({'jump': 'phase_4/models/props/SZ_fish-jump',
'swim': 'phase_4/models/props/SZ_fish-swim'})
self.fish = Actor.Actor('phase_4/models/props/SZ_fish-mod', {'jump': 'phase_4/models/props/SZ_fish-jump', 'swim': 'phase_4/models/props/SZ_fish-swim'}, copy=0)
self.fish.hide()
self.fish.reparentTo(node)
self.splashSfxList = (loader.loadSfx('phase_4/audio/sfx/TT_splash1.ogg'), loader.loadSfx('phase_4/audio/sfx/TT_splash2.ogg'))
self.node = self.fish
self.geom = self.fish.getGeomNode()
self.exitRipples = Ripples(self.geom)
self.exitRipples.setBin('fixed', 25, 1)
@ -25,7 +19,7 @@ class FishAnimatedProp(AnimatedProp.AnimatedProp):
self.splash = Splash(self.geom, wantParticles=0)
self.splash.setPosHprScale(-1, 0.0, 1.23, 0.0, 0.0, 0.0, 0.7, 0.7, 0.7)
randomSplash = random.choice(self.splashSfxList)
self.track = Sequence(FunctionInterval(self.randomizePosition), Func(self.node.unstash), Parallel(self.fish.actorInterval('jump'), Sequence(Wait(0.25), Func(self.exitRipples.play, 0.75)), Sequence(Wait(1.14), Func(self.splash.play), SoundInterval(randomSplash, volume=0.8, node=self.node))), Wait(1), Func(self.node.stash), Wait(4 + 10 * random.random()), name=self.uniqueName('Fish'))
self.track = Sequence(Parallel(Func(self.fish.show), self.fish.actorInterval('jump'), Sequence(Wait(0.25), Func(self.exitRipples.play, 0.75)), Sequence(Wait(1.13), Func(self.splash.play), SoundInterval(randomSplash, volume = 0.8, node = self.fish), Func(self.fish.hide))), Wait(5 + 10 * random.random()))
def delete(self):
self.exitRipples.destroy()
@ -35,22 +29,12 @@ class FishAnimatedProp(AnimatedProp.AnimatedProp):
del self.track
self.fish.removeNode()
del self.fish
del self.node
del self.geom
def randomizePosition(self):
x = 5 * (random.random() - 0.5)
y = 5 * (random.random() - 0.5)
h = 360 * random.random()
self.geom.setPos(x, y, 0)
self.geom.setHpr(h, 0, 0)
def enter(self):
AnimatedProp.AnimatedProp.enter(self)
self.track.loop()
def exit(self):
AnimatedProp.AnimatedProp.exit(self)
self.track.finish()
self.splash.stop()
self.exitRipples.stop()
self.exitRipples.stop()