Exemplo n.º 1
0
    /// <summary>
    /// 唤醒的时候
    /// </summary>
    private void Awake()
    {
        int nowMap = PlayerPrefUtil.GetNowMap();

        GetComponent <Camera>().backgroundColor =
            new Color(colorArr[nowMap, 0] / 255, colorArr[nowMap, 1] / 255, colorArr[nowMap, 2] / 255);
    }
Exemplo n.º 2
0
    private AudioSource audioSource;         //声音源组件


    private void Awake()
    {
        audioSource = GetComponent <AudioSource>();

        int nowMap = PlayerPrefUtil.GetNowMap();

        audioSource.clip = backGroundMusic[nowMap]; //设置背景音乐
    }
Exemplo n.º 3
0
    /// <summary>
    /// 保存分数
    /// </summary>
    public void SaveScore()
    {
        int highestScore = PlayerPrefUtil.GetNowMapLevelScore();

        if (nowScore > highestScore)
        {
            PlayerPrefUtil.SetNowMapLevelHighestScore(nowScore); //保存一下最高分
        }
    }
Exemplo n.º 4
0
 public void Select()
 {
     if (isSelect)
     {
         AudioUtil.sInstance.AudioPlay(selectAudio); //播放选择的声音
         PlayerPrefUtil.SetNowMap(nowIndex);         //存储一下当前地图索引
         Back.sInstance.SwitchPanels(nowIndex);      //切换一下面板
     }
 }
Exemplo n.º 5
0
    /// <summary>
    /// 将星星存储一下
    /// </summary>
    private void saveStar(int num)
    {
        int starNum = PlayerPrefUtil.GetNowMapLevelStarNum(); //得到星星数

        if (num > starNum)
        {
            PlayerPrefUtil.addTotalStar(num - starNum);       //添加总星星
            PlayerPrefUtil.addNowMapTotalStar(num - starNum); //添加当前地图星星
            PlayerPrefUtil.SetNowMapLevelStarNum(num);        //设置星星数
        }
    }
Exemplo n.º 6
0
    private void Start()
    {
        hasVoice = PlayerPrefUtil.isVoice();

        if (!hasVoice)
        {
            audioSource.Stop(); //停止播放音乐
        }
        else
        {
            audioSource.Play(); //播放音乐
        }
    }
Exemplo n.º 7
0
    /// <summary>
    /// 设置当前关卡
    /// </summary>
    public void SetNowIndex(int nowIndex)
    {
        this.nowIndex = nowIndex; //设置当前关卡的索引
        if (nowIndex == 0)
        {
            isSelected = true; //选择了
        }
        else
        {
            int starNum = PlayerPrefUtil.GetMapLevelStarNum(mapIndex, nowIndex - 1); //得到上一关卡星星数

            if (starNum > 0)                                                         //如果上一个关卡的星星数大于0那么解锁本关
            {
                isSelected = true;
            }
        }


        if (isSelected)
        {
            GetComponent <Image>().overrideSprite = levelBg;                      //替换下背景
            GameObject textObj    = transform.GetChild(1).gameObject;             //找到数字子物体
            Image      starNumImg = transform.GetChild(0).GetComponent <Image>(); //星星数图片
            starNumImg.gameObject.SetActive(true);                                //启用
            textObj.SetActive(true);                                              //启用

            textObj.GetComponent <Text>().text = nowIndex + 1 + "";               //设置关卡文本

            int starNum = PlayerPrefUtil.GetLevelStarNum(nowIndex);               //得到当前关卡星星数

            switch (starNum)
            {
            case 0:
                starNumImg.overrideSprite = starNone;
                break;

            case 1:
                starNumImg.overrideSprite = starOne;
                break;

            case 2:
                starNumImg.overrideSprite = starTwo;
                break;

            case 3:
                starNumImg.overrideSprite = starThree;
                break;
            }
        }
    }
Exemplo n.º 8
0
 /// <summary>
 /// 改变声音选项
 /// </summary>
 public void ChangeVoice()
 {
     AudioUtil.sInstance.hasVoice = !PlayerPrefUtil.isVoice();
     PlayerPrefUtil.setVoice(AudioUtil.sInstance.hasVoice); //设置一下声音变量
     if (AudioUtil.sInstance.hasVoice)
     {
         AudioUtil.sInstance.PlayBGM();                     //播放背景音乐
         transform.GetChild(0).gameObject.SetActive(false); //有声音
     }
     else
     {
         AudioUtil.sInstance.StopPlayBGM();                //停止背景音乐
         transform.GetChild(0).gameObject.SetActive(true); //静音
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// 鼠标点击之后的选择事件
 /// </summary>
 public void Select()
 {
     if (isSelected)
     {
         PlayerPrefUtil.SetNowLevel(nowIndex); //设置当前关卡
         if (nowIndex == 0)
         {
             SceneLoadUtil.LoadStoreScene(); //加载故事场景
         }
         else
         {
             SceneLoadUtil.LoadGameScene(); //加载游戏场景
         }
     }
 }
Exemplo n.º 10
0
    public GameObject nextBt;  //主页按钮

    /// <summary>
    /// 显示的时候
    /// </summary>
    private void Start()
    {
        int nowLevel = PlayerPrefUtil.GetNowLevel(); //当前关卡
        int nowMap   = PlayerPrefUtil.GetNowMap();   //当前地图

        int sumLevel = GameLevelUtil.sLevelNumArray[nowMap];

        if (nowLevel + 1 == sumLevel)
        {
            nextBt.SetActive(false);                                                        //失活
            homeBt.GetComponent <RectTransform>().anchoredPosition =
                new Vector2(-60, homeBt.GetComponent <RectTransform>().anchoredPosition.y); //重新定位
            retryBt.GetComponent <RectTransform>().anchoredPosition =
                new Vector2(60, retryBt.GetComponent <RectTransform>().anchoredPosition.y);
        }
    }
Exemplo n.º 11
0
    private GameObject scoreNum;        //成绩的数字

    /// <summary>
    /// 唤醒的时候
    /// </summary>
    private void Awake()
    {
        sInstance = this;
        highScore = transform.parent.Find("HighScore").gameObject; //得到最高分
        highNum   = highScore.transform.Find("num").gameObject;    //最高分数字
        scoreNum  = transform.Find("num").gameObject;              //存放数字的地方

        int highestScore = PlayerPrefUtil.GetNowMapLevelScore();

        if (highestScore != 0)
        {
            highScore.SetActive(true);                               //可见
            AddScoreImage(highestScore, highNum.transform, -25, 10); //加到最高分上
        }
        else
        {
            highScore.SetActive(false); //不可见
        }
    }
Exemplo n.º 12
0
    /// <summary>
    /// 设置当前是哪个关卡
    /// </summary>
    /// <param name="nowIndex"></param>
    public void SetNowIndex(int nowIndex)
    {
        this.nowIndex = nowIndex;

        if (PlayerPrefUtil.GetTotalStars() >= needStartNum)
        {
            isSelect = true;
        }

        needStarsText.text = needStartNum + ""; //设进去

        if (isSelect)
        {
            lockImg.SetActive(false); //失活
            stars.SetActive(true);    //启用

            int mapTotalStars = PlayerPrefUtil.GetMapTotalStars(nowIndex);
            int levelNum      = GameLevelUtil.sLevelNumArray[nowIndex]; //得到关卡数
            hasStarsCount.text = mapTotalStars + "/" + levelNum * 3;    //设置文本
        }
    }
Exemplo n.º 13
0
        /// <summary>
        /// 唤醒的时候
        /// </summary>
        private void Awake()
        {
            int nowMap = PlayerPrefUtil.GetNowMap();               //当前地图

            transform.GetChild(nowMap).gameObject.SetActive(true); //激活游戏介绍
        }
Exemplo n.º 14
0
 private void Awake()
 {
     Instantiate(Resources.Load(PlayerPrefUtil.GetNowMapLevelName())); //加载关卡
 }
Exemplo n.º 15
0
 /// <summary>
 ///下一关
 /// </summary>
 public void NextLevel()
 {
     Time.timeScale = 1;                                           // timeScale 恢复正常
     PlayerPrefUtil.SetNowLevel(PlayerPrefUtil.GetNowLevel() + 1); //下一关
     SceneLoadUtil.LoadGameScene();                                //重新加载自己
 }