├── destroy.cs ├── Loader.cs ├── UnityAdsExample.cs ├── Starter.cs ├── AutoDestruction.cs ├── HT_SetParticleSortingLayer.cs ├── restart.cs ├── music.cs ├── Anime.cs ├── ManageMusic.cs ├── Explode.cs ├── README.md ├── LICENSE ├── Movement.cs ├── googlePlayScript.cs ├── Controller.cs ├── Score.cs └── UIManager.cs /destroy.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class destroy : MonoBehaviour { 5 | 6 | void OnTriggerEnter2D (Collider2D other) { 7 | Destroy(other.gameObject); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Loader.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.SceneManagement; 3 | using System.Collections; 4 | 5 | public class Loader : MonoBehaviour { 6 | 7 | public void loader() 8 | { 9 | SceneManager.LoadScene("Main"); 10 | } 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /UnityAdsExample.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | 4 | public class UnityAdsExample : MonoBehaviour 5 | { 6 | /* public void ShowAd() 7 | { 8 | if (Advertisement.IsReady()) 9 | { 10 | Advertisement.Show(); 11 | Advertisement.Initialize("1247041", true); 12 | } 13 | }*/ 14 | } 15 | -------------------------------------------------------------------------------- /Starter.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using UnityEngine.SceneManagement; 4 | using System.Collections; 5 | 6 | public class Starter : MonoBehaviour { 7 | public GameObject Dark; 8 | Image d; 9 | void Start () { 10 | d = Dark.GetComponent(); 11 | d.color = new Color(d.color.r, d.color.g, d.color.b,255); 12 | d.CrossFadeColor(new Color(d.color.r, d.color.g, d.color.b, 0), 5f, true, true); 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /AutoDestruction.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class AutoDestruction : MonoBehaviour { 5 | public float lifeTime; 6 | public GameObject bombSFX; 7 | public AudioClip boom; 8 | 9 | // Use this for initialization 10 | void Start () { 11 | 12 | bombSFX = GameObject.Find("SFX Bomb"); 13 | bombSFX.GetComponent().clip = boom; 14 | bombSFX.GetComponent().Play(); 15 | Destroy(gameObject, lifeTime); 16 | } 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /HT_SetParticleSortingLayer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class HT_SetParticleSortingLayer : MonoBehaviour 5 | { 6 | public string sortingLayerName; // The name of the sorting layer the particles should be set to. 7 | public int sortingOrder; 8 | 9 | 10 | void Start () 11 | { 12 | // Set the sorting layer of the particle system. 13 | GetComponent().GetComponent().sortingLayerName = sortingLayerName; 14 | GetComponent().GetComponent().sortingOrder = sortingOrder; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /restart.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.SceneManagement; 3 | 4 | using System.Collections; 5 | 6 | public class restart : MonoBehaviour { 7 | 8 | // Update is called once per frame 9 | public void RestartGame () { 10 | 11 | // StartCoroutine(ShowAd()); 12 | 13 | 14 | 15 | 16 | } 17 | 18 | /* IEnumerator ShowAd() 19 | { 20 | while (!Advertisement.IsReady()) 21 | { 22 | yield return null; 23 | } 24 | Advertisement.Show(); 25 | Debug.Log("kinda working"); 26 | //SceneManager.LoadScene("Main"); 27 | }*/ 28 | } 29 | -------------------------------------------------------------------------------- /music.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Assets.Scripts 4 | { 5 | public class music : MonoBehaviour 6 | { 7 | public static music Instance; 8 | 9 | // Use this for initialization 10 | void Start() 11 | { 12 | 13 | } 14 | 15 | // Update is called once per frame 16 | void Update() 17 | { 18 | 19 | } 20 | 21 | void Awake() 22 | { 23 | 24 | if (Instance) 25 | DestroyImmediate(gameObject); 26 | else 27 | { 28 | DontDestroyOnLoad(gameObject); 29 | Instance = this; 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Anime.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using System.Collections; 4 | using UnityEngine.SceneManagement; 5 | 6 | public class Anime : MonoBehaviour { 7 | 8 | public void facebook() 9 | { 10 | Application.OpenURL("https://www.facebook.com/JetLightstudio/"); 11 | } 12 | public void site() 13 | { 14 | Application.OpenURL("https://www.jetlight-studio.tk/"); 15 | } 16 | public void googlePlus() 17 | { 18 | Application.OpenURL("https://plus.google.com/106078600308560786022"); 19 | } 20 | 21 | void Update() 22 | { 23 | if (Input.GetKeyDown(KeyCode.Escape)) 24 | { 25 | SceneManager.LoadScene("Main"); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ManageMusic.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | public class ManageMusic : MonoBehaviour 4 | { 5 | public static ManageMusic Instance; 6 | 7 | 8 | // Use this for initialization 9 | void Start() 10 | { 11 | if(PlayerPrefs.GetInt("sound") == 0) 12 | { 13 | GetComponent().Play(); 14 | } 15 | } 16 | 17 | // Update is called once per frame 18 | void Update() 19 | { 20 | 21 | } 22 | 23 | void Awake() 24 | { 25 | 26 | if (Instance) 27 | DestroyImmediate(gameObject); 28 | else 29 | { 30 | DontDestroyOnLoad(gameObject); 31 | Instance = this; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Explode.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Explode : MonoBehaviour { 5 | public GameObject explosion; 6 | public ParticleSystem[] effects; 7 | 8 | void OnCollisionEnter2D(Collision2D other) 9 | { 10 | if (other.gameObject.tag == "hoop") 11 | { 12 | exploding(); 13 | } 14 | } 15 | 16 | void exploding() 17 | { 18 | Instantiate(explosion, transform.position, transform.rotation); 19 | 20 | foreach (var effect in effects) 21 | { 22 | effect.transform.SetParent(null); 23 | effect.Stop(); 24 | Destroy(effect.gameObject, 1.0f); 25 | } 26 | Destroy(gameObject); 27 | 28 | } 29 | 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ball-Fall-Android-game 2 | ![Downloads](https://img.shields.io/badge/Aptoide%20store-3k--5k-orange.svg) 3 | ![Jetlight studio](https://img.shields.io/badge/Made%20by-Jetlight%20studio-blue.svg?color=082544) 4 | 5 | Ball Fall is an addictive catch game. Keep your eyes open and your fingers ready. 6 | 7 | ## Aptoide store link: 8 | [Download here](https://jetlight-studio-ball-fall.en.aptoide.com/) 9 | 10 | ## screenshots: 11 | 12 | 13 | ## Tools used: 14 | * Visual studio (IDE) 15 | * C# (logic) 16 | * Unity (game engine) 17 | * Paint.Net (Image editting) 18 | 19 | ## Contributing 20 | 21 | Feel free to `fork` this project and add whatever you like. If you have any suggestions or any comments please feel free to contact me or to open an issue. 22 | 23 | ## Team: 24 | [Jetlighters](https://github.com/JetLightStudio) having fun. 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Oussama Bonnor 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Movement.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using System.Collections; 4 | 5 | public class Movement : MonoBehaviour { 6 | public Camera cam; 7 | //public Slider slider; 8 | float maxWidth; 9 | private bool reverse; 10 | public bool can; 11 | Vector3 bounds; 12 | 13 | // Use this for initialization 14 | void Start () { 15 | bounds = new Vector3(Screen.width, 0.0f, 0.0f); 16 | // SliderPos = cam.ScreenToWorldPoint(bounds); 17 | 18 | can = false; 19 | reverse = false; 20 | if(cam == null) 21 | { 22 | cam = Camera.main; 23 | } 24 | Vector3 edge = new Vector3(Screen.width,Screen.height,0.0f); 25 | Vector3 target = cam.ScreenToWorldPoint(edge); 26 | float hoopWidth = (GetComponent().bounds.extents.x) / 2f; 27 | maxWidth = target.x - hoopWidth; 28 | } 29 | 30 | void FixedUpdate() 31 | { 32 | if (can) 33 | { 34 | Vector3 newPosition; 35 | Vector3 rawPosition = cam.ScreenToWorldPoint(Input.mousePosition); 36 | // Vector3 rawPosition = new Vector3(slider.value * SliderPos.x, transform.position.y); 37 | if (reverse) 38 | { 39 | newPosition = new Vector3(-rawPosition.x, transform.position.y, 0.0f); 40 | } 41 | else 42 | { 43 | newPosition = new Vector3(rawPosition.x, transform.position.y, 0.0f); 44 | } 45 | 46 | float target = Mathf.Clamp(newPosition.x, -maxWidth, maxWidth); 47 | 48 | transform.position = Vector3.Lerp(transform.position,new Vector3(target, transform.position.y, 0.0f),Time.fixedDeltaTime * 7.5f); 49 | 50 | } 51 | } 52 | 53 | public void toogle(bool other) 54 | { 55 | can = other; 56 | } 57 | 58 | public void Reversing(bool other) 59 | { 60 | reverse = other; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /googlePlayScript.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using GooglePlayGames; 5 | using GooglePlayGames.BasicApi; 6 | using UnityEngine; 7 | using UnityEngine.UI; 8 | 9 | public class googlePlayScript : MonoBehaviour 10 | { 11 | 12 | public GameObject text; 13 | 14 | // Use this for initialization 15 | void Start () { 16 | PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build(); 17 | PlayGamesPlatform.DebugLogEnabled = true; 18 | PlayGamesPlatform.InitializeInstance(config); 19 | PlayGamesPlatform.Activate(); 20 | GooglePlayGames.OurUtils.Logger.DebugLogEnabled = true; 21 | signIn(); 22 | } 23 | 24 | // Update is called once per frame 25 | void Update () { 26 | 27 | } 28 | 29 | public void SignInCallback(bool success) 30 | { 31 | if (success) 32 | { 33 | // Change sign-in button text 34 | text.GetComponent().text = ""; 35 | } 36 | else 37 | { 38 | text.SetActive(false); 39 | } 40 | } 41 | 42 | void signIn() 43 | { 44 | if (!Social.localUser.authenticated) 45 | { 46 | 47 | text.GetComponent().text = ""; 48 | // Sign in with Play Game Services, showing the consent dialog 49 | // by setting the second parameter to isSilent=false. 50 | Social.localUser.Authenticate(SignInCallback); 51 | } 52 | else 53 | { 54 | text.GetComponent().text = ""; 55 | } 56 | 57 | } 58 | 59 | public void unlockAchievement(string id) 60 | { 61 | Social.ReportProgress(id,100,succes =>{}); 62 | } 63 | 64 | public void showAchievementUI() 65 | { 66 | Social.ShowAchievementsUI(); 67 | } 68 | 69 | public void addScoreLeaderbord(string id, int score) 70 | { 71 | Social.ReportScore(score,id, succes =>{}); 72 | } 73 | 74 | public void showLeaderbordUI() 75 | { 76 | Social.ShowLeaderboardUI(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Controller.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using System.Collections; 4 | 5 | public class Controller : MonoBehaviour { 6 | 7 | public GameObject[] balls; 8 | public GameObject[] rareItems; 9 | public GameObject background; 10 | public Sprite[] BackgroundsSprites; 11 | public GameObject badView; 12 | 13 | public Movement m; 14 | public Text timer; 15 | public Camera cam1; 16 | 17 | float maxWidth; 18 | public float timeLeft; 19 | public bool startedPlaying; 20 | 21 | 22 | // Use this for initialization 23 | void Start() 24 | { 25 | startedPlaying = false; 26 | background.GetComponent().sprite = BackgroundsSprites[PlayerPrefs.GetInt("bg")]; 27 | if (PlayerPrefs.GetInt("bg") == 0) PlayerPrefs.SetInt("bg", 1); 28 | else PlayerPrefs.SetInt("bg", 0); 29 | ResizeBackground(background); 30 | 31 | Vector3 upperCorner = new Vector3(Screen.width, Screen.height, 0.0f); 32 | Vector3 targetWidth = cam1.ScreenToWorldPoint(upperCorner); 33 | float ballWidth = (balls[0].GetComponent().bounds.extents.x) / 2f; 34 | maxWidth = targetWidth.x - ballWidth; 35 | 36 | timeLeft = 60; 37 | 38 | } 39 | void ResizeBackground(GameObject background) 40 | { 41 | SpriteRenderer sr = background.GetComponent(); 42 | 43 | if (sr == null) return; 44 | 45 | transform.localScale = new Vector3(1, 1, 1); 46 | 47 | float width = sr.sprite.bounds.size.x; 48 | float height = sr.sprite.bounds.size.y; 49 | 50 | float worldScreenHeight = Camera.main.orthographicSize * 2.1f; 51 | float worldScreenWidth = worldScreenHeight / Screen.height * Screen.width; 52 | 53 | Vector3 xWidth = background.transform.localScale; 54 | xWidth.x = worldScreenWidth / width; 55 | background.transform.localScale = xWidth; 56 | 57 | Vector3 yHeight = background.transform.localScale; 58 | yHeight.y = worldScreenHeight / height; 59 | background.transform.localScale = yHeight; 60 | 61 | } 62 | 63 | void FixedUpdate() 64 | { 65 | if (startedPlaying) 66 | { 67 | timeLeft -= Time.deltaTime; 68 | if (timeLeft <= 0) 69 | { 70 | timer.text = ": 0"; 71 | } 72 | else timer.text = ": " + Mathf.RoundToInt(timeLeft); 73 | } 74 | 75 | } 76 | 77 | public IEnumerator Spawn() 78 | { 79 | while (timeLeft > 0) 80 | { 81 | Vector3 spawnPosition = new Vector3(Random.Range(-maxWidth, maxWidth), transform.position.y, 0.0f); 82 | Quaternion spawnRotation = Quaternion.identity; 83 | int luck = Random.Range(0, 5); 84 | GameObject ball; 85 | if (luck != 0) ball = balls[Random.Range(0, balls.Length)]; 86 | else ball = rareItems[Random.Range(0, rareItems.Length)]; 87 | Instantiate(ball, spawnPosition, spawnRotation); 88 | yield return new WaitForSeconds(Random.Range(0.5f, 0.8f)); 89 | } 90 | 91 | } 92 | 93 | 94 | } 95 | -------------------------------------------------------------------------------- /Score.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using System.Collections; 4 | 5 | public class Score : MonoBehaviour { 6 | public static int score; 7 | public int points; 8 | public GameObject noise; 9 | public GameObject bombNoise; 10 | public GameObject Scorer; 11 | public AudioClip[] goodBadVibe; 12 | int bestScore; 13 | public Controller controllerScript; 14 | public Movement m; 15 | public googlePlayScript uiManager; 16 | private bool reverse; 17 | 18 | private int taps; 19 | 20 | // Use this for initialization 21 | void Start () 22 | { 23 | taps = 0; 24 | reverse = false; 25 | score = 0; 26 | bestScore = PlayerPrefs.GetInt("Score"); 27 | UpdateScore(); 28 | } 29 | 30 | void OnTriggerEnter2D(Collider2D other) 31 | { 32 | if (other.gameObject.tag == "ball") 33 | { 34 | score += points; 35 | 36 | MakeNoise(); 37 | } 38 | else if(other.gameObject.tag == "bomb") 39 | { 40 | score -= points+1; 41 | } 42 | else if (other.gameObject.tag == "blue ball") 43 | { 44 | if (controllerScript.timeLeft > 55) controllerScript.timeLeft = 60; 45 | else controllerScript.timeLeft += 5; 46 | MakeNoise(); 47 | } 48 | else if (other.gameObject.tag == "black ball") 49 | { 50 | MakeNoise(); 51 | controllerScript.badView.SetActive(true); 52 | StartCoroutine(badView()); 53 | } 54 | else if (other.gameObject.tag == "reverse") 55 | { 56 | 57 | reverse = !reverse; 58 | m.Reversing(reverse); 59 | if (reverse) 60 | { 61 | points *= 2; 62 | bombNoise.GetComponent().clip = goodBadVibe[0]; 63 | } 64 | else 65 | { 66 | bombNoise.GetComponent().clip = goodBadVibe[1]; 67 | points = 2; 68 | } 69 | bombNoise.GetComponent().Play(); 70 | } 71 | else if (other.gameObject.tag == "purpul ball") 72 | { 73 | 74 | controllerScript.timeLeft -= 5; 75 | bombNoise.GetComponent().clip = goodBadVibe[0]; 76 | bombNoise.GetComponent().Play(); 77 | } 78 | else if (other.gameObject.tag == "green ball") 79 | { 80 | score += (points * 2) +1 ; 81 | MakeNoise(); 82 | 83 | } 84 | UpdateScore(); 85 | 86 | } 87 | 88 | void Update() 89 | { 90 | if (controllerScript.badView.activeSelf) 91 | { 92 | if (Input.GetMouseButtonDown(0)) 93 | { 94 | taps++; 95 | } 96 | } 97 | } 98 | 99 | void OnCollisionEnter2D (Collision2D other) 100 | { 101 | if (other.gameObject.tag == "bomb") 102 | { 103 | score -= 2; 104 | UpdateScore(); 105 | if (PlayerPrefs.GetInt("sound") == 0) 106 | { 107 | bombNoise.GetComponent().clip = goodBadVibe[2]; 108 | bombNoise.GetComponent().Play(); 109 | } 110 | } 111 | else 112 | { 113 | if (PlayerPrefs.GetInt("sound") == 0 && !GetComponent().isPlaying) 114 | { 115 | GetComponent().Play(); 116 | } 117 | } 118 | } 119 | 120 | void UpdateScore() 121 | { 122 | if (score < 0) score = 0; 123 | Scorer.GetComponent().text = "x " + score; 124 | } 125 | 126 | void FixedUpdate() 127 | { 128 | if (controllerScript.timeLeft <= 0) 129 | { 130 | if (score > bestScore) 131 | { 132 | PlayerPrefs.SetInt("Score", score); 133 | bestScore = score; 134 | if (score > 100 && PlayerPrefs.GetInt("firstAchievement") == 0) 135 | { 136 | uiManager.unlockAchievement(GPGSIds.achievement_score_100_for_the_first_time); 137 | PlayerPrefs.SetInt("firstAchievement", 1); 138 | } 139 | if (score > 200 && PlayerPrefs.GetInt("secondAchievement") == 0) 140 | { 141 | uiManager.unlockAchievement(GPGSIds.achievement_ball_fall_amateur); 142 | PlayerPrefs.SetInt("secondAchievement", 1); 143 | } 144 | if (score > 300 && PlayerPrefs.GetInt("thirdAchievement") == 0) 145 | { 146 | uiManager.unlockAchievement(GPGSIds.achievement_ball_fall_player_anyone); 147 | PlayerPrefs.SetInt("thirdAchievement", 1); 148 | } 149 | if (score > 400 && PlayerPrefs.GetInt("fourthAchievement") == 0) 150 | { 151 | uiManager.unlockAchievement(GPGSIds.achievement_wow_very_ball_much_fall); 152 | PlayerPrefs.SetInt("fourthAchievement", 1); 153 | } 154 | if (score > 500 && PlayerPrefs.GetInt("fifthAchievement") == 0) 155 | { 156 | uiManager.unlockAchievement(GPGSIds.achievement_balls_fall_at_your_feet_master); 157 | PlayerPrefs.SetInt("fifthAchievement", 1); 158 | } 159 | if (score > 750 && PlayerPrefs.GetInt("sixthAchievement") == 0) 160 | { 161 | uiManager.unlockAchievement(GPGSIds.achievement_we_did_not_think_it_was_possible); 162 | PlayerPrefs.SetInt("sixthAchievement", 1); 163 | } 164 | uiManager.addScoreLeaderbord(GPGSIds.leaderboard_best_scores,bestScore); 165 | } 166 | } 167 | } 168 | 169 | IEnumerator badView() 170 | { 171 | m.can = false; 172 | do 173 | { 174 | yield return new WaitForSeconds(0.01f); 175 | controllerScript.badView.transform.GetChild(0).GetComponent().text = "Taps Lefts: " + (9 - taps); 176 | } while (taps < 9); 177 | controllerScript.badView.SetActive(false); 178 | taps = 0; 179 | m.can = true; 180 | } 181 | 182 | void MakeNoise() 183 | { 184 | if (PlayerPrefs.GetInt("sound") == 0) 185 | { 186 | noise.GetComponent().Play(); 187 | } 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /UIManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Advertisements; 5 | using UnityEngine.SceneManagement; 6 | using UnityEngine.UI; 7 | 8 | public class UIManager : MonoBehaviour 9 | { 10 | [Header("UI components")] 11 | public GameObject highScoreText; 12 | public GameObject pauseMenu; 13 | public GameObject startDark; 14 | public GameObject startMenu; 15 | public GameObject parameterMenu; 16 | public GameObject creditMenu; 17 | public GameObject finishedMenu; 18 | public GameObject paramButton; 19 | public GameObject creditButton; 20 | public GameObject tutorielMenu; 21 | 22 | GameObject musicPlayer; 23 | 24 | [Header("Essentiel components")] 25 | public Sprite[] IconSprites; 26 | 27 | [Header("Scripts")] 28 | public Movement movementScript; 29 | public Controller controllerScript; 30 | public googlePlayScript uiManager; 31 | 32 | bool addition; 33 | private bool play; 34 | bool doubleTap; 35 | private float sessionTime; 36 | 37 | 38 | // Use this for initialization 39 | void Start() 40 | { 41 | sessionTime = 0; 42 | if (PlayerPrefs.GetInt("firstTime") == 0) 43 | { 44 | tutoriel(); 45 | PlayerPrefs.SetInt("firstTime",1); 46 | } 47 | 48 | doubleTap = false; 49 | addition = false; 50 | 51 | musicPlayer = GameObject.Find("Music Manager"); 52 | 53 | if (PlayerPrefs.GetInt("sound") == 0) 54 | { 55 | //sound on 56 | parameterMenu.transform.GetChild(2).GetComponent().sprite = IconSprites[0]; 57 | if(!musicPlayer.GetComponent().isPlaying) musicPlayer.GetComponent().Play(); 58 | } 59 | else 60 | { 61 | //sound off 62 | parameterMenu.transform.GetChild(2).GetComponent().sprite = IconSprites[1]; 63 | //ONOFF.GetComponent().text = "OFF"; 64 | if (musicPlayer.GetComponent().isPlaying) musicPlayer.GetComponent().Pause(); 65 | } 66 | highScoreText.GetComponent().text = " Best Score\n : " + PlayerPrefs.GetInt("Score"); 67 | play = false; 68 | 69 | } 70 | 71 | // Update is called once per frame 72 | void Update() 73 | { 74 | if (!play) 75 | { 76 | startMenu.transform.GetChild(0).GetComponent().transform.Rotate(0, 0, 50 * Time.deltaTime); 77 | } 78 | if (Input.GetKeyDown(KeyCode.Escape) && play) 79 | { 80 | PauseGame(); 81 | } 82 | 83 | if (play && controllerScript.timeLeft > 0) sessionTime += Time.deltaTime; 84 | if((int) controllerScript.timeLeft == 1) StopAllCoroutines(); 85 | if (controllerScript.timeLeft <= 0) 86 | { 87 | if (PlayerPrefs.GetFloat("sessionTime") < sessionTime) 88 | { 89 | uiManager.addScoreLeaderbord(GPGSIds.leaderboard_longest_game_session,(int) (sessionTime * 100)); 90 | } 91 | finishedMenu.SetActive(true); 92 | finishedMenu.transform.GetChild(4).GetComponent().text = "x "+ PlayerPrefs.GetInt("Score"); 93 | finishedMenu.transform.GetChild(5).GetComponent().text = "x " + Score.score; 94 | } 95 | } 96 | 97 | public void StartGame() 98 | { 99 | play = true; 100 | movementScript.can = true; 101 | controllerScript.startedPlaying = true; 102 | startDark.SetActive(false); 103 | StartCoroutine(controllerScript.Spawn()); 104 | } 105 | 106 | public void PauseGame() 107 | { 108 | if (PlayerPrefs.GetInt("sound") == 0) 109 | { 110 | GetComponent().Play(); 111 | } 112 | addition = true; 113 | play = !play; 114 | movementScript.toogle(play); 115 | pauseMenu.SetActive(!play); 116 | 117 | if (play == false) 118 | { 119 | Time.timeScale = 0; 120 | StopAllCoroutines(); 121 | } 122 | else 123 | { 124 | Time.timeScale = 1; 125 | StartCoroutine(controllerScript.Spawn()); 126 | } 127 | } 128 | 129 | //if we press Quit button 130 | public void QuitClicked() 131 | { 132 | pauseMenu.SetActive(false); 133 | parameterMenu.SetActive(false); 134 | startMenu.SetActive(false); 135 | } 136 | 137 | //if we press No (quit) button 138 | public void No() 139 | { 140 | startMenu.SetActive(true); 141 | } 142 | 143 | // if yes (quit) button 144 | public void QuitGame() 145 | { 146 | if (PlayerPrefs.GetInt("score") < Score.score) PlayerPrefs.SetInt("score", Score.score); 147 | Application.Quit(); 148 | } 149 | 150 | //about us button clicked 151 | public void AboutUs() 152 | { 153 | StartCoroutine(creditAnim(creditMenu.activeSelf)); 154 | } 155 | 156 | IEnumerator creditAnim(bool state) 157 | { 158 | creditButton.GetComponent