Methods
(async, static) saveAll(create)
Saves monsters to the database.
Parameters:
Name | Type | Description |
---|---|---|
create |
boolean | Create new monster rows (first save only) |
- Source:
attack(playerID)
Monster attacks PC
Parameters:
Name | Type | Description |
---|---|---|
playerID |
* | id for player that monster is attacking |
- Source:
beAttacked(hp)
Player attacks Monster
Parameters:
Name | Type | Description |
---|---|---|
hp |
* | health points that the monster's health decrements by |
- Source:
canSee(x, y)
Returns true if monster can see given pixel coordinate.
Parameters:
Name | Type | Description |
---|---|---|
x |
||
y |
- Source:
canSeePC()
Finds closest PC that can be seen and targets it.
- Source:
collisionEntities() → {boolean}
Checks to see if there's a monster colliding with this monster.
Compares corners of each sprite to do so.
- Source:
Returns:
- Type
- boolean
createSprite()
Generates sprite for a specific monster and adds it to the floor.
- Source:
die()
~WIP drop items down the road
Monster dies.
- Source:
die()
~WIP drop items down the road
Monster dies.
figureOutWhereToGo()
Moves monster.
If PC has been seen, move strategically towards last seen location.
Else (if PC not seen yet or last seen PC location has been explored) the monster wanders.
- Source:
findDistance(x, y) → {double}
Finds distance between monster and coodinate.
Parameters:
Name | Type | Description |
---|---|---|
x |
||
y |
- Source:
Returns:
- Type
- double
generateMonsters(floor)
Puts
monster in half of all "rooms".
Parameters:
Name | Type | Description |
---|---|---|
floor |
Floor | The floor to add monsters to |
- Source:
getHp()
Get the hp of the monster
getRandomNumber(min, max)
Given a min and a max integer, returns a random number between the two (*inclusive)
Parameters:
Name | Type | Description |
---|---|---|
min |
||
max |
- Source:
handleState()
Handle state updates from the server
- Source:
move(deltaTime)
Sets the position closer to the target position.
Parameters:
Name | Type | Description |
---|---|---|
deltaTime |
number | The number of ms since the last move |
- Source:
placeInRandomRoom()
Places monster in a random "room" with no other monsters.
- Source:
remove(container)
Remove a monster from a PIXI.Container
Parameters:
Name | Type | Description |
---|---|---|
container |
PIXI.Container |
- Source:
setCoodinates()
Manually set coordinates for a single
- Source:
spriteIsOnMap() → {boolean}
Check to see if whole sprite is on the map.
- Source:
Returns:
- Type
- boolean
tint()
Tints player's sprite red.
toJSON()
Select only the propertys we need for sending monsters to the client
- Source:
untint()
Untints player's sprite.
update(viewX, viewY)
Updates the sprite's position for all monsters on the floor.
Parameters:
Name | Type | Description |
---|---|---|
viewX |
||
viewY |
- Source:
wander()
Monster moves to an adjacent, unoccupied location.
- Source: