예제 #1
0
    // Update is called once per frame
    void Update()
    {
        // Update position (x,y)
        if (_move_left)
        {
            x -= moveSpeed;
        }
        if (_move_right)
        {
            x += moveSpeed;
        }
        if (_move_top)
        {
            y += moveSpeed;
        }
        if (_move_bottom)
        {
            y -= moveSpeed;
        }

        // Check position (x,y)
        if (x < -hw)
        {
            x = -hw;
        }
        else if (x > hw)
        {
            x = hw;
        }
        if (y < -hh)
        {
            y = -hh;
        }
        else if (y > hh)
        {
            y = hh;
        }

        // Update transform view
        viewTrans.localPosition = new Vector3(x, y, 0);

        float lt_x = x + hw;
        float lt_y = y + hh;

        kit.UpdateRange((int)lt_x, (int)lt_y, view_r);
        /// 为了测试,令视野大小等于地图大小,且固定视野最小点为(0,0)点
        kit.UpdateView(maskPic.material, 0, 0);

        kit.RefreshView();
        kit.RefreshMaskTexture2D(fogTexture);
        kit.CleanData();
    }
예제 #2
0
 /// <summary>
 /// 根据刷子的半径及坐标更新battlefieldAlpha数组,并记录viewAlpha变动点
 /// </summary>
 /// <param name="x">刷新圆心x坐标</param>
 /// <param name="y">刷新圆心y坐标</param>
 /// <param name="r">刷新圆半径</param>
 private void PixelUpdate(int x, int y, int r)
 {
     kit.UpdateRange(x, y, r);
 }