コード例 #1
0
ファイル: TerrainEntry.cs プロジェクト: kidsang/ProjectJ
 public void Load(TerrainFlagInfo info)
 {
     ColorField.color = info.Color;
     NameField.text = info.Name;
     FlagField.text = info.FlagName;
     Flag = info.Flag;
 }
コード例 #2
0
ファイル: TerrainFlagInfo.cs プロジェクト: kidsang/ProjectJ
 public static string GetNameByFlag(MapCellFlag flag)
 {
     TerrainFlagInfo info = GetInfoByFlag(flag);
     if (info != null)
         return info.Name;
     return "未知地形";
 }
コード例 #3
0
ファイル: TerrainFlagInfo.cs プロジェクト: kidsang/ProjectJ
 public static Color GetColorByFlag(MapCellFlag flag)
 {
     TerrainFlagInfo info = GetInfoByFlag(flag);
     if (info != null)
         return info.Color;
     return Color.black;
 }
コード例 #4
0
ファイル: TerrainFlagInfo.cs プロジェクト: kidsang/ProjectJ
 public TerrainFlagInfo(MapCellFlag flag, string name, Color color)
 {
     Flag = flag;
     Name = name;
     FlagName = Enum.GetName(typeof(MapCellFlag), flag);
     Color = color;
 }
コード例 #5
0
ファイル: TerrainFlagInfo.cs プロジェクト: kidsang/ProjectJ
 public static TerrainFlagInfo GetInfoByFlag(MapCellFlag flag)
 {
     foreach (TerrainFlagInfo info in Infos)
     {
         if (info.Flag == flag)
             return info;
     }
     return null;
 }
コード例 #6
0
        public void Load(TerrainFlagInfo info)
        {
            Flag = info.Flag;
            Color = Color.FromRgb((byte)(info.Color.r * 255), (byte)(info.Color.g * 255), (byte)(info.Color.b * 255));

            ColorBlock.Background = new SolidColorBrush(Color);
            NameField.Content = info.Name;
            TypeField.Content = info.FlagName;

            int visibleFlags = Properties.Settings.Default.TerrainVisibleFlags;
            CheckField.IsChecked = EditorUtils.HasFlag(visibleFlags, (int)Flag);
        }
コード例 #7
0
ファイル: SceneDataProxy.cs プロジェクト: kidsang/ProjectJ
        public void SetTerrainFlag(int x, int y, int radius, MapCellFlag flag, bool apply)
        {
            Dictionary<int, MapCellSetting> cellSettings = MapUtils.ArrayToDict(MapData.Cells);
            EditorMap map = GameEditor.Instance.Map;
            Vector2[] locations = MapUtils.Circle(x, y, radius);
            foreach (Vector2 location in locations)
            {
                MapCell cell = map.GetCell(location);
                if (cell == null)
                    continue;

                if (apply)
                {
                    MapCellSetting cellSetting;
                    if (!cellSettings.TryGetValue(cell.Key, out cellSetting))
                    {
                        cellSetting = new MapCellSetting();
                        cellSetting.X = cell.X;
                        cellSetting.Y = cell.Y;
                        cellSettings.Add(cell.Key, cellSetting);
                    }
                    EditorUtils.SetFlag(ref cellSetting.Flags, (int)flag, apply);
                }
                else
                {
                    MapCellSetting cellSetting;
                    if (cellSettings.TryGetValue(cell.Key, out cellSetting))
                    {
                        EditorUtils.SetFlag(ref cellSetting.Flags, (int)flag, apply);
                        if (cellSetting.Flags == 0)
                            cellSettings.Remove(cell.Key);
                    }
                }
            }

            MapData.Cells = MapUtils.DictToArray(cellSettings);

            InfoMap infos = new InfoMap();
            infos["flag"] = flag;
            Modify(EditorEvent.MAP_TERRAIN_UPDATE, infos);
        }
コード例 #8
0
ファイル: MapCell.cs プロジェクト: kidsang/ProjectJ
 public void SetFlag(MapCellFlag flag, bool value)
 {
     if (value)
         Flags = Flags | (int)flag;
     else
         Flags = Flags & (~(int)flag);
 }
コード例 #9
0
ファイル: MapCell.cs プロジェクト: kidsang/ProjectJ
 public bool HasFlag(MapCellFlag flag)
 {
     return (Flags & (int)flag) != 0;
 }
コード例 #10
0
ファイル: EditorMap.cs プロジェクト: kidsang/ProjectJ
        public void ToggleShowTerrain(MapCellFlag flag, bool show)
        {
            Transform root;
            if (show)
            {
                int markIndex;
                if (!terrainRoots.TryGetValue(flag, out root))
                {
                    root = new GameObject("Terrain_" + Enum.GetName(typeof(MapCellFlag), flag)).transform;
                    root.SetParent(terrainRoot, false);
                    terrainRoots.Add(flag, root);

                    List<int> indices = terrainMaskIndices.Values.ToList();
                    for (markIndex = 0; ; ++markIndex)
                    {
                        if (indices.IndexOf(markIndex) < 0)
                            break;
                    }
                    terrainMaskIndices[flag] = markIndex;
                }
                else
                {
                    markIndex = terrainMaskIndices[flag];
                }

                root.localPosition = new Vector3(0, 0, markIndex * -0.1f);
                float scale = Mathf.Max(0.2f, 1 - markIndex * 0.2f);

                Color color = TerrainFlagInfo.GetColorByFlag(flag);
                List<MapCell> cells = GetCellsByFlag(flag);
                int cellCount = cells.Count;
                int childCount = root.childCount;
                for (int i = 0; i < cellCount; ++i)
                {
                    MapCell cell = cells[i];
                    Transform terrainMark;
                    if (i >= childCount)
                    {
                        GameObject terrainMarkObj = Loader.LoadPrefab("Map/TerrainMark").Instantiate();
                        terrainMarkObj.GetComponent<SpriteRenderer>().color = color;
                        terrainMark = terrainMarkObj.transform;
                        terrainMark.SetParent(root, false);
                    }
                    else
                    {
                        terrainMark = root.GetChild(i);
                    }
                    terrainMark.position = cell.Position;
                    terrainMark.Translate(0, 0, -terrainMark.localPosition.z);
                    terrainMark.localScale = new Vector3(scale, scale);
                }

                for (int i = cellCount; i < childCount; ++i)
                    Destroy(root.GetChild(i).gameObject);
            }
            else
            {
                if (terrainRoots.TryGetValue(flag, out root))
                {
                    Destroy(root.gameObject);
                    terrainRoots.Remove(flag);
                    terrainMaskIndices.Remove(flag);
                }
            }
        }
コード例 #11
0
ファイル: EditorMap.cs プロジェクト: kidsang/ProjectJ
 private List<MapCell> GetCellsByFlag(MapCellFlag flag)
 {
     List<MapCell> ret = new List<MapCell>();
     foreach (MapCell cell in Cells.Values)
     {
         if (cell.HasFlag(flag))
             ret.Add(cell);
     }
     return ret;
 }