コード例 #1
0
        public byte SpawnItem(Point coords, Agent.Item item, OperacjeMapy.Pole[,] map, byte stackSize)
        {
            bool done = false;

            item.stackSize = stackSize;
            if (!(item.isStackable))
            {
                Console.WriteLine("Item [{0}] is not stackable.", item.name);
                return(0);
            }
            else
            {
                foreach (Agent.Item i in map[coords.X, coords.Y].Items)
                {
                    if (i.name == item.name && i.stackSize + item.stackSize <= 255)
                    {
                        i.stackSize += item.stackSize;
                        done         = true;
                        break;
                    }
                    else if (i.name == item.name)
                    {
                        item.stackSize -= Convert.ToByte(255 - i.stackSize);
                        i.stackSize     = 255;
                    }
                    if (item.stackSize == 0)
                    {
                        done = true;
                        break;
                    }
                }
                if (!(done))
                {
                    map[coords.X, coords.Y].Items.Add(item);
                }
            }
            Console.WriteLine("Spawning {0} to X{1},Y{2}.", item.name, coords.X, coords.Y);
            return(1);
        }
コード例 #2
0
        public void SpawnItem(Point coords, Agent.Item item, OperacjeMapy.Pole[,] map)
        {
            bool added = false;

            if (item.isStackable)
            {
                foreach (Agent.Item i in map[coords.X, coords.Y].Items)
                {
                    if (i.name == item.name && i.stackSize < 255)
                    {
                        i.stackSize++;
                        added = true;
                        break;
                    }
                }
                if (!(added))
                {
                    map[coords.X, coords.Y].Items.Add(item);
                }
            }
            Console.WriteLine("Spawning {0} to X{1},Y{2}.", item.name, coords.X, coords.Y);
        }