Exemplo n.º 1
0
        public static bool Test()
        {
            GridTile.ObjectLimit   = 5;
            GridTile.VolumeSoftCap = 30;
            GridTile.VolumeHardCap = 50;

            coords c;

            c.x = 1;
            c.y = 2;
            GridTile gt = new GridTile(c);

            if (gt.Coordinates.x != 1 || gt.Coordinates.y != 2)
            {
                throw new Exception("Grid Tile failed to set coordinates");
            }

            Item a = new Item("a", 3, 10, 0);
            Item b = new Item("b", 3, 9, 0);
            Item C = new Item("c", 3, 8, 0);
            Item d = new Item("d", 3, 7, 0);
            Item e = new Item("e", 3, 6, 0);
            Item f = new Item("f", 3, 29, 0);

            gt.AddThing(a);
            gt.AddThing(b);

            if (gt.ThingVolume != 19)
            {
                throw new Exception("GridTile has incorrect volume expected 19 got: " + gt.ThingVolume);
            }

            gt.AddThing(C);
            gt.AddThing(d);
            gt.AddThing(e);
            try
            {
                gt.AddThing(f);
                throw new Exception("GridTile exceeded maximum object capacity");
            }
            catch (GridTileException)
            {
            }

            if (gt.ThingVolume != 40)
            {
                throw new Exception("GridTile has incorrect volume expected 40 got: " + gt.ThingVolume);
            }

            if (gt.Passable == true)
            {
                throw new Exception("GridTile is passable but exceeds volume softcap");
            }

            gt.RemoveThing(a);
            if (gt.Passable == false)
            {
                throw new Exception("GridTile is impassable but does not exceed volume softcap");
            }
            if (gt.ThingVolume != 30)
            {
                throw new Exception("GridTile has incorrect volume expected 30 got: " + gt.ThingVolume);
            }

            return(true);
        }
Exemplo n.º 2
0
 public GridTileException(string message, GridTile tile) : base(message)
 {
     this.tile = tile;
 }