Relocated Asset Packs

Any scripts contained in subdirectory "WebPlayerTemplates/" will not be
compiled
-Fixes build errors created from reference scripts within Ultimate GUI
Kit
This commit is contained in:
2017-08-26 17:21:24 -04:00
parent ef64fc5c08
commit ad57d40c70
169 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using Holoville.HOTween;
/// <summary>
/// This class is the redirect class it should be attached to a button in the levels scene
/// Author : Pondomaniac Games
/// </summary>
public class ButtonRedirect : MonoBehaviour
{
public string _redirectedScene; //The name of the scene we want to redirect to
public AudioClip MenuSound; //The sound of the menu clicks
private bool ShouldTransit = false;//A transition flag
public static string _FirstLevel;//The sound of the menu clicks
public static string[] scenes;
//Called before init
void Awake ()
{
Time.timeScale = 1;
HOTween.Kill ();
}
//This method is called after the init
void Start ()
{
//Loading the editor scenes orders to determine if the player can go the level or not
int RedirectedSceneIndexInSettings = -1;
int ReachedLevelIndexIndexInSettings = -1;
int FirstLevel = -1;
for (int i=0; i<=scenes.Length-1; i++) {
if (_redirectedScene == scenes [i])
RedirectedSceneIndexInSettings = i;
if (PlayerPrefs.GetString ("ReachedLevel") == scenes [i])
ReachedLevelIndexIndexInSettings = i;
if (_FirstLevel == scenes [i])
FirstLevel = i;
}
if (_redirectedScene != string.Empty && (RedirectedSceneIndexInSettings <= ReachedLevelIndexIndexInSettings || RedirectedSceneIndexInSettings == FirstLevel)) {
this.GetComponent<Renderer>().enabled = true;
this.GetComponent<Collider2D>().enabled = true;
} else {
this.GetComponent<Renderer>().enabled = false;
this.GetComponent<Collider2D>().enabled = false;
var allChildren = this.GetComponentsInChildren (typeof(Transform), true);
foreach (Transform child in allChildren) {
GameObject Module = child.gameObject;
Module.GetComponent<Renderer>().enabled = false;
}
}
}
// Update is called once per frame
void Update ()
{
if (HOTween.GetAllTweens ().Count == 0 && ShouldTransit) {
if (_redirectedScene != string.Empty) {
Application.LoadLevel (_redirectedScene);
}
}
if (Input.GetKeyDown (KeyCode.Escape)) {
Application.Quit ();
}
//Detecting if the player clicked on the left mouse button and also if there is no animation playing
if (Input.GetButtonDown ("Fire1")) {
//The 3 following lines is to get the clicked GameObject and getting the RaycastHit2D that will help us know the clicked object
RaycastHit2D hit = Physics2D.Raycast (Camera.main.ScreenToWorldPoint (Input.mousePosition), Vector2.zero);
if (hit.transform != null) {
if ((hit.transform.gameObject.name == this.name)) {
GetComponent<AudioSource>().PlayOneShot (MenuSound);
Util.ButtonPressAnimation (hit.transform.gameObject);
ShouldTransit = true;
Time.timeScale = 1;
}
}
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: cef94d4330179284ebf1c08a6945802c
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,126 @@
using System.Collections.Generic;
using UnityEngine;
public class GameStateManager : MonoBehaviour
{
private static GameStateManager instance;
public static bool ScoringLockout = true;
public static int StartingLives = 3, StartingScore = 0;
private int lives, score;
private int? highScore;
private string username = null;
public static Texture UserTexture;
public static Texture FriendTexture = null;
private string friendName = null;
private string friendID = null;
public static bool IsFullscreen = false;
public bool Immortal;
private static bool immortal;
public static int ToSmash = -1;
public static string FriendID
{
set { Instance.friendID = value; }
get { return Instance.friendID; }
}
public static string FriendName
{
set { Instance.friendName = value; }
get { return Instance.friendName == null ? "Blue Guy" : Instance.friendName; }
}
public static Dictionary<string, Player> leaderboard;
void Start()
{
lives = StartingLives;
score = StartingScore;
immortal = Instance.Immortal;
ScoringLockout = false;
Time.timeScale = 1.0f;
}
public void StartGame()
{
Start();
}
void Awake()
{
DontDestroyOnLoad(this);
}
public static GameStateManager Instance { get { return current(); } }
public static int Score { get { return Instance.score; } }
public static int HighScore { get { return Instance.highScore.HasValue ? Instance.highScore.Value : 0; } set { Instance.highScore = value; }}
public static int LivesRemaining { get { return Instance.lives; } }
public static string Username
{
get { return Instance.username; }
set { Instance.username = value; }
}
delegate GameStateManager InstanceStep();
static InstanceStep init = delegate()
{
GameObject container = new GameObject("GameStateManagerManager");
instance = container.AddComponent<GameStateManager>();
instance.lives = StartingLives;
instance.score = StartingScore;
instance.highScore = null;
current = then;
return instance;
};
static InstanceStep then = delegate() { return instance; };
static InstanceStep current = init;
public static void onFriendDie()
{
if (--Instance.lives == 0)
{
EndGame();
}
}
public static void onFriendSmash()
{
if (!ScoringLockout) ++Instance.score;
}
public static void onEnemySmash(GameObject enemy)
{
// Instance.fatalEnemy = enemy;
}
public static void EndGame()
{
if (immortal) return;
GameObject[] friends = GameObject.FindGameObjectsWithTag("Friend");
GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
foreach (GameObject t in friends)
{
Destroy(t);
}
foreach (GameObject t in enemies)
{
Destroy(t);
}
FbDebug.Log("EndGame Instance.highScore = " + Instance.highScore + "\nInstance.score = " + Instance.score);
Instance.highScore = Instance.score;
FbDebug.Log("Player has new high score :" + Instance.score);
Application.LoadLevel("MainMenu");
Time.timeScale = 0.0f;
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: e65ba8df973e84847aefe317bf7f0b6f
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,409 @@
using UnityEngine;
using System.Collections;
using Holoville.HOTween;
/// <summary>
/// This class is the main entry point of the game it should be attached to a gameobject and be instanciate in the scene
/// Author : Pondomaniac Games
/// </summary>
public class Main : MonoBehaviour
{
public GameObject _Tutorial;//Tutorial GameObject
public int _scoreIncrement;//The amount of point to increment each time we score
private int _scoreTotal = 0;//The score
float progress = 0;//The progress bar progress
public float _timerCoef ;//The progress bar speed
public GameObject _Time;//The timer
public GameObject _PauseButton;//The pause button we use in the scene
private bool isPaused = false ;//A flag indicating if the game is paused
private bool isEnded = false ;//A flag indicating if the game has ended
private bool isCountingDown = true ;//A flag indicating if the game is counting down
public GameObject _ReloadButton;//The reload button we use in the scene
public GameObject _PlayButton;//The play button we use in the scene
public GameObject _MenuButton;//The menu button we use in the scene
public GameObject _PausedBackground;//The pause background
float timing = 0;//The local timer
public GameObject _TimeIsUp;//The object indicating if the time is up
public GameObject _MessageEffectWhenShown;//A particul effect we can use when a message is shown
bool _BestScoreReached = false ;//A flag indicating if the bestscore has been reached
bool _BestLevelReached = false ;//A flag indicating if the bestlevel has been reached
public GameObject _CurrentScore;//The current score in the scene
public GameObject _BestScore;//The best score in the scene
public GameObject _CurrentLevel;//The current level in the scene
public GameObject _BestLevel;//The best level in the scene
public GameObject _ScoreBoard;//The score board when the game has ended or when the time is up
public GameObject _FaceBookButton;//The facebook button to share the score with friends
public GameObject _Level;//Level reached
public GameObject _LevelTextValue;//Level reached text value
public GameObject _CountDown;//The CountDown object that is not used directly that we use to replicate the style when displaying countdown
public GameObject _TestScore;//The testscore button used to test the score and level increment
public GameObject _TestLevelEnd;//The testscore button used to test the rnd of the level
public AudioClip PowerSound;//The sound heared when we level up
public AudioClip MenuSound;//The sound heared when we click on a button
int level = 0;
float maxProgress = 0;
float ScoreByLevel = 0;
public AudioClip LevelUpSound;
public AudioClip TimeUpSound;
public AudioClip BestScoreSound;
public AudioClip EndSound;
public AudioClip CountDownSound;
// Use this for initialization
void Start ()
{
UpdateLevel (0);
progress = (float)(timing * _timerCoef);
//_Timer new Rect(pos.x, pos.y, size.x, size.y), progressBarEmpty);
_Time.transform.localScale = new Vector3 (Mathf.Clamp01 (progress), _Time.transform.localScale.y, 0);
StartCoroutine (Init ());
}
// Update is called once per frame
void Update ()
{
if (Input.GetKeyDown (KeyCode.Escape)) {
Application.Quit ();
}
//Detecting if the player clicked on the left mouse button and also if there is no animation playing
if (Input.GetButtonDown ("Fire1")) {
//The 3 following lines is to get the clicked GameObject and getting the RaycastHit2D that will help us know the clicked object
RaycastHit2D hit = Physics2D.Raycast (Camera.main.ScreenToWorldPoint (Input.mousePosition), Vector2.zero);
if (hit.transform != null) {
if (hit.transform.gameObject.name == _MenuButton.name) {
GetComponent<AudioSource>().PlayOneShot (MenuSound);
hit.transform.localScale = new Vector3 (1.1f, 1.1f, 0);
Application.LoadLevel ("MainMenu");
}
if (hit.transform.gameObject.name == _FaceBookButton.name) {
hit.transform.localScale = new Vector3 (1.5f, 1.5f, 0);
onBragClicked ();
}
if (hit.transform.gameObject.name == _ReloadButton.name) {
GetComponent<AudioSource>().PlayOneShot (MenuSound);
Time.timeScale = 1;
isPaused = false;
HOTween.Play ();
hit.transform.localScale = new Vector3 (1.1f, 1.1f, 0);
Application.LoadLevel (Application.loadedLevelName);
}
if (hit.transform.gameObject.name == _PauseButton.name && !isPaused && !isCountingDown && !isEnded && HOTween.GetTweenersByTarget (_PlayButton.transform, false).Count == 0 && HOTween.GetTweenersByTarget (_MenuButton.transform, false).Count == 0) {
GetComponent<AudioSource>().PlayOneShot (MenuSound);
StartCoroutine (ShowMenu ());
hit.transform.localScale = new Vector3 (1.1f, 1.1f, 0);
} else if ((hit.transform.gameObject.name == _PauseButton.name || hit.transform.gameObject.name == _PlayButton.name) && !isEnded && !isCountingDown && isPaused && HOTween.GetTweenersByTarget (_PlayButton.transform, false).Count == 0 && HOTween.GetTweenersByTarget (_MenuButton.transform, false).Count == 0) {
GetComponent<AudioSource>().PlayOneShot (MenuSound);
StartCoroutine (HideMenu ());
hit.transform.localScale = new Vector3 (1f, 1f, 0);
} else if ((hit.transform.gameObject.name == _TestScore.name) && !isEnded && !isCountingDown && !isPaused) {
GetComponent<AudioSource>().PlayOneShot (MenuSound);
_scoreTotal += _scoreIncrement;
UpdateLevel (20 * _scoreIncrement);
Util.ButtonPressAnimation (hit.transform.gameObject);
} else if ((hit.transform.gameObject.name == _TestLevelEnd.name) && !isEnded && !isCountingDown && !isPaused) {
isEnded = true;
isPaused = true;
StartCoroutine (ShowBoardScore ());
Util.ButtonPressAnimation (hit.transform.gameObject);
//Update the Level
UpdateReachedLevel ();
}
}
}
if (isPaused)
return;
if (! isPaused) {
timing += 0.001f;
progress = (float)(timing * _timerCoef);
_Time.transform.localScale = new Vector3 (Mathf.Clamp01 (progress), _Time.transform.localScale.y, 0);
}
if (Mathf.Clamp01 (progress) >= 1) {
isEnded = true;
isPaused = true;
TweenParms parms = new TweenParms ().Prop ("position", new Vector3 (_TimeIsUp.transform.position.x, -0.85f, -6)).Ease (EaseType.EaseOutQuart);
HOTween.To (_TimeIsUp.transform, 0.5f, parms).WaitForCompletion ();
StartCoroutine (ShowBoardScore ());
}
//Update the score
(GetComponent (typeof(TextMesh))as TextMesh).text = _scoreTotal.ToString ();
if (PlayerPrefs.GetInt ("HighScore") < _scoreTotal && !_BestScoreReached) {
_BestScoreReached = true;
}
if (PlayerPrefs.GetInt ("HighLevel") < level && !_BestLevelReached) {
_BestLevelReached = true;
}
}
//Update the Level
void UpdateLevel (int score)
{
ScoreByLevel += score;
maxProgress = (float)Mathf.Floor (250 * (level + 1));
_Level.transform.localScale = new Vector3 ((float)(ScoreByLevel / maxProgress), _Level.transform.localScale.y, 0);
if (Mathf.Clamp01 (_Level.transform.localScale.x) >= 1) {
//_Level.transform.localScale= new Vector3 (0, _Level.transform.localScale.y, 0) ;
//Order is important for calculus
level += 1;
ScoreByLevel = 0;
timing = 0;
GetComponent<AudioSource>().PlayOneShot (PowerSound);
TweenParms parms = new TweenParms ().Prop ("localScale", new Vector3 (0, _Level.transform.localScale.y, -6)).Ease (EaseType.EaseOutQuart);
HOTween.To (_Level.transform, 0.5f, parms).WaitForCompletion ();
parms = new TweenParms ().Prop ("localScale", new Vector3 (0, _Time.transform.localScale.y, -6)).Ease (EaseType.EaseOutQuart);
HOTween.To (_Time.transform, 0.5f, parms).WaitForCompletion ();
(_LevelTextValue.GetComponent (typeof(TextMesh))as TextMesh).text = level.ToString ();
var destroyingParticle = GameObject.Instantiate (_LevelTextValue as GameObject, new Vector3 (_LevelTextValue.transform.position.x, _LevelTextValue.transform.position.y, _LevelTextValue.transform.position.z - 1), transform.rotation) as GameObject;
Color oldColor = destroyingParticle.GetComponent<Renderer>().material.color;
parms = new TweenParms ().Prop ("color", new Color (oldColor.r, oldColor.b, oldColor.g, 0f)).Ease (EaseType.EaseOutQuart);
HOTween.To ((destroyingParticle.GetComponent (typeof(TextMesh))as TextMesh), 4f, parms);
parms = new TweenParms ().Prop ("fontSize", 150).Ease (EaseType.EaseOutQuart);
HOTween.To ((destroyingParticle.GetComponent (typeof(TextMesh))as TextMesh), 2f, parms);
Destroy (destroyingParticle, 5);
} else {
(_LevelTextValue.GetComponent (typeof(TextMesh))as TextMesh).text = level.ToString ();
}
}
//Show the bestscore board
IEnumerator ShowBoardScore ()
{
GetComponent<AudioSource>().Stop ();
GetComponent<AudioSource>().PlayOneShot (TimeUpSound);
yield return new WaitForSeconds (0.5f);
GetComponent<AudioSource>().PlayOneShot (EndSound);
(_BestScore.GetComponent (typeof(TextMesh))as TextMesh).text = "" + PlayerPrefs.GetInt ("HighScore");
(_BestLevel.GetComponent (typeof(TextMesh))as TextMesh).text = "" + PlayerPrefs.GetInt ("HighLevel");
(_CurrentScore.GetComponent (typeof(TextMesh))as TextMesh).text = "" + _scoreTotal;
(_CurrentLevel.GetComponent (typeof(TextMesh))as TextMesh).text = "" + (_LevelTextValue.GetComponent (typeof(TextMesh))as TextMesh).text;
SetScore (_scoreTotal);
yield return new WaitForSeconds (1);
TweenParms parms = new TweenParms ().Prop ("position", new Vector3 (_ScoreBoard.transform.position.x, 5f, _ScoreBoard.transform.position.z)).Ease (EaseType.EaseOutQuart);
HOTween.To (_ScoreBoard.transform, 0.5f, parms);
//_MenuButton.transform.position = new Vector3 (4, _MenuButton.transform.position.y, _MenuButton.transform.position.z);
parms = new TweenParms ().Prop ("position", new Vector3 (_MenuButton.transform.position.x, 1.7f, -8)).Ease (EaseType.EaseOutQuart);
HOTween.To (_MenuButton.transform, 0.7f, parms).WaitForCompletion ();
parms = new TweenParms ().Prop ("position", new Vector3 (_ReloadButton.transform.position.x, 1.7f, -8)).Ease (EaseType.EaseOutQuart);
HOTween.To (_ReloadButton.transform, 0.9f, parms).WaitForCompletion ();
}
//Update the pause menu
IEnumerator ShowMenu ()
{
isPaused = true;
HOTween.Pause ();
GetComponent<AudioSource>().Pause ();
TweenParms parms = new TweenParms ().Prop ("position", new Vector3 (_PausedBackground.transform.position.x, 4, -5)).Ease (EaseType.EaseOutQuart);
HOTween.To (_PausedBackground.transform, 0.2f, parms).WaitForCompletion ();
parms = new TweenParms ().Prop ("position", new Vector3 (_PlayButton.transform.position.x, 3.5f, -6)).Ease (EaseType.EaseOutQuart);
HOTween.To (_PlayButton.transform, 0.4f, parms).WaitForCompletion ();
parms = new TweenParms ().Prop ("position", new Vector3 (_ReloadButton.transform.position.x, 3.5f, -6)).Ease (EaseType.EaseOutQuart);
HOTween.To (_ReloadButton.transform, 0.5f, parms).WaitForCompletion ();
parms = new TweenParms ().Prop ("position", new Vector3 (_MenuButton.transform.position.x, 3.5f, -6)).Ease (EaseType.EaseOutQuart);
yield return StartCoroutine (HOTween.To (_MenuButton.transform, 0.6f, parms).WaitForCompletion ());
Time.timeScale = 0;
}
//Hide the pause menu
IEnumerator HideMenu ()
{
Time.timeScale = 1;
isPaused = false;
HOTween.Play ();
TweenParms parms = new TweenParms ().Prop ("position", new Vector3 (_PausedBackground.transform.position.x, 16, -5)).Ease (EaseType.EaseOutQuart);
HOTween.To (_PausedBackground.transform, 0.6f, parms).WaitForCompletion ();
parms = new TweenParms ().Prop ("position", new Vector3 (_PlayButton.transform.position.x, 16, -6)).Ease (EaseType.EaseOutQuart);
HOTween.To (_PlayButton.transform, 0.4f, parms).WaitForCompletion ();
GetComponent<AudioSource>().Play ();
parms = new TweenParms ().Prop ("position", new Vector3 (_ReloadButton.transform.position.x, 16, -6)).Ease (EaseType.EaseOutQuart);
HOTween.To (_ReloadButton.transform, 0.5f, parms).WaitForCompletion ();
parms = new TweenParms ().Prop ("position", new Vector3 (_MenuButton.transform.position.x, 16, -6)).Ease (EaseType.EaseOutQuart);
yield return StartCoroutine (HOTween.To (_MenuButton.transform, 0.2f, parms).WaitForCompletion ());
}
//Where facebook button is clicked
private void onBragClicked ()
{
if (!FB.IsLoggedIn) {
// Initialize FB SDK
enabled = false;
FB.Init (SetInit, OnHideUnity);
FB.Login ("email,publish_actions", LoginCallback);
}
FbDebug.Log ("onBragClicked");
FB.Feed (
linkCaption: "I just scored " + _scoreTotal + " ! Can you beat it?",
picture: "http://static.wix.com/media/13f8cb_48245b5b162848f493d15a0f40e05b6b.png?dn=Icone_300.png",
linkName: "Checkout my MatchMania greatness! Can you beat me?",
link: "http://apps.facebook.com/" + FB.AppId + "/?challenge_brag=" + (FB.IsLoggedIn ? FB.UserId : "guest")
);
}
void LoginCallback (FBResult result)
{
FbDebug.Log ("LoginCallback");
if (FB.IsLoggedIn) {
OnLoggedIn ();
}
}
void OnLoggedIn ()
{
FbDebug.Log ("Logged in. ID: " + FB.UserId);
// Request player info and profile picture
onBragClicked ();
}
private void SetInit ()
{
FbDebug.Log ("SetInit");
enabled = true; // "enabled" is a property inherited from MonoBehaviour
if (FB.IsLoggedIn) {
FbDebug.Log ("Already logged in");
OnLoggedIn ();
}
}
private void OnHideUnity (bool isGameShown)
{
FbDebug.Log ("OnHideUnity");
if (!isGameShown) {
// pause the game - we will need to hide
Time.timeScale = 0;
} else {
// start the game back up - we're getting focus again
Time.timeScale = 1;
}
}
//Setting the score in the player preferences
void SetScore (int _scoreTotal)
{
PlayerPrefs.SetInt ("LastScore", _scoreTotal);
if (PlayerPrefs.GetInt ("HighScore") < _scoreTotal) {
PlayerPrefs.SetInt ("HighScore", _scoreTotal);
GetComponent<AudioSource>().PlayOneShot (BestScoreSound);
}
if (PlayerPrefs.GetInt ("HighLevel") < _scoreTotal) {
//PlayerPrefs.SetInt ("OldHighLevel",PlayerPrefs.GetInt ("HighLevel"));
PlayerPrefs.SetInt ("HighLevel", int.Parse ((_LevelTextValue.GetComponent (typeof(TextMesh))as TextMesh).text));
}
}
//Show a message in the screen
IEnumerator Init ()
{
isPaused = true;
Vector3 center = Camera.main.ScreenToWorldPoint (new Vector3 (Screen.width / 2, Screen.height / 2, Camera.main.nearClipPlane));
//PlayerPrefs.SetInt ("Tutorial", 0);
if (PlayerPrefs.GetInt ("Tutorial") != 1) {
var isOkay = false;
while (isOkay==false) {
if (Input.GetButtonDown ("Fire1")) {
isOkay = true;
TweenParms parms = new TweenParms ().Prop ("localPosition", new Vector3 (100, 0, -10)).Ease (EaseType.EaseOutQuart);
HOTween.To (_Tutorial.transform, 3f, parms);
PlayerPrefs.SetInt ("Tutorial", 1);
}
yield return 0;
}
} else {
_Tutorial.transform.localPosition = new Vector3 (100, 0, -10);
}
//Count down from 3,2,1 Go!
AnimateBigSmall (_CountDown, new Vector3 (center.x, center.y, -5), "3");
GetComponent<AudioSource>().PlayOneShot (CountDownSound);
yield return new WaitForSeconds (0.7f);
AnimateBigSmall (_CountDown, new Vector3 (center.x, center.y, -5), "2");
GetComponent<AudioSource>().PlayOneShot (CountDownSound);
yield return new WaitForSeconds (0.7f);
AnimateBigSmall (_CountDown, new Vector3 (center.x, center.y, -5), "1");
GetComponent<AudioSource>().PlayOneShot (CountDownSound);
yield return new WaitForSeconds (0.7f);
AnimateBigSmall (_CountDown, new Vector3 (center.x, center.y, -5), "Go!");
GetComponent<AudioSource>().PlayOneShot (CountDownSound);
yield return new WaitForSeconds (0.5f);
isPaused = false;
isCountingDown = false;
}
//Gameobject animation from big to small when showing a message
void AnimateBigSmall (GameObject go, Vector3 position, string s)
{
var destroyingParticle = GameObject.Instantiate (go as GameObject, position, transform.rotation) as GameObject;
(destroyingParticle.GetComponent (typeof(TextMesh))as TextMesh).text = s;
Color oldColor2 = destroyingParticle.GetComponent<Renderer>().material.color;
TweenParms parms2 = new TweenParms ().Prop ("color", new Color (oldColor2.r, oldColor2.b, oldColor2.g, 0f)).Ease (EaseType.EaseOutQuart);
HOTween.To ((destroyingParticle.GetComponent (typeof(TextMesh))as TextMesh), 4f, parms2);
parms2 = new TweenParms ().Prop ("fontSize", 200).Ease (EaseType.EaseOutQuart);
HOTween.To ((destroyingParticle.GetComponent (typeof(TextMesh))as TextMesh), 3f, parms2);
Destroy (destroyingParticle, 4);
}
//Update the reached level in the player preferences
void UpdateReachedLevel ()
{
int LoadedSceneIndexInSettings = -1;
int ReachedLevelIndexIndexInSettings = -1;
for (int i=0; i<=ButtonRedirect.scenes.Length-1; i++) {
if (Application.loadedLevelName == ButtonRedirect.scenes [i])
LoadedSceneIndexInSettings = i;
if (PlayerPrefs.GetString ("ReachedLevel") == ButtonRedirect.scenes [i])
ReachedLevelIndexIndexInSettings = i;
}
if (LoadedSceneIndexInSettings >= ReachedLevelIndexIndexInSettings && (ButtonRedirect.scenes.Length - 1 >= LoadedSceneIndexInSettings + 1)) {
PlayerPrefs.SetString ("ReachedLevel", ButtonRedirect.scenes [LoadedSceneIndexInSettings + 1]);
Debug.Log (ButtonRedirect.scenes [LoadedSceneIndexInSettings + 1]);
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 1b8fba5683cadd2408bf3acf08818bdf
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,297 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using Holoville.HOTween;
/// <summary>
/// This class is the MainMenu class that contain the logic of the menu
/// Author : Pondomaniac Games
/// </summary>
public class MainMenu : MonoBehaviour {
public GameObject _Logo;//The animated logos
public GameObject _PlayButton;//The play button
public GameObject _PurchaseButton;//The purchase button
public GameObject _BestScore;//The bestscore text
public GameObject _BestLevel;//The level text
public GameObject _FacebookButton;//The facebook button to connect
public GameObject _AddCoinsButton;//The button used to add coins
public GameObject _MoreTimeButton;//The more time button
public GameObject _LuckButton;//The luck button
public GameObject _Luckx2Button;//The luck x 2 button
public GameObject _MoreTimeButtonText;//The more time text
public GameObject _LuckButtonText;//The luck text
public GameObject _Luckx2ButtonText;//The luck x 2 text
private Boolean _IsMoreTime;//More time flag
private Boolean _IsLuck;//Luck flag
private Boolean _IsLuckx2;//Luck x 2 flag
public GameObject _50CoinsButton;//50 Coins
public GameObject _100CoinsButton;//100 Coins
public GameObject _200CoinsButton;//200 Coins
public GameObject _300CoinsButton;//300 Coins
public GameObject _GoldValue;//Gold value text
public GameObject _GoldValue2;//Gold value text 2
public GameObject _TransitionPlayButton;//The small play button
public GameObject _TransitionReturnButton;//The return button
public GameObject _StoreReturnButton;//The return button to the store
public GameObject _MainMenuPanel;//The main panel
public GameObject _PowerPanel;//The panel that contains powers
public GameObject _StorePanel;//The panel that contains the store
// Use this for initialization
//private static List<object> friends = null;//The list of friends used by the facebook api
private static Dictionary<string, string> profile = null;//The list of profiles used by the facebook api
public string _NextScene;//The nextScene to navigate to
public string _Ladder;
public AudioClip MenuSound;//The menu sound when the user clicka buton
public float SpaceBetweenPanels;//The space to keep between panels
public EaseType AnimationTypeOfPanels;//The animation effect used on the panel
public float AnimationDurationOfPanels;//The animation duration time
public bool EnableFacebook;//Specify if we should display facebook buton or not
//Called before init
void Awake()
{ Time.timeScale=1;
GetGoldValues ();
_FacebookButton.GetComponent<Renderer>().enabled = false;
// Initialize FB SDK
if (EnableFacebook )FB.Init (SetInit, OnHideUnity);
}
void LoginCallback(FBResult result)
{
FbDebug.Log("LoginCallback");
if (FB.IsLoggedIn)
{
OnLoggedIn();
}
}
void OnLoggedIn()
{
FbDebug.Log("Logged in. ID: " + FB.UserId);
// Request player info and profile picture
FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback);
FB.API(Util.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, MyPictureCallback);
}
private void SetInit()
{
FbDebug.Log("SetInit");
// enabled = true; // "enabled" is a property inherited from MonoBehaviour
if (FB.IsLoggedIn)
{
FbDebug.Log("Already logged in");
OnLoggedIn();
}
}
private void OnHideUnity(bool isGameShown)
{
FbDebug.Log("OnHideUnity");
if (!isGameShown)
{
// pause the game - we will need to hide
Time.timeScale = 0;
}
else
{
// start the game back up - we're getting focus again
Time.timeScale = 1;
}
}
void APICallback(FBResult result)
{
FbDebug.Log("APICallback");
if (result.Error != null)
{
FbDebug.Error(result.Error);
// Let's just try again
FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback);
return;
}
profile = Util.DeserializeJSONProfile(result.Text);
GameStateManager.Username = profile["first_name"];
//friends = Util.DeserializeJSONFriends(result.Text);
}
void MyPictureCallback(FBResult result)
{
FbDebug.Log("MyPictureCallback");
if (result.Error != null)
{
FbDebug.Error(result.Error);
// Let's just try again
FB.API(Util.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, MyPictureCallback);
return;
}
GameStateManager.UserTexture = result.Texture;
}
//Display facebook button or not
void OnGUI()
{
if (EnableFacebook) {
if (!FB.IsLoggedIn) {
_FacebookButton.GetComponent<Renderer>().enabled = true;
} else {
_FacebookButton.GetComponent<Renderer>().enabled = false;
}
}
}
//This method is called after the init
void Start () {
PlayerPrefs.SetInt("MoreTime", 0);
PlayerPrefs.SetInt("Luck", 0);
PlayerPrefs.SetInt("Luckx2", 0);
AnimateLogo ();
(_BestScore.GetComponent (typeof(TextMesh))as TextMesh).text = "" + PlayerPrefs.GetInt ("HighScore");
(_BestLevel.GetComponent (typeof(TextMesh))as TextMesh).text = "" + PlayerPrefs.GetInt ("HighLevel");
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); }
//Detecting if the player clicked on the left mouse button and also if there is no animation playing
if (Input.GetButtonDown ("Fire1") ) {
//The 3 following lines is to get the clicked GameObject and getting the RaycastHit2D that will help us know the clicked object
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
if (hit.transform!=null )
{ if(( hit.transform.gameObject.name ==_FacebookButton.name ) ){
Util.ButtonPressAnimation(hit.transform.gameObject);
FB.Login("email,publish_actions", LoginCallback);
}
else if(( hit.transform.gameObject.name ==_PlayButton.name ) ){GetComponent<AudioSource>().PlayOneShot(MenuSound);Util.ButtonPressAnimation(hit.transform.gameObject); Application.LoadLevel(_NextScene);Time.timeScale=1; }
else if(( hit.transform.gameObject.name ==_PurchaseButton.name ) ){GetComponent<AudioSource>().PlayOneShot(MenuSound);Util.ButtonPressAnimation(hit.transform.gameObject);TransitToPowerMenu(); }
else if(( hit.transform.gameObject.name ==_TransitionPlayButton.name ) ){GetComponent<AudioSource>().PlayOneShot(MenuSound); Util.ButtonPressAnimation(hit.transform.gameObject);Application.LoadLevel(_NextScene);Time.timeScale=1; }
else if(( hit.transform.gameObject.name ==_TransitionReturnButton.name ) ){GetComponent<AudioSource>().PlayOneShot(MenuSound);Util.ButtonPressAnimation(hit.transform.gameObject);TransitMainMenu(); }
else if(( hit.transform.gameObject.name ==_AddCoinsButton.name ) ){GetComponent<AudioSource>().PlayOneShot(MenuSound); Util.ButtonPressAnimation(hit.transform.gameObject);TransitToStoreMenu(); }
else if(( hit.transform.gameObject.name ==_StoreReturnButton.name ) ){GetComponent<AudioSource>().PlayOneShot(MenuSound); Util.ButtonPressAnimation(hit.transform.gameObject);TransitToPowerMenu(); }
else if(( hit.transform.gameObject.name ==_50CoinsButton.name ) ){GetComponent<AudioSource>().PlayOneShot(MenuSound);Util.ButtonPressAnimation(hit.transform.gameObject);IncreaseGoldValue(50); }
else if(( hit.transform.gameObject.name ==_100CoinsButton.name ) ){GetComponent<AudioSource>().PlayOneShot(MenuSound); Util.ButtonPressAnimation(hit.transform.gameObject);IncreaseGoldValue(100); }
else if(( hit.transform.gameObject.name ==_200CoinsButton.name ) ){GetComponent<AudioSource>().PlayOneShot(MenuSound); Util.ButtonPressAnimation(hit.transform.gameObject);IncreaseGoldValue(200); }
else if(( hit.transform.gameObject.name ==_300CoinsButton.name ) ){GetComponent<AudioSource>().PlayOneShot(MenuSound); Util.ButtonPressAnimation(hit.transform.gameObject);IncreaseGoldValue(300); }
else if(( hit.transform.gameObject.name ==_MoreTimeButton.name ) && DecreaseGoldValue(10) ){GetComponent<AudioSource>().PlayOneShot(MenuSound); Util.ButtonPressAnimation(hit.transform.gameObject);if(! _IsMoreTime ){ _IsMoreTime = true ;PlayerPrefs.SetInt("MoreTime", 1); DisableButton(hit.transform.gameObject);DisableButton(_MoreTimeButtonText);}}
else if(( hit.transform.gameObject.name ==_LuckButton.name)&& DecreaseGoldValue(10)){GetComponent<AudioSource>().PlayOneShot(MenuSound); Util.ButtonPressAnimation(hit.transform.gameObject);if(! _IsLuck ){_IsLuck = true ;PlayerPrefs.SetInt("Luck", 1);DisableButton(hit.transform.gameObject);DisableButton(_LuckButtonText);}}
else if(( hit.transform.gameObject.name ==_Luckx2Button.name )&& DecreaseGoldValue(10) ){GetComponent<AudioSource>().PlayOneShot(MenuSound); Util.ButtonPressAnimation(hit.transform.gameObject);if(! _IsLuckx2 ){_IsLuckx2 = true ;PlayerPrefs.SetInt("Luckx2", 1);DisableButton(hit.transform.gameObject);DisableButton(_Luckx2ButtonText);} }
}}
}
// Transition animation to power panel
void TransitToPowerMenu() {
TweenParms parms = new TweenParms().Prop("position", new Vector3(-SpaceBetweenPanels,_MainMenuPanel.transform.position.y,_MainMenuPanel.transform.position.z)).Ease(AnimationTypeOfPanels);
HOTween.To (_MainMenuPanel.transform, AnimationDurationOfPanels, parms);
parms = new TweenParms().Prop("position", new Vector3(0,_PowerPanel.transform.position.y,_PowerPanel.transform.position.z)).Ease(AnimationTypeOfPanels);
HOTween.To(_PowerPanel.transform, AnimationDurationOfPanels, parms);
parms = new TweenParms().Prop("position", new Vector3(SpaceBetweenPanels,_StorePanel.transform.position.y,_StorePanel.transform.position.z)).Ease(AnimationTypeOfPanels);
HOTween.To(_StorePanel.transform, AnimationDurationOfPanels, parms);
}
// Transition animation to mainmenu panel
void TransitMainMenu() {
TweenParms parms = new TweenParms().Prop("position", new Vector3(SpaceBetweenPanels,_PowerPanel.transform.position.y,_PowerPanel.transform.position.z)).Ease(AnimationTypeOfPanels);
HOTween.To(_PowerPanel.transform, AnimationDurationOfPanels, parms);
parms = new TweenParms().Prop("position", new Vector3(0,_MainMenuPanel.transform.position.y,_MainMenuPanel.transform.position.z)).Ease(AnimationTypeOfPanels);
HOTween.To(_MainMenuPanel.transform, AnimationDurationOfPanels, parms);
parms = new TweenParms().Prop("position", new Vector3(SpaceBetweenPanels*2,_StorePanel.transform.position.y,_StorePanel.transform.position.z)).Ease(AnimationTypeOfPanels);
HOTween.To(_StorePanel.transform, AnimationDurationOfPanels, parms);
}
// Transition animation to store panel
void TransitToStoreMenu() {
TweenParms parms = new TweenParms().Prop("position", new Vector3(-SpaceBetweenPanels*2,_StorePanel.transform.position.y,_StorePanel.transform.position.z)).Ease(AnimationTypeOfPanels);
HOTween.To(_StorePanel.transform, AnimationDurationOfPanels, parms);
parms = new TweenParms().Prop("position", new Vector3(-SpaceBetweenPanels,_PowerPanel.transform.position.y,_PowerPanel.transform.position.z)).Ease(AnimationTypeOfPanels);
HOTween.To(_PowerPanel.transform, AnimationDurationOfPanels, parms);
parms = new TweenParms().Prop("position", new Vector3(0,_StorePanel.transform.position.y,_StorePanel.transform.position.z)).Ease(AnimationTypeOfPanels);
HOTween.To(_StorePanel.transform, AnimationDurationOfPanels, parms);
}
// Disable and disappear a button
void DisableButton(GameObject go){
Color oldColor = go.GetComponent<Renderer>().material.color;
TweenParms parms = new TweenParms().Prop("color", new Color(oldColor.r, oldColor.b, oldColor.g, 0f)).Ease(EaseType.EaseOutQuart);
HOTween.To(go.GetComponent<Renderer>().material, 1f,parms);
}
// Get the gold value to get displayed
void GetGoldValues()
{ if ( PlayerPrefs.GetInt ("NotFirstLaunch") !=1 ){
PlayerPrefs.SetInt("Gold", 100);
PlayerPrefs.SetInt("NotFirstLaunch", 1);
}
(_GoldValue.GetComponent(typeof( TextMesh))as TextMesh).text = PlayerPrefs.GetInt("Gold").ToString();
(_GoldValue2.GetComponent(typeof( TextMesh))as TextMesh).text =PlayerPrefs.GetInt("Gold").ToString();
}
// Add an amount to the stored gold value
void IncreaseGoldValue(int val)
{
PlayerPrefs.SetInt("Gold", PlayerPrefs.GetInt("Gold")+ val);
GetGoldValues ();
}
// Decrease an amount to the stored gold value
bool DecreaseGoldValue(int val)
{
int GoldValue = PlayerPrefs.GetInt ("Gold") - val;
if (GoldValue < 0) {
return false;
}
else {
PlayerPrefs.SetInt ("Gold", GoldValue);
GetGoldValues ();
return true;
}
}
// Animation of the logo
void AnimateLogo ()
{
Sequence mySequence = new Sequence(new SequenceParms().Loops(-1));
TweenParms parms;
Color oldColor = _Logo.GetComponent<Renderer>().material.color;
parms = new TweenParms().Prop("color", new Color(oldColor.r, oldColor.b, oldColor.g, 0.4f)).Ease(EaseType.EaseInQuart);
parms = new TweenParms().Prop("localScale", new Vector3(1.1f,1.1f,-2)).Ease(EaseType.EaseOutElastic);
mySequence.Append(HOTween.To(_Logo.transform, 6f, parms));
parms = new TweenParms().Prop("localScale", new Vector3(0.9f,0.9f,-2)).Ease(EaseType.EaseOutElastic);
mySequence.Append(HOTween.To(_Logo.transform, 5f, parms));
mySequence.Play ();
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: cb123a338976eba4a9ca6944678195d0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using System.Collections.Generic;
using UnityEngine;
public class Player
{
public string FirstName, Name, FacebookId;
public Texture ProfilePic;
public int Score;
public Dictionary<string, string> Data;
public void setProfilePic(Texture pic)
{ // convenient for callbacks
ProfilePic = pic;
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 9e1279266dbfec0498336091095dc8db
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ReadSceneNames : MonoBehaviour
{
public string[] scenes;
#if UNITY_EDITOR
private static string[] ReadNames()
{
List<string> temp = new List<string>();
foreach (UnityEditor.EditorBuildSettingsScene S in UnityEditor.EditorBuildSettings.scenes)
{
if (S.enabled)
{
string name = S.path.Substring(S.path.LastIndexOf('/')+1);
name = name.Substring(0,name.Length-6);
temp.Add(name);
}
}
return temp.ToArray();
}
[UnityEditor.MenuItem("CONTEXT/ReadSceneNames/Update Scene Names")]
private static void UpdateNames(UnityEditor.MenuCommand command)
{
ReadSceneNames context = (ReadSceneNames)command.context;
context.scenes = ReadNames();
}
private void Reset()
{
scenes = ReadNames();
}
#endif
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: e80dbb25976f4fc449dbd97cae4ebf3e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,157 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using Holoville.HOTween;
/// <summary>
/// This class is used to display or not a redirection button
/// Author : Pondomaniac Games
/// </summary>
public class SelectLevel : MonoBehaviour
{
public GameObject _BestScore;//The best score text
public GameObject _BestLevel;//The best level text
public GameObject _TransitionRightButton;//The left button
public GameObject _TransitionLeftButton;//The right button
public GameObject[] _listOfPanels;//The list of panel that transit to the right and left
public AudioClip MenuSound;//The sound of button clicks
public float SpaceBetweenPanels;//The space to keep betwwen panels
public EaseType AnimationTypeOfPanels;//The type of animation we want to use when panel transit
public float AnimationDurationOfPanels;//The duration of animation between panels
public string _FirstLevel;//The first level in the panel the help the system know where to start
private int _activePanelIndex;//The active panel index to know wich panel is active when transit
//Called before init
void Awake ()
{
Time.timeScale = 1;
HOTween.Kill ();
ButtonRedirect._FirstLevel = _FirstLevel;
if (_listOfPanels.Length > 0)
_activePanelIndex = 0;
ButtonRedirect.scenes = scenes;
}
//Initializing the scene
void Start ()
{
(_BestScore.GetComponent (typeof(TextMesh))as TextMesh).text = "" + PlayerPrefs.GetInt ("HighScore");
(_BestLevel.GetComponent (typeof(TextMesh))as TextMesh).text = "" + PlayerPrefs.GetInt ("HighLevel");
}
// Update is called once per frame
void Update ()
{
if (Input.GetKeyDown (KeyCode.Escape)) {
Application.Quit ();
}
//Detecting if the player clicked on the left mouse button and also if there is no animation playing
if (Input.GetButtonDown ("Fire1")) {
//The 3 following lines is to get the clicked GameObject and getting the RaycastHit2D that will help us know the clicked object
RaycastHit2D hit = Physics2D.Raycast (Camera.main.ScreenToWorldPoint (Input.mousePosition), Vector2.zero);
if (hit.transform != null) {
if ((hit.transform.gameObject.name == _TransitionRightButton.name && HOTween.GetAllTweens ().Count == 0)) {
GetComponent<AudioSource>().PlayOneShot (MenuSound);
TransitToTheLeft ();
Util.ButtonPressAnimation (_TransitionRightButton);
} else if ((hit.transform.gameObject.name == _TransitionLeftButton.name && HOTween.GetAllTweens ().Count == 0)) {
GetComponent<AudioSource>().PlayOneShot (MenuSound);
TransitToTheRight ();
Util.ButtonPressAnimation (_TransitionLeftButton);
}
}
}
}
//Animate the panel and update panel index
void TransitToTheRight ()
{
HOTween.Complete ();
if (0 <= _activePanelIndex - 1)
_activePanelIndex --;
for (int i = 0; i<= _listOfPanels.Length-1; i++) {
GameObject go = _listOfPanels [i] as GameObject;
TweenParms parms = new TweenParms ().Prop ("position", new Vector3 (go.transform.position.x + SpaceBetweenPanels, go.transform.position.y, go.transform.position.z)).Ease (AnimationTypeOfPanels);
HOTween.To (go.transform, AnimationDurationOfPanels, parms); }
}
//Animate the panel and update panel index
void TransitToTheLeft ()
{
HOTween.Complete ();
if (_listOfPanels.Length - 1 >= _activePanelIndex + 1)
_activePanelIndex ++;
for (int i = 0; i<= _listOfPanels.Length-1; i++) {
GameObject go = _listOfPanels [i] as GameObject;
TweenParms parms = new TweenParms ().Prop ("position", new Vector3 (go.transform.position.x - SpaceBetweenPanels, go.transform.position.y, go.transform.position.z)).Ease (AnimationTypeOfPanels);
HOTween.To (go.transform, AnimationDurationOfPanels, parms);
}
}
//display or not the right and left button
void OnGUI ()
{
if (_listOfPanels.Length > 0) {
if (_activePanelIndex <= 0) {
_TransitionLeftButton.GetComponent<Renderer>().enabled = false;
_TransitionLeftButton.GetComponent<Collider2D>().enabled = false;
} else {
_TransitionLeftButton.GetComponent<Renderer>().enabled = true;
_TransitionLeftButton.GetComponent<Collider2D>().enabled = true;
}
if (_activePanelIndex >= _listOfPanels.Length - 1) {
_TransitionRightButton.GetComponent<Renderer>().enabled = false;
_TransitionRightButton.GetComponent<Collider2D>().enabled = false;
} else {
_TransitionRightButton.GetComponent<Renderer>().enabled = true;
_TransitionRightButton.GetComponent<Collider2D>().enabled = true;
}
}
}
public string[] scenes;
#if UNITY_EDITOR
private static string[] ReadNames()
{
List<string> temp = new List<string>();
foreach (UnityEditor.EditorBuildSettingsScene S in UnityEditor.EditorBuildSettings.scenes)
{
if (S.enabled)
{
string name = S.path.Substring(S.path.LastIndexOf('/')+1);
name = name.Substring(0,name.Length-6);
temp.Add(name);
}
}
return temp.ToArray();
}
[UnityEditor.MenuItem("CONTEXT/SelectLevel/Update Scene Names")]
private static void UpdateNames(UnityEditor.MenuCommand command)
{
SelectLevel context = (SelectLevel)command.context;
context.scenes = ReadNames();
}
private void Reset()
{
scenes = ReadNames();
ButtonRedirect.scenes = scenes;
}
#endif
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 10a12f9c4e238d44bb7fdd2c1160d1fc
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
using UnityEngine;
using System.Collections;
using System;
using Holoville.HOTween;
/// <summary>
/// This class is used to animate the splatch screen
/// Author : Pondomaniac Games
/// </summary>
public class SplatchScreen : MonoBehaviour
{
public GameObject _Logo;//The logo to animate
public float _FadeInTime;//The fadeIn animation time
public float _WaitingTime;//The stay time of the logo
public float _FadeOutTime;//The fadeOut animation time
public string _nextScene;//The next scene to load
// Used before initialization
void Awake ()
{
Time.timeScale = 1;
}
// Used for initialization
void Start ()
{
StartCoroutine (Init ());
}
// Animate the Logos with fadeIn and fadeOut effect
IEnumerator Init ()
{
Sequence mySequence = new Sequence (new SequenceParms ());
TweenParms parms;
Color oldColor = _Logo.GetComponent<Renderer>().material.color;
_Logo.GetComponent<Renderer>().material.color = new Color (oldColor.r, oldColor.b, oldColor.g, 0f);
parms = new TweenParms ().Prop ("color", new Color (oldColor.r, oldColor.b, oldColor.g, 1f)).Ease (EaseType.EaseInQuart);
mySequence.Append (HOTween.To (_Logo.GetComponent<Renderer>().material, _FadeInTime, parms));
mySequence.Append (HOTween.To (_Logo.GetComponent<Renderer>().material, _WaitingTime, parms));
parms = new TweenParms ().Prop ("color", new Color (oldColor.r, oldColor.b, oldColor.g, 0f));
mySequence.Append (HOTween.To (_Logo.GetComponent<Renderer>().material, _FadeOutTime, parms));
mySequence.Play ();
yield return new WaitForSeconds (_FadeInTime + _WaitingTime + _FadeOutTime);
Application.LoadLevel (_nextScene);
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 7fca4a4c0dd25c440bc06d5c089a75b3
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,122 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Facebook.MiniJSON;
using Holoville.HOTween;
/// <summary>
/// This class contains all static method used in different part of the project or that may be usefull for you
/// Author : Pondomaniac Games
/// </summary>
public class Util : ScriptableObject
{
//Getting the picture using the facebook GRAPH api
public static string GetPictureURL(string facebookID, int? width = null, int? height = null, string type = null)
{
string url = string.Format("/{0}/picture", facebookID);
string query = width != null ? "&width=" + width.ToString() : "";
query += height != null ? "&height=" + height.ToString() : "";
query += type != null ? "&type=" + type : "";
if (query != "") url += ("?g" + query);
return url;
}
//Getting the picture texture
public static void FriendPictureCallback(FBResult result)
{
if (result.Error != null)
{
Debug.LogError(result.Error);
return;
}
GameStateManager.FriendTexture = result.Texture;
}
//Getting a random friend list
public static Dictionary<string, string> RandomFriend(List<object> friends)
{
var fd = ((Dictionary<string, object>)(friends[Random.Range(0, friends.Count - 1)]));
var friend = new Dictionary<string, string>();
friend["id"] = (string)fd["id"];
friend["first_name"] = (string)fd["first_name"];
return friend;
}
//Getting the profile infos
public static Dictionary<string, string> DeserializeJSONProfile(string response)
{
var responseObject = Json.Deserialize(response) as Dictionary<string, object>;
object nameH;
var profile = new Dictionary<string, string>();
if (responseObject.TryGetValue("first_name", out nameH))
{
profile["first_name"] = (string)nameH;
}
return profile;
}
//Getting the score
public static List<object> DeserializeScores(string response)
{
var responseObject = Json.Deserialize(response) as Dictionary<string, object>;
object scoresh;
var scores = new List<object>();
if (responseObject.TryGetValue ("data", out scoresh))
{
scores = (List<object>) scoresh;
}
return scores;
}
//Getting the friends
public static List<object> DeserializeJSONFriends(string response)
{
var responseObject = Json.Deserialize(response) as Dictionary<string, object>;
object friendsH;
var friends = new List<object>();
if (responseObject.TryGetValue("friends", out friendsH))
{
friends = (List<object>)(((Dictionary<string, object>)friendsH)["data"]);
}
return friends;
}
//Draw the texture picture
public static void DrawActualSizeTexture (Vector2 pos, Texture texture, float scale = 1.0f)
{
Rect rect = new Rect (pos.x, pos.y, texture.width * scale , texture.height * scale);
GUI.DrawTexture(rect, texture);
}
//Draw a text
public static void DrawSimpleText (Vector2 pos, GUIStyle style, string text)
{
Rect rect = new Rect (pos.x, pos.y, Screen.width, Screen.height);
GUI.Label (rect, text, style);
}
//The animation when you press a button
public static void ButtonPressAnimation(GameObject go) {
Sequence mySequence = new Sequence (new SequenceParms ());
TweenParms parms;
parms = new TweenParms ().Prop ("localScale", new Vector3 (0.7f, 0.7f, go.transform.position.z)).Ease (EaseType.EaseInQuad);
mySequence.Append (HOTween.To (go.transform, 0.12f, parms));
parms = new TweenParms ().Prop ("localScale", new Vector3 (1f, 1f, go.transform.position.z)).Ease (EaseType.EaseInQuad);
mySequence.Append (HOTween.To (go.transform, 0.12f, parms));
mySequence.Play ();
mySequence = new Sequence (new SequenceParms ());
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: fd12d227fe0669942894b47f7363e64e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: