Map.Update C# (CSharp) Метод

Update() публичный Метод

public Update ( string gameMapStr ) : void
gameMapStr string
Результат void
    public void Update(string gameMapStr)
    {
        var gameMapValues = new Queue<string>(gameMapStr.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries));

        ushort x = 0, y = 0;
        while (y < Height) {
            ushort counter, owner;
            if (!ushort.TryParse(gameMapValues.Dequeue(), out counter))
                throw new ApplicationException("Could not get some counter from stdin");
            if (!ushort.TryParse(gameMapValues.Dequeue(), out owner))
                throw new ApplicationException("Could not get some owner from stdin");
            while (counter > 0) {
                _sites[x, y] = new Site {Owner = owner};
                x++;
                if (x == Width) {
                    x = 0;
                    y++;
                }
                counter--;
            }
        }

        var strengthValues = gameMapValues; // Referencing same queue, but using a name that is more clear
        for (x = 0; x < Width; x++) {
            for (y = 0; y < Height; y++) {
                ushort strength;
                if (!ushort.TryParse(strengthValues.Dequeue(), out strength))
                    throw new ApplicationException("Could not get some strength value from stdin");
                _sites[x, y].Strength = strength;
            }
        }
    }

Usage Example

Пример #1
0
        /// <summary>
        ///     Use this to Remove Sprites
        ///     It will remove them from ingame to who those effected.
        ///     and invoke the objectmanager.
        /// </summary>
        public void Remove <T>() where T : Sprite, new()
        {
            var nearby   = GetObjects <Aisling>(i => i.WithinRangeOf(this));
            var response = new ServerFormat0E(Serial);

            foreach (var o in nearby)
            {
                o?.Client?.Send(response);
            }

            if (this is Monster)
            {
                DelObject(this as Monster);
            }
            if (this is Aisling)
            {
                DelObject(this as Aisling);
            }
            if (this is Money)
            {
                DelObject(this as Money);
            }
            if (this is Item)
            {
                DelObject(this as Item);
            }
            if (this is Mundane)
            {
                DelObject(this as Mundane);
            }

            Map?.Update(X, Y, TileContent.None);
        }
All Usage Examples Of Map::Update