-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathKnightStatue.java
More file actions
63 lines (53 loc) · 1.86 KB
/
Copy pathKnightStatue.java
File metadata and controls
63 lines (53 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* SPDX-FileCopyrightText: 2011-2024 Minicraft+ contributors
* SPDX-License-Identifier: GPL-3.0-only
*/
package minicraft.entity.furniture;
import minicraft.core.Game;
import minicraft.core.io.Localization;
import minicraft.entity.Direction;
import minicraft.entity.mob.ObsidianKnight;
import minicraft.entity.mob.Player;
import minicraft.gfx.SpriteLinker;
import minicraft.item.Item;
import org.jetbrains.annotations.NotNull;
public class KnightStatue extends Furniture {
private int touches = 0; // >= 0
private final int bossHealth;
public KnightStatue(int health) {
super("KnightStatue", new SpriteLinker.LinkedSprite(SpriteLinker.SpriteType.Entity, "knight_statue"), new SpriteLinker.LinkedSprite(SpriteLinker.SpriteType.Item, "knight_statue"), 3, 2);
bossHealth = health;
}
@Override
public boolean interact(Player player, Item heldItem, Direction attackDir) {
if (!ObsidianKnight.active) {
if (touches == 0) { // Touched the first time.
Game.notifications.add(Localization.getLocalized("minicraft.notifications.statue_tapped"));
touches++;
} else if (touches == 1) { // Touched the second time.
Game.notifications.add(Localization.getLocalized("minicraft.notifications.statue_touched"));
touches++;
} else { // Touched the third time.
// Awoken notifications is in Boss class
// Summon the Obsidian Knight boss
ObsidianKnight obk = new ObsidianKnight(bossHealth);
level.add(obk, x, y, false);
super.remove(); // Removing this statue.
}
return true;
} else { // The boss is active.
Game.notifications.add(Localization.getLocalized("minicraft.notification.boss_limit"));
return false;
}
}
@Override
public void tryPush(Player player) {
} // Nothing happens.
@Override
public @NotNull Furniture copy() {
return new KnightStatue(bossHealth);
}
public int getBossHealth() {
return bossHealth;
}
}