コード例 #1
0
    void Start()
    {
        //Debug.Log ("pass="******",star="+star);
//		if (lightSprite == null) {
//			Sprite sp = Resources.Load ("levelImage/lightSprite", typeof(Sprite)) as Sprite;
//			lightSprite = sp;
//		}
//		if (offSprite == null) {
//			Sprite sp = Resources.Load ("levelImage/offSprite", typeof(Sprite)) as Sprite;
//			offSprite = sp;
//		}
        Text level = transform.Find("level").GetComponent <Text>();

        level.text = ((pass - 1) / BigPass + 1) + "-" + ((pass - 1) % BigPass + 1);
        if (isOpen)
        {
            for (int i = 0; i < starImages.Length; i++)
            {
                if (star > i)
                {
                    starImages[i].sprite = SpriteCache.getLightSprite();
                }
                else
                {
                    starImages[i].sprite = SpriteCache.getOffSprite();
                }
            }
        }
        else
        {
            transform.Find("stars").gameObject.SetActive(false);
        }
    }
コード例 #2
0
    private void _checkEatBean(string userId, int pos)
    {
        int x = pos / size;
        int y = pos % size;

        if (beanMap [x] [y] != null)
        {
            Sound.playSound(SoundType.EatBean);
            Destroy(beanMap [x] [y].go);              // 计算在玩家身上,并做出相应的效果
            int addScore = beanMap [x] [y].score * pacmanMap [userId].mulBean;
            if (Mode == MapMode.Level || Mode == MapMode.Unlimited)
            {
                float old = starSlider.value;
                starSlider.value = starSlider.value + addScore;
//				Text scoreText = starSlider.transform.Find ("score").GetComponent<Text> ();
                showScore.text = starSlider.value + "";
                // 点亮星星
                for (int i = 1; i < 5; i++)
                {
                    int score = stars [i - 1];
                    if (score > old && score <= starSlider.value)                       // -1的自然就不会点亮
                    // 点亮
                    {
                        Image image = starSlider.transform.parent.Find("star" + i).GetComponent <Image>();
//						image.color = new Color (255,255,255);
                        image.sprite = SpriteCache.getLightSprite();
                    }
                }
            }
            else if (Mode == MapMode.Online)
            {
                scoreText [userId].text = int.Parse(scoreText [userId].text) + addScore + "";
            }
            pacmanMap [userId].score += addScore;
            Debug.Log("score:" + pacmanMap [userId].score);
            beanMap [x] [y] = null;
        }
    }