Beispiel #1
0
        public MapSdk(string directory)
        {
            #region initialize props

            CollectionColorArea      = new CollectionAreaColor();
            CollectionColorMountains = new CollectionAreaColorMountains();

            CollectionAreaItems           = new CollectionAreaItems();
            CollectionAreaItemsCoasts     = new CollectionAreaTransitionItemCoast();
            CollectionAreaTransitionItems = new CollectionAreaTransitionItems();


            CollectionAreaTexture                = new CollectionAreaTexture();
            CollectionAreaTransitionTexture      = new CollectionAreaTransitionTexture();
            CollectionAreaTransitionCliffTexture = new CollectionAreaTransitionCliffTexture();

            #endregion

            #region initialize Factories

            Factories = new List <Factory>();

            FactoryColor = new FactoryColorArea(Path.Combine(directory, "color_area.txt"));

            Factories.Add(FactoryColor);

            FactoryCoast = new FactoryCoast(Path.Combine(directory, "color_coast.txt"));

            Factories.Add(FactoryCoast);

            FactoryMountains = new FactoryMountains(Path.Combine(directory, "color_mntn.txt"));

            Factories.Add(FactoryMountains);

            FactoryItems = new FactoryItems(Path.Combine(directory, "items.txt"));

            Factories.Add(FactoryItems);

            FactoryItemCoasts = new FactoryItemCoasts(Path.Combine(directory, "ite_tex_coast.txt"));

            Factories.Add(FactoryItemCoasts);

            FactorySmoothItems = new FactorySmoothItems(Path.Combine(directory, "items_smooth.txt"));

            Factories.Add(FactorySmoothItems);

            FactoryTextureArea = new FactoryTextureArea(Path.Combine(directory, "texture_area.txt"));

            Factories.Add(FactoryTextureArea);

            FactoryTextureSmooth = new FactoryTextureSmooth(Path.Combine(directory, "texture_smooth.txt"));

            Factories.Add(FactoryTextureSmooth);

            FactoryCliff = new FactoryCliff(Path.Combine(directory, "texture_cliff.txt"));

            Factories.Add(FactoryCliff);

            #endregion
        }
        public void UpdateFactoryItems(PlayerInfo aPlayerInfo)
        {
            using (var DB = new FactoryItemsContext())
            {
                var FactoryItems = DB.FactoryItems
                                   .OrderByDescending(B => B.Timestamp)
                                   .FirstOrDefault(B => B.Id == aPlayerInfo.steamId);
                var IsNewBackpack = FactoryItems == null || (DateTime.Now - FactoryItems.Timestamp).TotalMinutes >= 1;
                var Content       = JsonConvert.SerializeObject(aPlayerInfo.bpResourcesInFactory?.Select(I => new ItemStack(I.Key, (int)I.Value)));

                if (FactoryItems != null)
                {
                    if (IsEqual(JsonConvert.DeserializeObject <ItemStack[]>(FactoryItems.Content),
                                aPlayerInfo.bpResourcesInFactory?.Select(I => new ItemStack(I.Key, (int)I.Value)).ToArray()))
                    {
                        return;
                    }
                }

                if (IsNewBackpack)
                {
                    FactoryItems = new FactoryItems()
                    {
                        Id           = aPlayerInfo.steamId,
                        Timestamp    = DateTime.Now,
                        Content      = Content,
                        InProduction = aPlayerInfo.bpInFactory,
                        Produced     = aPlayerInfo.producedPrefabs?.Aggregate("", (S, B) => string.IsNullOrEmpty(S) ? B :  S + "\t" + B),
                    };
                    DB.FactoryItems.Add(FactoryItems);
                }
                else
                {
                    FactoryItems.InProduction = aPlayerInfo.bpInFactory;
                    FactoryItems.Produced     = aPlayerInfo.producedPrefabs?.Aggregate("", (S, B) => string.IsNullOrEmpty(S) ? B : S + "\t" + B);
                }

                DB.SaveChanges();

                FactoryItems  = DB.FactoryItems.FirstOrDefault(B => B.Id == aPlayerInfo.steamId && B.Timestamp == DateTime.MinValue);
                IsNewBackpack = FactoryItems == null;
                if (IsNewBackpack)
                {
                    FactoryItems = new FactoryItems()
                    {
                        Id        = aPlayerInfo.steamId,
                        Timestamp = DateTime.MinValue,
                    }
                }
                ;

                FactoryItems.Content = Content;
                if (IsNewBackpack)
                {
                    DB.FactoryItems.Add(FactoryItems);
                }

                var count = DB.SaveChanges();
            }
        }
Beispiel #3
0
        public MakeMapSDK(string directory)
        {
            #region initialize props

            ColorArea      = new ColorAreas();
            ColorMountains = new MountainsAreas();

            Items       = new ItemsAll();
            ItemsCoasts = new CoastsAll();
            Smooths     = new SmoothsAll();


            TextureArea    = new TextureArea();
            SmoothTextures = new SmoothTextures();
            Cliffs         = new Cliffs();

            #endregion

            #region initialize Factories

            Factories = new List <Factory>();

            FactoryColor = new FactoryColorArea(Path.Combine(directory, "color_area.txt"));

            Factories.Add(FactoryColor);

            FactoryCoast = new FactoryCoast(Path.Combine(directory, "color_coast.txt"));

            Factories.Add(FactoryCoast);

            FactoryMountains = new FactoryMountains(Path.Combine(directory, "color_mntn.txt"));

            Factories.Add(FactoryMountains);

            FactoryItems = new FactoryItems(Path.Combine(directory, "items.txt"));

            Factories.Add(FactoryItems);

            FactoryItemCoasts = new FactoryItemCoasts(Path.Combine(directory, "ite_tex_coast.txt"));

            Factories.Add(FactoryItemCoasts);

            FactorySmoothItems = new FactorySmoothItems(Path.Combine(directory, "items_smooth.txt"));

            Factories.Add(FactorySmoothItems);

            FactoryTextureArea = new FactoryTextureArea(Path.Combine(directory, "texture_area.txt"));

            Factories.Add(FactoryTextureArea);

            FactoryTextureSmooth = new FactoryTextureSmooth(Path.Combine(directory, "texture_smooth.txt"));

            Factories.Add(FactoryTextureSmooth);

            FactoryCliff = new FactoryCliff(Path.Combine(directory, "texture_cliff.txt"));

            Factories.Add(FactoryCliff);

            #endregion
        }
