Exemplo n.º 1
0
 public static bool RemoveBitmap(GameBitmap bitmap)
 {
     string name;
     if (!bitmapUniqueDict.TryGetValue(bitmap, out name)) return false;
     bitmapUniqueDict.Remove(bitmap);
     bitmapNameDict.Remove(name);
     return true;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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));
 }
Exemplo n.º 5
0
 public GameObject(GameBitmap bitmap)
 {
     if (bitmap == null) throw new ArgumentNullException();
     this.bitmap = bitmap;
 }
Exemplo n.º 6
0
 public static bool TryGetBitmapName(GameBitmap bitmap, out string name)
 {
     return bitmapUniqueDict.TryGetValue(bitmap, out name);
 }
Exemplo n.º 7
0
 public static bool TryGetBitmap(string name, out GameBitmap bitmap)
 {
     return bitmapNameDict.TryGetValue(name, out bitmap);
 }
Exemplo n.º 8
0
 public static string GetBitmapName(GameBitmap bitmap)
 {
     string name;
     if (!bitmapUniqueDict.TryGetValue(bitmap, out name)) return null;
     return name;
 }