コード例 #1
0
ファイル: MapSdk.cs プロジェクト: nogu3ira/essence-udk
        public void LoadFromXML(string file)
        {
            var serializer = new SoapFormatter();

            NotificationObject[] collections;
            using (var strema = new FileStream(file, FileMode.Open))
            {
                collections = (NotificationObject[])serializer.Deserialize(strema);
            }
            CollectionAreaTexture = (CollectionAreaTexture)collections[0];
            CollectionColorArea   = (CollectionAreaColor)collections[1];

            foreach (var area in CollectionColorArea.List)
            {
                area.PropertyChanged += EventUpdateList;
            }

            if (CollectionAreaTexture != null)
            {
                CollectionAreaTexture.InitializeSeaches();
            }
            if (CollectionColorArea != null)
            {
                CollectionColorArea.InitializeSeaches();
            }

            EventUpdateList(this, null);

            if (CollectionAreaTexture != null && CollectionAreaTexture.List.First().AreaTransitionTexture.List.Count == 0)
            {
                foreach (var area in CollectionColorArea.List)
                {
                    foreach (var transition in area.TextureTransitions)
                    {
                        var texture = CollectionAreaTexture.FindByIndex(area.TextureIndex);
                        var areaTo  = CollectionColorArea.FindByColor(transition.ColorTo);
                        if (areaTo != null)
                        {
                            transition.TextureIdTo = areaTo.TextureIndex;
                        }

                        if (!texture.AreaTransitionTexture.List.Contains(transition))
                        {
                            texture.AreaTransitionTexture.List.Add(transition);
                        }
                    }
                    area.TextureTransitions.Clear();

                    foreach (var transitem in area.TransitionItems)
                    {
                        var texture = CollectionAreaTexture.FindByIndex(area.TextureIndex);
                        if (texture == null)
                        {
                            continue;
                        }
                        var areaTo = CollectionColorArea.FindByColor(transitem.ColorTo);
                        if (areaTo != null)
                        {
                            transitem.TextureIdTo = areaTo.TextureIndex;
                        }
                        if (texture.CollectionAreaItems == null)
                        {
                            texture.CollectionAreaItems = new CollectionAreaTransitionItems();
                        }
                        if (!texture.CollectionAreaItems.List.Contains(transitem))
                        {
                            texture.CollectionAreaItems.List.Add(transitem);
                        }
                    }

                    area.TransitionItems.Clear();
                }
            }
        }
コード例 #2
0
ファイル: MapSdk.cs プロジェクト: nogu3ira/essence-udk
        private void MergingData()
        {
            #region AreaColors

            if (CollectionColorArea == null)
            {
                return;
            }

            CollectionColorArea.List.CollectionChanged += EventUpdateList;

            foreach (var area in CollectionColorArea.List)
            {
                area.Type             = TypeColor.Land;
                area.PropertyChanged += EventUpdateList;
            }

            CollectionColorArea.InitializeSeaches();

            if (CollectionColorMountains != null)
            {
                foreach (var mnt in CollectionColorMountains.List)
                {
                    mnt.Type = TypeColor.Moutains;
                    var area = CollectionColorArea.FindByColor(mnt.Color);
                    if (area == null)
                    {
                        mnt.Index = CollectionColorArea.List.Count;
                        CollectionColorArea.List.Add(mnt);
                    }
                    else
                    {
                        int index = area.Index;
                        CollectionColorArea.List.Remove(area);
                        mnt.Name  = area.Name;
                        mnt.Index = index;
                        CollectionColorArea.List.Insert(index, mnt);
                        CollectionColorArea.InitializeSeaches();
                    }
                }
            }


            CollectionColorArea.InitializeSeaches();
            if (CollectionColorCoast != null)
            {
                foreach (var coast in CollectionColorCoast.List)
                {
                    var area = CollectionColorArea.FindByColor(coast.Color);
                    if (area != null)
                    {
                        area.Type = TypeColor.Water;
                        area.Min  = coast.Min;
                        area.Max  = coast.Max;
                    }
                    else
                    {
                        coast.Index = CollectionColorArea.List.Count;
                        CollectionColorArea.List.Add(coast);
                        coast.Type = TypeColor.Water;
                        CollectionColorArea.InitializeSeaches();
                    }
                }
            }

            #endregion //Colors

            #region Textures
            if (CollectionAreaTransitionTexture != null)
            {
                foreach (var transition in CollectionAreaTransitionTexture.List)
                {
                    var area = CollectionColorArea.FindByColor(transition.ColorFrom);
                    if (area == null)
                    {
                        continue;
                    }

                    area.TextureTransitions.Add(transition);
                    var area2 = CollectionColorArea.FindByColor(transition.ColorTo);
                    if (area2 == null)
                    {
                        continue;
                    }

                    transition.IndexTo = area2.Index;
                }
            }
            if (CollectionAreaTransitionCliffTexture != null)
            {
                var colorclif = new AreaColor {
                    Color = CollectionAreaTransitionCliffTexture.Color, Type = TypeColor.Cliff, Name = "Cliff", Index = CollectionColorArea.List.Count
                };
                CollectionColorArea.List.Add(colorclif);

                CollectionColorArea.InitializeSeaches();

                foreach (var cliff in CollectionAreaTransitionCliffTexture.List)
                {
                    var area = CollectionColorArea.FindByColor(cliff.ColorFrom);
                    if (area == null)
                    {
                        continue;
                    }

                    area.TransitionCliffTextures.Add(cliff);

                    var areato = CollectionColorArea.FindByColor(cliff.ColorTo);
                    if (areato == null)
                    {
                        continue;
                    }
                    cliff.IdTo = areato.Index;
                }
            }

            CollectionAreaTexture.InitializeSeaches();

            #endregion //Textures

            #region Items
            if (CollectionAreaItems != null)
            {
                foreach (var items in CollectionAreaItems.List)
                {
                    var area = CollectionColorArea.FindByColor(items.Color);
                    if (area == null)
                    {
                        continue;
                    }

                    area.Items = items;
                }
            }
            if (CollectionAreaItemsCoasts != null)
            {
                foreach (var coast in CollectionAreaItemsCoasts.List)
                {
                    var area = CollectionColorArea.FindByColor(coast.Ground.Color);

                    if (area == null)
                    {
                        continue;
                    }

                    area.Coasts = coast;
                }
            }
            if (CollectionAreaTransitionItems != null)
            {
                foreach (var itemtransition in CollectionAreaTransitionItems.List)
                {
                    var area = CollectionColorArea.FindByColor(itemtransition.ColorFrom);

                    if (area == null)
                    {
                        continue;
                    }

                    area.TransitionItems.Add(itemtransition);
                }
            }

            #endregion


            if (CollectionAreaTexture != null)
            {
                CollectionAreaTexture.InitializeSeaches();
            }
            if (CollectionColorArea != null)
            {
                CollectionColorArea.InitializeSeaches();
            }

            EventUpdateList(this, null);

            if (CollectionAreaTexture != null && CollectionAreaTexture.List.First().AreaTransitionTexture.List.Count == 0)
            {
                foreach (var area in CollectionColorArea.List)
                {
                    foreach (var transition in area.TextureTransitions)
                    {
                        var texture = CollectionAreaTexture.FindByIndex(area.TextureIndex);
                        var chiappa = CollectionColorArea.FindByColor(transition.ColorTo);
                        if (chiappa != null)
                        {
                            transition.TextureIdTo = chiappa.TextureIndex;
                        }

                        if (!texture.AreaTransitionTexture.List.Contains(transition))
                        {
                            texture.AreaTransitionTexture.List.Add(transition);
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: MapSdk.cs プロジェクト: nogu3ira/essence-udk
        public void MapMake(string directory, string bitmaplocation, string bitmapZLocation, int x, int y, int index)
        {
            CollectionColorArea.InitializeSeaches();
            CollectionAreaTexture.InitializeSeaches();
            var list_errors = new List <string>();

            foreach (var VARIABLE in CollectionColorArea.List)
            {
                Elements.Textures.TextureArea.AreaTextures area;
                CollectionAreaTexture._fast.TryGetValue(VARIABLE.TextureIndex, out area);
                if (VARIABLE.Max < VARIABLE.Min)
                {
                    var tmp = VARIABLE.Max;
                    VARIABLE.Max = VARIABLE.Min;
                    VARIABLE.Min = tmp;
                }

                if (area != null || VARIABLE.Type == TypeColor.Cliff)
                {
                    continue;
                }

                var error = VARIABLE.Name + @" refers to a non-existent texture '" + VARIABLE.TextureIndex + @"' not found";
                list_errors.Add(error);
            }

            if (list_errors.Count > 0)
            {
                string errors = "";
                foreach (var error_in in list_errors)
                {
                    errors += error_in + '\n';
                }

                throw new Exception(errors);
            }

            var task = new Task[2];



            var taskMapBitmap =
                Task <AreaColor[]> .Factory.StartNew(() => BitmapReader.ColorsFromBitmap(CollectionColorArea,
                                                                                         bitmaplocation, x, y));

            var taskMapZ = Task <sbyte[]> .Factory.StartNew(() => BitmapReader.AltitudeFromBitmapVersion2(bitmapZLocation, x, y));

            task[0] = taskMapBitmap;
            task[1] = taskMapZ;
            try
            {
                Task.WaitAll(task);
            }
            catch (Exception e)
            {
                throw e;
            }
            GC.Collect();

            var mulmaker = new MapMaking.MapMaker(taskMapZ.Result, taskMapBitmap.Result, x, y, index)
            {
                CollectionAreaColor = CollectionColorArea,
                TextureAreas        = CollectionAreaTexture,
                AutomaticZMode      = AutomaticMode,
                MulDirectory        = directory
            };

            mulmaker.ProgressText += EventProgress;

            try
            {
                mulmaker.Bmp2Map();
                OnMakingMap(EventArgs.Empty);
            }
            catch (Exception e)
            {
                throw e;
            }
            GC.Collect();
        }
コード例 #4
0
ファイル: MapSdk.cs プロジェクト: nogu3ira/essence-udk
        public void Populate()
        {
            #region Textures

            if (FactoryTextureArea != null)
            {
                FactoryTextureArea.Read();
                CollectionAreaTexture = FactoryTextureArea.Textures;
            }
            if (FactoryTextureSmooth != null)
            {
                FactoryTextureSmooth.Read();
                CollectionAreaTransitionTexture = FactoryTextureSmooth.Smooth;
            }

            if (FactoryCliff != null)
            {
                FactoryCliff.Read();
                CollectionAreaTransitionCliffTexture = FactoryCliff.CollectionAreaCliffs;
            }


            #endregion

            #region colorread

            if (FactoryColor != null)
            {
                FactoryColor.Read();
                CollectionColorArea = FactoryColor.Areas;
            }


            if (CollectionColorArea != null)
            {
                CollectionColorArea.InitializeSeaches();
            }

            if (FactoryCoast != null)
            {
                FactoryCoast.Read();
                CollectionColorCoast = FactoryCoast.Area;
            }

            if (FactoryMountains != null)
            {
                FactoryMountains.Read();
                CollectionColorMountains = FactoryMountains.Mountains;
            }

            #endregion

            #region items

            if (FactoryItems != null)
            {
                FactoryItems.Read();
                CollectionAreaItems = FactoryItems.Items;
            }

            if (FactoryItemCoasts != null)
            {
                FactoryItemCoasts.Read();
                CollectionAreaItemsCoasts = FactoryItemCoasts.CoastsAll;
            }

            if (FactorySmoothItems != null)
            {
                FactorySmoothItems.Read();
                CollectionAreaTransitionItems = FactorySmoothItems.SmoothsAll;
            }

            #endregion

            #region Merging Data
            MergingData();
            #endregion //Merging Data
        }