Beispiel #4
0
        public void InitializeFactories(string directory)
        {
            #region initialize Factories

            Factories = new List <Factory>();

            FactoryColor = new FactoryColorArea(Path.Combine(directory, "color_area.txt"));

            Factories.Add(FactoryColor);

            FactoryCoast = new FactoryCoast(Path.Combine(directory, "color_coast.txt"));

            Factories.Add(FactoryCoast);

            FactoryMountains = new FactoryMountains(Path.Combine(directory, "color_mntn.txt"));

            Factories.Add(FactoryMountains);

            FactoryItems = new FactoryItems(Path.Combine(directory, "items.txt"));

            Factories.Add(FactoryItems);

            FactoryItemCoasts = new FactoryItemCoasts(Path.Combine(directory, "ite_tex_coast.txt"));

            Factories.Add(FactoryItemCoasts);

            FactorySmoothItems = new FactorySmoothItems(Path.Combine(directory, "items_smooth.txt"));

            Factories.Add(FactorySmoothItems);

            FactoryTextureArea = new FactoryTextureArea(Path.Combine(directory, "texture_area.txt"));

            Factories.Add(FactoryTextureArea);

            FactoryTextureSmooth = new FactoryTextureSmooth(Path.Combine(directory, "texture_smooth.txt"));

            Factories.Add(FactoryTextureSmooth);

            FactoryCliff = new FactoryCliff(Path.Combine(directory, "texture_cliff.txt"));

            Factories.Add(FactoryCliff);

            #endregion
        }
Beispiel #5
0
        public void Populate()
        {
            #region colorread
            FactoryColor.Read();
            ColorArea = FactoryColor.Areas;


            FactoryCoast.Read();
            ColorCoast = FactoryCoast.Area;


            FactoryMountains.Read();
            ColorMountains = FactoryMountains.Mountains;
            #endregion

            #region items

            FactoryItems.Read();
            Items = FactoryItems.Items;

            FactoryItemCoasts.Read();
            ItemsCoasts = FactoryItemCoasts.CoastsAll;

            FactorySmoothItems.Read();
            Smooths = FactorySmoothItems.SmoothsAll;

            #endregion

            #region Textures

            FactoryTextureArea.Read();
            TextureArea = FactoryTextureArea.Textures;

            FactoryTextureSmooth.Read();
            SmoothTextures = FactoryTextureSmooth.Smooth;

            FactoryCliff.Read();
            Cliffs = FactoryCliff.Cliffs;

            #endregion
        }
Beispiel #6
0
        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
        }
Beispiel #7
0
        public void InitializeFactories(string directory)
        {
            #region initialize Factories

            FolderLocation = directory;

            Factories = new List <Factory>();

            try
            {
                FactoryColor = new FactoryColorArea(Path.Combine(directory, "color_area.txt"));
            }
            catch (Exception)
            {
            }
            if (FactoryColor != null)
            {
                Factories.Add(FactoryColor);
            }

            try
            {
                FactoryCoast = new FactoryCoast(Path.Combine(directory, "color_coast.txt"));
            }
            catch (Exception)
            {
            }
            if (FactoryCoast != null)
            {
                Factories.Add(FactoryCoast);
            }

            try
            {
                FactoryMountains = new FactoryMountains(Path.Combine(directory, "color_mntn.txt"));
            }
            catch (Exception)
            {
            }
            if (FactoryMountains != null)
            {
                Factories.Add(FactoryMountains);
            }

            try
            {
                FactoryItems = new FactoryItems(Path.Combine(directory, "items.txt"));
            }
            catch (Exception)
            {
            }
            if (FactoryItems != null)
            {
                Factories.Add(FactoryItems);
            }

            try
            {
                FactoryItemCoasts = new FactoryItemCoasts(Path.Combine(directory, "ite_tex_coast.txt"));
            }
            catch (Exception)
            {
            }
            if (FactoryItemCoasts != null)
            {
                Factories.Add(FactoryItemCoasts);
            }

            try
            {
                FactorySmoothItems = new FactorySmoothItems(Path.Combine(directory, "items_smooth.txt"));
            }
            catch (Exception)
            {
            }
            if (FactorySmoothItems != null)
            {
                Factories.Add(FactorySmoothItems);
            }

            try
            {
                FactoryTextureArea = new FactoryTextureArea(Path.Combine(directory, "texture_area.txt"));
            }
            catch (Exception)
            {
            }
            if (FactoryTextureArea != null)
            {
                Factories.Add(FactoryTextureArea);
            }

            try
            {
                FactoryTextureSmooth = new FactoryTextureSmooth(Path.Combine(directory, "texture_smooth.txt"));
            }
            catch (Exception)
            {
            }
            if (FactoryTextureSmooth != null)
            {
                Factories.Add(FactoryTextureSmooth);
            }

            try
            {
                FactoryCliff = new FactoryCliff(Path.Combine(directory, "texture_cliff.txt"));
            }
            catch (Exception)
            {
            }
            if (FactoryCliff != null)
            {
                Factories.Add(FactoryCliff);
            }

            #endregion
        }