43 lines
1.2 KiB
Kotlin
43 lines
1.2 KiB
Kotlin
package cc.maxmc.blastingcrisis.game
|
|
|
|
import cc.maxmc.blastingcrisis.configuration.GlobalSettings
|
|
import cc.maxmc.blastingcrisis.packet.BEntityVillager
|
|
import org.bukkit.Bukkit
|
|
import taboolib.platform.BukkitPlugin
|
|
import taboolib.platform.util.asLangText
|
|
|
|
class TeamVillager(private val team: GameTeam) {
|
|
private val packetVillager = BEntityVillager.create(team.teamInfo.villager)
|
|
var health: Int = GlobalSettings.GameSettings.villagerMaxHealth
|
|
private set
|
|
|
|
init {
|
|
packetVillager.name = {
|
|
if (it.team == team) {
|
|
it.asLangText("team_villager_name_internal", health)
|
|
} else {
|
|
it.asLangText("team_villager_name_outer", health)
|
|
}
|
|
}
|
|
}
|
|
|
|
fun spawn() {
|
|
team.game.broadcast(packetVillager::addViewer)
|
|
}
|
|
|
|
fun damage() {
|
|
health -= GlobalSettings.GameSettings.villagerDamagePerHealth
|
|
if (health <= 0) {
|
|
packetVillager.dieAnimate()
|
|
Bukkit.getScheduler().runTaskLater(BukkitPlugin.getInstance(), {
|
|
packetVillager.destroy()
|
|
}, 20 * 3)
|
|
|
|
}
|
|
packetVillager.hurtAnimate()
|
|
team.checkTeamAlive()
|
|
team.game.checkEnd()
|
|
}
|
|
|
|
|
|
} |