-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove directions to cardinal points
get emeny attacking and tracking when active
- Loading branch information
David Henry
committed
Feb 13, 2012
1 parent
ce4f86b
commit d0b7a5c
Showing
13 changed files
with
272 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ def self.included(base) | |
end | ||
|
||
def initialize(options) | ||
super | ||
@options = options | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,63 @@ | ||
class Game | ||
class Object | ||
module Enemy | ||
IDLE = :idle | ||
def self.included(base) | ||
base.send :attr_reader, :direction | ||
end | ||
|
||
def initialize(*args) | ||
super | ||
@direction = Game::Map::NORTH | ||
Game::Object.add(Game::Engine.instance.map.name, status, self) | ||
end | ||
|
||
def passible? | ||
false | ||
end | ||
|
||
def range | ||
@options['range'] || 4 | ||
end | ||
|
||
def status | ||
IDLE | ||
@status ||= Game::Object::IDLE | ||
end | ||
|
||
def active_turn | ||
raise 'This should not happen.. only call when status is active..' unless status == Game::Object::ACTIVE | ||
@direction = player_direction | ||
|
||
if player_in_front? | ||
Game::Player.instance.damage(attack) | ||
elsif !player_in_range? | ||
Game::Object.remove(Game::Engine.instance.map.name, status, self) | ||
@status = Game::Object::IDLE | ||
Game::Object.add(Game::Engine.instance.map.name, status, self) | ||
elsif (tile = @tile.at(@direction)).passible? | ||
move_to(tile) | ||
end | ||
end | ||
|
||
def move_to(tile) | ||
@tile.remove(self) | ||
@tile = tile | ||
@tile.add(self) | ||
end | ||
|
||
def player_in_range? | ||
@tile.in_range?(Game::Player.instance.tile, range) | ||
end | ||
private :player_in_range? | ||
|
||
def player_in_front? | ||
@tile.at(@direction).has_object?(Game::Player) | ||
end | ||
private :player_in_front? | ||
|
||
def player_direction | ||
@tile.direction_to(Game::Player.instance.tile) | ||
end | ||
private :player_direction | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.