Exemplo n.º 1
0
    def __init__(self):
        ChasingEnemy.__init__(self, Vec3(0, 0, 0),
                       "Models/EnemyRangedBasic/enemyRangedBasic",
                       {
                        "stand" : "Models/EnemyRangedBasic/enemyRangedBasic-stand",
                        "walk" : "Models/EnemyRangedBasic/enemyRangedBasic-walk",
                        "attack" : "Models/EnemyRangedBasic/enemyRangedBasic-attack",
                        "die" : "Models/EnemyRangedBasic/enemyRangedBasic-die",
                        "spawn" : "Models/EnemyRangedBasic/enemyRangedBasic-spawn",
                        "strafeLeft" : "Models/EnemyRangedBasic/enemyRangedBasic-strafeLeft",
                        "strafeRight" : "Models/EnemyRangedBasic/enemyRangedBasic-strafeRight",
                        "flinch1" : "Models/EnemyRangedBasic/enemyRangedBasic-flinch"
                        },
                       20,
                       5.0,
                       "walkingEnemy",
                       1,
                        steeringFootHeight = 0.5)
        Walker.__init__(self)

        self.movementNames.append("strafeLeft")
        self.movementNames.append("strafeRight")

        self.actor.setScale(0.6)

        projectile = Projectile("Models/EnemyRangedBasic/shot", MASK_INTO_PLAYER, 20, 10, 10, 0.3, 1.0, 0, 0)
        weapon = ProjectileWeapon(projectile)
        weapon.desiredRange = 15
        weapon.setAvailable(True)
        self.addWeapon(weapon)
        self.setCurrentWeapon(0)

        self.attackAnimsPerWeapon[self.weapons[0]] = "attack"

        self.flinchAnims = [
            "flinch1"
        ]

        self.deathSound = loader.loadSfx("Sounds/enemyDie.ogg")
        self.attackSound = loader.loadSfx("Sounds/enemyAttack.ogg")

        self.weaponNP = self.actor.attachNewNode(PandaNode("weapon"))
        self.weaponNP.setZ(self.height*0.75)

        self.minStrafeInterval = 3
        self.maxStrafeInterval = 7
        self.strafeSpeed = 10
        self.resetStrafeIntervalTimer()
        self.strafeDuration = 0.2
        self.strafeTimer = 0
Exemplo n.º 2
0
    def cleanup(self):
        if self.uiRoot is not None:
            self.uiRoot.removeNode()
            self.uiRoot = None
        self.healthBar = None
        self.weaponUIRoot = None

        if self.lightNP is not None:
            render.clearLight(self.lightNP)
            self.lightNP.removeNode()
            self.lightNP = None

        for effect in self.updatingEffects:
            effect.cleanup()
        self.updatingEffects = []

        ArmedObject.cleanup(self)
        Walker.cleanup(self)
        GameObject.cleanup(self)
Exemplo n.º 3
0
    def __init__(self):
        ChasingEnemy.__init__(self, Vec3(0, 0, 0),
                       "Models/EnemyMeleeBasic/enemyMeleeBasic",
                       {
                        "stand" : "Models/EnemyMeleeBasic/enemyMeleeBasic-stand",
                        "walk" : "Models/EnemyMeleeBasic/enemyMeleeBasic-walk",
                        "attack" : "Models/EnemyMeleeBasic/enemyMeleeBasic-attack",
                        "die" : "Models/EnemyMeleeBasic/enemyMeleeBasic-die",
                        "spawn" : "Models/EnemyMeleeBasic/enemyMeleeBasic-spawn",
                        "flinch1" : "Models/EnemyMeleeBasic/enemyMeleeBasic-flinch"
                        },
                       50,
                       7.0,
                       "walkingEnemy",
                       1,
                        steeringFootHeight = 0.5)
        Walker.__init__(self)

        self.actor.setScale(0.6)

        weapon = HitscanWeapon(MASK_INTO_PLAYER, 15, 2.0, 0.75)
        weapon.setAvailable(True)
        self.addWeapon(weapon)
        self.setCurrentWeapon(0)

        self.attackAnimsPerWeapon[self.weapons[0]] = "attack"

        self.flinchAnims = [
            "flinch1"
        ]

        self.deathSound = loader.loadSfx("Sounds/enemyDie.ogg")
        self.attackSound = loader.loadSfx("Sounds/enemyAttack.ogg")

        self.weaponNP = self.actor.attachNewNode(PandaNode("weapon"))
        self.weaponNP.setZ(self.height*0.75)
