示例#1
0
    def OnCollision(self, CollisionEvent):
        if not CollisionEvent.OtherObject.PlayerController:
            Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
            self.Owner.Collider.Ghost = True

            self.Owner.TimedDeath.Active = True
            self.Owner.CanHurtOnce.Active = False
            self.Owner.RigidBody.Static = True
        else:
            Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
            self.Owner.Collider.Ghost = True
            self.Owner.RigidBody.Static = True
            self.Owner.TimedDeath.Active = True
            self.Owner.GravityEffect.Active = False
            self.Owner.AttachToRelative(CollisionEvent.OtherObject)
示例#2
0
    def OnCollision(self, CollisionEvent):
        self.EnsureObserver()
        for observer in self.observers:
            observer.Summoned.ShowAll()

        Zero.Connect(self.Space, Events.LogicUpdate, self.FlyUpdate)
        Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
示例#3
0
    def FlyUpdate(self, UpdateEvent):
        t = self.Owner.Transform.WorldTranslation
        self.Owner.Transform.WorldTranslation = t * 0.9 + self.destination * 0.1

        if (self.Owner.Transform.WorldTranslation -
                self.destination).length() < 0.01:
            Zero.Disconnect(self.Space, Events.LogicUpdate, self)
示例#4
0
 def OnLogicUpdate(self, UpdateEvent):
     if not self.Activated:
         if self.StartFreezing:
             self.FreezeCounter += UpdateEvent.Dt
             self.Owner.DragEffect.Drag *= 1.1
             if self.FreezeCounter > self.FreezeDelay:
                 self.Activated = True
                 self.Owner.Collider.Ghost = False
                 self.Owner.DragEffect.Active = False
                 self.Owner.GravityEffect.Active = True
                 for contactholder in self.Owner.Collider.Contacts:
                     otherobj = contactholder.OtherObject
                     if otherobj.CannotBeFrozen:
                         continue
                     if otherobj.RigidBody:
                         otherobj.RigidBody.Kinematic = False
                         otherobj.RigidBody.Static = True
                     if otherobj.AIMovementInterface:
                         otherobj.AIMovementInterface.Deactivate()
                     if otherobj.BurnAnim:
                         otherobj.BurnAnim.Active = False
                     if otherobj.PoisonAnim:
                         otherobj.PoisonAnim.Active = False
                     if otherobj.FreezeAnim:
                         otherobj.FreezeAnim.Active = False
     else:
         effect_active = False
         for contactholder in self.Owner.Collider.Contacts:
             if contactholder.OtherObject.CannotBeFrozen:
                 effect_active = True
         if not effect_active:
             self.Owner.GravityEffect.Active = False
             Zero.Disconnect(self.Owner, Events.LogicUpdate,
                             self.OnLogicUpdate)
示例#5
0
    def OnLogicUpdate(self, UpdateEvent):
        if not self.followed.CanFancyDie.DeathActive:
            self.Owner.RigidBody.Kinematic = False

            Zero.Disconnect(self.Space, Events.LogicUpdate, self)
        else:

            self.Owner.Transform.Translation = self.followpoint + self.followed.Transform.Translation
示例#6
0
    def OnLogicUpdate(self, UpdateEvent):
        if not self.Activated:
            if self.StartFreezing:
                self.FreezeCounter += UpdateEvent.Dt
                self.Owner.DragEffect.Drag *= 1.1
                if self.Owner.FlowEffect:
                    self.Owner.FlowEffect.FlowSpeed *= 0.95
                
                #self.Owner.AddComponentByName("FreezeAnim")
                if self.FreezeCounter > self.FreezeDelay:
                    freezeflow = Zero.ScriptEvent()
                    self.Owner.Region.DispatchEvent("FreezeFlowEvent", freezeflow)
                    self.Activated = True
                    self.Owner.Collider.Ghost = False
                    self.Owner.DragEffect.Active = False
                    
                    if self.Owner.FlowEffect:
                        self.Owner.FlowEffect.Active = False
                        
                    self.Owner.GravityEffect.Active = True
                    for contactholder in self.Owner.Collider.Contacts:
                        
                        otherobj = contactholder.OtherObject
                        if otherobj.MouseLocationIndicator:
                            continue
                        elif otherobj.CannotBeFrozen:
                            continue
                        elif otherobj.GrowableGround:
                            continue
                        elif otherobj.PlantAnnihilator:
                            continue  
                        if otherobj.RigidBody:
                            otherobj.RigidBody.Kinematic= False
                            otherobj.RigidBody.Static= True
                        if otherobj.AIMovementInterface:
                            otherobj.AIMovementInterface.Deactivate()
                        if otherobj.BurnAnim:
                            otherobj.BurnAnim.Active = False
                        if otherobj.PoisonAnim:
                            otherobj.PoisonAnim.Active = False
                        
                        #if otherobj.FreezeAnim:
                        #    otherobj.FreezeAnim.Active = False
        else:
            effect_active = False
            for contactholder in self.Owner.Collider.Contacts:
                if contactholder.OtherObject.CannotBeFrozen:
                    effect_active = True

            if not effect_active:
                s = self.Owner.Sprite.Color 
                self.Owner.Sprite.Color = VectorMath.Vec4(s.x * 2.3, s.y * 2.3, s.z * 2.3, 1)
                self.Owner.GravityEffect.Active = False
                if self.Owner.CanHurt:
                    self.Owner.CanHurt.Active = False
                Zero.Disconnect(self.Space, Events.LogicUpdate, self)
示例#7
0
 def OnLogicUpdate(self, UpdateEvent):
     self.target.RigidBody.Kinematic = True
     self.target.Transform.WorldTranslation = self.target.Transform.WorldTranslation * 0.8 + self.Owner.Transform.WorldTranslation * 0.2
     
     if (self.target.Transform.WorldTranslation-self.Owner.Transform.WorldTranslation).length() < 0.0001:
         Zero.Disconnect(self.Space, Events.LogicUpdate, self)
         
     if self.target.PlayerController:
         self.target.PlayerController.DontUpdateAnim = True
         self.target.PlayerController.PlayPainAnim()
示例#8
0
    def OnCollision(self, CollisionEvent):
        if not CollisionEvent.OtherObject.PlayerController:
            Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
            self.Owner.Collider.Ghost = True

            self.Owner.TimedDeath.Active = True
            self.Owner.CanHurtOnce.Active = False
            self.Owner.RigidBody.Kinematic = True
        else:
            Zero.Disconnect(self.Owner, Events.CollisionStarted, self)

            self.Owner.Collider.Ghost = True
            self.Owner.RigidBody.Kinematic = True
            self.Owner.TimedDeath.Active = True
            self.Owner.GravityEffect.Active = False

            self.followed = CollisionEvent.OtherObject
            self.followpoint = self.Owner.Transform.Translation - self.followed.Transform.Translation

            Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate)
示例#9
0
    def UnHook(self):
        self.Owner.RigidBody.Static = False
        self.Owner.DetachRelative()
        if self.Owner.Teleportable:
            self.Owner.Teleportable.Active = True
        if self.Owner.TimedDeath:
            self.Owner.TimedDeath.Active = True
        if self.Owner.CanCollect:
            self.Owner.RemoveComponentByName("CanCollect")

        Zero.Disconnect(self.Space, Events.LogicUpdate, self)
示例#10
0
    def OnCollision(self, CollideEvent):
        if CollideEvent.OtherObject == self.Target:

            def DestroyIt():
                self.Space.CreateAtPosition(
                    "SoulHitEffect", self.Owner.Transform.WorldTranslation)
                self.Owner.Destroy()

            seq = Action.Sequence(self.Owner.Actions)
            Action.Delay(seq, 0.1)
            Action.Call(seq, DestroyIt)
            Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
示例#11
0
    def OnCollision(self, CollisionEvent):
        if CollisionEvent.OtherObject.GrowableGround:

            normal = -CollisionEvent.FirstPoint.WorldNormalTowardsOther
            self.Owner.Transform.Translation += normal * CollisionEvent.FirstPoint.Penetration
            if self.ShouldRoot:
                self.Owner.Transform.Rotation = CollisionEvent.OtherObject.Transform.Rotation
                self.Owner.RigidBody.Kinematic = True

            if self.Owner.CanBounce:
                self.Owner.CanBounce.ToDirection(normal)

            Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
示例#12
0
    def OnCollision(self, CollisionEvent):
        if CollisionEvent.OtherObject.GrowableGround or CollisionEvent.OtherObject.PlantAnnihilator:

            self.normal = -CollisionEvent.FirstPoint.WorldNormalTowardsOther
            self.normal.z = 0

            self.Owner.Transform.Translation += self.normal * CollisionEvent.FirstPoint.Penetration
            if self.ShouldRoot:
                #self.Owner.Transform.RotateByAngles(VectorMath.Vec3(0,0,self.normal.angleZ()-math.pi/2))
                #CollisionEvent.OtherObject.Transform.Rotation
                self.Owner.RigidBody.Kinematic = True

            #if self.Owner.CanBounce:
            #self.Owner.CanBounce.ToDirection(self.normal)

            Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
示例#13
0
 def OnCollision(self, CollisionEvent):
     CollisionEvent.OtherObject.RigidBody.Kinematic = True
     seq = Action.Sequence(self.Owner.Actions)
     Action.Delay(seq,1)
     
     
     def Blacker():
         self.Space.FindObjectByName("Camera").CameraFunction.SetCameraFade(VectorMath.Vec4(0,0,0,0),VectorMath.Vec4(0,0,0,1),0.15,0)
         self.Space.FindObjectByName("LevelSettings").LevelStart.HUDManager.HideBoxes()
     Action.Call(seq, Blacker)
     
     Action.Delay(seq,3)
     
     def DestroyAll():
         self.Space.LoadLevel("MenuScreen")
         self.Space.FindObjectByName("LevelSettings").LevelStart.HUDManager.Space.Destroy()
     Action.Call(seq, DestroyAll)
     
     Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
示例#14
0
    def OnLogicUpdate(self, UpdateEvent):
        if not self.Activated:
            if self.StartFreezing:
                if self.FreezingObject:
                    self.last_pos = self.FreezingObject.Transform.WorldTranslation
                self.FreezeCounter += UpdateEvent.Dt
                self.Owner.DragEffect.Drag *= 1.1
                if self.Owner.FlowEffect:
                    self.Owner.FlowEffect.FlowSpeed *= 0.95
                
                #self.Owner.AddComponentByName("FreezeAnim")
                if self.FreezeCounter > self.FreezeDelay:
                    #freezeflow = Zero.ScriptEvent()
                    #self.Owner.Region.DispatchEvent("FreezeFlowEvent", freezeflow)
                    self.Activated = True
                    self.Owner.Collider.Ghost = False
                    self.Owner.DragEffect.Active = False
                    
                    if self.Owner.FlowEffect:
                        self.Owner.FlowEffect.Active = False
                        
                    self.Owner.GravityEffect.Active = True
                    for contactholder in self.Owner.Collider.Contacts:
                        
                        otherobj = contactholder.OtherObject
                        if otherobj.MouseLocationIndicator:
                            continue
                        elif otherobj.CannotBeFrozen:
                            continue
                        elif otherobj.GrowableGround:
                            continue
                        elif otherobj.PlantAnnihilator:
                            continue  
                        if otherobj.RigidBody:
                            otherobj.RigidBody.Kinematic= False
                            otherobj.RigidBody.Static= True
                        if otherobj.AIMovementInterface:
                            otherobj.AIMovementInterface.Deactivate()
                        if otherobj.BurnAnim:
                            otherobj.BurnAnim.Active = False
                        if otherobj.PoisonAnim:
                            otherobj.PoisonAnim.Active = False
                        
                        if otherobj.FreezeAnim:
                            otherobj.FreezeAnim.Active = False
                        if otherobj.Hierarchy and not otherobj.FreezableFlow:
                            for child in otherobj.Hierarchy.Children:
                                if child.Sprite:
                                    child.Sprite.AnimationActive = False
                        if otherobj.FreezableFlow:
                            
                            otherobj.FreezableFlow.DirectActivate(self.Owner)
                            
                        otherobj.Transform.Translation *= VectorMath.Vec3(1,1,-1)


        else:
            effect_active = False
            for contactholder in self.Owner.Collider.Contacts:
                if contactholder.OtherObject.CannotBeFrozen:
                    effect_active = True

            if not effect_active:
                s = self.Owner.Sprite.Color
                self.Owner.Sprite.Color = VectorMath.Vec4(s.x * 2.3, s.y * 2.3, s.z * 2.3, 1)
                self.Owner.GravityEffect.Active = False
                if self.Owner.CanHurt:
                    self.Owner.CanHurt.Active = False
                
                if self.FreezingObject:
                    self.Owner.WaterLayerGenerator.FreezeAt(self.FreezingObject.Transform.WorldTranslation)
                else:
                    self.Owner.WaterLayerGenerator.FreezeAt(self.last_pos)
                self.Owner.AddComponentByName("IsSentry")
                Zero.Disconnect(self.Space, Events.LogicUpdate, self)
示例#15
0
 def DeactivateAndReset(self):
     self.Owner.Sprite.SpriteSource = self.AnimTable.FindValue(
         "NonActivated")
     Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
示例#16
0
 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)
示例#17
0
 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)
示例#18
0
 def OnCollision(self, CollisionEvent):
     Zero.Connect(self.Space, Events.LogicUpdate, self.FlyUpdate)
     Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
示例#19
0
 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)
示例#20
0
 def Unhide(self):
     if self.hided:
         self.hided = False
         Zero.Disconnect(self.Owner, Events.LogicUpdate, self)
         Zero.Connect(self.Space, Events.LogicUpdate, self.UnhidingUpdate)
示例#21
0
 def OnLogicUpdate(self, UpdateEvent):
     camera = self.Space.FindObjectByName("Camera")
     camera.CameraFunction.SetCameraFade(Vec4(1,1,1,1),Vec4(1,1,1,0),0.03,0)
     Zero.Disconnect(self.Space, Events.LogicUpdate, self)
示例#22
0
 def OnCollision(self, CollisionEvent):
     self.Owner.Sprite.SpriteSource = self.AnimTable.FindValue("Activated")
     Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
示例#23
0
 def OnCollision(self, CollisionEvent):
     self.target = CollisionEvent.OtherObject
     Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
     Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate)