Beispiel #1
0
        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();
                }
            }
        }
Beispiel #2
0
        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);
                        }
                    }
                }
            }
        }