private void Bird_OnDiad(object sender, System.EventArgs e)
 {
     VideoAds.GetInstance().DisplayVideoAd();
     GoldHandeler.GetInstance().setCoins(Level.GetInstance().GetPipePassed());
     scoreText.text = Level.GetInstance().GetPipePassed().ToString();
     Gold.text      = (Level.GetInstance().GetPipePassed() / 5).ToString();
     inGameScore.SetActive(false);
     inGameGold.SetActive(false);
     if (Level.GetInstance().GetPipePassed() >= Score.GetHighScore())
     {
         //new highscore!
         highscoreText.text = "NEW HIGHSCORE";
     }
     else
     {
         highscoreText.text = "HIGHSCORE: " + Score.GetHighScore();
     }
     Show();
 }
Exemple #2
0
 void Awake()
 {
     _instance = this;
 }
        public IActionResult EditAds(Ads model)
        {
            if (string.IsNullOrEmpty(model.Title))
            {
                tip.Message = "广告标题不能为空!";
                return(Json(tip));
            }
            if (model.Id <= 0)
            {
                tip.Message = "错误参数传递!";
                Json(tip);
            }
            Ads entity = Ads.Find(Ads._.Id == model.Id);

            if (entity == null)
            {
                tip.Message = "系统找不到本记录!";
                return(Json(tip));
            }

            string   content = "";
            DateTime StartTime, EndTime;

            StartTime = Convert.ToDateTime("2000-01-01");
            EndTime   = Convert.ToDateTime("2999-01-01");

            #region 获取数据
            switch (model.TId)
            {
            case 0:    //代码
                ScriptAds script = new ScriptAds();
                script.content = Request.Form["txtScript"];
                if (string.IsNullOrEmpty(script.content))
                {
                    tip.Message = "代码不能为空!";
                    return(Json(tip));
                }
                content = JsonConvert.SerializeObject(script);
                break;

            case 1:    //文字
                TextAds text = new TextAds();
                text.txt   = Request.Form["txt_Txt"];
                text.link  = Request.Form["txt_Link"];
                text.style = Request.Form["txt_Style"];
                if (string.IsNullOrEmpty(text.txt))
                {
                    tip.Message = "文字内容不能为空!";
                    return(Json(tip));
                }
                if (string.IsNullOrEmpty(text.link))
                {
                    tip.Message = "文字链接不能为空!";
                    return(Json(tip));
                }
                content = JsonConvert.SerializeObject(text);
                break;

            case 2:    //图片
                ImgAds img = new ImgAds();
                img.img  = Request.Form["img_Img"];
                img.link = Request.Form["img_Link"];
                img.alt  = Request.Form["img_Alt"];
                string iw = Request.Form["img_Width"];
                string ih = Request.Form["img_Height"];
                if (!string.IsNullOrEmpty(iw) && Utils.IsInt(iw))
                {
                    img.width = int.Parse(iw);
                }
                if (!string.IsNullOrEmpty(ih) && Utils.IsInt(ih))
                {
                    img.height = int.Parse(ih);
                }
                if (string.IsNullOrEmpty(img.img))
                {
                    tip.Message = "图片地址不能为空!";
                    return(Json(tip));
                }
                if (string.IsNullOrEmpty(img.link))
                {
                    tip.Message = "图片链接不能为空!";
                    return(Json(tip));
                }
                content = JsonConvert.SerializeObject(img);
                break;

            case 3:    //Flash
                FlashAds flash = new FlashAds();
                flash.swf = Request.Form["flash_Swf"];
                string fw = Request.Form["flash_Width"];
                string fh = Request.Form["flash_Height"];
                if (string.IsNullOrEmpty(flash.swf))
                {
                    tip.Message = "Flash 地址不能为空!";
                    return(Json(tip));
                }

                if (string.IsNullOrEmpty(fw) || !Utils.IsInt(fw))
                {
                    tip.Message = "Flash 宽度不能为空或者不是整数!";
                    return(Json(tip));
                }
                else
                {
                    flash.width = int.Parse(fw);
                }
                if (string.IsNullOrEmpty(fh) || !Utils.IsInt(fh))
                {
                    tip.Message = "Flash 高度不能为空或者不是整数!";
                    return(Json(tip));
                }
                else
                {
                    flash.height = int.Parse(fh);
                }
                content = JsonConvert.SerializeObject(flash);
                break;

            case 4:    //幻灯片
                string sw = Request.Form["slide_Width"];
                string sh = Request.Form["slide_Height"];
                if (string.IsNullOrEmpty(sw) || !Utils.IsInt(sw))
                {
                    tip.Message = "幻灯片宽度不能为空或者不是整数!";
                    return(Json(tip));
                }
                if (string.IsNullOrEmpty(sh) || !Utils.IsInt(sh))
                {
                    tip.Message = "幻灯片高度不能为空或者不是整数!";
                    return(Json(tip));;
                }
                string[]      arrsimg  = Request.Form["slide_Img"];  // SImg.Split(new string[] { "," }, StringSplitOptions.None);
                string[]      arrslink = Request.Form["slide_Link"]; //SLink.Split(new string[] { "," }, StringSplitOptions.None);
                string[]      arralt   = Request.Form["slide_Alt"];  //SAlt.Split(new string[] { "," }, StringSplitOptions.None);
                List <ImgAds> listimg  = new List <ImgAds>();
                for (int i = 0; i < arrsimg.Length; i++)
                {
                    if (!string.IsNullOrEmpty(arrsimg[i]) && !string.IsNullOrEmpty(arrslink[i]))    //图片跟地址都不为空
                    {
                        ImgAds tplimgads = new ImgAds();
                        tplimgads.img    = arrsimg[i];
                        tplimgads.link   = arrslink[i];
                        tplimgads.height = int.Parse(sh);
                        tplimgads.width  = int.Parse(sw);
                        tplimgads.alt    = arralt[i];
                        listimg.Add(tplimgads);
                    }
                }
                if (listimg == null || listimg.Count <= 0)
                {
                    tip.Message = "幻灯片请至少添加一张图片!";
                    return(Json(tip));;
                }
                content = JsonConvert.SerializeObject(listimg);
                break;

            case 7:    //视频广告
                VideoAds video = new VideoAds();
                video.poster = Request.Form["video_Poster"];
                video.src    = Request.Form["video_Src"];
                video.title  = Request.Form["video_Title"];
                string vw = Request.Form["video_Width"];
                string vh = Request.Form["video_Height"];
                if (!string.IsNullOrEmpty(vw) && Utils.IsInt(vw))
                {
                    video.width = int.Parse(vw);
                }
                if (!string.IsNullOrEmpty(vh) && Utils.IsInt(vh))
                {
                    video.height = int.Parse(vh);
                }
                if (string.IsNullOrEmpty(video.src))
                {
                    tip.Message = "视频广告地址不能为空!";
                    return(Json(tip));
                }
                content = JsonConvert.SerializeObject(video);
                break;
            }
            #endregion

            model.StartTime = StartTime;
            model.EndTime   = EndTime;
            model.Content   = content;
            model.Update();

            tip.Status    = JsonTip.SUCCESS;
            tip.Message   = "编辑广告成功";
            tip.ReturnUrl = "close";

            Core.Admin.WriteLogActions("编辑广告(" + model.Id + ");");
            return(Json(tip));
        }
