private void UpdatePart(GameObject o, DrawTask t) { o.layer = renderLayer; o.GetComponent <MeshFilter>().mesh = (t.mesh as VtsMesh).Get(); Material mat = o.GetComponent <MeshRenderer>().material; UpdateMaterial(mat); bool monochromatic = false; if (t.texColor != null) { var tt = t.texColor as VtsTexture; mat.SetTexture(shaderPropertyMainTex, tt.Get()); monochromatic = tt.monochromatic; } if (t.texMask != null) { var tt = t.texMask as VtsTexture; mat.SetTexture(shaderPropertyMaskTex, tt.Get()); } mat.SetMatrix(shaderPropertyUvMat, VtsUtil.V2U33(t.data.uvm)); mat.SetVector(shaderPropertyUvClip, VtsUtil.V2U4(t.data.uvClip)); mat.SetVector(shaderPropertyColor, VtsUtil.V2U4(t.data.color)); // flags: mask, monochromatic, flat shading, uv source mat.SetVector(shaderPropertyFlags, new Vector4(t.texMask == null ? 0 : 1, monochromatic ? 1 : 0, 0, t.data.externalUv ? 1 : 0)); VtsUtil.Matrix2Transform(o.transform, VtsUtil.V2U44(Math.Mul44x44(conv, System.Array.ConvertAll(t.data.mv, System.Convert.ToDouble)))); }
/// <summary> /// 水辺系のタイルを生成する。 /// </summary> /// <param name="pictbl">画像テーブル(画像はミニタイル(16x16)であること)</param> /// <param name="pictbl_l">使用する画像の左上(X-座標)</param> /// <param name="pictbl_t">使用する画像の左上(Y-座標)</param> /// <param name="animeKomaNum">アニメーションのコマ数(1~)</param> /// <param name="animeKomaCycle">アニメーションの1コマの表示時間(0~,フレーム数)</param> public Tile_水辺系(DDPicture[,] pictbl, int pictbl_l, int pictbl_t, int animeKomaNum, int animeKomaCycle) { _draw = new DrawTask() { PictureTable = pictbl, PictureTable_L = pictbl_l, PictureTable_T = pictbl_t, AnimeKomaNum = animeKomaNum, AnimeKomaCycle = animeKomaCycle, F_IsFriend = this.IsFriend, }; }
/// <summary> /// 森林系のタイル(2x2倍)を生成する。 /// </summary> /// <param name="pictbl">画像テーブル(画像はタイル(32x32)であること)</param> /// <param name="密集_l">「密集」画像の左上(X-座標)</param> /// <param name="密集_t">「密集」画像の左上(Y-座標)</param> /// <param name="単独_l">「単独」画像の左上(X-座標)</param> /// <param name="単独_t">「単独」画像の左上(Y-座標)</param> /// <param name="groundPicture">地面の画像</param> /// <param name="単独セルPicture">密集・単独を使用出来ないマップセル用の画像</param> public Tile_大森林系(DDPicture[,] pictbl, int 密集_l, int 密集_t, int 単独_l, int 単独_t, DDPicture groundPicture, DDPicture 単独セルPicture) { _draw = new DrawTask() { PictureTable = pictbl, 単独_L = 単独_l, 単独_T = 単独_t, 密集_L = 密集_l, 密集_T = 密集_t, GroundPicture = groundPicture, 単独セルPicture = 単独セルPicture, F_IsFriend = this.IsFriend, }; }
public static void BeginDrawEnd(this SpriteBatch sb, DrawTask task, GameTime gameTime = null, SpriteBatchBeginState state = null) { if (state != null) { sb.Begin(state); } else { sb.Begin(); } task(sb, gameTime); sb.End(); }
public async void Redraw() { if (DrawTask.Status == TaskStatus.Running) { _cancellationTokenSource?.Cancel(); } await Task.Run(() => { while (DrawTask.Status == TaskStatus.Running) { } }); // Clear canvas draw.Clear(); CalculateSizes(Width, Height); if (Volume == null || !sizesCalculated) { return; } //this._drawThread = new Thread(new ThreadStart(this.DrawBlocks)); //this.DrawThread.Start(); _cancellationTokenSource = new CancellationTokenSource(); _drawTask = new Task(DrawBlocks, _cancellationTokenSource.Token); DrawTask.Start(); await DrawTask; _cancellationTokenSource.Dispose(); _cancellationTokenSource = null; }