Exemplo n.º 1
0
 public GameScreen()
 {
     this.currView            = NormalView;
     this.currScreenColorInfo = new ScreenColorInfo();
     this.pictures            = new Dictionary <int, GamePicture>();
     this.targetToGameObject  = 0;
     this.targetToDuration    = -1;
     this.currTargetPos       = Vector2.zero;
 }
Exemplo n.º 2
0
    public void update()
    {
        // 更新镜头位置
        this.updateCurrPos();
        // 刷新色调
        if (this.isColorChanging())
        {
            this.screenColorTransformFrames -= 1;
            if (this.screenColorTransformFrames == 0)
            {
                this.currScreenColorInfo   = this.targetScreenColorInfo;
                this.targetScreenColorInfo = null;
            }
            else
            {
                this.currScreenColorInfo.brightness +=
                    (this.targetScreenColorInfo.brightness - this.currScreenColorInfo.brightness) / this.screenColorTransformFrames;
                this.currScreenColorInfo.contrast +=
                    (this.targetScreenColorInfo.contrast - this.currScreenColorInfo.contrast) / this.screenColorTransformFrames;
                this.currScreenColorInfo.saturation +=
                    (this.targetScreenColorInfo.saturation - this.currScreenColorInfo.saturation) / this.screenColorTransformFrames;
                this.currScreenColorInfo.hue +=
                    (this.targetScreenColorInfo.hue - this.currScreenColorInfo.hue) / this.screenColorTransformFrames;
            }
        }

        // 刷新视野
        if (currView < targetView)
        {
            currView = Mathf.Min(currView + (Util.GRID_WIDTH / Util.PPU) / 8, targetView);
        }
        if (currView > targetView)
        {
            currView = Mathf.Max(currView - (Util.GRID_WIDTH / Util.PPU) / 8, targetView);
        }

        // 刷新图片
        foreach (GamePicture pic in this.pictures.Values)
        {
            pic.update();
        }

        // 刷新震动
        if (this.isShaking())
        {
            // 移动位置X
            this.shakePosX += this.shakeDirX;
            if (this.shakePosX > this.shakePower * 2)
            {
                this.shakeDirX        = -1;
                this.shakeRandOffsetX = UnityEngine.Random.Range(-this.shakePower, this.shakePower);
            }
            else if (this.shakePosX < -this.shakePower * 2)
            {
                this.shakeDirX        = 1;
                this.shakeRandOffsetX = UnityEngine.Random.Range(-this.shakePower, this.shakePower);
            }
            // 移动位置y
            this.shakePosY += this.shakeDirY;
            if (this.shakePosY > this.shakePower * 2)
            {
                this.shakeDirY        = -1;
                this.shakeRandOffsetY = UnityEngine.Random.Range(-this.shakePower, this.shakePower);
            }
            else if (this.shakePosY < -this.shakePower * 2)
            {
                this.shakeDirY        = 1;
                this.shakeRandOffsetY = UnityEngine.Random.Range(-this.shakePower, this.shakePower);
            }
            // 帧步进
            this.shakeDuration -= 1;
            // 位置还原
            if (this.shakeDuration == 0)
            {
                this.shakePosX = 0;
                this.shakePosY = 0;
            }
        }
    }
Exemplo n.º 3
0
 /// <summary>
 /// 转换画面色调
 /// </summary>
 /// <param name="info">Info.</param>
 /// <param name="time">Time.</param>
 public void screenColorChange(ScreenColorInfo info, int time)
 {
     this.targetScreenColorInfo      = info;
     this.screenColorTransformFrames = time;
 }