The book of inspiration

March 1, 2010

MonetizationUseCase

Filed under: tech — zproxy @ 12:41 pm

MochiGames - Premium Flash Games

Your game has been bound to a market place. The compiler will help you integrate to it by rewriting method calls to actually show up Shop User Interface at the right time.

What are we selling?

Buy MoreArmor for 40 €

This post is about a probable future feature of MonetizationAttribute.

15 static class MonetizationUseCase

16 {

17 class Player

18 {

19 public bool MoreArmorBought;

20

21 public bool AppearBigger;

22 }

23

24 [Monetization(Prize = 40 /*€*/)]

25 public static void BuyMoreArmor(

26 this Player p,

27 string ArmorType,

28 Action YieldReturn)

29 {

30 // the rewriter injected code to ask user for cash

31 // if he did not pay this code did not get called

32

33 // lets add some value what the user payed for

34 p.MoreArmorBought = true;

35

36 // this method finished and now we should let

37 // the callee know about it

38 YieldReturn();

39 }

40

41 public static void ByMoreArmor_Click(this Player p)

42 {

43 p.BuyMoreArmor(“BetterArmor”,

44 delegate

45 {

46 if (p.MoreArmorBought)

47 {

48 // BetterArmor makes the player bigger

49 p.AppearBigger = true;

50 }

51 else

52 {

53 // no cash? too bad…

54 Console.Beep();

55 }

56 }

57 );

58 }

59 }

xxx

The Shocking Blue Green Theme Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 62 other followers