Ejemplo n.º 1
0
        public void AddItem(int itemid, int hue, sbyte z)
        {
            if(Items == null)
                Items = new List<ItemClone>();

            var item = new ItemClone {Id = itemid, Hue = hue, Z = z};
            Items.Add(item);
        }
Ejemplo n.º 2
0
        public void AddItem(int itemid, int hue, sbyte z)
        {
            if (Items == null)
            {
                Items = new List <ItemClone>();
            }

            var item = new ItemClone {
                Id = itemid, Hue = hue, Z = z
            };

            Items.Add(item);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// function to make the translations with items
        /// </summary>
        /// <param name="coordinates"> </param>
        /// <param name="areaColorCoordinates"> </param>
        /// <param name="mapObjectCoordinates"> </param>
        private void ItemsTransitions
            (Coordinates coordinates,
             AreaColorCoordinates areaColorCoordinates,
             MapObjectCoordinates
                 mapObjectCoordinates,
             Random random)
        {
            if (areaColorCoordinates.Center.Type == TypeColor.Cliff) return;
            if (mapObjectCoordinates.Center.Items != null || mapObjectCoordinates.Center.Occupied != 0) return;
            //int special = 0;
            var texturelist = areaColorCoordinates.List.Select(o => o.TextureIndex).Distinct();
            if (texturelist.Count() <= 1)
                return;

            var transitionList = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems;
            if (!transitionList.List.Any())
                return;
            transitionList.InitializeSeaches();
            if (areaColorCoordinates.List.All(o => o.Color == areaColorCoordinates.Center.Color))
                return;

            var indexes = areaColorCoordinates.List.Select(o => o.TextureIndex);
            AreaTransitionItem k = null;

            foreach (var id in indexes)
            {
                k = transitionList.FindById(id);
                if (k != null) break;
            }
            if (k == null) return;

            int zlev = 0;
            var item = new ItemClone();


            #region Border

            //Border
            //GB
            //xG
            if (areaColorCoordinates.NorthEast.Color != areaColorCoordinates.Center.Color)
            {
                var transation =
                    areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.NorthEast.Color);
                //7
                if (transation != null)
                    item = new ItemClone() {Id = RandomFromList(transation.BorderSouthWest.List, random)};
            }
            //BG
            //Gx
            if (areaColorCoordinates.NorthWest.Color != areaColorCoordinates.Center.Color)
            {
                var transation =
                    areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.NorthWest.Color);
                //6
                if (transation != null)
                    item = new ItemClone {Id = RandomFromList(transation.BorderSouthEast.List, random)};
            }
            //Gx
            //BG
            if (areaColorCoordinates.SouthWest.Color != areaColorCoordinates.Center.Color)
            {
                var transation =
                    areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.SouthWest.Color);
                //5
                if (transation != null)
                    item = new ItemClone {Id = RandomFromList(transation.BorderNorthEast.List, random)};
            }
            //xG
            //GB
            if (areaColorCoordinates.SouthEast.Color != areaColorCoordinates.Center.Color)
            {
                var transation =
                    areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.SouthEast.Color);
                //4
                if (transation != null)
                    item = new ItemClone {Id = RandomFromList(transation.BorderNorthWest.List, random)};
            }

            #endregion //Border


            #region Line

            //Line
            // B
            //GxG
            if (areaColorCoordinates.North.TextureIndex != areaColorCoordinates.Center.TextureIndex)
            {
                //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.North.Color);
                var transition =
                    TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById(
                        areaColorCoordinates.North.TextureIndex);
                //2
                if (transition != null) item = new ItemClone {Id = RandomFromList(transition.LineSouth.List, random)};
            }
            //GxG
            // B
            if (areaColorCoordinates.South.TextureIndex != areaColorCoordinates.Center.TextureIndex)
            {
                //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.South.Color);
                var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.
                    FindById(
                        areaColorCoordinates.South.TextureIndex);
                //0
                if (transition != null) item = new ItemClone {Id = RandomFromList(transition.LineNorth.List, random)};
            }
            //G
            //xB
            //G
            if (areaColorCoordinates.East.TextureIndex != areaColorCoordinates.Center.TextureIndex)
            {
                //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.East.Color);
                var transition =
                    TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById(
                        areaColorCoordinates.East.TextureIndex);
                //3
                if (transition != null) item = new ItemClone {Id = RandomFromList(transition.LineWest.List, random)};
            }
            // G
            //Bx
            // G
            if (areaColorCoordinates.West.TextureIndex != areaColorCoordinates.Center.TextureIndex)
            {

                //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.West.Color);
                var transition =
                    TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById(
                        areaColorCoordinates.West.TextureIndex);
                //1
                if (transition != null) item = new ItemClone {Id = RandomFromList(transition.LineEast.List, random)};
            }

            #endregion //Line


            #region Edge

            //Edge
            //B
            //xB
            if (
                areaColorCoordinates.East.TextureIndex != areaColorCoordinates.Center.TextureIndex
                && areaColorCoordinates.North.TextureIndex != areaColorCoordinates.Center.TextureIndex
                )
            {
                //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.NorthEast.Color);
                var transition =
                    TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById(
                        areaColorCoordinates.NorthEast.TextureIndex);
                //11
                if (transition != null)
                    item = new ItemClone {Id = RandomFromList(transition.EdgeSouthWest.List, random)};
            }
            // B
            //Bx
            if (
                areaColorCoordinates.West.TextureIndex != areaColorCoordinates.Center.TextureIndex &&
                areaColorCoordinates.North.TextureIndex != areaColorCoordinates.Center.TextureIndex
                )
            {
                //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.NorthWest.Color);
                var transition =
                    TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById(
                        areaColorCoordinates.NorthWest.TextureIndex);
                //10
                if (transition != null)
                    item = new ItemClone {Id = RandomFromList(transition.EdgeSouthEast.List, random)};
            }
            //Bx
            // B
            if (
                areaColorCoordinates.West.TextureIndex != areaColorCoordinates.Center.TextureIndex
                && areaColorCoordinates.South.TextureIndex != areaColorCoordinates.Center.TextureIndex
                )
            {
                //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.SouthWest.Color);
                var transition =
                    TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById(
                        areaColorCoordinates.SouthWest.TextureIndex);
                //9
                if (transition != null)
                    item = new ItemClone {Id = RandomFromList(transition.EdgeNorthEast.List, random)};
            }
            //xB
            //B
            if (
                areaColorCoordinates.East.TextureIndex != areaColorCoordinates.Center.TextureIndex
                && areaColorCoordinates.South.TextureIndex != areaColorCoordinates.Center.TextureIndex
                )
            {
                var transition =
                    TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById(
                        areaColorCoordinates.SouthEast.TextureIndex);
                //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.SouthEast.Color);
                //8
                if (transition != null)
                    item = new ItemClone {Id = RandomFromList(transition.EdgeNorthWest.List, random)};
            }

            #endregion //Edge

            if (item.Id == 0) return;

            var coast = areaColorCoordinates.Center;

            if (coast.Type == TypeColor.Water)
            {
                //zlev = random.Next(coast.Min, coast.Max);
                item.Z = (sbyte) areaColorCoordinates.Center.ItemsAltitude;
            }


            if (mapObjectCoordinates.Center.Items == null)
                mapObjectCoordinates.Center.Items = new List<ItemClone>();
            mapObjectCoordinates.Center.Items.Add(item);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// method to set items in the map
        /// </summary>
        void SetItem()
        {
            var randomGen = new Random();
            int x, y, z = 0;

            for (x = MinX; x < _X; x++)
                for (y = MinY; y < _Y; y++)
                {
                    var location = CalculateZone(x, y, _stride);

                    if (_mapObjects[location].Occupied != 0) continue;

                    var itemgroups = _bitmapAreaColor[location].Items;
                    if (itemgroups == null || itemgroups.List.Count <= 0) continue;

                    var group = itemgroups.List[randomGen.Next(0, itemgroups.List.Count)];
                    var random = randomGen.Next(0, 100);
                    if (random > @group.Percent) continue;

                    var tmp_item = @group.List.First();
                    if (@group.List.Count > 1)
                    {
                        z = tmp_item.Z;
                    }

                    foreach (SingleItem item in @group.List)
                    {
                        var locationshift = CalculateZone(x + item.X, y + item.Y, _stride);

                        if (_mapObjects[locationshift].Items == null)
                            _mapObjects[locationshift].Items = new List<ItemClone>();

                        var itemclone = new ItemClone(item);

                        _mapObjects[locationshift].Items.Add(itemclone);
                        if (tmp_item == item)
                        {
                            itemclone.Z = (sbyte)((_mapObjects[locationshift].Altitude +
                                                   _mapObjects[CalculateZone(x + item.X + 1, y + item.Y, _stride)].Altitude +
                                                   _mapObjects[CalculateZone(x + item.X, y + item.Y + 1, _stride)].Altitude +
                                                   _mapObjects[CalculateZone(x + item.X + 1, y + item.Y + 1, _stride)].Altitude) / 4 + item.Z);
                        }
                        else
                        {
                            itemclone.Z = (sbyte)((_mapObjects[CalculateZone(x + tmp_item.X, y + tmp_item.Y, _stride)].Altitude +
                                                   _mapObjects[CalculateZone(x + tmp_item.X + 1, y + tmp_item.Y, _stride)].Altitude +
                                                   _mapObjects[CalculateZone(x + tmp_item.X, y + tmp_item.Y + 1, _stride)].Altitude +
                                                   _mapObjects[CalculateZone(x + tmp_item.X + 1, y + tmp_item.Y + 1, _stride)].Altitude) / 4 + tmp_item.Z + z);

                        }
                    }
                }
        }