Exemplo n.º 4
0
 def cleanup(self):
     Walker.cleanup(self)
     ChasingEnemy.cleanup(self)
Exemplo n.º 5
0
 def update(self, player, dt):
     ChasingEnemy.update(self, player, dt)
     Walker.update(self, dt)
Exemplo n.º 6
0
    def update(self, player, dt):
        ChasingEnemy.update(self, player, dt)
        Walker.update(self, dt)

        if not self.inControl:
            self.strafeTimer = 0
Exemplo n.º 7
0
    def __init__(self):
        GameObject.__init__(self, Vec3(0, 0, 0), None, None, 100, 15, "player",
                            1, MASK_INTO_PLAYER)
        Walker.__init__(self)
        ArmedObject.__init__(self)

        self.weaponNP = self.actor

        light = PointLight("basic light")
        light.setColor(Vec4(1, 1, 1, 1))
        light.setAttenuation((1, 0.01, 0.005))
        self.lightNP = self.root.attachNewNode(light)
        self.lightNP.setZ(1)
        render.setLight(self.lightNP)

        self.collider.node().setFromCollideMask(MASK_WALLS | MASK_FROM_PLAYER)

        self.actor.setZ(self.height)

        base.camera.reparentTo(self.actor)
        base.camera.setPos(0, 0, 0)
        base.camera.setHpr(0, 0, 0)

        lens = base.camLens
        ratio = lens.getAspectRatio()

        lens.setFov(80 * ratio)
        lens.setNear(0.03)

        self.lastMousePos = Vec2(0, 0)
        self.mouseSpeedHori = 50.0
        self.mouseSpeedVert = 30.0
        self.mouseSensitivity = 1.0

        self.healthLeft = -0.9
        self.healthRight = 0.9
        self.healthWidth = self.healthRight - self.healthLeft

        self.uiRoot = base.a2dBottomCenter.attachNewNode(
            PandaNode("player UI"))

        self.healthBar = loader.loadModel("UI/healthBar")
        self.healthBar.reparentTo(self.uiRoot)
        self.healthBar.setZ(0.05)
        self.healthBar.setX(self.healthLeft)
        self.healthBar.getChild(0).setScale(self.healthWidth / 6.0)

        self.weaponUIRoot = self.uiRoot.attachNewNode(
            PandaNode("player weapon UI"))
        self.weaponUIRoot.setPos(0, 0, 0.1)

        self.addWeapon(RapidShotgunWeapon(self.weaponUIRoot))
        self.addWeapon(BlasterWeapon(self.weaponUIRoot))

        self.weapons[0].setAvailable(True)

        self.setCurrentWeapon(0)

        self.updateHealthUI()

        self.inventory = []

        self.updatingEffects = []

        self.interactionSegment = CollisionSegment(0, 0, 0, 0, 1.5, 0)

        rayNode = CollisionNode("player interaction ray")
        rayNode.addSolid(self.interactionSegment)

        rayNode.setFromCollideMask(MASK_WALLS | MASK_FLOORS | MASK_INTO_ENEMY)
        rayNode.setIntoCollideMask(0)

        self.interactionSegmentNodePath = self.actor.attachNewNode(rayNode)
        #self.interactionSegmentNodePath.show()
        self.interactionSegmentQueue = CollisionHandlerQueue()

        self.interactionSegmentTraverser = CollisionTraverser()
        self.interactionSegmentTraverser.addCollider(
            self.interactionSegmentNodePath, self.interactionSegmentQueue)
Exemplo n.º 8
0
 def postTraversalUpdate(self, dt):
     Walker.update(self, dt)
     ArmedObject.update(self, dt)