-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
206 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
class_name TeamMode extends Node | ||
|
||
|
||
# This enum defines how players are placed into teams. | ||
|
||
|
||
enum enm { | ||
ONE_PLAYER_PER_TEAM, | ||
TWO_PLAYERS_PER_TEAM, | ||
} | ||
|
||
static var _string_map: Dictionary = { | ||
TeamMode.enm.ONE_PLAYER_PER_TEAM: "ffa", | ||
TeamMode.enm.TWO_PLAYERS_PER_TEAM: "coop", | ||
} | ||
|
||
|
||
static var _display_string_map: Dictionary = { | ||
TeamMode.enm.ONE_PLAYER_PER_TEAM: "FFA", | ||
TeamMode.enm.TWO_PLAYERS_PER_TEAM: "Co-op", | ||
} | ||
|
||
|
||
static var _player_count_max_map: Dictionary = { | ||
TeamMode.enm.ONE_PLAYER_PER_TEAM: 4, | ||
TeamMode.enm.TWO_PLAYERS_PER_TEAM: 8, | ||
} | ||
|
||
|
||
static var _player_count_per_team_map: Dictionary = { | ||
TeamMode.enm.ONE_PLAYER_PER_TEAM: 1, | ||
TeamMode.enm.TWO_PLAYERS_PER_TEAM: 2, | ||
} | ||
|
||
|
||
static func convert_to_string(type: TeamMode.enm): | ||
return _string_map[type] | ||
|
||
|
||
static func from_string(string: String) -> TeamMode.enm: | ||
var key = _string_map.find_key(string) | ||
|
||
if key != null: | ||
return key | ||
else: | ||
push_error("Invalid string: \"%s\". Possible values: %s" % [string, _string_map.values()]) | ||
|
||
return TeamMode.enm.ONE_PLAYER_PER_TEAM | ||
|
||
|
||
static func convert_to_display_string(type: TeamMode.enm): | ||
return _display_string_map[type] | ||
|
||
|
||
static func get_player_count_max(type: TeamMode.enm): | ||
return _player_count_max_map[type] | ||
|
||
|
||
static func get_player_count_per_team(type: TeamMode.enm): | ||
return _player_count_per_team_map[type] |
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
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.