RuneHive-Game
Loading...
Searching...
No Matches
CerberusActivity.java
Go to the documentation of this file.
1package com.runehive.content.activity.impl;
2
3import com.runehive.content.activity.Activity;
4import com.runehive.content.activity.ActivityType;
5import com.runehive.game.Animation;
6import com.runehive.game.Graphic;
7import com.runehive.game.world.World;
8import com.runehive.game.world.entity.mob.Mob;
9import com.runehive.game.world.entity.mob.npc.Npc;
10import com.runehive.game.world.entity.mob.npc.NpcDeath;
11import com.runehive.game.world.entity.mob.player.Player;
12import com.runehive.game.world.object.CustomGameObject;
13import com.runehive.game.world.object.GameObject;
14import com.runehive.game.world.position.Area;
15import com.runehive.game.world.position.Position;
16
17import java.util.ArrayList;
18import java.util.List;
19
20/**
21 * Created by Daniel on 2018-01-20.
22 */
23public class CerberusActivity extends Activity {
24 private static final GameObject[] OBJECTS = {new CustomGameObject(23105, new Position(1241, 1242)), new CustomGameObject(23105, new Position(1240, 1242)), new CustomGameObject(23105, new Position(1239, 1242)), new CustomGameObject(23105, new Position(1240, 1236))};
25 private final Player player;
26 private Npc cerberus = new Npc(5862, new Position(1240, 1252));
27 private List<GameObject> objectList = new ArrayList<>(4);
28
30 super(1, instance);
31 this.player = player;
32 }
33
35 CerberusActivity activity = new CerberusActivity(player, player.playerAssistant.instance());
36 activity.add(player);
37 activity.resetCooldown();
38 return activity;
39 }
40
41 @Override
42 protected void start() {
43 for (GameObject object : OBJECTS) {
44 object.register();
45 objectList.add(object);
46 }
47
49 pause();
50 }
51
52 @Override
53 public void finish() {
54 cleanup();
55 remove(player);
56 }
57
58 @Override
59 public void cleanup() {
60 for (GameObject object : objectList) {
61 System.out.println("unregistering " + object.getId());
62 object.unregister();
63 }
64
65 objectList.clear();
66 remove(cerberus);
67 }
68
69 @Override
70 public void onDeath(Mob mob) {
71 if (mob.isPlayer()) {
72 cleanup();
73
74 player.move(new Position(3087, 3497));
75
76 player.animate(Animation.RESET, true);
77 player.graphic(Graphic.RESET, true);
78 return;
79 }
80
81 World.schedule(new NpcDeath(mob.getNpc(), () -> {
82 finish();
83 restart(10, () -> {
84 if (Area.inCerberus(player)) {
85 create(player);
86 } else {
87 remove(player);
88 }
89 });
90 }));
91 }
92
93 @Override
95 if (!Area.inCerberus(player)) {
96 cleanup();
97 remove(player);
98 }
99 }
100
101 @Override
102 public void onLogout(Player player) {
103 cleanup();
104 remove(player);
105 }
106
107 @Override
108 public boolean canTeleport(Player player) {
109 return true;
110 }
111
112 @Override
114 return ActivityType.CERBERUS;
115 }
116}
Activity(int cooldown, int instance)
Constructs a new SequencedMinigame object.
Definition Activity.java:55
int instance
The activity instance level.
Definition Activity.java:46
final void pause()
Sets the cooldown flag to PAUSE.
void add(Mob mob)
Adds a mob to the activity.
void start()
Starts the next activity stage.
void onLogout(Player player)
Called when the player logs out.
void onDeath(Mob mob)
Called when the player die.
void cleanup()
Cleans up the activity when finished.
boolean canTeleport(Player player)
Called when the player attempts to teleport.
void onRegionChange(Player player)
Called when the player changes region.
static CerberusActivity create(Player player)
Class that models a single animation used by an entity.
static final Animation RESET
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
static final Graphic RESET
Definition Graphic.java:17
Represents the game world.
Definition World.java:46
static void schedule(Task task)
Submits a new event.
Definition World.java:247
Handles the mob class.
Definition Mob.java:66
final boolean isPlayer()
Check if an entity is a player.
Definition Mob.java:564
Represents a non-player character in the in-game world.
Definition Npc.java:29
This class represents a character controlled by a player.
Definition Player.java:125
Represents a static game object loaded from the map fs.
Handles checking if mobs are in a certain area.
Definition Area.java:13
static boolean inCerberus(Interactable entity)
Definition Area.java:125
Represents a single tile on the game world.
Definition Position.java:14
Holds all activity types that are timed.