Exemplo n.º 1
0
import Zero
import Events
import Property
import VectorMath


class PlayerGravityModifier:
    Active = Property.Bool(True)

    def Initialize(self, initializer):
        Zero.Connect(self.Owner, Events.CollisionPersisted, self.OnCollision)

    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) * 4 and abs(normal.y) * 1.5 > abs(
                    normal.x):
                force = VectorMath.Vec3(normal.x * 11, -normal.y * 3, 0)
                self.Owner.RigidBody.ApplyForce(force)


Zero.RegisterComponent("PlayerGravityModifier", PlayerGravityModifier)
            elif (self.CanFall is True):
                self.Owner.Sprite.SpriteSource = "GunManFall"
                self.CanFall = False

            self.Owner.RigidBody.ApplyForce(MoveDirection * self.MoveSpeed)

    def GetDegreeDifference(self, SurfaceNormal):
        UpDirection = Vector3(0, 1, 0)
        CosTheta = SurfaceNormal.dot(UpDirection)
        CosTheta = min(max(CosTheta, -1.0), 1.0)
        Radians = math.acos(CosTheta)
        Degrees = math.degrees(Radians)
        return Degrees

    def IsGround(self, SurfaceNormal):

        Degrees = self.GetDegreeDifference(SurfaceNormal)
        return Degrees < 60.0

    def UpdateJumpState(self):
        if (self.OnGround):
            self.JumpsRemaining = self.MaxNumberOfJumps

    def SubtractJumpsRemaining(self):
        self.JumpsRemaining -= 1
        if (self.JumpsRemaining < 0):
            self.JumpsRemaining = 0


Zero.RegisterComponent("GunManControllerTest", GunManControllerTest)
Exemplo n.º 3
0
                    self.Owner.Sprite.Visible = True
            #Level 6
            elif (self.Owner.Name == "Check6"):
                if (self.scores[5] > 0):
                    self.Owner.Sprite.Visible = True
            #Level 7
            elif (self.Owner.Name == "Check7"):
                if (self.scores[6] > 0):
                    self.Owner.Sprite.Visible = True
            #Level 8
            elif (self.Owner.Name == "Check8"):
                if (self.scores[7] > 0):
                    self.Owner.Sprite.Visible = True
            #Level 9
            elif (self.Owner.Name == "Check9"):
                if (self.scores[8] > 0):
                    self.Owner.Sprite.Visible = True
            #Level 10
            elif (self.Owner.Name == "Check10"):
                if (self.scores[9] > 0):
                    self.Owner.Sprite.Visible = True
            #Level 11
            elif (self.Owner.Name == "Check11"):
                if (self.scores[10] > 0):
                    self.Owner.Sprite.Visible = True


#-----------------------------------------------------------------------------------

Zero.RegisterComponent("LvlDoneCheck", LvlDoneCheck)
Exemplo n.º 4
0
import Zero
import Events
import Property
import VectorMath


class WindSpawningPlant:
    def Initialize(self, initializer):
        pass


Zero.RegisterComponent("WindSpawningPlant", WindSpawningPlant)
Exemplo n.º 5
0
class DoorEnterer:
    def Initialize(self, initializer):
        Zero.Connect(self.Owner, Events.CollisionStarted, self.OnCollision)
        Zero.Connect(self.Owner, Events.CollisionEnded, self.OnCollisionEnd)
        Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate)
        
        self.current_door = None
        
    def OnCollision(self, CollisionEvent):
        if CollisionEvent.OtherObject.KeyHoleDoor and CollisionEvent.OtherObject.KeyHoleDoor.IsOpened():
            self.current_door = CollisionEvent.OtherObject
            if self.current_door.KeyHoleDoor.SimpleTeleport:
                self.current_door.KeyHoleDoor.TeleportThis(self.Owner)
            
    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
            
    def OnCollisionEnd(self, CollisionEvent):
        if CollisionEvent.OtherObject == self.current_door:
            self.current_door = None
        
        
        
        
