示例#1
0
    def UpdatePosition(self, UpdateEvent):
        destination = VectorMath.Vec3(
            .2, .59,
            0) if not self.Owner.Parent.Sprite.FlipX else VectorMath.Vec3(
                -.2, .59, 0)

        self.Owner.Transform.Translation = 0.95 * self.Owner.Transform.Translation + 0.05 * destination
示例#2
0
 def swingPlayer(self, ray):
     
     #For Swinging Right
     if(self.swingRight and self.swingDown):
         self.Pendulum = VectorMath.Vec3(math.fabs(ray.y), -math.fabs(ray.x), 0)
         #setting swing speeds
         self.Owner.Transform.Translation += self.Pendulum * (self.DeltaTime * 18)
         if(ray.x < 0):
             self.swingDown = False
     elif(self.swingRight and not self.swingDown):
         self.Pendulum = VectorMath.Vec3(math.fabs(ray.y), math.fabs(ray.x), 0)
         #setting swing speeds
         self.Owner.Transform.Translation += self.Pendulum * (self.DeltaTime * 18)
         #when have reached the same height swing started at after swing stop
         if(self.Owner.Transform.Translation.y > self.rayY):
             self.StopGrapple()
             self.swingDown = True
             self.Swing = False
             
    #For Swinging Left
     elif(not self.swingRight and self.swingDown):
         self.Pendulum = VectorMath.Vec3(-math.fabs(ray.y), -math.fabs(ray.x), 0)
         #setting swing speeds
         self.Owner.Transform.Translation += self.Pendulum * (self.DeltaTime * 18)
         if(ray.x > 0):
             self.swingDown = False
     elif(not self.swingRight and not self.swingDown):
         self.Pendulum = VectorMath.Vec3(-math.fabs(ray.y), math.fabs(ray.x), 0)
         #setting swing speeds
         self.Owner.Transform.Translation += self.Pendulum * (self.DeltaTime * 18)
         #when have reached the same height swing started at after swing stop
         if(self.Owner.Transform.Translation.y > self.rayY):
             self.StopGrapple()
             self.swingDown = True
             self.Swing = False
示例#3
0
 def OnMouseDown(self, ViewportMouseEvent):
     
     #Sets if mouse is being held down
     self.MouseDown = True
     #Stops a grapple if there was one already
     self.StopGrapple()
     #Changes arm sprite source
     self.Owner.FindChildByName("arm").Sprite.SpriteSource = "armfired"
     
     #telling that the player is shooting grappling hook
     self.playerGrappleShot = True
     #making a variable that is the same as MouseDirection variable
     direction = self.MouseDirection
     direction = math.atan2(direction.y, direction.x)
     #direction of making a variable into where mousePosition is
     self.grappleDirectionPoint = self.mousePosition
     
     #Grappling 'Rope' object and 'poof' effect
     if(self.Space.CurrentLevel.Name != "MainMenu"):
         self.Grapple = self.Space.CreateAtPosition("Rope", VectorMath.Vec3(self.Owner.Transform.Translation.x + (math.cos(self.PointDirection) * .5), self.Owner.Transform.Translation.y + (math.sin(self.PointDirection) * .5) + .15, 0) )
         self.Space.CreateAtPosition("Poof", VectorMath.Vec3(self.Owner.Transform.Translation.x + (math.cos(self.PointDirection) * 1), self.Owner.Transform.Translation.y + (math.sin(self.PointDirection) * 1) + .15, 0) )
         #Grappling 'Hook' object
         self.hook = self.Space.CreateAtPosition("Hook", VectorMath.Vec3(self.Owner.Transform.Translation.x + (math.cos(self.PointDirection) * .5), self.Owner.Transform.Translation.y + (math.sin(self.PointDirection) * .5) + .15, 0) )
     
     self.grappleDirection = self.MouseDirection
