Example #1
0
        protected override void OnActivated(object parameter = null)
        {
            Task.Run(async() =>
            {
                await Task.Delay(2000);
                var tapToPlay = new TapToPlay();
                AddChild(tapToPlay);
                tapToPlay.Down += OnTapped;
            });


            _logoSprite = new Sprite(SpriteConst.BelowTheStars, Width / 2, Height * 0.2f, Width * 0.33f, Height * 0.2f, new SKPaint {
                Color = new SKColor(255, 255, 255), BlendMode = SKBlendMode.Plus
            });
            _logoSprite.Opacity = 0.7f;
            _logoSprite.AddBehavior(new ToastBehavior(0, 0.3f, 1, 5000, 5000));

            _smallPlanetSprite = new Sprite(SpriteConst.SmallPlanet, Width / 2, Height * 0.8f, Width * 0.37f, Width * 0.37f, new SKPaint {
                Color = new SKColor(255, 255, 255), BlendMode = SKBlendMode.Plus
            });
            _smallPlanetSprite.Opacity = 0.5f;
            _smallPlanetSprite.AddBehavior(new ToastBehavior(0, 0.2f, 1, 10000, 15000));
            _smallPlanetSprite.Angle = (float)Math.PI * 1f / 4f;

            _mediumPlanetSprite = new Sprite(SpriteConst.MediumPlanet, Width / 2, Height * 0.5f, Width * 0.55f, Width * 0.5f, new SKPaint {
                Color = new SKColor(255, 255, 255), BlendMode = SKBlendMode.Plus
            });
            _mediumPlanetSprite.Opacity = 0.1f;
            _mediumPlanetSprite.AddBehavior(new ToastBehavior(0, 0.3f, 1, 0, 12000));
            _mediumPlanetSprite.Angle = (float)Math.PI * 1f / 4f;

            _bigPlanetSprite = new Sprite(SpriteConst.MediumPlanet, Width / 2, Height * 0.15f, Width * 0.78f, Width * 0.78f, new SKPaint {
                Color = new SKColor(255, 255, 255), BlendMode = SKBlendMode.Plus
            });
            _bigPlanetSprite.Opacity = 0.05f;
            _bigPlanetSprite.AddBehavior(new ToastBehavior(0, -0.3f, 1, 10000, 4000));
            _bigPlanetSprite.Angle = (float)Math.PI * 1f / 4f;

            AddChild(_smallPlanetSprite);


            AddChild(_mediumPlanetSprite);


            AddChild(_bigPlanetSprite);


            AddChild(_logoSprite);
        }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        coinsTex.text = "Coins: " + coins;



        if (NoADS.ads == 0)
        {
            if (startAd == 0)
            {
                if (ad)
                {
                    timer3 += Time.deltaTime;
                    if (timer3 >= 1)
                    {
                        if (rand)
                        {
                            showVid = Random.Range(0, 3);
                            rand    = false;
                        }


                        if (showVid == 1)
                        {
                            if (Appodeal.isLoaded(Appodeal.VIDEO))
                            {
                                timer3  = 0;
                                startAd = 5;
                                PlayerPrefs.SetInt("startAD", startAd);

                                Appodeal.show(Appodeal.VIDEO);
                                ad = false;
                            }
                        }
                        else
                        {
                            timer3  = 0;
                            ad      = false;
                            startAd = 5;
                            PlayerPrefs.SetInt("startAD", startAd);
                            AppnextVideoAndroid.showInterstitial("feb28299-00d1-4c17-a5f5-79f33cfda3bb", AppnextVideoAndroid.INTERSTITIAL);
                        }
                    }
                }
            }
        }


        if (musicOn == 1)
        {
            if (Music2)
            {
                Destroy(Music2);
            }
        }
        else
        {
            if (!Music2)
            {
                Instantiate(Music, Music.transform.position, Music.transform.rotation);
                Music2 = GameObject.FindGameObjectWithTag("music");
                DontDestroyOnLoad(Music2);
            }
        }


        if (sfxON == 0)
        {
            if (coinSound)
            {
                coinSound = false;
                Instantiate(CoinSFX, CoinSFX.transform.position, CoinSFX.transform.rotation);
                CoinSFX2 = GameObject.FindGameObjectWithTag("SFX");
                SFX      = CoinSFX2.GetComponent <AudioSource> ();
            }
        }

        if (SFX)
        {
            if (!SFX.isPlaying)
            {
                Destroy(CoinSFX2);
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            timer = 0;
            if (!earnMoneyOn)
            {
                game2 = true;
            }
            buttonDown = true;
        }



        if (buttonDown)
        {
            if (!game)
            {
                timer += Time.deltaTime;
                if (timer >= 0.5f)
                {
                    buttonDown = false;
                    timer      = 0;

                    if (exitOn)
                    {
                        Application.Quit();
                    }

                    if (game2)
                    {
                        RateBut.SetActive(false);
                        PrizesBut.SetActive(false);
                        earnCoinBut.SetActive(false);
                        distanceText.SetActive(true);
                        coinsText.SetActive(true);
                        RecordText.SetActive(false);
                        coinsText2.SetActive(false);
                        Appodeal.hide(Appodeal.BANNER_TOP);
                        ExitButton.SetActive(false);
                        sfxToggle.SetActive(false);
                        musicToggle.SetActive(false);
                        TapToPlay.SetActive(false);
                        shop.SetActive(false);
                        leaders.SetActive(false);
                        achievements.SetActive(false);
                        NoAds.SetActive(false);
                        Instantiate(balls [iBall], new Vector3(0, 1, 0), balls [iBall].transform.rotation);
                        Instantiate(tiltControll, tiltControll.transform.position, tiltControll.transform.rotation);
                        balls [iBall] = GameObject.FindGameObjectWithTag("Ball");
                        game          = true;
                    }
                }
            }
        }



        if (game)
        {
            cameraPos = transform.position;



            if (exitOn)
            {
                timer += Time.deltaTime;
                if (timer >= 0.5f)
                {
                    Application.Quit();
                }
            }


            if (isDestroy)
            {
                isDestroy = false;

                targetZ += 20;
                newPosition.Set(0, 0, targetZ);

                i = Random.Range(0, 47);
                Instantiate(parts [i], newPosition, parts [i].transform.rotation);

                i2 = Random.Range(0, 3);
                if (i2 == 1)
                {
                    i = Random.Range(0, 47);
                    Instantiate(parts [i], newPosition, parts [i].transform.rotation);
                }
            }

            if (balls [iBall])
            {
                if (balls [iBall].transform.position.y <= -20)
                {
                    if (NoADS.ads == 0)
                    {
                        Appodeal.show(Appodeal.BANNER_TOP);
                    }
                    ad = true;
                    if (done)
                    {
                        done = false;
                        if (startAd > 0)
                        {
                            startAd -= 1;
                        }
                    }
                    PlayerPrefs.SetInt("startAD", startAd);
                    gameOverCanv.SetActive(true);
                    mainCanv.SetActive(false);
                    PlayerPrefs.SetInt("coins", coins);
                }
            }



            newZ = transform.position.z;


            cameraPosition.Set(0, 35, newZ + speed);
            skyPosition.Set(0, -10, newZ + speed);
            sky.position       = skyPosition;
            transform.position = cameraPosition;
            if (speed < 0.037f)
            {
                speed += 0.000007f;
            }
        }



        if (tapPlayOn)
        {
            if (!game)
            {
                timer2 += Time.deltaTime;
                if (timer2 >= 1)
                {
                    timer2 = 0;

                    if (TapToPlay.activeSelf)
                    {
                        TapToPlay.SetActive(false);
                    }
                    else
                    {
                        TapToPlay.SetActive(true);
                    }
                }
            }
        }
    }
Example #3
0
 private void Awake()
 {
     tapToPlayInstance = this;
 }