Zero.RegisterComponent("DoorEnterer", DoorEnterer)
Exemplo n.º 6
0
        #for setting and update timer
        self.secondsPassed = 0
        self.starttime = self.secondsPassed
        self.timertext = self.Owner.HUDCreator.HUDSpace.FindObjectByName(
            "Timer")

    def OnLogicUpdate(self, UpdateEvent):

        #updating seconds pass and total time
        self.secondsPassed += UpdateEvent.Dt
        self.totalTime += UpdateEvent.Dt

        #----------------------------------------------------------------------------
        #Finding the HUD if there is one and updating the timer text object
        hudSpace = Zero.Game.FindSpaceByName("HUDSpace")
        if (not hudSpace):
            pass
        timeObject = hudSpace.FindObjectByName("Timer")
        if (timeObject):
            timeObject.SpriteText.Text = str(round(self.secondsPassed, 1))

    #----------------------------------------------------------------------------

    #If players time goes over the par set for that letter the timer text turns red
        if (self.totalTime > self.par):
            self.timertext.SpriteText.Color = Color.Red


Zero.RegisterComponent("Timer", Timer)
Exemplo n.º 7
0
        if not self.Active:
            if self.freezeanim:
                self.freezeanim.Destroy()
        else: 
            if not self.freezeanim:
                if not self.Owner == self.Owner.FindRoot():
                    self.freezeanim = self.Space.CreateAtPosition("IceParticle", self.Owner.FindRoot().Transform.Translation)
                    self.freezeanim.Transform.Scale = self.Owner.FindRoot().Transform.Scale
                    self.freezeanim.AttachToRelative(self.Owner.FindRoot())
                    self.freezeanim.Transform.Translation = self.Owner.Transform.Translation
                    self.freezeanim.AttachToRelative(self.Owner)
                else:
                    self.freezeanim = self.Space.CreateAtPosition("IceParticle", self.Owner.Transform.Translation)
                    
                    t = self.freezeanim.SpriteParticleSystem.Tint
                    t.a = self.Alpha
                    self.freezeanim.SpriteParticleSystem.Tint = t
                    
                    self.freezeanim.SphericalParticleEmitter.EmitterSize *= self.Owner.Transform.WorldScale.x
                    self.freezeanim.SphericalParticleEmitter.EmitRate *= self.Owner.Transform.WorldScale.x / 0.5
                    if self.freezeanim.SphericalParticleEmitter.EmitRate < 4:
                        self.freezeanim.SphericalParticleEmitter.EmitRate = 4
                    self.freezeanim.AttachToRelative(self.Owner)
                    
                
    def Destroyed(self):
        if self.freezeanim:
            self.freezeanim.Destroy()

Zero.RegisterComponent("FreezeAnim", FreezeAnim)
Exemplo n.º 8
0
                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)
                
                
    def DirectActivate(self, obj):
        if not self.Activated:
            self.FreezingObject = obj
            self.StartFreeze()
            
    def OnCollision(self, CollisionEvent):
        
        if not self.Activated:            
            otherobj = CollisionEvent.OtherObject
            if otherobj.CanFreeze and otherobj.CanFreeze.Active:
                self.FreezingObject = CollisionEvent.OtherObject
                self.StartFreeze()
                
                    
            

Zero.RegisterComponent("FreezableFlow", FreezableFlow)
Exemplo n.º 9
0
    MaxLife = Property.Float(4)
    Done = False

    def Initialize(self, initializer):
        Zero.Connect(self.Owner, Events.CollisionStarted, self.OnCollision)
        #Zero.Connect(self.Owner, "WeatherDestory", self.OnWeatherDestory)

        sequence = Action.Sequence(self.Owner.Actions)
        Action.Delay(sequence, self.MaxLife)
        Action.Call(sequence, self.Death)

    def OnCollision(self, CollisionEvent):
        if CollisionEvent.OtherObject.Collider.Ghost == False:
            if CollisionEvent.OtherObject.NoRainDropEffect == None and not self.Done:
                self.Space.CreateAtPosition(
                    "RainDrop", CollisionEvent.FirstPoint.WorldPoint)
                self.Done = True
            self.Death()

    #def OnWeatherDestory(self, WeatherEvent):
    #    if WeatherEvent.RainDropEffect and not self.Done:
    #        self.Space.CreateAtPosition("RainDrop", WeatherEvent.CollidePos)
    #        self.Done = True
    #    self.Death()

    def Death(self):
        self.Owner.Destroy()


Zero.RegisterComponent("WeatherObjects", WeatherObjects)
Exemplo n.º 10
0
import Zero
import Events
import Property
import VectorMath


class Collectible:
    def Initialize(self, initializer):
        pass

    def Collected(self):
        self.Space.CreateAtPosition("GoldParticle",
                                    self.Owner.Transform.Translation)
        self.Owner.Destroy()


Zero.RegisterComponent("Collectible", Collectible)
Exemplo n.º 11
0
    def GetBackSkill(self):
        fts = self.ForcedTreeSkill.FindValue(
            self.ParentSpace.CurrentLevel.Name)
        fps = self.ForcedPhysSkill.FindValue(
            self.ParentSpace.CurrentLevel.Name)

        if self.skillnames:
            if not fts:
                fts = self.skillnames[0]
            if not fps:
                fps = self.skillnames[1]

        self.Player.AbilityStatus.SwapTreeSkill(fts)
        self.Player.AbilityStatus.SwapPhysSkill(fps)

    def HideBoxesSmooth(self):
        self.PBoxLarge.HiderScript.Hide()
        self.PBoxSmall.HiderScript.Hide()
        self.PBoxLargeBack.HiderScript.Hide()
        self.PBoxSmallBack.HiderScript.Hide()

    def ShowBoxesSmooth(self):
        self.PBoxLarge.HiderScript.Unhide()
        self.PBoxSmall.HiderScript.Unhide()
        self.PBoxLargeBack.HiderScript.Unhide()
        self.PBoxSmallBack.HiderScript.Unhide()


Zero.RegisterComponent("HUDManager", HUDManager)
Exemplo n.º 12
0
import Zero
import Events
import Property
import VectorMath


class CanInstantKill:
    def Initialize(self, initializer):
        Zero.Connect(self.Owner, Events.CollisionStarted, self.OnCollision)

    def OnCollision(self, CollisionEvent):
        if CollisionEvent.OtherObject.CanFancyDie:
            CollisionEvent.OtherObject.CanFancyDie.Die()


Zero.RegisterComponent("CanInstantKill", CanInstantKill)
Exemplo n.º 13
0
                abilitysoul = self.Space.CreateAtPosition(
                    "AbilitySoul", self.Owner.Transform.Translation)
                callbacks = []

                if self.GrantTreeAbility:
                    callbacks.append(lambda: player.AbilityStatus.
                                     SwapTreeSkill(self.GrantTreeAbility))
                    abilitysoul.SpriteParticleSystem.Tint = self.ColorDict[
                        self.GrantTreeAbility]

                if self.GrantPhysAbility:
                    callbacks.append(lambda: player.AbilityStatus.
                                     SwapPhysSkill(self.GrantPhysAbility))
                    abilitysoul.SpriteParticleSystem.Tint = self.ColorDict[
                        self.GrantPhysAbility]

                if callbacks:

                    def callbacker():
                        for callback in callbacks:
                            callback()

                    abilitysoul.CanTransferAbility.SetCallback(callbacker)
                else:
                    abilitysoul.RemoveComponentByName("CanTransferAbility")
                    abilitysoul.AbilitySoulBehavior.NoMoving = True
                self.DestroyOwner()


Zero.RegisterComponent("ClickReceiver", ClickReceiver)
Exemplo n.º 14
0
import Zero
import Events
import Property
import VectorMath


class Hookable:
    Active = Property.Bool(False)
    NonActivatable = Property.Bool(False)

    def Initialize(self, initializer):
        if self.NonActivatable:
            self.Active = False

    def Hook(self, target):
        if self.Active:
            if self.Owner.Teleportable:
                self.Owner.Teleportable.Active = False
            self.Owner.AttachToRelative(target)
            self.Owner.RigidBody.Static = True

    def UnHook(self):
        self.Owner.RigidBody.Static = False
        self.Owner.DetachRelative()
        if self.Owner.Teleportable:
            self.Owner.Teleportable.Active = True