示例#4
0
    def OnCollisionPersisted(self, CollisionEvent):
        
        #checking for whether or not player has key
        keyAttached = self.Space.FindObjectByName("Player").MasterPlayerContr.keyAttached
        #variable for collision object
        otherObject = CollisionEvent.OtherObject
        #variable for key object
        key = self.Space.FindObjectByName("Key")
            
        #if the key collides with gate(actually region (GateAOE))
        #gate and gateAOE are parented in an achetype
        if(otherObject.Name == "Player" and keyAttached == True):
            
            #open gates
            self.access = True
            #move one gate up and one gate down
            self.gate2.Transform.Translation = self.startGate2 + VectorMath.Vec3(0, -self.yAxis, 0)
            self.gate1.Transform.Translation = self.startGate1 + VectorMath.Vec3(0, self.yAxis, 0)

            #once the y coordinate reaches max value desired stop the gate
            if(self.yAxis > 0.8):
                
                #reset y variable
                self.yAxis += 0
                #set these new positions at translations of gate
                self.startGate1 = self.gate1.Transform.Translation
                self.startGate2 = self.gate2.Transform.Translation
                #detach key from player and destroy it
                self.Space.FindObjectByName("Player").MasterPlayerContr.keyAttached = False
                key.Destroy()
示例#5
0
 def OnCollision(self, CollisionEvent):
     if self.Active and CollisionEvent.OtherObject.Bounceable:
         modifier = -1 if self.UpdateBasedOnSprite and self.Owner.Sprite.FlipX else 1
         
         
         adder = 0
         if self.TopModify:
             boxloc = self.Owner.Transform.Translation + self.Owner.BoxCollider.Offset
             
             boxdims = self.Owner.BoxCollider.Size
             angle = self.Owner.Transform.EulerAngles.z
             normal = VectorMath.Vec3.RotateVector(VectorMath.Vec3(0,1,0), VectorMath.Vec3(0,0,1), angle)
             
             shifter = (boxloc + boxdims * .5 * normal) - CollisionEvent.FirstPoint.WorldPoint
             
             adder = shifter.y if shifter.y > 0 else 0
             if self.Owner.Name == "Mushroom":
                 print(adder)
             #rigid = CollisionEvent.OtherObject.RigidBody
             
             #def Modifying():
             #    rigid.Velocity += VectorMath.Vec3(0, shifter.y,0)
                 
             #seq = Action.Sequence(CollisionEvent.OtherObject.Actions)                
             #Action.Call(seq, Modifying)
             #Action.Delay(seq, 0.1)
             
         if CollisionEvent.OtherObject.Bounceable:
             impulseEvent = Zero.ScriptEvent()
             impulseEvent.ForcedVx = self.ForcedVx * modifier     
             impulseEvent.ForcedVy = self.ForcedVy + adder 
             CollisionEvent.OtherObject.DispatchEvent("BounceEvent", impulseEvent)
示例#6
0
 def OnLogicUpdate(self, UpdateEvent):
     #cameraTimer = 15
     randomDirectionX = random.uniform(-3, 3)
     randomDirectionY = random.uniform(1, 2)
     #Sends the object flying in a random direction and then destroys it after a certain time
     self.Owner.RigidBody.ApplyLinearVelocity(
         VectorMath.Vec3(randomDirectionX, randomDirectionY, 0))
     self.Owner.Sprite.Color = self.Owner.Sprite.Color - VectorMath.Vec4(
         0, 0, 0, self.alphaTimer)
     self.destroyTimer -= 1
     self.Owner.RigidBody.ApplyLinearVelocity(VectorMath.Vec3(0, 0, 0))
     if (self.destroyTimer == 0):
         self.Owner.Destroy()
示例#7
0
    def OnCollision(self, CollisionEvent):
        if self.Active and not CollisionEvent.OtherObject.Collider.Ghost:

            normal = CollisionEvent.FirstPoint.WorldNormalTowardsOther
            # if degree > 22.5 and degree < 65
            if abs(normal.y) < abs(normal.x) * 1.5 and abs(
                    normal.y) * 1.5 > abs(normal.x):
                force = VectorMath.Vec3(normal.x * 11, -normal.y * 3, 0)
                self.Owner.RigidBody.ApplyForce(force)
            elif abs(normal.y) < abs(normal.x) * 4 and abs(
                    normal.y) * 1.5 > abs(normal.x):
                force = VectorMath.Vec3(normal.x * 8.8, -normal.y * 2, 0)
                self.Owner.RigidBody.ApplyForce(force)
示例#8
0
 def OnLogicUpdate(self, UpdateEvent):
     if Zero.Keyboard.KeyIsDown(Zero.Keys.Up):
         self.Owner.RigidBody.ApplyLinearVelocity(
             VectorMath.Vec3(0, self.MoveSpeed, 0))
     if Zero.Keyboard.KeyIsDown(Zero.Keys.Down):
         self.Owner.RigidBody.ApplyLinearVelocity(
             VectorMath.Vec3(0, -self.MoveSpeed, 0))
     if Zero.Keyboard.KeyIsDown(Zero.Keys.Left):
         self.Owner.RigidBody.ApplyLinearVelocity(
             VectorMath.Vec3(-self.MoveSpeed, 0, 0))
     if Zero.Keyboard.KeyIsDown(Zero.Keys.Right):
         self.Owner.RigidBody.ApplyLinearVelocity(
             VectorMath.Vec3(self.MoveSpeed, 0, 0))
示例#9
0
    def OnCollision(self, CollisionEvent):
        if CollisionEvent.OtherObject.RigidBody and CollisionEvent.OtherObject.Transform.Translation.y > self.Owner.Transform.Translation.y:

            if CollisionEvent.OtherObject.RigidBody.Velocity.y < 0:

                CollisionEvent.OtherObject.RigidBody.Velocity *= VectorMath.Vec3(
                    1, 0, 0)
            if CollisionEvent.OtherObject.RigidBody.Force.y < 0:
                CollisionEvent.OtherObject.RigidBody.Force *= VectorMath.Vec3(
                    1, 0, 0)

            CollisionEvent.OtherObject.Transform.Translation += Vec3(
                0, CollisionEvent.FirstPoint.Penetration * 1.3, 0)
            self.Owner.Collider.Ghost = False
示例#10
0
    def Initialize(self, initializer):
        if not self.Owner.Collider:
            self.Owner.AddComponentByName("BoxCollider")
            pos0 = self.Owner.SpriteText.GetCharacterPosition(0)
            pos_end = self.Owner.SpriteText.GetCharacterPosition(
                len(self.Owner.SpriteText.Text) - 1)

            width = 9
            self.Owner.BoxCollider.Size = VectorMath.Vec3(width, 0.6, 300)
            self.Owner.BoxCollider.Offset = VectorMath.Vec3(width / 2, -0.3, 0)

            if not self.Owner.RigidBody:
                self.Owner.AddComponentByName("RigidBody")
                self.Owner.RigidBody.Static = True
                self.Owner.RigidBody.AllowSleep = False
    def Attacking(self):
        self.Owner.Teleportable.Active = True
        self.Owner.Bounceable.Active = False

        self.Owner.ClickReceiver.Receivable = True

        if not self.Owner.Sprite.SpriteSource == self.outanim:
            self.Owner.SoundEmitter.PlayCue("DigCue")
            self.Owner.Sprite.SpriteSource = self.outanim

        if self.Owner.Sprite.CurrentFrame == 2:
            hurtbox = self.Space.CreateAtPosition(
                "HurtBox", self.Owner.Transform.Translation + Vec3(0, .6, 0))
            hurtbox.Transform.Scale = Vec3(.32, 0.85, 1)
            hurtbox.CanHurt.HurtRate = -100
            hurtbox.TimedDeath.LifeTime = 0.05
            hurtbox.AttachToRelative(self.Owner)

            sandsmoke = self.Space.CreateAtPosition(
                "SandSmokeParticle", self.Owner.Transform.Translation)
            t = sandsmoke.SpriteParticleSystem.Tint
            sandsmoke.SpriteParticleSystem.Tint = VectorMath.Vec4(
                t.x, t.y, t.z, 0.1)
            sandsmoke.SphericalParticleEmitter.RandomVelocity *= 0.4
            sandsmoke.SphericalParticleEmitter.EmitCount = 3
            sandsmoke.SphericalParticleEmitter.ResetCount()
        if self.Owner.Sprite.CurrentFrame == 3:
            self.Owner.RigidBody.ApplyLinearImpulse(VectorMath.Vec3(0, 2.5, 0))
        if self.Owner.Sprite.CurrentFrame == 5:
            self.dumbcounter = 20
            self.CurrentUpdate = self.Resting
