Created
January 9, 2015 05:27
-
-
Save quabug/09fe11b8b8245e7579e7 to your computer and use it in GitHub Desktop.
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
class TalkingGame: | |
var agent | |
func _init(agent): | |
self.agent = agent | |
func onVirtualCurrencyReward(virtualCurrencyAmount, reason): | |
agent.onVirtualCurrencyReward(float(virtualCurrencyAmount), reason) | |
func onItemPurchase(item, itemNumber, priceInVirtualCurrency): | |
agent.onItemPurchase(item, itemNumber, float(priceInVirtualCurrency)) | |
func onItemUse(item, itemNumber): | |
agent.onItemUse(item, itemNumber) | |
func onMissionBegin(missionId): | |
agent.onMissionBegin(missionId) | |
func onMissionCompleted(missionId): | |
agent.onMissionCompleted(missionId) | |
func onMissionFailed(missionId, cause): | |
agent.onMissionFailed(missionId, cause) | |
func onEvent(eventId, eventData): | |
agent.onEvent(eventId, eventData) | |
class PrintAgent: | |
func onVirtualCurrencyReward(virtualCurrencyAmount, reason): | |
print("onVirtualCurrencyReward", " virtualCurrencyAmount=", virtualCurrencyAmount, " reason=", reason) | |
func onItemPurchase(item, itemNumber, priceInVirtualCurrency): | |
print("onItemPurchase", " item=", item, " itemNumber=", itemNumber, " priceInVirtualCurrency=", priceInVirtualCurrency) | |
func onItemUse(item, itemNumber): | |
print("onItemUse", " item=", item, " itemNumber=", itemNumber) | |
func onMissionBegin(missionId): | |
print("onMissionBegin", " missionId=", missionId) | |
func onMissionCompleted(missionId): | |
print("onMissionCompleted", " missionId=", missionId) | |
func onMissionFailed(missionId, cause): | |
print("onMissionFailed", " missionId=", missionId, " cause=", cause) | |
func onEvent(eventId, eventData): | |
print("onEvent", " eventId=", eventId, " eventData=", eventData) | |
var wrapper | |
func _init(): | |
var talking_game = Globals.get_singleton("TalkingGame") | |
if talking_game == null: | |
wrapper = PrintAgent.new() | |
print("create PrintAgent for TalkingGame") | |
else: | |
wrapper = TalkingGame.new(talking_game) | |
print("create TalkingGame") | |
func onVirtualCurrencyReward(virtualCurrencyAmount, reason): | |
wrapper.onVirtualCurrencyReward(virtualCurrencyAmount, reason) | |
func onItemPurchase(item, itemNumber, priceInVirtualCurrency): | |
wrapper.onItemPurchase(item, itemNumber, priceInVirtualCurrency) | |
func onItemUse(item, itemNumber): | |
wrapper.onItemUse(item, itemNumber) | |
func onMissionBegin(missionId): | |
wrapper.onMissionBegin(missionId) | |
func onMissionCompleted(missionId): | |
wrapper.onMissionCompleted(missionId) | |
func onMissionFailed(missionId, cause): | |
wrapper.onMissionFailed(missionId, cause) | |
func onEvent(eventId, eventData): | |
wrapper.onEvent(eventId, eventData) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment