using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; using Materials = Rmake.Model.Materials; using Rmake.Framework.Logging; using Rmake.Model.Enums; using Rmake.Rendering.APIWrapper; using Rmake.Rendering.ComponentLayer; namespace Rmake.GameRendering { /// /// チップを敷き詰めたマップの描画をおこなうクラス /// public class TileViewWrapper : GameRenderingView { private TileView tileView = null; private TextViewWrapper textViewWrapper = null; internal override int LayerIndex { get { return tileView.LayerIndex; } set { tileView.LayerIndex = value; } } /// /// チップのサイズ /// public Size ChipSize { set{ tileView.ChipSize = value; } get{ return tileView.ChipSize; } } /// /// マップのサイズ /// public Size TileSize { set{ tileView.TileSize = value; } get{ return tileView.TileSize; } } /// /// 文字を書く位置のオフセット /// public Point TextOffset { set{ tileView.TextOffset = value; } get{ return tileView.TextOffset; } } /// /// 基本の色 /// public int BaseColor { get { return tileView.BaseColor; } set { tileView.BaseColor = value; } } /// /// マップの取得 /// public TileChip[][] Tile { get{ return tileView.Tile; } } /// /// x,yのマップが何番目のテクスチャーで描画されるかを取得 /// /// マップのx座標(マップチップ単位) /// マップのy座標(マップチップ単位) /// 何番目のテクスチャーかが返る public int GetTextureIndex(int x, int y) { return Tile[y][x].textureIndex; } /// /// x,yのマップを何番目のテクスチャーで描画するかの指定 /// /// マップのx座標(マップチップ単位) /// マップのy座標(マップチップ単位) /// 何番目のテクスチャーかを指定する public void SetTextureIndex(int x, int y, int textureIndex) { Tile[y][x].textureIndex = textureIndex; } /// /// マップチップのタイプを取得 /// /// マップのx座標(マップチップ単位) /// マップのy座標(マップチップ単位) /// /// チップの描画方法 /// 0: 通常描画 /// 1: 透明 /// 2: 海用 /// public int GetChipType(int x, int y) { return Tile[y][x].chipType; } /// /// マップチップのタイプを指定 /// /// マップのx座標(マップチップ単位) /// マップのy座標(マップチップ単位) /// /// チップの描画方法 /// 0: 通常描画 /// 1: 透明 /// 2: 海用 /// public void SetChipType(int x, int y, int chipType) { Tile[y][x].chipType = chipType; } /// /// マップチップのコピー元の取得 /// /// マップのx座標(マップチップ単位) /// マップのy座標(マップチップ単位) /// コピー元の座標(左上)をチップの幅と高さで割ったもの public Point GetP(int x, int y) { return Tile[y][x].p; } /// /// マップチップのコピー元の設定 /// /// マップのx座標(マップチップ単位) /// マップのy座標(マップチップ単位) /// コピー元の座標(左上)をチップの幅と高さで割ったもの public void SetP(int x, int y, Point p) { Tile[y][x].p = p; } /// /// マップチップに設定されている色の取得 /// /// マップのx座標(マップチップ単位) /// マップのy座標(マップチップ単位) /// マップチップに設定されている色 public int GetRectColor(int x, int y) { return Tile[y][x].rectColor; } /// /// マップチップの色の設定 /// /// マップのx座標(マップチップ単位) /// マップのy座標(マップチップ単位) /// マップチップの色 public void SetRectColor(int x, int y, int rectColor) { Tile[y][x].rectColor = rectColor; } /// /// マップチップの文字列の取得 /// /// マップのx座標(マップチップ単位) /// マップのy座標(マップチップ単位) /// マップチップの文字列 public string GetText(int x, int y) { return Tile[y][x].text; } /// /// マップチップの文字列の設定 /// /// マップのx座標(マップチップ単位) /// マップのy座標(マップチップ単位) /// マップチップの文字列 public void SetText(int x, int y, string text) { Tile[y][x].text = text; } /// /// マップチップの文字列の色の取得 /// /// マップのx座標(マップチップ単位) /// マップのy座標(マップチップ単位) /// マップチップの文字列の色 public int GetTextColor(int x, int y) { return Tile[y][x].textColor; } /// /// マップチップの文字列の色の設定 /// /// マップのx座標(マップチップ単位) /// マップのy座標(マップチップ単位) /// マップチップの文字列の色 public void SetTextColor(int x, int y, int textColor) { Tile[y][x].textColor = textColor; } /// /// テクスチャーの幅の取得 /// /// 何番目のテクスチャーかの指定 /// テクスチャーの幅 public int GetImageWidth(int idx) { return ((DividedTextureMesh)tileView.TextureMesh[idx]).ImageWidth; } /// /// テクスチャーの高さの取得 /// /// 何番目のテクスチャーかの指定 /// テクスチャーの高さ public int GetImageHeight(int idx) { return ((DividedTextureMesh)tileView.TextureMesh[idx]).ImageHeight; } /// /// 出力先のtextViewWrapperの設定 /// /// 出力先のtextViewWrapper public void SetTextViewWrapper(TextViewWrapper textViewWrapper) { this.textViewWrapper = textViewWrapper; if (textViewWrapper != null) { textViewWrapper.IsDependCamera = false; this.tileView.SetTextView(textViewWrapper.GetTextView()); } else this.tileView.SetTextView(null); } /// /// 出力先のtextViewWrapperの取得 /// /// 出力先のtextViewWrapper public TextViewWrapper GetTextViewWrapper() { return textViewWrapper; } public void SetTexture(int index, string fileName, bool leftTopTransparent) { tileView.SetTexture(index, fileName, leftTopTransparent); } public void SetTexture(int index, Materials.Material material) { string filename = Folders.GetMaterialFolder(material.MaterialType) + material.Filename; tileView.SetTexture(index, filename, material.IsTransparencyByTopLeftPixel); } public TileViewWrapper() { } internal void Initialize(TileView tileView) { this.tileView = tileView; } internal override void Finalize(GameRenderingManager manager) { manager.Manager.DeleteRenderView(tileView); } internal override void Render(GameRenderingManager manager) { } internal override void SetVisible(bool visible) { tileView.ViewVisible = visible; } } }