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

Commit

Permalink
Improving gameplay experience when no friend permission is granted.
Browse files Browse the repository at this point in the history
  • Loading branch information
andyborrell committed Jun 24, 2014
1 parent 2f01008 commit 4bb2253
Show file tree
Hide file tree
Showing 25 changed files with 260 additions and 75 deletions.
27 changes: 27 additions & 0 deletions friendsmash_advanced/Assets/Scenes/MainMenu.unity
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ Camera:
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_HDR: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: .0219999999
--- !u!4 &491552207
Transform:
m_ObjectHideFlags: 0
Expand All @@ -154,6 +157,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!1 &2077195017
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -182,6 +186,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
--- !u!114 &2077195019
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -222,6 +227,28 @@ MonoBehaviour:
CoinBalance: 0
NumLives: 0
NumBombs: 0
CelebTextures:
- {fileID: 2800000, guid: 0ab4831d71dee4ab7a5875f73f5ade1a, type: 3}
- {fileID: 2800000, guid: 36df35d8da60948b1907594105506598, type: 3}
- {fileID: 2800000, guid: 51b7c5f99732b4e4d9a8f1b10b0b1a3d, type: 3}
- {fileID: 2800000, guid: 1763cb1c4c548496391d72ffb453cf31, type: 3}
- {fileID: 2800000, guid: b25bc993f26fc46dba96990660e4a1a1, type: 3}
- {fileID: 2800000, guid: ccf18164baeee4a67b47ad6755877fdd, type: 3}
- {fileID: 2800000, guid: 4c0f74174a23c46b582b0daf1fb603bc, type: 3}
- {fileID: 2800000, guid: 392a3ee99bc334a94b73593e0975a7a1, type: 3}
- {fileID: 2800000, guid: 4e5d478c0aec44e8a9f5d86f75ff8245, type: 3}
- {fileID: 2800000, guid: 781542d34785547459298b0dea07a221, type: 3}
CelebNames:
- Einstein
- Xzibit
- Goldsmith
- Sinatra
- George
- Jacko
- Rick
- Keanu
- Arnie
- Jean-Luc
--- !u!114 &2077195020
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
17 changes: 13 additions & 4 deletions friendsmash_advanced/Assets/Scripts/FriendMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@

