using System; using System.Collections; using System.Collections.Generic; using Rmake.Model.Casts; using Rmake.Model.Configurations; using Rmake.Model.Enums; using Rmake.Model.Maps; using Rmake.Model.Materials; using System.Drawing; namespace Rmake.Model { /// /// 作成するゲームを管理するクラス。 /// [Serializable()] public class Game : BaseEntity { #region Fields private List maps = null; private List mapchipSets = null; private List characters = null; private List items = null; private List magics = null; private List equipmentPoints = null; private Map startMap = null; private int layerIndex = 1; private Point startPosition = new Point(10, 8); // private Material splashImage = null; private MaterialManager materialManager = null; private Glossaries glossaries = null; // private MapManager mapManager = null; // ゲーム設定用情報 private String profile = ""; private Material startMusic = null; private Party startParty = null; private int walkingSpeed = 1; private bool isFullScreen = false; #endregion Fields #region Properties public List Maps { get { return maps; } } public List MapchipSets { get { return mapchipSets; } } public int WalkingSpeed { get {return walkingSpeed;} set {walkingSpeed = value;} } public bool IsFullScreen { get {return isFullScreen;} set {isFullScreen = value;} } // ゲーム設定用情報 public String Profile { get {return profile;} set {profile = value;} } public Map StartMap { get { return startMap; } set { startMap = value; } } public int LayerIndex { get { return layerIndex; } set { layerIndex = value; } } public Point StartPosition { get { return startPosition; } set { startPosition = value; } } public Material StartMusic { get {return startMusic;} set {startMusic = value;} } public Party StartParty { get {return startParty;} set {startParty = value;} } public List Characters { get {return characters;} } public List Items { get {return items;} } public List Magics { get {return magics;} } public List EquipmentPoints { get {return equipmentPoints;} } public Glossaries GlossaryList { get {return glossaries;} set {glossaries = value;} } /* public MapManager MapManagers { get { return mapManager; } } */ /// /// 素材のリスト /// public MaterialManager Materials { get {return materialManager;} set {materialManager = value;} } public Material SplashImage { get { return this.Materials.GetMaterialByFileName(MaterialTypes.SystemImage, "Splash.bmp"); } } #endregion Properties /// /// Unique な ID の初期値は 10000 /// Game は無条件に 9999 になる。 /// public const Int64 DefaultID = 9999; /// /// 最新の Unique な ID(永続化用) /// private IDGenerator idGenerator = null; public IDGenerator Generator { get {return idGenerator;} } /// /// 永続化専用の Constructor /// private Game() : base(-1) { // mapManager = new MapManager(); } /// /// 唯一のコンストラクタ。 /// public Game(Int64 id) : base(DefaultID) { idGenerator = new IDGenerator(DefaultID); Name = "Default"; characters = new List(); items = new List(); magics = new List(); maps = new List(); mapchipSets = new List(); equipmentPoints = new List(); // materialManager = new MaterialManager(); glossaries = new Glossaries(-1); // mapManager = new MapManager(); // 初期歩行速度 walkingSpeed = 3; } public MapchipSet GetMapChipByID(Int64 id) { foreach (MapchipSet mapchip in MapchipSets) { if (mapchip.ID == id) { return mapchip; } } return null; } /* public void RemoveMap(Map map) { rootMap.ChildMaps.Remove(map); for (int i = 0; i < rootMap.ChildMaps.Count; i++) { ((Map)rootMap.ChildMaps[i]).Remove(map); } } * */ public BaseEntity RemoveEntity(BaseEntity entity) { BaseEntity removed = null; if ((entity as Map != null) && (maps.Contains((Map) entity))) { maps.Remove((Map)entity); removed = entity; } if ((entity as MapchipSet != null) && (mapchipSets.Contains((MapchipSet)entity))) { mapchipSets.Remove((MapchipSet)entity); removed = entity; } if ((entity as Character != null) && (characters.Contains((Character)entity))) { characters.Remove((Character)entity); removed = entity; } if ((entity as Item != null) && (items.Contains((Item)entity))) { items.Remove((Item)entity); removed = entity; } if ((entity as Magic != null) && (magics.Contains((Magic)entity))) { magics.Remove((Magic)entity); removed = entity; } if ((entity as EquipmentPoint != null) && (equipmentPoints.Contains((EquipmentPoint)entity))) { equipmentPoints.Remove((EquipmentPoint)entity); removed = entity; } return removed; } public BaseEntity RemoveEntityByID(Int64 id) { BaseEntity removed = null; /* if (characters.Contains(id)) { removed = (BaseEntity)characters[id]; characters.Remove(id); } if (items.Contains(id)) { removed = (BaseEntity)items[id]; items.Remove(id); } if (magics.Contains(id)) { removed = (BaseEntity)magics[id]; magics.Remove(id); } if (equipmentPoints.Contains(id)) { removed = (BaseEntity)equipmentPoints[id]; equipmentPoints.Remove(id); } if (mapchipSets.Contains(id)) { removed = (BaseEntity)mapchipSets[id]; mapchipSets.Remove(id); } // Start Map は削除できない /* if (maps.Contains(id)) { removed = (BaseEntity)maps[id]; if (StartMap.ID != removed.ID) { maps.Remove(id); } else { removed = null; } } * */ return removed; } } }