Esempio n. 1
0
    public void ReloadLevel()
    {
        MusicSound.instance.ClickButtonSound();
        if (Time.timeScale == 0)
        {
            Time.timeScale = 1;
        }
        if (GameObject.FindGameObjectWithTag("StarsEffect") != null)
        {
            GameObject.FindGameObjectWithTag("StarsEffect").GetComponent <ParticleSystem>().Pause();
        }
        //Camera.main.GetComponent<IntroductionLevel>().enabled = false;
//		GameObject.FindObjectOfType<KeepDataOnPlayMode> ().reloadedLevel = true;
        KeepDataOnPlayMode.instance.reloadedLevel  = true;
        KeepDataOnPlayMode.instance.reloadedTimes += 1;
        if (KeepDataOnPlayMode.instance.reloadedTimes > 5)
        {
            KeepDataOnPlayMode.instance.reloadedTimes = 0;
        }
        //	Debug.Log ("randomAds: " + KeepDataOnPlayMode.instance.randomAds);
        //	Debug.Log ("reloadedTimes: " + KeepDataOnPlayMode.instance.reloadedTimes);
        if (KeepDataOnPlayMode.instance.randomAds == KeepDataOnPlayMode.instance.reloadedTimes)
        {
            KeepDataOnPlayMode.instance.reloadedTimes = 0;
            KeepDataOnPlayMode.instance.randomAds     = KeepDataOnPlayMode.instance.generateIntAds();
            TotalData.LoadTotalFromFile();
            if (!TotalData.totalData.noads)
            {
                ShowAd();
            }
        }
//		Debug.Log("reloaded level: " + GameObject.FindObjectOfType<KeepDataOnPlayMode> ().reloadedLevel);
        Application.LoadLevel(Application.loadedLevel);
    }
Esempio n. 2
0
    private void HandleShowResult50Coins(ShowResult result)
    {
        Debug.Log("show result");
        switch (result)
        {
        case ShowResult.Finished:
            TotalData.LoadTotalFromFile();
            //		Debug.Log ("The ad was successfully shown.");
            int curValue = TotalData.totalData.totalCoins;
            //		Debug.Log ("total 0: " + curValue);
            TotalData.totalData.totalCoins += 50;
            //		Debug.Log ("total 1: " + TotalData.totalData.totalCoins);
            //	TotalData.totalData.totalCoins += currentLevelData.levelScore;
            //		KeepDataOnPlayMode.instance.reloadedTimes = 0;
            //GameObject.Find ("x2Coins").SetActive (false);
            TotalData.SaveTotalToFile();
            //	GameObject.FindObjectOfType<PowerUps> ().updateCoins (curValue, TotalData.totalData.totalCoins);
            GameObject.FindObjectOfType <BuyCoins> ().updateCoinsAfterAppearing();

            //	GameObject.FindObjectOfType<WinDialog> ().fireCountTo (curValue, TotalData.totalData.totalCoins);

            break;

        case ShowResult.Skipped:
            Debug.Log("The ad was skipped before reaching the end.");
            break;

        case ShowResult.Failed:
            Debug.LogError("The ad failed to be shown.");
            break;
        }
    }
Esempio n. 3
0
 public void checkEligibilityForPurchase()
 {
     MusicSound.instance.ClickButtonSound();
     TotalData.LoadTotalFromFile();
     if (!transform.GetComponent <Player> ().isLocked)
     {
         changeActivePlayerUnLocked();
     }
     else
     {
         if (TotalData.total.totalScore < transform.GetComponent <Player> ().price)
         {
             ShopScore.instance.notEnoughMoney();
         }
         else
         {
             if (!transform.GetComponent <Player> ().isLocked)
             {
                 return;
             }
             mediumScore = TotalData.total.totalScore;
             TotalData.total.totalScore -= transform.GetComponent <Player> ().price;
             transform.GetComponent <Player> ().isLocked = false;
             changeActivePlayer();
         }
     }
 }
Esempio n. 4
0
    IEnumerator ReloadGame()
    {
        //	AsyncOperation async = Application.LoadLevelAsync (Application.loadedLevel);
        //	while (!async.isDone) {
        //		yield return 0;
        //
        //	}


        //		Debug.Log ("destroyer34");
        // ... pause briefly
        yield return(new WaitForSeconds(2));

        //		Debug.Log ("destroyer4");
        // ... and then reload the level.
        KeepDataOnPlayMode.instance.reloadedTimes += 1;
        if (KeepDataOnPlayMode.instance.reloadedTimes > 5)
        {
            KeepDataOnPlayMode.instance.reloadedTimes = 0;
        }
        if (KeepDataOnPlayMode.instance.randomAds == KeepDataOnPlayMode.instance.reloadedTimes)
        {
            KeepDataOnPlayMode.instance.reloadedTimes = 0;
            KeepDataOnPlayMode.instance.randomAds     = KeepDataOnPlayMode.instance.generateIntAds();
            TotalData.LoadTotalFromFile();
            if (!TotalData.totalData.noads)
            {
                ShowAd();
            }
        }
        Application.LoadLevel(Application.loadedLevel);
    }
Esempio n. 5
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }
                #if UNITY_IOS
        System.Environment.SetEnvironmentVariable("MONO_REFLECTION_SERIALIZER", "yes");
                #endif
        TotalData.LoadTotalFromFile();
        if (TotalData.total.firstGame)
        {
            transform.GetComponent <SpriteRenderer> ().color = newColorRange [0];
            transform.GetChild(1).GetComponent <TrailRenderer> ().enabled = true;
            enabledTrail = 1;
        }
        else
        {
            randomColor = Random.Range(0, newColorRange.Length);
            transform.GetComponent <SpriteRenderer> ().color = newColorRange [randomColor];
        }

        if (randomColor == newColorRange.Length - 1)
        {
            line.transform.GetChild(0).GetComponent <SpriteRenderer> ().color = newColorRange [0];
        }
        else
        {
            line.transform.GetChild(0).GetComponent <SpriteRenderer> ().color = newColorRange [randomColor + 1];
        }
    }
Esempio n. 6
0
    private void HandleShowResult(ShowResult result)
    {
        switch (result)
        {
        case ShowResult.Finished:
            // Reward for watching ads
            Debug.Log("The ad was successfully shown.");
            TotalData.LoadTotalFromFile();
            mediumScore = TotalData.total.totalScore;
            TotalData.total.totalScore += 20;
            totalScore.GetComponent <CountTo> ().fireCountTo(mediumScore, TotalData.total.totalScore, 1.0f);
            TotalData.SaveTotalToFile();
            ReplayObjects.instance.afterAds();

            break;

        case ShowResult.Skipped:
            Debug.Log("The ad was skipped before reaching the end.");
            break;

        case ShowResult.Failed:
            Debug.LogError("The ad failed to be shown.");
            break;
        }
    }
Esempio n. 7
0
    void Start()
    {
        playerColor  = gameObject.GetComponent <SpriteRenderer> ().color;
        screenHeight = 2.0f * Camera.main.orthographicSize;
        screenWidth  = screenHeight * Camera.main.aspect;

        TotalData.LoadTotalFromFile();
    }
Esempio n. 8
0
 // Use this for initialization
 void Awake()
 {
             #if UNITY_IOS
     System.Environment.SetEnvironmentVariable("MONO_REFLECTION_SERIALIZER", "yes");
             #endif
     TotalData.LoadTotalFromFile();
     KeepDataOnPlayMode.instance.noAds     = TotalData.total.noAds;
     KeepDataOnPlayMode.instance.isMusicOn = TotalData.total.isMusicOn;
     KeepDataOnPlayMode.instance.isSoundOn = TotalData.total.isSoundOn;
 }
Esempio n. 9
0
 public void TestBuying()
 {
     TotalData.LoadTotalFromFile();
     TotalData.total.noAds = true;
     TotalData.SaveTotalToFile();
     if (ShowBannerAd.instance.bannerView != null)
     {
         ShowBannerAd.instance.bannerView.Hide();
     }
 }
Esempio n. 10
0
    void Start()
    {
        randomBarrier = Random.Range(lowCount, upCount);
        playerColor   = gameObject.GetComponent <SpriteRenderer> ().color;
        screenHeight  = 2.0f * Camera.main.orthographicSize;
        screenWidth   = screenHeight * Camera.main.aspect;

        containerObject = new GameObject("Lines");
        containerObject.transform.parent = gameObjectsHolder.transform;
        TotalData.LoadTotalFromFile();
    }
Esempio n. 11
0
    public void saveScore()
    {
        TotalData.LoadTotalFromFile();
        TotalData.total.lastScore = score;

        if (score > TotalData.total.bestScore)
        {
            TotalData.total.bestScore = score;
        }
        TotalData.total.totalScore += score;
        TotalData.SaveTotalToFile();
    }
Esempio n. 12
0
 public void pressedMusicBttn()
 {
     MusicSound.instance.ClickButtonSound();
     TotalData.LoadTotalFromFile();
     if (TotalData.total.isMusicOn)
     {
         OffMusic();
     }
     else
     {
         OnMusic();
     }
 }
Esempio n. 13
0
    public void startSettings()
    {
        TotalData.LoadTotalFromFile();

        if (!TotalData.total.isSoundOn)
        {
            soundBttn.GetComponent <Button> ().image.overrideSprite = soundsOff;
        }

        if (!TotalData.total.isMusicOn)
        {
            musicBttn.GetComponent <Button> ().image.overrideSprite = musicOff;
        }
    }
Esempio n. 14
0
 public void pressedSoundBttn()
 {
     MusicSound.instance.ClickButtonSound();
     TotalData.LoadTotalFromFile();
     if (TotalData.total.isSoundOn)
     {
         OffSound();
     }
     else
     {
         OnSound();
     }
     TotalData.SaveTotalToFile();
 }
Esempio n. 15
0
    public void preloadNativeAd()
    {
        TotalData.LoadTotalFromFile();
        if (TotalData.total.noAds)
        {
//			nativeExpressAdView.Hide ();
        }
        else
        {
            nativeExpressAdView = new NativeExpressAdView(adUnitId, AdSize.MediumRectangle, AdPosition.BottomRight);
            AdRequest request = new AdRequest.Builder().Build();
            nativeExpressAdView.LoadAd(request);
            nativeExpressAdView.Hide();
        }
    }
Esempio n. 16
0
    void Start()
    {
        TotalData.LoadTotalFromFile();
        score.text      = TotalData.total.lastScore.ToString();
        bestScore.text  = TotalData.total.bestScore.ToString();
        totalScore.text = TotalData.total.totalScore.ToString();

        if (KeepDataOnPlayMode.instance.randomRewardAds != KeepDataOnPlayMode.instance.reloadedTimesRewardVideo)
        {
            afterAds();
        }
        else
        {
            KeepDataOnPlayMode.instance.reloadedTimesRewardVideo = 0;
            KeepDataOnPlayMode.instance.randomRewardAds          = KeepDataOnPlayMode.instance.generateIntRewardAds();
        }
    }
Esempio n. 17
0
        public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
        {
            // A consumable product has been purchased by this user.
            if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable, StringComparison.Ordinal))
            {
                // The consumable item has been successfully purchased, add 100 coins to the player's in-game score.
                //ScoreManager.score += 100;
                TotalData.LoadTotalFromFile();
                int currentScore = TotalData.total.totalScore;
                TotalData.total.totalScore *= 2;
                ShopScore.instance.checkScore(currentScore, TotalData.total.totalScore, 0.8f);
                TotalData.SaveTotalToFile();
            }
            // Or ... a non-consumable product has been purchased by this user.
            else if (String.Equals(args.purchasedProduct.definition.id, kProductIDNonConsumable, StringComparison.Ordinal))
            {
                //	TotalData.LoadTotalFromFile ();
                TotalData.total.noAds             = true;
                KeepDataOnPlayMode.instance.noAds = true;
                TotalData.SaveTotalToFile();
                if (ShowBannerAd.instance.bannerView != null)
                {
                    ShowBannerAd.instance.bannerView.Hide();
                }
                // TODO: The non-consumable item has been successfully purchased, grant this item to the player.
            }
            // Or ... a subscription product has been purchased by this user.
            else if (String.Equals(args.purchasedProduct.definition.id, kProductIDSubscription, StringComparison.Ordinal))
            {
                // TODO: The subscription item has been successfully purchased, grant this to the player.
            }
            // Or ... an unknown product has been purchased by this user. Fill in additional products here....
            else
            {
///				Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id));
            }

            // Return a flag indicating whether this product has completely been received, or if the application needs
            // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still
            // saving purchased products to the cloud, and when that save is delayed.
            return(PurchaseProcessingResult.Complete);
        }
Esempio n. 18
0
    void Start()
    {
        TotalData.LoadTotalFromFile();
        if (TotalData.total.players.Count == 0)
        {
            id = 1;
        }
        else
        {
            foreach (TotalData.Players player in TotalData.total.players)
            {
                if (player.isActive)
                {
                    id = player.ID;
                }
            }
        }

        transform.GetComponent <SpriteRenderer> ().sprite = players [(id * 2) - 2];
        transform.GetChild(0).transform.GetComponent <SpriteRenderer> ().sprite = players [((id * 2) - 2) + 1];
        ChangeColor.instance.changeTrailWidth(transform.GetComponent <SpriteRenderer> ().sprite.name);
    }
Esempio n. 19
0
    /// <summary>
    ///On level complete.
    /// </summary>
    public void OnLevelComplete()
    {
        if (instantiated)
        {
            return;
        }
        instantiated = true;
        KeepDataOnPlayMode.instance.reloadedTimes += 1;
        if (KeepDataOnPlayMode.instance.reloadedTimes > 5)
        {
            KeepDataOnPlayMode.instance.reloadedTimes = 0;
        }
        if (KeepDataOnPlayMode.instance.randomAds == KeepDataOnPlayMode.instance.reloadedTimes)
        {
            KeepDataOnPlayMode.instance.reloadedTimes = 0;
            KeepDataOnPlayMode.instance.randomAds     = KeepDataOnPlayMode.instance.generateIntAds();
            TotalData.LoadTotalFromFile();
            if (!TotalData.totalData.noads)
            {
                ShowAd();
            }
        }
//		Debug.Log("on Level Complete");
        int timerType = 0;

        if (timer != null)
        {
//			Debug.Log("timer");
            timer.Stop();
            timerType = 1;
            CoinsToInt();
        }
        else
        {
//			Debug.Log("timer countdown");
            CoinsToInt();
            timerCountdown.Stop();
            timerType = 2;
        }
        isRunning = false;
        //	Time.timeScale = 0;
        try {
            ///Save the stars level

            DataManager.WorldData currentWorldData = DataManager.FindWorldDataById(World.selectedWorld.ID, DataManager.filterdWorldsData);

            DataManager.LevelData currentLevelData = currentWorldData.FindLevelDataById(TableLevel.selectedLevel.ID);
            TotalData.LoadTotalFromFile();

//			Debug.Log ("currentWorldData: " + currentWorldData);
//			Debug.Log ("currentLevelData: " + currentLevelData.ID);

//			Debug.Log("timerType: " + timerType);
            if (timerType == 1)
            {
//				Debug.Log("first");
                //			currentLevelData.leveltime = (int)timer.timeInSeconds;
                //			Debug.Log ("currentLevelData.leveltime " + currentLevelData.leveltime);
                int currentTime = currentLevelData.leveltime;
                currentLevelData.leveltime = timer.timeInSeconds;
                if (currentTime == 0)
                {
                    //				if(currentLevelData.ID == 1){
                    //					TotalData.totalData.laser = 3;
                    //					TotalData.totalData.green = 3;
                    //					TotalData.totalData.blue = 3;
                    //					TotalData.SaveTotalToFile();
                    //		Debug.Log("done");
                    //				}
                    //			Debug.Log("zero");
                    ///		currentWorldData.Worldtime += timer.timeInSeconds;
                }
                //		currentWorldData.Worldtime += currentTime;
                TotalData.totalData.totalTime += timer.timeInSeconds;

                //		currentWorldData.Worldtime += currentLevelData.leveltime;
                //		currentTotalData.totalTime += currentWorldData.Worldtime;


                if (currentTime > timer.timeInSeconds)
                {
                    //			Debug.Log("less");
                    currentLevelData.leveltime     = timer.timeInSeconds;
                    currentWorldData.Worldtime    += timer.timeInSeconds;
                    TotalData.totalData.totalTime -= (currentTime - timer.timeInSeconds);
                    //			currentWorldData.Worldtime -= (currentTime - timer.timeInSeconds);
                }
                TotalData.SaveTotalToFile();
                //		Debug.Log("currentTime: " + currentTime);
                //		Debug.Log ("currentWorldData.Worldtime: " + currentWorldData.Worldtime);
                currentLevelData.levelScore = coins;
                //		currentWorldData.worldScore += coins;
                //	DataManager.SaveWorldsDataToFile (DataManager.);
                //TotalData.totalData.totalCoins = coins;

//				Debug.Log ("totaldata2: " + TotalData.totalData.totalCoins);
//				Debug.Log("currentTotalData.totalCoins: " + currentTotalData.totalCoins);
                //TotalData.SaveTotalToFile();
//				Debug.Log("gamemanager: " + currentTotalData.totalCoins);
                //			if (currentLevelData.starsLevel < TableLevel.StarsNumber.TWO){
                //				Debug.Log ("good thing");
                //			}
                //Calculate the stars rating
                if (timer.timeInSeconds >= 0 && timer.timeInSeconds <= threeStarsTimePeriod)
                {
                    currentLevelData.starsLevel = TableLevel.StarsNumber.THREE;
                }
                else if (timer.timeInSeconds > threeStarsTimePeriod && timer.timeInSeconds <= twoStarsTimePeriod)
                {
                    currentLevelData.starsLevel = TableLevel.StarsNumber.TWO;
                }
                else
                {
                    currentLevelData.starsLevel = TableLevel.StarsNumber.ONE;
                }
            }
            else if (timerType == 2)
            {
//				Debug.Log("second");
//				Debug.Log ("timerCountdown.timeInSeconds " + timerCountdown.timeInSeconds);
                //	int currentScore = currentLevelData.leveltime;
                //	currentWorldData.Worldtime += currentLevelData.leveltime;
                //	if(currentLevelData.leveltime > timer.timeInSeconds || currentLevelData.leveltime == 0){
                //		currentLevelData.leveltime = timer.timeInSeconds;
                //		currentWorldData.Worldtime -= timer.timeInSeconds;
                //	}
                //	currentLevelData.levelScore = coins;
                //			if (currentLevelData.starsLevel < TableLevel.StarsNumber.TWO){
                //				Debug.Log ("good thing");
                //			}
                //Calculate the stars rating
                //	Debug.Log ("test");
                currentLevelData.levelScore  = coins;
                currentWorldData.worldScore += coins;
                //	TotalData.totalData.totalCoins += coins;
                //	TotalData.SaveTotalToFile();
                if (timerCountdown.timeInSeconds >= 0 && timerCountdown.timeInSeconds <= threeStarsTimePeriod)
                {
                    currentLevelData.starsLevel = TableLevel.StarsNumber.THREE;
                }
                else if (timerCountdown.timeInSeconds > threeStarsTimePeriod && timerCountdown.timeInSeconds <= twoStarsTimePeriod)
                {
                    currentLevelData.starsLevel = TableLevel.StarsNumber.TWO;
                }
                else
                {
                    currentLevelData.starsLevel = TableLevel.StarsNumber.ONE;
                }
            }
//			Debug.Log ("test2");
//			Debug.Log ("levelsdata.count " + currentWorldData.levelsData.Count);
            if (currentLevelData.ID + 1 <= currentWorldData.levelsData.Count)
            {
                //				///Unlock the next level
//				Debug.Log ("Unlock next level");
                DataManager.LevelData nextLevelData = currentWorldData.FindLevelDataById(TableLevel.selectedLevel.ID + 1);
//				Debug.Log ("nextleveldata: " + nextLevelData);
                nextLevelData.isLocked = false;
                DataManager.SaveWorldsDataToFile(DataManager.filterdWorldsData);
            }

            if (currentLevelData.ID == currentWorldData.levelsData.Count)
            {
//				Debug.Log ("Last level: " + currentLevelData .ID);
                DataManager.WorldData nextWorldData = DataManager.FindWorldDataById(World.selectedWorld.ID + 1, DataManager.filterdWorldsData);
                nextWorldData.WorldIsLocked = false;
//				Debug.Log ("world " + nextWorldData.ID + nextWorldData.WorldIsLocked);
            }
//			Debug.Log ("test3");
            DataManager.SaveWorldsDataToFile(DataManager.filterdWorldsData);
            TotalData.totalData.totalCoins += coins;
//			Debug.Log ("currentWorldData.Worldtime: " + currentWorldData.Worldtime);
            TotalData.SaveTotalToFile();

            //	for (int ID = 0; ID < 5; ID ++){
            //	int ID = 2;
            //		Debug.Log("World_GameManger " + World.selectedWorld.ID + World.selectedWorld.WorldIsLocked);
            //	}
            BlackArea2.Show();
            WinDialogObj.gameObject.SetActive(true);
            winDialog.starsNumber = currentLevelData.starsLevel;
            winDialog.Show();
        } catch (Exception ex) {
            Debug.Log(ex.Message);
        }
//		Debug.Log ("You win...");
        Time.timeScale = 0;
        //AudioSource.PlayClipAtPoint(finishSFX,Vector3.zero);
    }
Esempio n. 20
0
    /// <summary>
    /// Settings up the level contents in the table.
    /// </summary>
    /// <param name="tableLevel">Table level.</param>
    /// <param name="ID">ID of the level.</param>
    private void SettingUpLevel(TableLevel tableLevel, int ID)
    {
        if (tableLevel == null)
        {
            return;
        }

        ///Get World Data of the current World

        tempWorldData = DataManager.FindWorldDataById(World.selectedWorld.ID, DataManager.filterdWorldsData);
        //	Debug.Log("tempworlddata0 " + World.selectedWorld.ID + ".." + DataManager.filterdWorldsData);
        //	Debug.Log("tempworlddata " + World.selectedWorld.ID + tempWorldData + "..." + DataManager.filterdWorldsData);
        if (tempWorldData == null)
        {
            Debug.Log("Null WorldData");
            return;
        }

        ///Get Level Data of the wanted (selected) Level
        tempLevelData = tempWorldData.FindLevelDataById(tableLevel.ID);
        if (tempLevelData == null)
        {
            Debug.Log("Null LevelData");
            return;
        }
//		Debug.Log("tempLevelData " + tableLevel.ID + "..."+tempLevelData.isLocked + "...."+tempLevelData);
        ///		Debug.Log("time for levels " + tempLevelData.leveltime);

        //If the level is locked then , skip the next
        if (tempLevelData.isLocked)
        {
            return;
        }
        //show summary time
        TotalData.LoadTotalFromFile();
//		Debug.Log ("totaldata: " + TotalData.totalData.totalCoins);
//		Debug.Log("levelsTable: " + currentTotalData.totalTime)
        //	sumTime  = currentTotalData.totalTime;
//		Debug.Log ("Worldtime: " + TotalData.totalData.totalTime);
        //	Debug.Log ("leveltime: " + tempLevelData.leveltime);
        //	Debug.Log ("levelScore: " +  tempLevelData.levelScore);
        //	sumTime = TotalData.totalData.totalTime;
        //	sumTime = tempWorldData.Worldtime;
        //	sumTime += tempLevelData.leveltime;
        //	time.text = ": " + currentTotalData.totalCoins.ToString();
        time.text = ": " + TotalData.totalData.totalTime.ToString();

        //show summary coins
        //	sumCoins =
        sumCoins  += tempLevelData.levelScore;
        coins.text = ": " + TotalData.totalData.totalCoins.ToString();
//		Debug.Log ("data: " + TotalData.totalData.totalCoins);
//		Debug.Log ("laser: " + TotalData.totalData.laser);

        //	Debug.Log ("time: " + tempLevelData.leveltime );
        //Enable level animator
        tableLevel.GetComponent <Animator> ().enabled = true;

        ///Make the button interactable
        tableLevel.GetComponent <Button> ().interactable = true;

        ///Show the stars of the level
        tableLevel.transform.Find("Stars").gameObject.SetActive(true);

        ///Hide the lock
        tableLevel.transform.Find("Lock").gameObject.SetActive(false);

        tableLevel.transform.Find("Background").gameObject.SetActive(true);

        ///Show the title of the level
        tableLevel.transform.Find("LevelTitle").gameObject.SetActive(true);

        ///Setting up the level title
        tableLevel.transform.Find("LevelTitle").GetComponent <Text> ().text = ID.ToString();

        ///Get stars Number from current Level Data
        tableLevel.starsNumber = tempLevelData.starsLevel;
        tempTransform          = tableLevel.transform.Find("Stars");

        ///Apply the current Stars Rating
        if (tempLevelData.starsLevel == TableLevel.StarsNumber.ONE)          //One Star
        {
            tempTransform.Find("FirstStar").GetComponent <Image> ().sprite  = starOn;
            tempTransform.Find("SecondStar").GetComponent <Image> ().sprite = starOff;
            tempTransform.Find("ThirdStar").GetComponent <Image> ().sprite  = starOff;
        }
        else if (tempLevelData.starsLevel == TableLevel.StarsNumber.TWO)            //Two Stars
        {
            tempTransform.Find("FirstStar").GetComponent <Image> ().sprite  = starOn;
            tempTransform.Find("SecondStar").GetComponent <Image> ().sprite = starOn;
            tempTransform.Find("ThirdStar").GetComponent <Image> ().sprite  = starOff;
        }
        else if (tempLevelData.starsLevel == TableLevel.StarsNumber.THREE)            //Three Stars
        {
            tempTransform.Find("FirstStar").GetComponent <Image> ().sprite  = starOn;
            tempTransform.Find("SecondStar").GetComponent <Image> ().sprite = starOn;
            tempTransform.Find("ThirdStar").GetComponent <Image> ().sprite  = starOn;
        }
        else            //Zero Stars
        {
            tempTransform.Find("FirstStar").GetComponent <Image> ().sprite  = starOff;
            tempTransform.Find("SecondStar").GetComponent <Image> ().sprite = starOff;
            tempTransform.Find("ThirdStar").GetComponent <Image> ().sprite  = starOff;
        }
    }
Esempio n. 21
0
    void Start()
    {
        TotalData.LoadTotalFromFile();
//		Debug.Log (TotalData.totalData.totalCoins);
        totalCoins.text = TotalData.totalData.totalCoins.ToString();
    }
Esempio n. 22
0
    // Use this for initialization
    void Start()
    {
        if (TotalData.total.players.Count == 0)
        {
            TotalData.Players tempPlayers = null;

            foreach (Transform obj in transform)
            {
                tempPlayers          = new TotalData.Players();
                tempPlayers.ID       = obj.GetComponent <Player> ().ID;
                tempPlayers.price    = obj.GetComponent <Player> ().price;
                tempPlayers.isLocked = true;
                if (tempPlayers.ID == 1)
                {
                    tempPlayers.isLocked = false;
                    tempPlayers.isActive = true;
                }
                TotalData.total.players.Add(tempPlayers);
            }

            TotalData.SaveTotalToFile();
        }

        if (TotalData.total.players.Count < transform.childCount)
        {
            int totalPlayers = TotalData.total.players.Count;
            int scenePlayers = transform.childCount;

            TotalData.Players tempPlayers = null;
            for (int i = totalPlayers; i < scenePlayers; i++)
            {
                tempPlayers          = new TotalData.Players();
                tempPlayers.ID       = transform.GetChild(i).GetComponent <Player> ().ID;
                tempPlayers.price    = transform.GetChild(i).GetComponent <Player> ().price;
                tempPlayers.isLocked = true;

                TotalData.total.players.Add(tempPlayers);
            }
            TotalData.SaveTotalToFile();
        }
        TotalData.LoadTotalFromFile();
        foreach (TotalData.Players player in TotalData.total.players)
        {
            foreach (Transform obj in transform)
            {
                if (obj.GetComponent <Player> ().ID == player.ID)
                {
                    if (!player.isLocked)
                    {
                        obj.GetComponent <Player> ().isLocked = false;
                    }
                    if (player.isActive)
                    {
                        obj.GetComponent <Player> ().isActive = true;
                    }
                    obj.GetComponent <Player> ().price = player.price;
                    obj.GetComponent <Player> ().setPlayer();
                }
            }
        }
    }