示例#12
0
class HiderScript:
    TeleportDistance = Property.Vector3(VectorMath.Vec3(4, 0, 0))

    def Initialize(self, initializer):
        self.initial_loc = self.Owner.Transform.WorldTranslation
        self.destination_loc = self.Owner.Transform.WorldTranslation + self.TeleportDistance

        self.hided = False

    def HidingUpdate(self, UpdateEvent):
        self.Owner.Transform.WorldTranslation = 0.95 * self.Owner.Transform.WorldTranslation + 0.05 * self.destination_loc
        if (self.Owner.Transform.WorldTranslation -
                self.destination_loc).length() < 0.1:
            Zero.Disconnect(self.Space, Events.LogicUpdate, self)

    def UnhidingUpdate(self, UpdateEvent):
        self.Owner.Transform.WorldTranslation = 0.95 * self.Owner.Transform.WorldTranslation + 0.05 * self.initial_loc
        #print("unhiding",(self.Owner.Transform.WorldTranslation - self.initial_loc).length())
        if (self.Owner.Transform.WorldTranslation -
                self.initial_loc).length() < 0.1:
            Zero.Disconnect(self.Space, Events.LogicUpdate, self)

    def Hide(self):
        if not self.hided:
            self.hided = True
            Zero.Disconnect(self.Owner, Events.LogicUpdate, self)
            Zero.Connect(self.Space, Events.LogicUpdate, self.HidingUpdate)

    def Unhide(self):
        if self.hided:
            self.hided = False
            Zero.Disconnect(self.Owner, Events.LogicUpdate, self)
            Zero.Connect(self.Space, Events.LogicUpdate, self.UnhidingUpdate)
示例#13
0
 def Perform(self, position, pre_rotate = None):
     if self.TreeSkill:
         tree = self.TreeSkill.Perform(position, self.PhysSkill)
         if tree:
             if pre_rotate and not tree.Name == "Whirlingnut":
                 tree.Transform.RotateByAngles(VectorMath.Vec3(0,0,pre_rotate.angleZ()-math.pi/2))
                 
             if tree.Name == "Mushroom":
                 tree.CanBounce.ToDirection(pre_rotate)
                 
             
             
             selected = self.PhysSkill.Name if self.PhysSkill else "Normal"
             if tree.Hierarchy:
                 for child in tree.Hierarchy.Children:
                     if child.AnimManager:
                         child.Sprite.SpriteSource = child.AnimManager.AnimTable.FindValue(selected)
             
             if self.PlantTimeOverride > 0:
                 tree.TimedDeath.LifeTime = self.PlantTimeOverride
     #elif self.PhysSkill:
         #pass
         #self.PhysSkill.Perform(position)
     else:
         pass
示例#14
0
 def OnRightClick(self, ViewportMouseEvent):
     # if you can't shoot it makes a sound effect
     if(self.CanShoot == False):
         self.Space.SoundSpace.PlayCue("Overheat")
         
     else:
         #plays sound effect
         self.Space.SoundSpace.PlayCue("gunsound1")
         #Adds heat
         self.Heat += 50.0
         #Assigns Shooting projectile
         Shoot = self.Space.CreateAtPosition("Projectile", VectorMath.Vec3(self.Owner.Transform.Translation.x + (math.cos(self.PointDirection) * .5), self.Owner.Transform.Translation.y + (math.sin(self.PointDirection) * .5) + .15, 0) )
         #Assigns Shoot direction
         Shoot.Projectile.Direction = self.mousePosition - VectorMath.Vec3(self.Owner.Transform.Translation.x + (math.cos(self.PointDirection) * .5), self.Owner.Transform.Translation.y + (math.sin(self.PointDirection) * .5) + .15, 0) 
         #Normalizes speed
         Shoot.Projectile.Direction = Vec3(Shoot.Projectile.Direction.x / Shoot.Projectile.Direction.length(), Shoot.Projectile.Direction.y / Shoot.Projectile.Direction.length(), 0) * self.ShootSpeed
示例#15
0
    def TeleportThis(self, target):
        if self.NextLevel.Name != "DefaultLevel":
            self.Space.FindObjectByName("Camera").CameraFunction.SetCameraFade(
                Vec4(1, 1, 1, 0), Vec4(1, 1, 1, 1), .03, 0)
            sequence = Action.Sequence(self.Owner.Actions)

            ls = self.Space.FindObjectByName("LevelSettings").LevelStart
            if ls:
                hm = ls.HUDManager
                hm.CacheSkills()

            Action.Delay(sequence, 1.5)
            Action.Call(sequence, lambda: self.Space.LoadLevel(self.NextLevel))

        elif self.Teleport:
            camera = self.Space.FindObjectByName("Camera")

            dest = self.Teleport.Transform.Translation
            ct = camera.Transform.Translation
            pt = target.Transform.Translation

            #camera.CameraFunction.SetCameraFade(Vec4(0,0,0,1),Vec4(0,0,0,0),.03,0)
            #camera.Transform.Translation = VectorMath.Vec3(dest.x, dest.y,ct.z)
            target.Transform.Translation = VectorMath.Vec3(
                dest.x, dest.y, pt.z)
示例#16
0
 def Destroy(self):
     if not self.Activated:
         if self.InvalidateCollider:
             self.Owner.Collider.Offset += VectorMath.Vec3(0, 0, 999)
         
         self.Activated = True
         
         if not self.Owner.ActionList:
             self.Owner.AddComponentByName("ActionList")
         self.Owner.ActionList.EmptyAll()
         self.Owner.GrowthAnim.SetReverse(True)
         self.Owner.GrowthAnim.Active = True
             
         def waitmovieend():
             return not self.Owner.GrowthAnim.Active
         def destroy():
             self.Owner.Destroy()
         
         self.Owner.ActionList.AddCallback(callback=waitmovieend, 
                                           has_self=False, 
                                           blocking=True, 
                                           countdown=None)
                                           
         self.Owner.ActionList.AddCallback(callback=destroy, 
                                           has_self=False, 
                                           blocking=True, 
                                           countdown=0)
    def HighAttack(self):
        self.Owner.Teleportable.Active = True
        self.Owner.Bounceable.Active = False

        self.Owner.ClickReceiver.Receivable = True

        if not self.Owner.Sprite.SpriteSource == self.outanim:
            self.Owner.Sprite.SpriteSource = self.outanim

        if self.Owner.Sprite.CurrentFrame == 2:
            hurtbox = self.Space.CreateAtPosition(
                "HurtBox", self.Owner.Transform.Translation + Vec3(0, .7, 0))
            hurtbox.Transform.Scale = Vec3(.26, 0.75, 1)
            hurtbox.CanHurt.HurtRate = -20
            hurtbox.TimedDeath.LifeTime = 0.05
            hurtbox.AttachToRelative(self.Owner)

            self.Owner.RigidBody.ApplyLinearImpulse(VectorMath.Vec3(0, 5, 0))

            sandsmoke = self.Space.CreateAtPosition(
                "SandSmokeParticle", self.Owner.Transform.Translation)
            t = sandsmoke.SpriteParticleSystem.Tint
            sandsmoke.SpriteParticleSystem.Tint = VectorMath.Vec4(
                t.x, t.y, t.z, 0.1)
            sandsmoke.SphericalParticleEmitter.RandomVelocity *= 0.4
            sandsmoke.SphericalParticleEmitter.EmitCount = 3
            sandsmoke.SphericalParticleEmitter.ResetCount()

        if self.Owner.Sprite.CurrentFrame == 3:
            self.Owner.Sprite.AnimationSpeed = 0

        if self.Owner.RigidBody.Velocity.y < 0:
            self.Owner.Sprite.AnimationSpeed = 1
            self.CurrentUpdate = self.GoUnder
示例#18
0
 def OnLogicUpdate(self, UpdateEvent):
     if Zero.Keyboard.KeyIsPressed(Zero.Keys.W):
         if self.current_door:
             self.current_door.KeyHoleDoor.TeleportThis(self.Owner)
             self.Owner.RigidBody.Velocity = VectorMath.Vec3(0,0,0)
             if self.current_door.KeyHoleDoor.Teleport:
                 self.current_door = self.current_door.KeyHoleDoor.Teleport
示例#19
0
    def OnLogicUpdate(self, UpdateEvent):

        #to make the text big scale object and it's boxcollider
        if (self.big):
            self.Owner.Transform.Scale += VectorMath.Vec3(.006, .006, 0)
            if (self.Owner.BoxCollider):
                self.Owner.BoxCollider.Size += VectorMath.Vec3(.006, .006, 0)
            if (self.Owner.Transform.Scale.x > 1.4):
                self.big = False

        #if it has reached the biggest size set start to shrink
        else:
            self.Owner.Transform.Scale -= VectorMath.Vec3(.006, .006, 0)
            if (self.Owner.BoxCollider):
                self.Owner.BoxCollider.Size -= VectorMath.Vec3(.006, .006, 0)
            if (self.Owner.Transform.Scale.x < 1):
                self.big = True
 def OnCollision(self, CollisionEvent):
     normal = CollisionEvent.FirstPoint.WorldNormalTowardsOther
     # if degree > 22.5 and degree < 65
     if abs(normal.y) < abs(normal.x) * 4 and abs(normal.y) * 1.5 > abs(
             normal.x):
         #print("gravity")
         force = VectorMath.Vec3(normal.x * 22, 0, 0)
         self.Owner.RigidBody.ApplyForce(force)
示例#21
0
    def Initialize(self, initializer):
        self.destination = self.Owner.Transform.WorldTranslation
        hiding_vec = self.HidingOffset * self.Owner.Transform.TransformNormalLocal(
            self.Normal)

        self.Owner.Transform.WorldTranslation += hiding_vec
        self.Owner.Collider.Offset -= VectorMath.Vec3(0, self.HidingOffset, 0)
        Zero.Connect(self.Owner, Events.CollisionStarted, self.OnCollision)
示例#22
0
class CanTeleport:
    Offset = Property.Vector3(VectorMath.Vec3(0, 4, 0))

    def Initialize(self, initializer):
        pass

    def Teleport(self, target):
        target.Transform.Translation += self.Offset
示例#23
0
 def HideDestroy(self, target):
     target.Sprite.Visible = False
     target.Transform.Translation = VectorMath.Vec3(0, 0, -1000)
     target.Collider.Ghost = True
     if not target.RigidBody.Static and not target.RigidBody.Kinematic:
         target.RigidBody.Static = True
     if target.HealthStatus:
         target.HealthStatus.ResetHealth()
示例#24
0
    def OnLogicUpdate(self, UpdateEvent):
        self.EnsureSetting()

        if not self.LevelName == self.parentspace.CurrentLevel.Name:
            self.EnsureKey()

        sets = self.key_status.GetKeySet()
        has_key = False

        for child in self.Owner.Hierarchy.Children:
            child.Sprite.Color *= VectorMath.Vec3(1, 1, 1, 0.9)

        for key, child in zip(sets, self.Owner.Hierarchy.Children):
            has_key = True
            c = child.Sprite.Color
            child.Sprite.Color = VectorMath.Vec3(c.x, c.y, c.z, c.a + 0.1)
            child.Sprite.SpriteSource = self.PicTable.FindResource(key)
    def OnLogicUpdate(self, UpdateEvent):
        self.Owner.Transform.Translation = self.MousePos

        self.UpdateEnvironmentInfo()
        if self.AbsorbActive and self.WithInRange:
            self.PerformAbsorb()

        target_color = VectorMath.Vec4(1, 1, 1, 1)
        target_scale = 5
        target_sprite = self.ShadeTable.FindValue("OutRange")
        radius = 1.2
        self.Owner.Transform.Rotation = self.init_rotate

        skillname = self.hero.AbilityStatus.GetTreeSkillName()
        physskill = self.hero.AbilityStatus.GetPhysSkillName()

        self.Owner.BurnAnim.Active = False
        self.Owner.FreezeAnim.Active = False
        self.Owner.PoisonAnim.Active = False

        if self.TouchPlant and not self.Deactivated:
            target_sprite = self.ShadeTable.FindValue("Cross")
            self.SetPlantAlpha(0.5)

        elif self.WithInRange and not self.Deactivated:
            if self.TouchAttackable:
                target_sprite = self.ShadeTable.FindValue("Attack")
                radius = 2.4
            elif self.TouchAnnihilator or not skillname:
                target_sprite = self.ShadeTable.FindValue("OutRange")

            elif self.TouchGrowable and not self.hero.AbilityStatus.NoTreeSkill(
            ):
                target_color = VectorMath.Vec4(1, 1, 1, 0.75)
                target_sprite = self.ShadeTable.FindValue(skillname)

                if skillname in self.scale_table:
                    target_scale *= self.scale_table[skillname]

                if not skillname == "TreeSkillWhirlingnut":
                    self.Owner.Transform.RotateByAngles(
                        VectorMath.Vec3(
                            0, 0,
                            self.touch_normal.angleZ() - math.pi / 2))

                if physskill and skillname:
                    if physskill in self.color_table:
                        target_color = self.color_table[physskill]
                    if physskill in self.anim_table:
                        self.anim_table[physskill].Active = True
            else:
                target_sprite = self.ShadeTable.FindValue("InRange")

        self.Owner.SphereCollider.Radius = radius
        self.Owner.Sprite.Color = target_color
        self.Owner.Transform.Scale = self.initial_size * target_scale
        self.Owner.SphereCollider.Radius = self.ball_size / target_scale
        self.Owner.Sprite.SpriteSource = target_sprite