public class FriendMarker : MonoBehaviour
{

private MainMenu mainMenu;
public Texture FriendTexture, EnemyTexture;
public Texture[] CelebTextures;
Texture[] CelebTextures;

public float FriendThreshold = 0.5f;

// Use this for initialization
void Start()
{
if (GameStateManager.FriendTexture != null) FriendTexture = GameStateManager.FriendTexture;

mainMenu = (MainMenu)(GameObject.Find("Main Menu").GetComponent("MainMenu"));
CelebTextures = mainMenu.CelebTextures;
if (GameStateManager.CelebFriend != -1 )
FriendTexture = CelebTextures[GameStateManager.CelebFriend];
else if (GameStateManager.FriendTexture != null) FriendTexture = GameStateManager.FriendTexture;

float diceRoll = Random.value;
if (diceRoll <= FriendThreshold)
{
Expand All @@ -22,7 +28,10 @@ void Start()
else
{
gameObject.tag = "Enemy";
int which = Random.Range(0, CelebTextures.Length - 1);
int numValidCelebs = GameStateManager.CelebFriend == -1 ? CelebTextures.Length - 1 : CelebTextures.Length - 2;
int which = Random.Range(0,numValidCelebs);
if (GameStateManager.CelebFriend == which)
which = CelebTextures.Length - 1;
EnemyTexture = CelebTextures[which];
renderer.material.mainTexture = EnemyTexture;
}
Expand Down
1 change: 1 addition & 0 deletions friendsmash_advanced/Assets/Scripts/GameStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class GameStateManager : MonoBehaviour
private string username = null;
public static Texture UserTexture;
public static Texture FriendTexture = null;
public static int CelebFriend = -1;
private string friendName = null;
private string friendID = null;

Expand Down
12 changes: 11 additions & 1 deletion friendsmash_advanced/Assets/Scripts/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public class MainMenu : MonoBehaviour
public int NumLives;
public int NumBombs;

public Texture[] CelebTextures;
public string [] CelebNames;



// Private members //

Expand Down Expand Up @@ -590,9 +594,15 @@ private void onPlayClicked()
Dictionary<string, string> friend = Util.RandomFriend(friends);
GameStateManager.FriendName = friend["first_name"];
GameStateManager.FriendID = friend["id"];

GameStateManager.CelebFriend = -1;
LoadPicture(Util.GetPictureURL((string)friend["id"], 128, 128),FriendPictureCallback);
}
else
{
//We can't access friends
GameStateManager.CelebFriend = UnityEngine.Random.Range(0,CelebTextures.Length - 1);
GameStateManager.FriendName = CelebNames[GameStateManager.CelebFriend];
}

// Start the main game
Application.LoadLevel("GameStage");
Expand Down
10 changes: 0 additions & 10 deletions friendsmash_advanced/Assets/Scripts/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ public static string GetPictureURL(string facebookID, int? width = null, int? he
return url;
}

public static void FriendPictureCallback(FBResult result)
{
if (result.Error != null)
{
Debug.LogError(result.Error);
return;
}

GameStateManager.FriendTexture = result.Texture;
}

public static Dictionary<string, string> RandomFriend(List<object> friends)
{
Expand Down
27 changes: 27 additions & 0 deletions friendsmash_complete/Assets/Scenes/MainMenu.unity
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ Camera:
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_HDR: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: .0219999999
--- !u!4 &491552207
Transform:
m_ObjectHideFlags: 0
Expand All @@ -154,6 +157,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!1 &2077195017
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -182,6 +186,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
--- !u!114 &2077195019
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -222,6 +227,28 @@ MonoBehaviour:
CoinBalance: 0
NumLives: 0
NumBombs: 0
CelebTextures:
- {fileID: 2800000, guid: 0ab4831d71dee4ab7a5875f73f5ade1a, type: 3}
- {fileID: 2800000, guid: 36df35d8da60948b1907594105506598, type: 3}
- {fileID: 2800000, guid: 51b7c5f99732b4e4d9a8f1b10b0b1a3d, type: 3}
- {fileID: 2800000, guid: 1763cb1c4c548496391d72ffb453cf31, type: 3}
- {fileID: 2800000, guid: b25bc993f26fc46dba96990660e4a1a1, type: 3}
- {fileID: 2800000, guid: ccf18164baeee4a67b47ad6755877fdd, type: 3}
- {fileID: 2800000, guid: 4c0f74174a23c46b582b0daf1fb603bc, type: 3}
- {fileID: 2800000, guid: 392a3ee99bc334a94b73593e0975a7a1, type: 3}
- {fileID: 2800000, guid: 4e5d478c0aec44e8a9f5d86f75ff8245, type: 3}
- {fileID: 2800000, guid: 781542d34785547459298b0dea07a221, type: 3}
CelebNames:
- Einstein
- Xzibit
- Goldsmith
- Sinatra
- George
- Jacko
- Rick
- Keanu
- Arnie
- Jean-Luc
--- !u!114 &2077195020
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
17 changes: 13 additions & 4 deletions friendsmash_complete/Assets/Scripts/FriendMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@

public class FriendMarker : MonoBehaviour
{

private MainMenu mainMenu;
public Texture FriendTexture, EnemyTexture;
public Texture[] CelebTextures;
Texture[] CelebTextures;

public float FriendThreshold = 0.5f;

// Use this for initialization
void Start()
{
if (GameStateManager.FriendTexture != null) FriendTexture = GameStateManager.FriendTexture;

mainMenu = (MainMenu)(GameObject.Find("Main Menu").GetComponent("MainMenu"));
CelebTextures = mainMenu.CelebTextures;
if (GameStateManager.CelebFriend != -1 )
FriendTexture = CelebTextures[GameStateManager.CelebFriend];
else if (GameStateManager.FriendTexture != null) FriendTexture = GameStateManager.FriendTexture;

float diceRoll = Random.value;
if (diceRoll <= FriendThreshold)
{
Expand All @@ -22,7 +28,10 @@ void Start()
else
{
gameObject.tag = "Enemy";
int which = Random.Range(0, CelebTextures.Length - 1);
int numValidCelebs = GameStateManager.CelebFriend == -1 ? CelebTextures.Length - 1 : CelebTextures.Length - 2;
int which = Random.Range(0,numValidCelebs);
if (GameStateManager.CelebFriend == which)
which = CelebTextures.Length - 1;
EnemyTexture = CelebTextures[which];
renderer.material.mainTexture = EnemyTexture;
}
Expand Down
1 change: 1 addition & 0 deletions friendsmash_complete/Assets/Scripts/GameStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class GameStateManager : MonoBehaviour
private string username = null;
public static Texture UserTexture;
public static Texture FriendTexture = null;
public static int CelebFriend = -1;
private string friendName = null;
private string friendID = null;

Expand Down
12 changes: 11 additions & 1 deletion friendsmash_complete/Assets/Scripts/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public class MainMenu : MonoBehaviour
public int NumLives;
public int NumBombs;

public Texture[] CelebTextures;
public string [] CelebNames;



// Private members //

Expand Down Expand Up @@ -539,9 +543,15 @@ private void onPlayClicked()
Dictionary<string, string> friend = Util.RandomFriend(friends);
GameStateManager.FriendName = friend["first_name"];
GameStateManager.FriendID = friend["id"];

GameStateManager.CelebFriend = -1;
LoadPicture(Util.GetPictureURL((string)friend["id"], 128, 128),FriendPictureCallback);
}
else
{
//We can't access friends
GameStateManager.CelebFriend = UnityEngine.Random.Range(0,CelebTextures.Length - 1);
GameStateManager.FriendName = CelebNames[GameStateManager.CelebFriend];
}

// Start the main game
Application.LoadLevel("GameStage");
Expand Down
10 changes: 0 additions & 10 deletions friendsmash_complete/Assets/Scripts/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ public static string GetPictureURL(string facebookID, int? width = null, int? he
return url;
}

public static void FriendPictureCallback(FBResult result)
{
if (result.Error != null)
{
Debug.LogError(result.Error);
return;
}

GameStateManager.FriendTexture = result.Texture;
}

public static Dictionary<string, string> RandomFriend(List<object> friends)
{
Expand Down
27 changes: 27 additions & 0 deletions friendsmash_payments_complete/Assets/Scenes/MainMenu.unity
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ Camera:
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_HDR: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: .0219999999
--- !u!4 &491552207
Transform:
m_ObjectHideFlags: 0
Expand All @@ -154,6 +157,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!1 &2077195017
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -182,6 +186,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
--- !u!114 &2077195019
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -222,6 +227,28 @@ MonoBehaviour:
CoinBalance: 0
NumLives: 0
NumBombs: 0
CelebTextures:
- {fileID: 2800000, guid: 0ab4831d71dee4ab7a5875f73f5ade1a, type: 3}
- {fileID: 2800000, guid: 36df35d8da60948b1907594105506598, type: 3}
- {fileID: 2800000, guid: 51b7c5f99732b4e4d9a8f1b10b0b1a3d, type: 3}
- {fileID: 2800000, guid: 1763cb1c4c548496391d72ffb453cf31, type: 3}
- {fileID: 2800000, guid: b25bc993f26fc46dba96990660e4a1a1, type: 3}
- {fileID: 2800000, guid: ccf18164baeee4a67b47ad6755877fdd, type: 3}
- {fileID: 2800000, guid: 4c0f74174a23c46b582b0daf1fb603bc, type: 3}
- {fileID: 2800000, guid: 392a3ee99bc334a94b73593e0975a7a1, type: 3}
- {fileID: 2800000, guid: 4e5d478c0aec44e8a9f5d86f75ff8245, type: 3}
- {fileID: 2800000, guid: 781542d34785547459298b0dea07a221, type: 3}
CelebNames:
- Einstein
- Xzibit
- Goldsmith
- Sinatra
- George
- Jacko
- Rick
- Keanu
- Arnie
- Jean-Luc
--- !u!114 &2077195020
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
17 changes: 13 additions & 4 deletions friendsmash_payments_complete/Assets/Scripts/FriendMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@

public class FriendMarker : MonoBehaviour
{

private MainMenu mainMenu;
public Texture FriendTexture, EnemyTexture;
public Texture[] CelebTextures;
Texture[] CelebTextures;

public float FriendThreshold = 0.5f;

// Use this for initialization
void Start()
{
if (GameStateManager.FriendTexture != null) FriendTexture = GameStateManager.FriendTexture;

mainMenu = (MainMenu)(GameObject.Find("Main Menu").GetComponent("MainMenu"));
CelebTextures = mainMenu.CelebTextures;
if (GameStateManager.CelebFriend != -1 )
FriendTexture = CelebTextures[GameStateManager.CelebFriend];
else if (GameStateManager.FriendTexture != null) FriendTexture = GameStateManager.FriendTexture;

float diceRoll = Random.value;
if (diceRoll <= FriendThreshold)
{
Expand All @@ -22,7 +28,10 @@ void Start()
else
{
gameObject.tag = "Enemy";
int which = Random.Range(0, CelebTextures.Length - 1);
int numValidCelebs = GameStateManager.CelebFriend == -1 ? CelebTextures.Length - 1 : CelebTextures.Length - 2;
int which = Random.Range(0,numValidCelebs);
if (GameStateManager.CelebFriend == which)
which = CelebTextures.Length - 1;
EnemyTexture = CelebTextures[which];
renderer.material.mainTexture = EnemyTexture;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class GameStateManager : MonoBehaviour
private string username = null;
public static Texture UserTexture;
public static Texture FriendTexture = null;
public static int CelebFriend = -1;
private string friendName = null;
private string friendID = null;

Expand Down
Loading

0 comments on commit 4bb2253

Please sign in to comment.