Beispiel #1
0
    def attack(self, render, time):
        if time - self.shootTimeDelayNow >= (
                self.shootTimeDelay if not self.has_a_gun else self.gun.
                seconde_between_shoot) and self.shoot_or_not_decision > 0.5:
            theta = self.shoot_decision
            shootammo = Actor("model_territory/ammo2")
            shootammo.reparentTo(render)
            shootammo.setPos(self.getPos() +
                             (cos(theta) * 1.5, sin(theta) * 1.5, 5))
            #print(shootammo.getPos())
            shootammo.setScale(4)
            shootammo.setColor(1, 0., 0, 1.0)

            if not self.has_a_gun:
                shootammo.dammage = random.randint(2, 8)
            else:
                shootammo.dammage = random.randint(self.gun.min_damage,
                                                   self.gun.max_damage)

            shootammo.id = self.id
            shootammo.x_origine = shootammo.getX()
            shootammo.y_origine = shootammo.getY()
            shootammo.time = time
            shootammo.r = 4
            shootammo.theta = theta
            shootammo.number = self.ammonumber
            shootammo.hit = False
            a = shootammo.attach_new_node(
                CollisionNode('ammo/' + str(self.id) + '/' +
                              str(self.ammonumber)))
            a.node().addSolid(CollisionSphere(0, 0, 0, 0.5))
            a.show()
            #print(shootammo.getTightBounds())

            self.shoot.append(shootammo)
            self.shootTimeDelayNow = time
            self.ammonumber += 1