Exemple #4
0
    public void ButtonClick(string buttonName)
    {
        //GetComponent<AudioSource>().clip = buttonAudio;
        //GetComponent<AudioSource>().Play();
        playHand = GameObject.FindGameObjectWithTag("PlayHand");
        //sg = playHand.GetComponent<StartGame> ();
        if (buttonName == "GunsButton")
        {
            HunterMovement hm = GameObject.FindGameObjectWithTag("Player").GetComponent <HunterMovement>();
            hm.stopStart();
            sr.reset(PlayerPrefs.GetInt("gunIndex") - 1);
            PlayerPrefs.SetInt("isGuncanvasOpen", 1);
            isGuncanvasOpen = true;
            guns.SetActive(true);
        }
        else if (buttonName == "BackButton")
        {
            PlayerPrefs.SetInt("isGuncanvasOpen", 0);
            isGuncanvasOpen = false;
            guns.SetActive(false);
            //sg.deactiveCanvas();
        }
        if (buttonName == "StartButton")
        {
            /**/
            GameObject.FindGameObjectWithTag("GameTitle").GetComponent <Animator>().SetBool("isDown", true);
            GameObject.FindGameObjectWithTag("ButtonCountDown").GetComponent <Animator>().SetBool("isStart", true);
            GameObject.FindGameObjectWithTag("CoinObject").GetComponent <Animator>().SetBool("isStart", true);
            PlayerPrefs.SetInt("isGuncanvasOpen", 0);
            StartCoroutine(startanimation());
        }

        if (buttonName == "MapButton")
        {
            HunterMovement hm = GameObject.FindGameObjectWithTag("Player").GetComponent <HunterMovement>();
            hm.stopStart();
            MapScrollScript sr = GameObject.FindGameObjectWithTag("GameController").GetComponent <MapScrollScript>();
            sr.reset(0);
            maps.SetActive(true);
        }

        if (buttonName == "BackMapButton")
        {
            maps.SetActive(false);
            //sg.deactiveCanvas();
        }

        if (buttonName == "Play")
        {
        }

        if (buttonName == "Pause")
        {
            Time.timeScale = 0;
            pauseCanvas.SetActive(true);
            pauseSmallCanvas.SetActive(false);
        }

        if (buttonName == "Resume")
        {
            Time.timeScale = 1;
            pauseCanvas.SetActive(false);
            pauseSmallCanvas.SetActive(true);
        }

        if (buttonName == "GiftButton")
        {
            gameover = GameObject.FindGameObjectWithTag("GameOver");
            gtemp    = (GameObject)Instantiate(gift, new Vector2(gift.transform.position.x, gift.transform.position.y), Quaternion.identity);
            gtemp.SetActive(true);


            Text giftText = GameObject.FindGameObjectWithTag("GiftCoin").GetComponent <Text> ();

            val           = Random.Range(50, 100);
            giftText.text = val.ToString();

            timerIcon         = GameObject.FindGameObjectWithTag("GreenStripeTimer").GetComponent <Image> ();
            timerIcon.enabled = false;

            minute = GameObject.FindGameObjectWithTag("GreenStripeMinute").GetComponent <Text> ();

            Text textObject = GameObject.FindGameObjectWithTag("FreeGiftText").GetComponent <Text> ();
            textObject.text = "FREE GIFT IN";

            /*Image label = GameObject.FindGameObjectWithTag ("FreeGiftIn_Label").GetComponent<Image> ();
             * label.enabled = true;*/

            timerIcon.enabled = true;
            minute.text       = "6:00";

            GameObject     gcc = GameObject.FindGameObjectWithTag("GameController");
            GameController gc  = gcc.GetComponent <GameController>();
            gc.resetGiftTimer();
            timeLeft = TotalTime;
            int sc = PlayerPrefs.GetInt("Score");
            sc = sc + val;
            PlayerPrefs.SetInt("Score", sc);

            GameObject giftButton = GameObject.FindGameObjectWithTag("GreenStripeButton");
            giftButton.SetActive(false);
            //GameOverVisibility(false);

            GameOverScript go_script = GameObject.FindGameObjectWithTag("GameOver").GetComponent <GameOverScript>();
            go_script.calculateTotalCoins();
        }

        if (buttonName == "Restart")
        {
            GameObject.FindGameObjectWithTag("ButtonCountDown").GetComponent <Animator>().SetBool("isStart", true);
            GameObject.FindGameObjectWithTag("CoinObject").GetComponent <Animator>().SetBool("isStart", true);
            GameObject.FindGameObjectWithTag("ButtonCountDown").GetComponent <Animator>().SetBool("isEnd", false);
            GameObject.FindGameObjectWithTag("CoinObject").GetComponent <Animator>().SetBool("isEnd", false);
            GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController> ().activeCoinCanvas();
            //sg.deactiveCanvas();
            restartLevel();
        }

        if (buttonName == "Menu")
        {
            Application.LoadLevel(0);
        }

        if (buttonName == "VideoButton")
        {
            VideoAds gamecontroller = GameObject.FindGameObjectWithTag("GameController").GetComponent <VideoAds>();
            //gamecontroller.loadAd();
        }

        if (buttonName == "RestartLevel")
        {
            Application.LoadLevel("MainScene");
        }

        if (buttonName == "MoveLeft")
        {
            GameObject.FindGameObjectWithTag("Player").GetComponent <JoystickMovement>().buttonClick("left");

            /*if(isRight)
             * {
             *      isRight = false;
             *      GameObject.FindGameObjectWithTag("Player").GetComponent<PirateMovement>().Flip();
             * }
             * direction = -1;*/
        }

        if (buttonName == "MoveRight")
        {
            if (GameObject.FindGameObjectWithTag("Player") != null)
            {
                GameObject.FindGameObjectWithTag("Player").GetComponent <JoystickMovement>().buttonClick("right");
            }

            /*if(!isRight)
             * {
             *      isRight = true;
             *      GameObject.FindGameObjectWithTag("Player").GetComponent<PirateMovement>().Flip();
             * }
             * direction = 1;*/
        }

        if (buttonName == "SeeUp")
        {
            if (GameObject.FindGameObjectWithTag("Player") != null)
            {
                GameObject.FindGameObjectWithTag("Player").GetComponent <JoystickMovement>().buttonClick("up");
            }

            /*if(!isRight)
             * {
             *      isRight = true;
             *      GameObject.FindGameObjectWithTag("Player").GetComponent<PirateMovement>().Flip();
             * }
             * direction = 1;*/
        }

        if (buttonName == "Still")
        {
            //direction = 0;
            if (GameObject.FindGameObjectWithTag("Player") != null)
            {
                GameObject.FindGameObjectWithTag("Player").GetComponent <JoystickMovement>().standStill();
            }
        }

        if (buttonName == "Fire")
        {
            GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerFireScript>().InitiateFire();
        }

        if (buttonName == "Jump" && GameObject.FindGameObjectWithTag("Player") != null)
        {
            if (GameObject.FindGameObjectWithTag("Player").GetComponent <JoystickMovement>().grounded)
            {
                GameObject.FindGameObjectWithTag("Player").GetComponent <PirateMovement>().isgrounded = false;
                //GameObject.FindGameObjectWithTag("Player").GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, 900f));
                GameObject.FindGameObjectWithTag("Player").GetComponent <JoystickMovement>().activateJump();
            }
        }
    }
Exemple #5
0
 private void Awake()
 {
     instance = this;
 }