Zero.RegisterComponent("Hookable", Hookable)
Exemplo n.º 15
0
            PlayerBlasterProjectile = self.Space.CreateAtPosition(
                "WoodParticle", Vector3(Position.x, Position.y + 0.5, 4))
            PlayerBlasterProjectile = self.Space.CreateAtPosition(
                "WoodParticle", Vector3(Position.x, Position.y + 0.5, 4))
            PlayerBlasterProjectile = self.Space.CreateAtPosition(
                "WoodParticle", Vector3(Position.x, Position.y + 0.5, 4))
            self.Owner.Destroy()

    def OnCollisionStarted(self, CollisionEvent):

        other = CollisionEvent.OtherObject

        if (other.Name == "PlayerSmallBullet"):

            self.CurrentHealth -= 10

        elif (other.Name == "PlayerGiantBullet"):

            self.CurrentHealth -= 15

        elif (other.Name == "EnemySmallBullet"):

            self.CurrentHealth -= 10

        elif (other.Name == "EnemyGiantBullet"):

            self.CurrentHealth -= 15


Zero.RegisterComponent("Bridge", Bridge)
Exemplo n.º 16
0
                Parent.GunManStatus.CanShoot = True
                Parent.GunManStatus.RayCast8 = True
            else:
                Parent.GunManStatus.RayCast8 = 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("Look8", Look8)
            if (self.timer2 > 0.6):
                self.CanAnimateIdle = True

                if (self.CanAnimate is True):
                    self.CanShoot = True
                    self.CanAnimate = False
            else:
                if (self.CanAnimateIdle is True):
                    self.CanIdle = True
                self.CanAnimate = True
                self.CanAnimateIdle = False

        else:
            self.timer2 = 0

            if (self.CanAnimateIdle is True):
                self.CanIdle = True
                self.CanAnimate = True
                self.CanAnimateIdle = False

        if (self.CanShoot is True):
            self.Owner.Sprite.SpriteSource = "HeavyGunManBodyShoot"
            self.CanShoot = False
        elif (self.CanIdle is True):
            self.Owner.Sprite.SpriteSource = "HeavyGunManBody"
            self.CanIdle = False


Zero.RegisterComponent("HeavyGunManBodyShoot", HeavyGunManBodyShoot)
Exemplo n.º 18
0
            
        if(Tracker.PlayerTracker.TreyIsAlive is True):
            TreyNum = 1
        else:
            TreyNum = 0
            
        if(Tracker.PlayerTracker.PeytonIsAlive is True):
            PeytonNum = 1
        else:
            PeytonNum = 0
            
        if(Tracker.PlayerTracker.SedrickIsAlive is True):
            SedrickNum = 1
        else:
            SedrickNum = 0
            
        if(Tracker.PlayerTracker.JulioIsAlive is True):
            JulioNum = 1
        else:
            JulioNum = 0
        
        TotalNumber = TungNum + AustinNum + TreyNum + PeytonNum + SedrickNum + JulioNum
        
        if(TotalNumber < 0):
            TotalNumber = 0
        
        
        self.Owner.SpriteText.Text = str(TotalNumber)

Zero.RegisterComponent("LivesNumber", LivesNumber)
Exemplo n.º 19
0
import Zero
import Events
import Property
import VectorMath


class DeathEvent:
    def Initialize(self, initializer):
        Zero.Connect(self.Owner, Events.CollisionStarted, self.OnCollision)

    def OnCollision(self, CollideEvent):
        otherObj = CollideEvent.OtherObject

        if (otherObj.CanDie != None):
            otherObj.CanDie.Die()


Zero.RegisterComponent("DeathEvent", DeathEvent)
Exemplo n.º 20
0
import Zero
import Events
import Property
import VectorMath


class TreeSkillMushroom:
    Name = Property.String("TreeSkillMushroom")

    def Initialize(self, initializer):
        pass

    def Perform(self, position, physeffect=None):
        mushroom = self.Space.CreateAtPosition("Mushroom", position)
        if physeffect:
            physeffect.Modify(mushroom)

        if mushroom.TimedDeath:

            def DeactivateBounce(self):
                self.Owner.CanBounce.Active = False

            mushroom.TimedDeath.SetCallback(DeactivateBounce)
            mushroom.TimedDeath.Active = True


Zero.RegisterComponent("TreeSkillMushroom", TreeSkillMushroom)
Exemplo n.º 21
0
        self.oricolor = self.Owner.Sprite.Color
        Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate)
    def SetCountDown(self, countdown):
        self.Countdown = countdown
        
    def OnLogicUpdate(self, UpdateEvent):
        
        if self.Active:
            if self.Countdown > 0:
                self.Countdown -= 1
            if self.Countdown == 0:
                self.Active = False
                self.Countdown = -1
            
            if self.blink_tick <= self.BlinkTick:
                self.blink_tick += 1
            if self.blink_tick >= self.BlinkTick:
                if not self.Owner.Sprite.Color == self.BlinkColor:
                    self.Owner.Sprite.Color = self.BlinkColor
                    #self.Owner.Sprite.BlendMode = Zero.BlendMode.Additive
                  
                else:
                    self.Owner.Sprite.Color = self.oricolor
                self.blink_tick = 0
        else:
            c = self.Owner.Sprite.Color
            self.Owner.Sprite.Color = VectorMath.Vec4(self.oricolor.x,self.oricolor.y,self.oricolor.z,c.a)
            #self.Owner.Sprite.BlendMode = Zero.BlendMode.Alpha

Zero.RegisterComponent("BlinkAnim", BlinkAnim)
Exemplo n.º 22
0
import Property
import VectorMath


class ParticleFadeAnim:
    Active = Property.Bool(True)
    DecaySpeed = Property.Float(0.01)
    DestroyAtEnd = Property.Bool(True)

    def Initialize(self, initializer):
        Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate)

    def OnLogicUpdate(self, UpdateEvent):
        if self.Active:
            self.Owner.SpriteParticleSystem.Tint *= VectorMath.Vec4(
                1, 1, 1, 1 - self.DecaySpeed)
            if self.Owner.SpriteParticleSystem.Tint.a < 0.01:
                self.Owner.Destroy()
            #if self.Owner.SphericalParticleEmitter.Size > 0:
            #    self.Owner.SphericalParticleEmitter.Size -= self.DecaySpeed
            #elif self.Owner.SphericalParticleEmitter.Size < 0:
            #    self.Owner.SphericalParticleEmitter.Size = 0
            #    if self.DestroyAtEnd:
            #        if self.Owner.DestroyInterface:
            #            self.Owner.DestroyInterface.Destroy()
            #        else:
            #            self.Owner.Destroy()


Zero.RegisterComponent("ParticleFadeAnim", ParticleFadeAnim)
Exemplo n.º 23
0
class PlayerController:
    JumpStrength = Property.Float(2.0)
    MoveForce = Property.Float(3.0)
    JumpActive = Property.Bool(True)

    Active = Property.Bool(True)

    def Initialize(self, initializer):
        Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate)

    def OnLogicUpdate(self, UpdateEvent):
        if (not self.Active): return
        self.Owner.Sprite.AnimationSpeed = abs(self.Owner.RigidBody.Velocity.x)

        force = Vec3(0, 0, 0)
        impulse = Vec3(0, 0, 0)
        if Zero.Keyboard.KeyIsDown(Zero.Keys.D):
            self.Owner.Sprite.FlipX = False
            force += Vec3(1, 0, 0)
        if Zero.Keyboard.KeyIsDown(Zero.Keys.A):
            self.Owner.Sprite.FlipX = True
            force -= Vec3(1, 0, 0)
        if Zero.Keyboard.KeyIsDown(Zero.Keys.W):
            impulse += Vec3(0, 1, 0)

        self.Owner.RigidBody.ApplyLinearVelocity(force * self.MoveForce)
        self.Owner.RigidBody.ApplyLinearVelocity(impulse * self.JumpStrength)


Zero.RegisterComponent("PlayerController", PlayerController)
Exemplo n.º 24
0
    def EmptyTreeSkill(self):
        if self.TreeSkill:
            self.Owner.RemoveComponentByName(self.TreeSkill.Name)
            self.TreeSkill = None

    def EmptySkills(self):
        self.EmptyPhysSkill()
        self.EmptyTreeSkill()

    def NoPhysSkill(self):
        return not self.PhysSkill

    def NoTreeSkill(self):
        return not self.TreeSkill

    def GetTreeSkillName(self):
        if self.TreeSkill:
            return self.TreeSkill.Name
        else:
            return ""

    def GetPhysSkillName(self):
        if self.PhysSkill:
            return self.PhysSkill.Name
        else:
            return ""


