public static bool RemoveBitmap(GameBitmap bitmap)
 {
     string name;
     if (!bitmapUniqueDict.TryGetValue(bitmap, out name)) return false;
     bitmapUniqueDict.Remove(bitmap);
     bitmapNameDict.Remove(name);
     return true;
 }
 public static bool AddBitmap(string name, GameBitmap bitmap)
 {
     if (bitmapUniqueDict.ContainsKey(bitmap)) return false;
     if (bitmapNameDict.ContainsKey(name)) return false;
     bitmapNameDict.Add(name, bitmap);
     bitmapUniqueDict.Add(bitmap, name);
     return true;
 }
Example #3
0
 static GameBitmap GetBitmap()
 {
     GameBitmap gBitmap;
     if (!GameBitmapDictionary.TryGetBitmap("+", out gBitmap)) {
         gBitmap = new GameBitmap(new bool[][] { new bool[] { true } });
         GameBitmapDictionary.AddBitmap("+", gBitmap);
     }
     return gBitmap;
 }
Example #4
0
 public void Collision()
 {
     GameBitmap bitmap1 = new GameBitmap(new bool[][]{
         new bool[] { true, true, true },
         new bool[] { false, true, false }
     });
     GameBitmap bitmap2 = new GameBitmap(new bool[][]{
         new bool[] { false, true, false },
         new bool[] { true, true, true }
     });
     GameTable gt = new GameTable(30, 60);
     GameObject go1bm1 = new GameObject(bitmap1);
     GameObject go1bm2 = new GameObject(bitmap2);
     gt.AddObject(go1bm1, 0, 0);
     gt.AddObject(go1bm2, 0, 3);
     Assert.AreEqual(CanMoveResult.TableBoundsCollision, gt.TryMoveObjectHere(go1bm2, 0, -1));
     Assert.AreEqual(CanMoveResult.ObjectCollision, gt.TryMoveObjectHere(go1bm2, 0, 0));
     Assert.AreEqual(CanMoveResult.ObjectCollision, gt.TryMoveObjectHere(go1bm2, 0, 1));
     Assert.AreEqual(CanMoveResult.Success, gt.TryMoveObjectHere(go1bm2, 0, 2));
     Assert.AreEqual(CanMoveResult.Success, gt.TryMoveObjectHere(go1bm2, 0, 3));
 }
Example #5
0
 public GameObject(GameBitmap bitmap)
 {
     if (bitmap == null) throw new ArgumentNullException();
     this.bitmap = bitmap;
 }
 public static bool TryGetBitmapName(GameBitmap bitmap, out string name)
 {
     return bitmapUniqueDict.TryGetValue(bitmap, out name);
 }
 public static bool TryGetBitmap(string name, out GameBitmap bitmap)
 {
     return bitmapNameDict.TryGetValue(name, out bitmap);
 }
 public static string GetBitmapName(GameBitmap bitmap)
 {
     string name;
     if (!bitmapUniqueDict.TryGetValue(bitmap, out name)) return null;
     return name;
 }