UnityPhone

From ETC Public Wiki
Jump to: navigation, search

Unity Phone API

Unity Phone is a platform developed by Evil Genius Designs to use cell phones as massive input into your worlds. Guests can call into a number provided by Evil Genius' servers which relay data on their input to your worlds.


How to use UnityPhone, the Evil Genius Designs phone server.

Functions:

begin_processing init and start game

gameReadyHandler called when the game is initialized

clientUpdate maintain connection to server

end_processing end game

getPhoneNumber get the game’s phone number getGameID get the lobby code

censor shorten a phone number to the last 4 digits

hang_up_on hang up on a single caller

hang_up_on_all hang up on all callers in the game


Variables

stateDict stores phone number mapping

eventList stores list of events in order


Function Descriptions

Your main class should extend GameFunctions, where these functions and variables are defined. It must also call clientUpdate() from within its Update() function.

begin_processing(): @params: None @returns: None Loads the config information, initializes the connection to the server, and begins listening for phone numbers and button presses. Make sure you specify the game ID (your team number) in the editor as a variable of your GameFunctions subclass.

virtual gameReadyhandler(): @params: None @returns: None Called by GameFunctions when initialization is complete; override to set up state in your game

clientUpdate(): @params: None @returns: None Used by GameFunctions internally to maintain its state and its connection to the server; this must be called from your subclass’s Update() function.

end_processing(): @params: None @returns: None Stops listening for phone numbers and button presses, and closes the connection to the server.

getPhoneNumber(): @params: None @returns: the game phone number, a string of the form "12345556789" This is the initial phone number that the guests must dial to join the game

getLobbyCode(): @params: None @returns: the game's lobby code, of the form '1234' This is the lobby code that the guests must key in once they have dialed the game phone number and listened to the automated greeting

censor(phonenumber): @params: phonenumber = the phone number to censor @returns: the last four digits of a given phone number "12345556789" becomes "6789" An easy method to protect the guest's privacy by clipping their phone numbers to only the last four digits

hang_up_on(phonenumber): @params: phonenumber = phone number to hang up on, a string of the form "12345556789" @returns: None Hangs up on one specific caller

hang_up_on_all(): @params: None @returns: None Hangs up on all callers in the game


stateDict: State dictionary: maps a phone number to its specific state information. Stores the current state of the game. The state information maps a phone number to an array of strings, (button, pitch, volume, isIn), where button is the last button pressed, pitch is the last pitch that the phone has recorded, volume is the last volume that the phone has recorded, and isIn is True if the player is in the game and False if the player has hung up.

eventList: List of the events that have happened so far in the game A list of the most recent events that have happened, stored as arrays of strings: (action, phonenumber, value). The action is a string defining what has taken place, the phonenumber is the number of the guest who has performed the event. The value is an optional value for the "btn", "ptch", and "vol" actions. "newuser" - a person has joined the game "hangup" - a person has hungup "btn" - a person has pressed a button value - a string "0"-"9", "#", or "*" "ptch" - a person has recorded a new pitch (in development) value - an int between 1 and 999 hz "vol" - a person has recorded a new volume (in development) value - a float between 0.0 and 1.0, where 0.0 is softest and 1.0 is loudest


Files

unityPhone Package "http://wiki.etc.cmu.edu/unity3d/images/7/7b/UnityPhone.zip"