Zero.RegisterComponent("AbilityStatus", AbilityStatus)
Exemplo n.º 25
0
            self.Owner.SphericalParticleEmitter.Size *= 0.9
        else:
            if self.Owner.CanTransferAbility and self.Owner.CanTransferAbility.IsActivated(
            ):
                souls = tuple(
                    self.Space.CreateAtPosition(
                        "SoulEffect",
                        self.TrackingTarget.Transform.Translation)
                    for _ in range(20))
                for item in souls:
                    item.SphericalParticleEmitter.Size = 0.3
                    item.SoulBehavior.WillDecay = True
                    item.SpriteParticleSystem.Tint = self.Owner.SpriteParticleSystem.Tint
                self.Owner.Destroy()

            elif not self.Owner.CanTransferAbility:
                souls = tuple(
                    self.Space.CreateAtPosition(
                        "SoulEffect", self.Owner.Transform.Translation)
                    for _ in range(10))
                for item in souls:
                    item.SphericalParticleEmitter.Size = 0.1
                    item.SoulBehavior.WillDecay = True
                    item.SpriteParticleSystem.Tint = self.Owner.SpriteParticleSystem.Tint
                self.Owner.Destroy()

        #self.Owner.Destroy()


Zero.RegisterComponent("AbilitySoulBehavior", AbilitySoulBehavior)
Exemplo n.º 26
0
import Zero
import Events
import Property
import VectorMath


class GroundSoundManager:
    def Initialize(self, initializer):
        passz


Zero.RegisterComponent("GroundSoundManager", GroundSoundManager)
Exemplo n.º 27
0
import Zero
import Events
import Property
import VectorMath


class Yeller:
    def Initialize(self, initializer):
        Zero.Connect(self.Owner, Events.CollisionStarted, self.OnCollision)

    def OnCollision(self, CollisionEvent):
        print(CollisionEvent.OtherObject.Name)


Zero.RegisterComponent("Yeller", Yeller)
Exemplo n.º 28
0
    def Initialize(self, initializer):
        Zero.Connect(self.Owner, Events.MouseEnter, self.OnMouseEnter)
        Zero.Connect(self.Owner, Events.MouseExit, self.OnMouseExit)
        Zero.Connect(self.Owner, Events.MouseDown, self.OnMouseDown)
        Zero.Connect(self.Owner, Events.MouseUp, self.OnMouseUp)

    def OnMouseUp(self, ViewportMouseEvent):
        #Let Go Of Click

        self.Space.LoadLevel("Tung")

    def OnMouseDown(self, ViewportMouseEvent):
        #Clicked

        self.Owner.Transform.Scale = Vector3(1.6, 1.6, 2)

    def OnMouseExit(self, ViewportMouseEvent):
        #Exiting Button

        self.Owner.Transform.Scale = Vector3(2, 2, 2)
        self.Owner.Sprite.SpriteSource = "InstructionIdle"

    def OnMouseEnter(self, ViewportMouseEvent):
        #Entering Button

        self.Owner.Transform.Scale = Vector3(1.8, 1.8, 2)
        self.Owner.Sprite.SpriteSource = "InstuctionMoused"


Zero.RegisterComponent("InstructionButton", InstructionButton)
Exemplo n.º 29
0
        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
        self.FadeDone = False

    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
        self.FadeDone = True

    # 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)
Exemplo n.º 30
0
    #    self.Owner.Transform.Translation = mousePos

    def Test(self):
        self.Max = self.MaxRange + random.uniform(0, self.MaxVariation)
        self.Owner.SphereCollider.Radius = self.Max

        self.LightStart.Min = self.Min
        self.LightStart.Max = self.Max
        self.LightStart.Source = self.Owner
        self.LightStart.Center = self.Owner.Transform.Translation

        Action.Delay(self.sequence,
                     random.uniform(self.MaxTimeMinVar, self.MaxTimeMaxVar))
        Action.Call(self.sequence, self.Test)

    def Test2(self):
        self.Min = self.MinRange + random.uniform(0, self.MinVariation)
        sequence = Action.Sequence(self.Owner.Actions)

        self.LightStart.Min = self.Min
        self.LightStart.Max = self.Max
        self.LightStart.Source = self.Owner
        self.LightStart.Center = self.Owner.Transform.Translation

        Action.Delay(self.sequence,
                     random.uniform(self.MinTimeMinVar, self.MinTimeMaxVar))
        Action.Call(self.sequence, self.Test2)


Zero.RegisterComponent("LightSource", LightSource)