Player.SedrickPlayerController.IsOnAirShip = True Player.BoxCollider.Offset = Vector3(0, 0.05, 0) Player.BoxCollider.Size = Vector3(0.5, 0.5, 10) Tracker.PlayerTracker.SedrickIsAlive = False self.Switch5 = False else: if (self.Switch5 is True): self.Start = True self.Switch5 = False elif (self.Chance == 6): Tracker = self.Space.FindObjectByName("PlayerTracker") if (Tracker.PlayerTracker.JulioIsAlive is True): Player = self.Space.CreateAtPosition( "Julio", Vector3(Position.x, Position.y, 0)) Player.JulioPlayerController.IsOnAirShip = True Player.BoxCollider.Offset = Vector3(0, 0.05, 0) Player.BoxCollider.Size = Vector3(0.5, 0.5, 10) Tracker.PlayerTracker.JulioIsAlive = False self.Switch6 = False else: if (self.Switch6 is True): self.Start = True self.Switch6 = False if (Zero.Keyboard.KeyIsPressed(Zero.Keys.O)): self.Start = True Zero.RegisterComponent("CheckPoint", CheckPoint)
def Initialize(self, initializer): self.Space.SoundSpace.PlayMusic("Rain") Zero.Connect(self.Space, Events.LevelStarted, self.OnLevelStart) Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate)
self.Active = False self.NumberTimes = self.Times self.Thunder_1() def Thunder_1(self): self.NumberTimes -= 1 if self.NumberTimes < 0: self.CurrentUpdate = None self.Space.SoundSpace.PlayCue("Thunder") sequence = Action.Sequence(self.Owner.Actions) Action.Delay(sequence, self.ActiveCD) Action.Call(sequence, self.ActiveThunder) return self.Owner.Sprite.Color = Vec3(self.Owner.Sprite.Color.x, self.Owner.Sprite.Color.y, self.Owner.Sprite.Color.z, self.Alpha_Upper) sequence = Action.Sequence(self.Owner.Actions) Action.Delay(sequence, random.uniform(self.CD_Lower, self.CD_Upper)) Action.Call(sequence, self.Thunder_2) def Thunder_2(self): self.Owner.Sprite.Color = Vec3(self.Owner.Sprite.Color.x, self.Owner.Sprite.Color.y, self.Owner.Sprite.Color.z, self.Alpha_Lower) sequence = Action.Sequence(self.Owner.Actions) Action.Delay(sequence, random.uniform(self.CD_Lower, self.CD_Upper)) Action.Call(sequence, self.Thunder_1) def ActiveThunder(self): self.Active = True Zero.RegisterComponent("ThunderTest", ThunderTest)
#print(Parent.GunManStatus.CanShoot) for CastResult in CastResultsRange: if(CastResult.Distance >= MaxRayCastDistance): break if(CastResult.ObjectHit.Name == "Tung" or CastResult.ObjectHit.Name == "Austin" or CastResult.ObjectHit.Name == "Trey" or CastResult.ObjectHit.Name == "Peyton" or CastResult.ObjectHit.Name == "Sedrick" or CastResult.ObjectHit.Name == "Julio"): Parent.GunManStatus.CanShoot = True Parent.GunManStatus.RayCast4 = True else: Parent.GunManStatus.RayCast4 = False if(Parent.GunManStatus.RayCast1 is False and Parent.GunManStatus.RayCast2 is False and Parent.GunManStatus.RayCast3 is False and Parent.GunManStatus.RayCast4 is False and Parent.GunManStatus.RayCast5 is False and Parent.GunManStatus.RayCast6 is False and Parent.GunManStatus.RayCast7 is False and Parent.GunManStatus.RayCast8 is False and Parent.GunManStatus.RayCast9 is False): Parent.GunManStatus.CanShoot = False LastCastResult = CastResult #Limit if(not LastCastResult): #Limit EndPosition = Ray.Start + Ray.Direction * MaxRayCastDistance #self.DrawArrow(Ray.Start, EndPosition, RayColor) else: EndPosition = Ray.Start + Ray.Direction * LastCastResult.Distance #self.DrawArrow(Ray.Start, EndPosition, RayColor) #def DrawArrow(self, StartPos, EndPos, ArrowColor): #DebugDraw.DrawArrow(StartPos, EndPos, 0.25, ArrowColor) Zero.RegisterComponent("Look4", Look4)
def Initialize(self, initializer): Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate) self.FadeLayer = self.Owner.FindChildByName("AlphaLayer")
def Initialize(self, initializer): Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate) self.player = self.Space.FindObjectByName("Hero")
self.Owner.RemoveComponentByName("BoxCollider") self.Owner.AddComponentByName("SphereCollider") self.Owner.SphereCollider.CollisionGroup = "Terrain" self.Owner.SphereCollider.Radius = 1.5 OtherObject = other.Transform.WorldTranslation Difference = Vector3(OtherObject.x - ObjectPosition.x, OtherObject.y - ObjectPosition.y, OtherObject.z - ObjectPosition.z) Distance = math.sqrt( math.pow(Difference.x, 2) + math.pow(Difference.y, 2) + math.pow(Difference.z, 2)) Damage = 8 - Distance other.Bridge.CurrentHealth -= Damage * 100 Action.Delay(sequence, 0.1) Action.Call(sequence, self.OnDeath) def OnDeath(self): Position = self.Owner.Transform.WorldTranslation if (self.CanBlow is True): PlayerBlasterProjectile = self.Space.CreateAtPosition( "PlayerMissleExplodeParticle", Vector3(Position.x, Position.y + 0.5, 4)) self.CanBlow = False self.Owner.Destroy() Zero.RegisterComponent("PlayerMissle", PlayerMissle)
import Zero import Events import Property import VectorMath class Key: KeyValue = Property.String("") 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 def OnCollision(self, CollisionEvent): CollisionEvent.OtherObject.DispatchEvent("GetKeyEvent", self.GetKeyEvent) Zero.RegisterComponent("Key", Key)
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
if(self.LeftRight is True): #print("Right") RotationAngles.y = 1 self.Owner.Transform.Rotation = RotationAngles self.LeftRight = False if(Distance.x > 0): self.IsLeft = False self.IsRight = True if(self.IsRight is True): if(self.LeftRight is False): #print("Left") RotationAngles.y = 0 self.Owner.Transform.Rotation = RotationAngles self.LeftRight = True if(Zero.Keyboard.KeyIsDown(Zero.Keys.S) and not Zero.Keyboard.KeyIsDown(Zero.Keys.A) and not Zero.Keyboard.KeyIsDown(Zero.Keys.D)): self.Owner.Transform.Translation = Vector3(self.BodyX, self.BodyY - 0.09, self.BodyZ) Parent.BoxCollider.Offset = Vector3(0.02, 0.07, 0) Parent.BoxCollider.Size = Vector3(0.1, 0.3, 10) elif(Zero.Keyboard.KeyIsDown(Zero.Keys.Space) or Parent.AustinPlayerController.OnGround is False): self.Owner.Transform.Translation = Vector3(self.BodyX, self.BodyY - 0.02, self.BodyZ) else: self.Owner.Transform.Translation = Vector3(self.BodyX, self.BodyY, self.BodyZ) Parent.BoxCollider.Offset = Vector3(0.02, 0.15, 0) Parent.BoxCollider.Size = Vector3(0.1, 0.5, 10) Zero.RegisterComponent("AustinBody", AustinBody)
self.InitializeObserverList() if self.Owner.DestroyCreateArchetype: self.Destroyer = self.Owner.DestroyCreateArchetype elif self.Owner.DestroyPlayAnim: self.Destroyer = self.Owner.DestroyPlayAnim elif self.Owner.DestroyFadeAnim: self.Destroyer = self.Owner.DestroyFadeAnim elif self.Owner.DestroyTeleport: self.Destroyer = self.Owner.DestroyTeleport else: self.Destroyer = None def Destroy(self): for callback in self.destroy_observers: callback() self.destroy_observers = [] if self.Destroyer: self.Destroyer.Destroy() else: self.Owner.Destroy() def InitializeObserverList(self): self.destroy_observers = [] def Null(): pass self.InitializeObserverList = Null def RegisterObserver(self,callback): self.InitializeObserverList() self.destroy_observers.append(callback) Zero.RegisterComponent("DestroyInterface", DestroyInterface)
Action.Delay(sequence, 0.1) Action.Call(sequence, self.OnDeath) elif (other.Name == "Julio" and self.CanExplode is True): OtherObject = other.Transform.WorldTranslation Difference = Vector3(OtherObject.x - ObjectPosition.x, OtherObject.y - ObjectPosition.y, OtherObject.z - ObjectPosition.z) Distance = math.sqrt( math.pow(Difference.x, 2) + math.pow(Difference.y, 2) + math.pow(Difference.z, 2)) Damage = 8 - Distance other.JulioHealth.CurrentHealth -= Damage * 100 Action.Delay(sequence, 0.1) Action.Call(sequence, self.OnDeath) def OnDeath(self): Position = self.Owner.Transform.WorldTranslation if (self.CanBlow is True): PlayerBlasterProjectile = self.Space.CreateAtPosition( "PlayerMissleExplodeParticle", Vector3(Position.x, Position.y + 0.5, 4)) self.CanBlow = False self.Owner.Destroy() Zero.RegisterComponent("FireBarrel", FireBarrel)
import Zero import Events import Property import VectorMath class CanCheck: def Initialize(self, initializer): self.init_place = self.Owner.Transform.Translation self.current_check = None def SetCheck(self, checkpoint): if self.current_check: self.current_check.Checkable.CheckOut() self.current_check = checkpoint def GetCheck(self): if not self.current_check: return self.init_place else: return self.current_check.Transform.Translation Zero.RegisterComponent("CanCheck", CanCheck)
def OnLogicUpdate(self, UpdateEvent): if self.Active: if self.Owner.RigidBody.Velocity.length() > 2: self.Owner.RigidBody.Velocity *= 0.9 self.CurrentUpdate() def OnCollision(self, CollisionEvent): if CollisionEvent.OtherObject.IsSentry: normal = -CollisionEvent.FirstPoint.WorldNormalTowardsOther #if abs(CollisionEvent.FirstPoint.WorldNormalTowardsOther.x) > 0.95: #v = self.Owner.RigidBody.Velocity #xspeed = v.x #v.x = math.copysign(CollisionEvent.FirstPoint.WorldNormalTowardsOther.x, v.x) #self.Owner.RigidBody.Velocity = v self.Owner.RigidBody.ApplyLinearVelocity(normal * .2) self.CurrentUpdate = self.Walking self.dumbcounter = 30 direction = CollisionEvent.OtherObject.IsSentry.SentryDirection if direction.x == 0 and direction.y == 0: self.Direction = Vec3(1,0,0) if CollisionEvent.FirstPoint.WorldNormalTowardsOther.x < 0 else Vec3(-1,0,0) else: self.Direction = direction def SlowDownBy(self, SlowDownRatio, TimeSteps): pass Zero.RegisterComponent("AIMovementFloatProjectile", AIMovementFloatProjectile)
def Initialize(self, initializer): self.Logo = self.Space.CreateAtPosition("DigipenLogo", Vec3(0, 0, 0)) Zero.Connect(self.Space, Events.LevelStarted, self.OnLevelStart) Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate)
self.counter -= 1 if self.counter == 0: for callback in self.observers: callback() self.observers = None if self.Owner.Hierarchy: for child in self.Owner.Hierarchy.Children: if child.MultiObserverDelegate and child.MultiObserverDelegate.Target: self.counter += 1 child.MultiObserverDelegate.RegisterObserver(Activated) self.counter += 1 if self.Target: self.Target.DestroyInterface.RegisterObserver(Activated) def EnsureObservers(self): self.observers = [] def Null(): pass self.EnsureObservers = Null def RegisterObserver(self, callback): self.EnsureObservers() self.observers.append(callback) Zero.RegisterComponent("MultiObserverDelegate", MultiObserverDelegate)
import Zero import Events import Property import VectorMath import math Vec3 = VectorMath.Vec3 class CameraMovement: CameraFollowSpeed = Property.Float(0.1) def Initialize(self, initializer): Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate) self.player = self.Space.FindObjectByName("Hero") def OnLogicUpdate(self, OnLogicUpdate): towardVec = self.player.Transform.LocalTranslation - self.Owner.Transform.LocalTranslation towardVec.z = 0 if (math.fabs(towardVec.length()) > 0.01): self.Owner.Transform.Translation += towardVec * self.CameraFollowSpeed Zero.RegisterComponent("CameraMovement", CameraMovement)
self.Active = False self.NumberTimes = self.Times self.Thunder_1() def Thunder_1(self): self.NumberTimes -= 1 if self.NumberTimes < 0: self.CurrentUpdate = None self.Space.SoundSpace.PlayCue(self.ThunderCue) sequence = Action.Sequence(self.Owner.Actions) Action.Delay(sequence, self.ActiveCD) Action.Call(sequence, self.ActiveThunder) return self.ThunderLayer.Sprite.Color = Vec3(self.ThunderLayer.Sprite.Color.x, self.ThunderLayer.Sprite.Color.y, self.ThunderLayer.Sprite.Color.z, self.Alpha_Upper) sequence = Action.Sequence(self.Owner.Actions) Action.Delay(sequence, random.uniform(self.CD_Lower, self.CD_Upper)) Action.Call(sequence, self.Thunder_2) def Thunder_2(self): self.ThunderLayer.Sprite.Color = Vec3(self.ThunderLayer.Sprite.Color.x, self.ThunderLayer.Sprite.Color.y, self.ThunderLayer.Sprite.Color.z, self.Alpha_Lower) sequence = Action.Sequence(self.Owner.Actions) Action.Delay(sequence, random.uniform(self.CD_Lower, self.CD_Upper)) Action.Call(sequence, self.Thunder_1) def ActiveThunder(self): self.Active = True Zero.RegisterComponent("ThunderGenerator", ThunderGenerator)
if child.Name == "Preventer": child.Collider.Ghost = True child.DetachRelative() child.Destroy() if obj.RigidBody: obj.RigidBody.RotationLocked = False if obj.MassOverride: obj.MassOverride.Active = False if obj.Sprite: obj.Sprite.AnimationActive = False def Perform(self, position): ice = self.Space.CreateAtPosition("IceParticle", self.mouse.Transform.Translation) ice.AddComponentByName("ActionList") ice.Transform.Translation += VectorMath.Vector3(0, 0, 1) def shrink(self): self.Owner.SpriteParticleSystem.Tint -= VectorMath.Vec4( 0, 0, 0, 0.01) if self.Owner.SpriteParticleSystem.Tint.a < 0.01: self.Owner.Destroy() ice.ActionList.AddCallback(callback=shrink, has_self=True, blocking=True, countdown=None) Zero.RegisterComponent("PhysSkillIce", PhysSkillIce)
size -= Vec3(self.DecreaseSizeDelta, self.DecreaseSizeDelta, self.DecreaseSizeDelta) if (size.x <= self.MinSize or size.y <= self.MinSize or size.z <= self.MinSize): self.CurrentUpdate = None self.Soul.Destroy() self.Death_Stage4() self.Soul.SphericalParticleEmitter.EmitterSize = size def Death_Stage4(self): self.Owner.Sprite.Visible = True self.Owner.Sprite.Color = Vec3(1, 1, 1, 0) self.Owner.BoxCollider.Ghost = False self.Owner.RigidBody.Kinematic = False self.Owner.PlayerController.Active = True self.Owner.Sprite.AnimationActive = True self.CurrentUpdate = self.IncreaseAlpha def IncreaseAlpha(self): color = self.Owner.Sprite.Color color.w += self.IncreaseAlphaDelta if (color.w >= 1.0): color.w = 1.0 self.CurrentUpdate = None self.DeathActive = True self.Owner.Sprite.Color = color Zero.RegisterComponent("CanDie", CanDie)
def Initialize(self, initializer): Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate) Zero.Connect(self.Owner, Events.CollisionStarted, self.OnCollisionStarted)
def Initialize(self, initializer): self.CheckPoint = self.Space.FindObjectByName("CheckPoint") Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate)
self.FadeColorEnd = endColor delta = endColor - startColor self.FadeRDelta = delta.x * deltaRate self.FadeGDelta = delta.y * deltaRate self.FadeBDelta = delta.z * deltaRate self.FadeADelta = delta.a * deltaRate self.FadeLayer.Sprite.Color = startColor self.FadeDelay = cd self.FadeEnable = True def TurnOffCameraFade(self): self.FadeEnable = False self.FadeColorStart = Vec4(0, 0, 0, 0) self.FadeColorEnd = Vec4(0, 0, 0, 0) self.FadeDelay = 0 self.FadeTimer = 0 self.FadeRDelta = 0 self.FadeGDelta = 0 self.FadeBDelta = 0 self.FadeADelta = 0 self.FadeEndFlag = False # Helper def clampCheck(self, minimum, x, maximum): return x > maximum or x < minimum def clamp(self, minimum, x, maximum): return max(minimum, min(x, maximum)) Zero.RegisterComponent("CameraFunction", CameraFunction)
if self.Owner.Hierarchy: for child in self.Owner.Hierarchy.Children: #if not child.Name == "Door": if self.sudden_black_countdown == 0: c = child.Sprite.Color if c.a < 0.05: child.Sprite.Color = Vec4(c.x, c.y, c.z, 0.25) else: child.Sprite.Color = Vec4(c.x, c.y, c.z, .98 * c.a + .02 * da) else: c = child.Sprite.Color child.Sprite.Color = Vec4(c.x, c.y, c.z, .1 * c.a) if child.Hierarchy: for ch in child.Hierarchy.Children: if self.sudden_black_countdown == 0: c = ch.Sprite.Color if c.a < 0.05: ch.Sprite.Color = Vec4(c.x, c.y, c.z, 0.25) else: ch.Sprite.Color = Vec4(c.x, c.y, c.z, .98 * c.a + .02 * da) else: c = child.Sprite.Color child.Sprite.Color = Vec4(c.x, c.y, c.z, .1 * c.a) Zero.RegisterComponent("RandomFlickering", RandomFlickering)
def OnLogicUpdate(self, UpdateEvent): if self.CurrentFunction == None: return self.CurrentFunction() def OnLevelStart(self, LevelStartEvent): self.Camera.CameraFunction.SetCameraFade(Vec4(0, 0, 0, 1), Vec4(0, 0, 0, 0), 0.01, 0) self.CurrentFunction = self.E1_ActivateLogo def E1_ActivateLogo(self): if self.Camera.CameraFunction.FadeDone: self.CurrentFunction = None self.Camera.ThunderGenerator.ActivateThunder() sequence = Action.Sequence(self.Owner.Actions) Action.Delay(sequence, self.E1ToE2Delay) Action.Call(sequence, self.GoToE2) def GoToE2(self): self.CurrentFunction = self.E2_CheckAnimatorEnd self.Camera.CameraFunction.SetCameraFade(Vec4(0, 0, 0, 0), Vec4(0, 0, 0, 1), 0.01, 0) def E2_CheckAnimatorEnd(self): if self.Camera.CameraFunction.FadeDone: self.Space.SoundSpace.StopMusic() self.Space.LoadLevel("MenuScreen") Zero.RegisterComponent("Event_StudioLevel", Event_StudioLevel)
def Initialize(self, initializer): Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate) self.sum = random.random() * 10 self.sudden_black_countdown = 0
if(self.OnGround): self.JumpsRemaining = self.MaxNumberOfJumps def SubtractJumpsRemaining(self): self.JumpsRemaining -= 1 if(self.JumpsRemaining < 0): self.JumpsRemaining = 0 def ChaseTarget(self, UpdateEvent): CameraPosition = self.Space.FindObjectByName("Camera") #PlayPosition = self.Owner.Transform.Translation #CamDistance = CameraPosition.Transform.Translation - PlayPosition CameraPosition.Transform.Translation += Vector3(self.ChaseDirection.x, self.ChaseDirection.y, 0) * UpdateEvent.Dt * self.ChaseSpeed def CalculateChaseDirectionAndDistance(self): CameraPosition = self.Space.FindObjectByName("Camera") PlayPosition = self.Owner.Transform.Translation self.ChaseDirection = Vector3(PlayPosition.x - 2 + self.HorizontalDistance, PlayPosition.y + self.VerticleDistance, 40) - CameraPosition.Transform.Translation #self.DistanceFromTarget = self.ChaseDirection.length() #self.ChaseDirection.normalize() def CalculateChaseDirectionAndDistance2(self): CameraPosition = self.Space.FindObjectByName("Camera") PlayPosition = self.Owner.Transform.Translation self.ChaseDirection = Vector3(PlayPosition.x + 2 + self.HorizontalDistance, PlayPosition.y + self.VerticleDistance, 40) - CameraPosition.Transform.Translation Zero.RegisterComponent("JulioPlayerController", JulioPlayerController)
def E1_ActivateLogo(self): if self.Camera.CameraFunction.FadeDone: self.CurrentFunction = None sequence = Action.Sequence(self.Owner.Actions) Action.Delay(sequence, self.DigipenDisplayDelay) Action.Call(sequence, self.GoToE2) def GoToE2(self): self.Logo.Animator.Active = True self.CurrentFunction = self.E2_CheckAnimatorEnd def E2_CheckAnimatorEnd(self): if not self.Logo.Animator.Active: self.CurrentFunction = None self.Space.SoundSpace.PlayCue("RavenCue") sequence = Action.Sequence(self.Owner.Actions) Action.Delay(sequence, self.LogoDisplayDelay) Action.Call(sequence, self.GoToE3) def GoToE3(self): self.Camera.CameraFunction.SetCameraFade(Vec4(0, 0, 0, 0), Vec4(0, 0, 0, 1), 0.01, 0) self.CurrentFunction = self.E3_Done def E3_Done(self): if self.Camera.CameraFunction.FadeDone: self.Space.LoadLevel("LogoScreen") Zero.RegisterComponent("Event_IntroLevel", Event_IntroLevel)
def Initialize(self, initializer): Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate)
import Zero import Events import Property import VectorMath class PhysSkillFire: Name = Property.String("PhysSkillFire") def Initialize(self, initializer): self.powertext = "I use fire power!!" self.modifiertext = "with fire!!" def OnLogicUpdate(self, UpdateEvent): print (self.powertext) def GetModifier(self): return self.modifiertext Zero.RegisterComponent("PhysSkillFire", PhysSkillFire)