Skip to content
This repository has been archived by the owner on Dec 15, 2017. It is now read-only.

Commit

Permalink
Building Friend Smash to be compatible with the latest Unity Facebook…
Browse files Browse the repository at this point in the history
… SDK (4.2.4)
  • Loading branch information
Marco Alvarez committed Oct 2, 2013
1 parent 5967d43 commit 171e33a
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 68 deletions.
12 changes: 6 additions & 6 deletions Assembly-CSharp-Editor-vs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B4FEAA55-CCBB-1997-26D4-C37ACF6E2020}</ProjectGuid>
<ProjectGuid>{3C36D92E-7A2D-2A9C-6E2D-0379922847FC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace></RootNamespace>
Expand All @@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_STANDALONE_OSX;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_GAMECENTER;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_2_0;UNITY_4_2;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_OSX</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_WEBPLAYER;WEBPLUG;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_2_0;UNITY_4_2;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_OSX</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
Expand Down Expand Up @@ -98,6 +98,9 @@
<None Include="Assets\Plugins\Android\res\layout\com_facebook_placepickerfragment.xml" />
<None Include="Assets\Plugins\Android\res\drawable\com_facebook_loginbutton_blue.xml" />
<None Include="Assets\Plugins\Android\res\layout\com_facebook_usersettingsfragment.xml" />
<Reference Include="Assets\Facebook\Scripts\IFacebook">
<HintPath>Assets\Facebook\Scripts\IFacebook.dll</HintPath>
</Reference>
<Reference Include="\Applications\Unity\Unity.app\Contents\Frameworks\Managed\UnityEditor.Graphs">
<HintPath>\Applications\Unity\Unity.app\Contents\Frameworks\Managed\UnityEditor.Graphs.dll</HintPath>
</Reference>
Expand All @@ -109,14 +112,11 @@
</Reference>
<Reference Include="\Applications\Unity\Unity.app\Contents\PlaybackEngines\AndroidPlayer\EditorExtensions\UnityEditor.Android.Extensions">
<HintPath>\Applications\Unity\Unity.app\Contents\PlaybackEngines\AndroidPlayer\EditorExtensions\UnityEditor.Android.Extensions.dll</HintPath>
</Reference>
<Reference Include="Assets\Facebook\Scripts\IFacebook">
<HintPath>Assets\Facebook\Scripts\IFacebook.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="Assembly-CSharp-vs.csproj">
<Project>{D1DF54C5-EAD5-1ED5-1118-5A34D5D07374}</Project> <Name>Assembly-CSharp-vs</Name> </ProjectReference>
<Project>{5F426483-533C-780E-3227-74BA451DB70C}</Project> <Name>Assembly-CSharp-vs</Name> </ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
12 changes: 6 additions & 6 deletions Assembly-CSharp-Editor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B4FEAA55-CCBB-1997-26D4-C37ACF6E2020}</ProjectGuid>
<ProjectGuid>{3C36D92E-7A2D-2A9C-6E2D-0379922847FC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace></RootNamespace>
Expand All @@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_STANDALONE_OSX;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_GAMECENTER;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_2_0;UNITY_4_2;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_OSX</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_WEBPLAYER;WEBPLUG;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_2_0;UNITY_4_2;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_OSX</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
Expand Down Expand Up @@ -98,6 +98,9 @@
<None Include="Assets\Plugins\Android\res\layout\com_facebook_placepickerfragment.xml" />
<None Include="Assets\Plugins\Android\res\drawable\com_facebook_loginbutton_blue.xml" />
<None Include="Assets\Plugins\Android\res\layout\com_facebook_usersettingsfragment.xml" />
<Reference Include="Assets\Facebook\Scripts\IFacebook">
<HintPath>Assets\Facebook\Scripts\IFacebook.dll</HintPath>
</Reference>
<Reference Include="\Applications\Unity\Unity.app\Contents\Frameworks\Managed\UnityEditor.Graphs">
<HintPath>\Applications\Unity\Unity.app\Contents\Frameworks\Managed\UnityEditor.Graphs.dll</HintPath>
</Reference>
Expand All @@ -109,14 +112,11 @@
</Reference>
<Reference Include="\Applications\Unity\Unity.app\Contents\PlaybackEngines\AndroidPlayer\EditorExtensions\UnityEditor.Android.Extensions">
<HintPath>\Applications\Unity\Unity.app\Contents\PlaybackEngines\AndroidPlayer\EditorExtensions\UnityEditor.Android.Extensions.dll</HintPath>
</Reference>
<Reference Include="Assets\Facebook\Scripts\IFacebook">
<HintPath>Assets\Facebook\Scripts\IFacebook.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="Assembly-CSharp.csproj">
<Project>{D1DF54C5-EAD5-1ED5-1118-5A34D5D07374}</Project> <Name>Assembly-CSharp</Name> </ProjectReference>
<Project>{5F426483-533C-780E-3227-74BA451DB70C}</Project> <Name>Assembly-CSharp</Name> </ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
Binary file modified Assembly-CSharp-Editor.pidb
Binary file not shown.
7 changes: 3 additions & 4 deletions Assembly-CSharp-vs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D1DF54C5-EAD5-1ED5-1118-5A34D5D07374}</ProjectGuid>
<ProjectGuid>{5F426483-533C-780E-3227-74BA451DB70C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace></RootNamespace>
Expand All @@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_STANDALONE_OSX;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_GAMECENTER;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_2_0;UNITY_4_2;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_OSX</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_WEBPLAYER;WEBPLUG;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_2_0;UNITY_4_2;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_OSX</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
Expand All @@ -44,7 +44,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\Examples\Scripts\InteractiveConsole.cs" />
<Compile Include="Assets\Facebook\Scripts\AndroidFacebook.cs" />
<Compile Include="Assets\Facebook\Scripts\AndroidFacebookLoader.cs" />
<Compile Include="Assets\Facebook\Scripts\CanvasFacebookLoader.cs" />
Expand All @@ -58,7 +57,6 @@
<Compile Include="Assets\Facebook\Scripts\NativeDialogModes.cs" />
<Compile Include="Assets\Scripts\Destroyer.cs" />
<Compile Include="Assets\Scripts\EnemyExploder.cs" />
<Compile Include="Assets\Scripts\FBUtil.cs" />
<Compile Include="Assets\Scripts\FriendMarker.cs" />
<Compile Include="Assets\Scripts\GameState.cs" />
<Compile Include="Assets\Scripts\GameStateDisplay.cs" />
Expand All @@ -67,6 +65,7 @@
<Compile Include="Assets\Scripts\PhysicsTweaker.cs" />
<Compile Include="Assets\Scripts\Player.cs" />
<Compile Include="Assets\Scripts\Spawner.cs" />
<Compile Include="Assets\Scripts\Util.cs" />
<Compile Include="Assets\Scripts\WebAssetManager.cs" />
<None Include="Assets\Plugins\Android\res\drawable\com_facebook_picker_list_selector.xml" />
<None Include="Assets\Plugins\Android\res\layout\com_facebook_picker_activity_circle_row.xml" />
Expand Down
7 changes: 3 additions & 4 deletions Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D1DF54C5-EAD5-1ED5-1118-5A34D5D07374}</ProjectGuid>
<ProjectGuid>{5F426483-533C-780E-3227-74BA451DB70C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace></RootNamespace>
Expand All @@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_STANDALONE_OSX;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_GAMECENTER;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_2_0;UNITY_4_2;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_OSX</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_WEBPLAYER;WEBPLUG;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_2_0;UNITY_4_2;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_OSX</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
Expand All @@ -44,7 +44,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\Examples\Scripts\InteractiveConsole.cs" />
<Compile Include="Assets\Facebook\Scripts\AndroidFacebook.cs" />
<Compile Include="Assets\Facebook\Scripts\AndroidFacebookLoader.cs" />
<Compile Include="Assets\Facebook\Scripts\CanvasFacebookLoader.cs" />
Expand All @@ -58,7 +57,6 @@
<Compile Include="Assets\Facebook\Scripts\NativeDialogModes.cs" />
<Compile Include="Assets\Scripts\Destroyer.cs" />
<Compile Include="Assets\Scripts\EnemyExploder.cs" />
<Compile Include="Assets\Scripts\FBUtil.cs" />
<Compile Include="Assets\Scripts\FriendMarker.cs" />
<Compile Include="Assets\Scripts\GameState.cs" />
<Compile Include="Assets\Scripts\GameStateDisplay.cs" />
Expand All @@ -67,6 +65,7 @@
<Compile Include="Assets\Scripts\PhysicsTweaker.cs" />
<Compile Include="Assets\Scripts\Player.cs" />
<Compile Include="Assets\Scripts\Spawner.cs" />
<Compile Include="Assets\Scripts\Util.cs" />
<Compile Include="Assets\Scripts\WebAssetManager.cs" />
<None Include="Assets\Plugins\Android\res\drawable\com_facebook_picker_list_selector.xml" />
<None Include="Assets\Plugins\Android\res\layout\com_facebook_picker_activity_circle_row.xml" />
Expand Down
Binary file modified Assembly-CSharp.pidb
Binary file not shown.
1 change: 1 addition & 0 deletions Assets/Scripts.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Scripts/GameStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static void EndGame()
query["score"] = Instance.score.ToString();

// xxxxx scores
FB.API("/me/scores", Facebook.HttpMethod.POST, delegate(string r) { ; }, query);
FB.API("/me/scores", Facebook.HttpMethod.POST, delegate(FBResult r) { Debug.Log("Result: " + r.Text); }, query);

Application.LoadLevel("MainMenu");
Time.timeScale = 0.0f;
Expand Down
68 changes: 46 additions & 22 deletions Assets/Scripts/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ void OnGUI()
{
if (friends != null && friends.Count > 0)
{
Dictionary<string, string> friend = FBUtil.RandomFriend(friends);
Dictionary<string, string> friend = Util.RandomFriend(friends);
GameStateManager.FriendName = friend["first_name"];
GameStateManager.FriendID = friend["id"];
StartCoroutine(FBUtil.GetFriendPictureTexture(friend["id"]));
FB.API(Util.GetPictureURL((string)friend["id"], 128, 128), Facebook.HttpMethod.GET, Util.FriendPictureCallback);
}

Application.LoadLevel("GameStage");
Expand Down Expand Up @@ -163,46 +163,70 @@ void SetUserTexture(Texture t)
GameStateManager.UserTexture = t;
}

void LoginCallback()
void LoginCallback(FBResult result)
{
FbDebug.Log("call login: " + FB.UserId);
FbDebug.Log("login result: " + result.Text);
FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback);
FB.API ("/app/scores?fields=score,user.limit(20)", Facebook.HttpMethod.GET, ScoresCallback);
FB.API(Util.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, MyPictureCallback);
FB.API("/app/scores?fields=score,user.limit(20)", Facebook.HttpMethod.GET, ScoresCallback);
}