示例#26
0
 def OnLogicUpdate(self, UpdateEvent):
     
     # If open gates move
     if(self.access == True):
         #increase the y coordinate
         self.yAxis += UpdateEvent.Dt
         #move one gate up and one gate down
         self.Switchgate2.Transform.Translation = self.startGate2 + VectorMath.Vec3(0, -self.yAxis, 0)
         self.Switchgate1.Transform.Translation = self.startGate1 + VectorMath.Vec3(0, self.yAxis, 0)
         #Until max then set doors there
         if(self.yAxis > 3):
             self.yAxis += 0
             self.startGate1 = self.Switchgate1.Transform.Translation
             self.startGate2 = self.Switchgate2.Transform.Translation
     
     #Limit for gate raising
     if(self.yAxis > 3):
         self.access = False
示例#27
0
 def OnCollision(self, CollisionEvent):
     if (CollisionEvent.OtherObject.Collider.Ghost == False and
             not self.Done) or CollisionEvent.OtherObject.WeatherDestroy:
         self.Done = True
         raindrop = self.Space.CreateAtPosition(
             "RainDrop", CollisionEvent.FirstPoint.WorldPoint +
             VectorMath.Vec3(0, 0, 1))
         for child in self.Owner.Hierarchy.Children:
             raindrop.Sprite.Color = child.Sprite.Color
         self.Owner.Destroy()
示例#28
0
    def Initialize(self, initializer):
        self.Owner.Transform.Scale *= random.random() * .7 + 0.5

        color_shader = random.random() * .7 + 0.3
        self.Owner.Sprite.Color *= Vec4(color_shader, color_shader,
                                        color_shader, 1)
        self.Owner.Sprite.FlipX = random.random() > 0.5

        self.Owner.Transform.RotateByAngles(
            VectorMath.Vec3(0, 0, math.pi / 6 * (random.random() - .5)))
示例#29
0
    def OnCollisionStart(self, CollisionEvent):

        #if the key falls into a fire pit, create fizzle effect and put it back at start location
        if (CollisionEvent.OtherObject.Name == "Pit"):
            self.Space.CreateAtPosition(
                "FizzleKey",
                VectorMath.Vec3(
                    self.Space.FindObjectByName("Key").Transform.Translation))
            self.Space.FindObjectByName(
                "Key").Transform.Translation = self.StartLocation
示例#30
0
class CanBlow:
    BlowDirection = Property.Vector3(VectorMath.Vec3(0, 1, 0))
    BlowForce = Property.Float(4)

    def Initialize(self, initializer):
        pass

    def Blow(self, target, decay):
        if target.RigidBody:
            target.RigidBody.ApplyForce(self.BlowDirection * self.BlowForce *
                                        decay)