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)
def Initialize(self, initializer): Zero.Connect(self.Owner, Events.CollisionStarted, self.OnCollision) self.TriggerEvent = Zero.ScriptEvent() self.triggerable = True if not self.Owner.SoundEmitter: self.Owner.AddComponentByName("SoundEmitter") self.Owner.SoundEmitter.Positional = False
def OnMouseDown(self, MouseDownEvent): self.Owner.Sprite.Color = VectorMath.Vec4(1, 0, 0, 0.25) heroClickEvent = Zero.ScriptEvent() heroClickEvent.Target = self.hero heroClickEvent.MaxRangeSqrt = 36 self.Owner.Region.DispatchEvent("heroClickEvent", heroClickEvent)
def OnLogicUpdate(self, LogicUpdate): LightStart = Zero.ScriptEvent() LightStart.Min = self.Min LightStart.Max = self.Max LightStart.Source = self.Owner LightStart.Center = self.Owner.Transform.Translation self.Owner.Region.DispatchEvent("LightStartEvent", LightStart)
def Initialize(self, initializer): Zero.Connect(self.Owner, Events.CollisionStarted, self.OnCollision) self.TryKeyEvent = Zero.ScriptEvent() self.TryKeyEvent.Callback = lambda: self.OpenDoor() self.TryKeyEvent.KeyHole = self.KeyHole self.Opened = True if not self.KeyHole else False self.observer_list = []
def OnCollision(self, CollisionEvent): obj = CollisionEvent.OtherObject if (obj.WeatherObjects != None): WeatherDestory = Zero.ScriptEvent() WeatherDestory.Owner = self.Owner WeatherDestory.CollidePos = CollisionEvent.FirstPoint.WorldPoint WeatherDestory.RainDropEffect = self.RainDropEffect obj.DispatchEvent("WeatherDestory", WeatherDestory)
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)
def Initialize(self, initializer): self.xnum = int(self.Owner.Transform.Scale.x * 2) self.ynum = int(self.Owner.Transform.Scale.y * 2) self.RecArray = [[None for x in range(self.xnum)] for x in range(self.ynum)] self.freeze_event = Zero.ScriptEvent() self.frozen_set = set() self.curious_offset = Vec3(0, 0.035, 0) if self.CreateWaterRing: self.cache_ring = dict() self.cache_ring2 = dict() onlytop = "WaterTopOnly" for i, col in enumerate(self.RecArray): for j, item in enumerate(col): boxwidth = self.Owner.Sprite.Size.x * self.Owner.Transform.Scale.x boxheight = self.Owner.Sprite.Size.y * self.Owner.Transform.Scale.y self.origin = self.Owner.Transform.Translation + Vec3( -boxwidth / 2 + self.Rec_W * 0.5, +boxheight / 2 - self.Rec_W * 0.5, 0.1) v3 = Vec3((self.Rec_W + 0.0000001) * j, -1 * (self.Rec_H + 0.0000001) * i, 0) objname = "WaterTop" if i == 0 else "WaterMid" item = self.Space.CreateAtPosition(objname, self.origin + v3) item.AttachToRelative(self.Owner) self.RecArray[i][j] = item if self.CreateWaterRing: # manage side waves obj = None if j == self.xnum - 1: obj = self.Space.CreateAtPosition( onlytop, self.origin + v3 + Vec3(0, 0, 1)) obj.Transform.RotateByAngles(Vec3(0, 0, -math.pi / 2)) if j == 0: obj = self.Space.CreateAtPosition( onlytop, self.origin + v3 + Vec3(0, 0, 1)) obj.Transform.RotateByAngles(Vec3(0, 0, math.pi / 2)) if obj: self.cache_ring[(j, i)] = obj # manage bottom waves if i == self.ynum - 1: obj = self.Space.CreateAtPosition( onlytop, self.origin + v3 + self.curious_offset + Vec3(0, 0, 1)) obj.Transform.RotateByAngles(Vec3(0, 0, math.pi)) self.cache_ring2[(j, i)] = obj
def Initialize(self, initializer): Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate) #Zero.Connect(self.Space, Events.MouseUpdate, self.OnMouseUpdate) self.sequence = Action.Sequence(self.Owner.Actions) self.LightStart = Zero.ScriptEvent() self.LightStart.Min = self.Min self.LightStart.Max = self.Max self.LightStart.Source = self.Owner self.LightStart.Center = self.Owner.Transform.Translation self.Test() self.Test2()
def Initialize(self, initializer): Zero.Connect(self.Owner, Events.CollisionStarted, self.OnCollision) self.GetKeyEvent = Zero.ScriptEvent() def destroyer(): if self.Owner.DestroyInterface: self.Owner.DestroyInterface.Destroy() else: self.Owner.Destroy() self.Owner.Destroy() self.GetKeyEvent.Callback = destroyer self.GetKeyEvent.KeyValue = self.KeyValue
def OnCollision(self, CollisionEvent): if self.Active: if self.UpdateBasedOnSprite: if (self.Owner.Sprite.FlipX == True and self.ForcedVx > 0) or (self.Owner.Sprite.FlipX == False and self.ForcedVx < 0): self.ForcedVx = -self.ForcedVx if CollisionEvent.OtherObject.Bounceable: impulseEvent = Zero.ScriptEvent() impulseEvent.ForcedVx = self.ForcedVx impulseEvent.ForcedVy = self.ForcedVy CollisionEvent.OtherObject.DispatchEvent( "BounceEvent", impulseEvent)
def Initialize(self, initializer): self.xnum = int(self.Owner.Transform.Scale.x * 2) self.ynum = int(self.Owner.Transform.Scale.y * 2) self.RecArray = [[None for x in range(self.xnum)] for x in range(self.ynum)] self.freeze_event = Zero.ScriptEvent() self.frozen_set = set() for i, col in enumerate(self.RecArray): for j, item in enumerate(col): boxwidth = self.Owner.Sprite.Size.x * self.Owner.Transform.Scale.x boxheight = self.Owner.Sprite.Size.y * self.Owner.Transform.Scale.y self.origin = self.Owner.Transform.Translation + Vec3( -boxwidth / 2 + self.Rec_W * 0.5, +boxheight / 2 - self.Rec_W * 0.5, 0.1) v3 = Vec3((self.Rec_W + 0.0000001) * j, -1 * (self.Rec_H + 0.0000001) * i, 0) objname = "WaterTop" if i == 0 else "WaterMid" item = self.Space.CreateAtPosition(objname, self.origin + v3) item.AttachToRelative(self.Owner) self.RecArray[i][j] = item
def OnCollision(self, CollisionEvent): if self.Active: FreezeEvent = Zero.ScriptEvent() CollisionEvent.OtherObject.DispatchEvent("FreezeEvent", FreezeEvent)
def PerformAbsorb(self): if not self.Deactivated: heroClickEvent = Zero.ScriptEvent() heroClickEvent.Target = self.hero self.Owner.Region.DispatchEvent("heroClickEvent", heroClickEvent)
def Initialize(self, initializer): Zero.Connect(self.Owner, Events.CollisionStarted, self.OnCollision) self.GetKeyEvent = Zero.ScriptEvent() self.GetKeyEvent.Callback = lambda: self.Owner.Destroy() self.GetKeyEvent.KeyValue = self.KeyValue
Action.Delay(sequence, self.Lifetime) Action.Call(sequence, self.OnDeath) def OnDeath(self): #let anyone listening know we just died
def Initialize(self, initializer): Zero.Connect(self.Owner, Events.CollisionStarted, self.OnCollision) self.TriggerEvent = Zero.ScriptEvent() self.triggerable = True
def OnCollision(self, CollisionEvent): PoisonEvent = Zero.ScriptEvent() CollisionEvent.OtherObject.DispatchEvent("PoisonEvent", PoisonEvent)
def OnCollision(self, CollisionEvent): if self.Active: BurnEvent = Zero.ScriptEvent() CollisionEvent.OtherObject.DispatchEvent("BurnEvent", BurnEvent)
def Initialize(self, initializer): Zero.Connect(self.Owner, Events.CollisionStarted, self.OnCollision) self.TryKeyEvent = Zero.ScriptEvent() self.TryKeyEvent.Callback = lambda: self.OpenDoor() self.TryKeyEvent.KeyHole = self.KeyHole
def BurnFriends(): burnevent = Zero.ScriptEvent() for ch in self.Owner.Collider.Contacts: ch.OtherObject.DispatchEvent("BurnEvent", burnevent)