void ScoresCallback(string response)
void ScoresCallback(FBResult result)
{
if (result.Error != null)
{
Debug.LogError(result.Error);
return;
}

scores = new Dictionary<string, object>();
List<object> scoresList = FBUtil.DeserializeScores(response);
List<object> scoresList = Util.DeserializeScores(result.Text);

foreach(object score in scoresList)
{
Dictionary<string,object> entry = (Dictionary<string,object>) score;
Dictionary<string,object> user = (Dictionary<string,object>) entry["user"];

scores.Add((string) user["id"], entry);
string userId = (string)user["id"];

StartCoroutine(
GetFriendTexture((string)user["id"])
);
scores.Add(userId, entry);
FB.API(Util.GetPictureURL(userId, 128, 128), Facebook.HttpMethod.GET, pictureResult =>
{
if (pictureResult.Error != null)
{
Debug.LogError(pictureResult.Error);
}
else
{
friendImages.Add(userId, pictureResult.Texture);
}
});
}
}

IEnumerator GetFriendTexture(string uid) {
string url = FBUtil.GetPictureURL (uid, 128, 128);
WWW www = new WWW(url);
yield return www;
friendImages.Add(uid, (Texture) www.texture);
void APICallback(FBResult result)
{
if (result.Error != null)
{
Debug.LogError(result.Error);
return;
}

profile = Util.DeserializeJSONProfile(result.Text);
GameStateManager.Username = profile["first_name"];
friends = Util.DeserializeJSONFriends(result.Text);
}

void APICallback(string response)
void MyPictureCallback(FBResult result)
{
profile = FBUtil.DeserializeJSONProfile(response);
GameStateManager.Username = profile["first_name"];
StartCoroutine(
FBUtil.GetPictureTexture(facebookID: FB.UserId, callback: delegate(Texture t) { GameStateManager.UserTexture = t; })
);
friends = FBUtil.DeserializeJSONFriends(response);
if (result.Error != null)
{
Debug.LogError(result.Error);
return;
}

GameStateManager.UserTexture = result.Texture;
}

void TournamentCallback() {
Expand Down
Loading

0 comments on commit 171e33a

Please sign in to comment.