// kiểm tra xem ống đã thêm creepUp1 và creepUp2 vào chưa public static bool HasCreepUp(Canvas cvMap, int indexPipe) { if (indexPipe < 0) { indexPipe = 0; } else if (indexPipe > 1) { indexPipe = 1; } EObjectName obj = (EObjectName)((int)EObjectName.CREEP_UP_PIPE_1 + indexPipe); if (cvMap.Children != null && cvMap.Children.Count > 0) { foreach (var item in cvMap.Children) { if ((item is Image) && ((Image)item).Opacity != 0.5f && (EObjectName)(int)((Image)item).Tag == obj) { return(true); } } } return(false); }
// kiểm tra 1 đối tượng là động hay tĩnh <có thể di chuyển được> public static ObjectType CheckObjectType(EObjectName obj) { switch (obj) { case EObjectName.ENEMY: case EObjectName.TURTLE: case EObjectName.FLYING_TURTLE: case EObjectName.MUSHROOM: case EObjectName.MUSHROOM_BLOCK: case EObjectName.LIFE_MUSHROOM: case EObjectName.LIFE_MUSHROOM_BLOCK: case EObjectName.STAR: case EObjectName.STAR_BLOCK: case EObjectName.BAR: case EObjectName.GODOWN_BAR: case EObjectName.GOUP_BAR: case EObjectName.HORIZONTAL_BAR: case EObjectName.MACHINE: case EObjectName.TURTLE2: return(ObjectType.NON_STATIC); default: return(ObjectType.STATIC); } }
// khởi tạo các đối tượng cho Image Bitmap, dùng để load lên listbox public OImage(EObjectName name, string filename, int width = 50, int height = 50) { this.Bitmap = new Image(); this.Bitmap.Tag = (int)name; this.Bitmap.Source = new BitmapImage(new Uri(filename, UriKind.Relative)); this.Bitmap.Width = width; this.Bitmap.Height = height; }
// kiểm tra xem đối tượng có thể xét va chạm đc k public static bool CheckObjectCollisionAbility(EObjectName obj) { switch (obj) { default: return(true); } }
// kiểm tra 1 đối tượng là động hay tĩnh <có thể di chuyển được> public static ObjectType CheckObjectType(EObjectName obj) { switch (obj) { //case EObjectName.SMALL_MARIO: //case EObjectName.SUPER_MARIO: //case EObjectName.ENEMY_GOOMBA_OW: //case EObjectName.ENEMY_KOOPA_OW: //case EObjectName.ITEM_SUPER_MUSHROOM: //case EObjectName.ITEM_1UP_MUSHROOM: // return ObjectType.NON_STATIC; default: return(ObjectType.STATIC); } }
// kiểm tra xem đối tượng có thể xét va chạm đc k public static bool CheckObjectCollisionAbility(EObjectName obj) { switch (obj) { case EObjectName.CLOUD: case EObjectName.FENCE: case EObjectName.GRASS: case EObjectName.MOUNTAIN: case EObjectName.SIGN: case EObjectName.LAMP: case EObjectName.TREE: case EObjectName.BIG_TREE: case EObjectName.FLAG_POSITION: case EObjectName.MARIO: return(false); default: return(true); } }
public static BitmapImage GetBitmapImage(EObjectName type) { BitmapImage bitmap = null; switch (type) { case EObjectName.SMALL_MARIO: bitmap = new BitmapImage(new Uri(@"\Images\Mario\MarioIcon-16-16.png", UriKind.Relative)); break; case EObjectName.SUPER_MARIO: bitmap = new BitmapImage(new Uri(@"\Images\Mario\MarioIcon-16-16.png", UriKind.Relative)); break; case EObjectName.ENEMY_GOOMBA_OW: bitmap = new BitmapImage(new Uri(@"\Images\Enemy\MushroomBrown-16-16.png", UriKind.Relative)); break; case EObjectName.ENEMY_KOOPA_OW: bitmap = new BitmapImage(new Uri(@"\Images\Enemy\TurtleGreen-16-24.png", UriKind.Relative)); break; case EObjectName.ENEMY_BOSS: bitmap = new BitmapImage(new Uri(@"\Images\Enemy\BossGreen-32-32.png", UriKind.Relative)); break; case EObjectName.MISC_BASE_BRICK: bitmap = new BitmapImage(new Uri(@"\Images\Misc\BrickHard-16-16.png", UriKind.Relative)); break; case EObjectName.MISC_QUESTION_BRICK: bitmap = new BitmapImage(new Uri(@"\Images\Misc\BrickSoft-16-16.png", UriKind.Relative)); break; case EObjectName.MISC_IRON_BRICK: bitmap = new BitmapImage(new Uri(@"\Images\Misc\HardBrick-16-16.png", UriKind.Relative)); break; case EObjectName.MISC_SOFT_BRICK: bitmap = new BitmapImage(new Uri(@"\Images\Misc\BrickSoft-16-16.png", UriKind.Relative)); break; case EObjectName.MISC_PIECE: bitmap = new BitmapImage(new Uri(@"\Images\Misc\PipeUp-62-32.png", UriKind.Relative)); break; case EObjectName.MISC_STOCK_PIPE: bitmap = new BitmapImage(new Uri(@"\Images\Misc\PipeStock-32-16.png", UriKind.Relative)); break; case EObjectName.MISC_SMALL_CLOUND: bitmap = new BitmapImage(new Uri(@"\Images\Misc\SmallClound-32-24.png", UriKind.Relative)); break; case EObjectName.MISC_MEDIUM_CLOUND: bitmap = new BitmapImage(new Uri(@"\Images\Misc\MediumClound-48-24.png", UriKind.Relative)); break; case EObjectName.MISC_BIG_CLOUND: bitmap = new BitmapImage(new Uri(@"\Images\Misc\BigClound-64-24.png", UriKind.Relative)); break; case EObjectName.MISC_GATE_PIPE: bitmap = new BitmapImage(new Uri(@"\Images\Misc\PipeGate-32-16.png", UriKind.Relative)); break; case EObjectName.MISC_SMALL_GRASS: bitmap = new BitmapImage(new Uri(@"\Images\Misc\SmallGrass-48-16.png", UriKind.Relative)); break; case EObjectName.MISC_MEDIUM_GRASS: bitmap = new BitmapImage(new Uri(@"\Images\Misc\MediumGrass-48-16.png", UriKind.Relative)); break; case EObjectName.MISC_BIG_GRASS: bitmap = new BitmapImage(new Uri(@"\Images\Misc\BigGrass-64-16.png", UriKind.Relative)); break; case EObjectName.MISC_BIG_MOUNTAIN: bitmap = new BitmapImage(new Uri(@"\Images\Misc\BigMountain-80-35.png", UriKind.Relative)); break; case EObjectName.MISC_MEDIUM_MOUNTAIN: bitmap = new BitmapImage(new Uri(@"\Images\Misc\MediumMountain-48-24.png", UriKind.Relative)); break; case EObjectName.MISC_HARD_BRICK: bitmap = new BitmapImage(new Uri(@"\Images\Misc\HardBrick-16-16.png", UriKind.Relative)); break; case EObjectName.MISC_CASTLE: bitmap = new BitmapImage(new Uri(@"\Images\Misc\Castle-80-80.png", UriKind.Relative)); break; case EObjectName.ITEM_COIN_ACTIVATED: bitmap = new BitmapImage(new Uri(@"\Images\Item\BrickCoin-16-16.png", UriKind.Relative)); break; case EObjectName.ITEM_COIN_NORMAL: bitmap = new BitmapImage(new Uri(@"\Images\Item\Coin-16-16.png", UriKind.Relative)); break; case EObjectName.ITEM_FIRE_FLOWER: bitmap = new BitmapImage(new Uri(@"\Images\Item\BrickFlower-16-16.png", UriKind.Relative)); break; case EObjectName.ITEM_SUPER_MUSHROOM: bitmap = new BitmapImage(new Uri(@"\Images\Item\BrickMushroom-16-16.png", UriKind.Relative)); break; case EObjectName.ITEM_1UP_MUSHROOM: // đây làm một item để gắn bitmap = new BitmapImage(new Uri(@"\Images\Item\BrickMushroomGreen.png", UriKind.Relative)); break; case EObjectName.BRICK_COIN: bitmap = new BitmapImage(new Uri(@"\Images\Item\BrickCoin-16-16.png", UriKind.Relative)); break; case EObjectName.BRICK_FLOWER: bitmap = new BitmapImage(new Uri(@"\Images\Item\BrickFlower-16-16.png", UriKind.Relative)); break; case EObjectName.BRICK_SUPPERMUSHROOM: bitmap = new BitmapImage(new Uri(@"\Images\Item\BrickMushroom-16-16.png", UriKind.Relative)); break; case EObjectName.BRICK_1UPMUSHROOM: bitmap = new BitmapImage(new Uri(@"\Images\Item\BrickMushroomGreen.png", UriKind.Relative)); break; case EObjectName.BRICK_STAR: bitmap = new BitmapImage(new Uri(@"\Images\Item\BrickStarman-16-16.png", UriKind.Relative)); break; case EObjectName.BRICK_QUESTION_ITEM: bitmap = new BitmapImage(new Uri(@"\Images\Item\BrickQuestion-16-16.png", UriKind.Relative)); break; case EObjectName.MISC_GOAL_POLE: bitmap = new BitmapImage(new Uri(@"\Images\Misc\GoalPole-16-136.png", UriKind.Relative)); break; case EObjectName.MISC_FLAG: bitmap = new BitmapImage(new Uri(@"\Images\Misc\Flag-16-16.png", UriKind.Relative)); break; default: break; } return(bitmap); }
public static BitmapImage GetBitmapImage(EObjectName type) { BitmapImage bitmap = null; switch (type) { case EObjectName.MARIO: bitmap = new BitmapImage(new Uri(@"\Images\Mario\SmallMario.png", UriKind.Relative)); break; case EObjectName.ENEMY: bitmap = new BitmapImage(new Uri(@"\Images\Enemy\Enemy.png", UriKind.Relative)); break; case EObjectName.TURTLE: bitmap = new BitmapImage(new Uri(@"\Images\Enemy\Turtle.png", UriKind.Relative)); break; case EObjectName.FLYING_TURTLE: bitmap = new BitmapImage(new Uri(@"\Images\Enemy\FlyingTurtle.png", UriKind.Relative)); break; case EObjectName.MUSHROOM: bitmap = new BitmapImage(new Uri(@"\Images\Bonus\Mushroom.png", UriKind.Relative)); break; case EObjectName.MUSHROOM_BLOCK: bitmap = new BitmapImage(new Uri(@"\Images\Bonus\MushroomBlock.png", UriKind.Relative)); break; case EObjectName.FLOWER: bitmap = new BitmapImage(new Uri(@"\Images\Bonus\Flower.png", UriKind.Relative)); break; case EObjectName.FLOWER_BLOCK: bitmap = new BitmapImage(new Uri(@"\Images\Bonus\FlowerBlock.png", UriKind.Relative)); break; case EObjectName.LIFE_MUSHROOM: bitmap = new BitmapImage(new Uri(@"\Images\Bonus\LifeMushroom.png", UriKind.Relative)); break; case EObjectName.LIFE_MUSHROOM_BLOCK: bitmap = new BitmapImage(new Uri(@"\Images\Bonus\LifeMushroomBlock.png", UriKind.Relative)); break; case EObjectName.COIN: bitmap = new BitmapImage(new Uri(@"\Images\Bonus\Coin.png", UriKind.Relative)); break; case EObjectName.COIN_BRICK: bitmap = new BitmapImage(new Uri(@"\Images\Bonus\CoinBrick.png", UriKind.Relative)); break; case EObjectName.COIN_BLOCK: bitmap = new BitmapImage(new Uri(@"\Images\Bonus\CoinBlock.png", UriKind.Relative)); break; case EObjectName.STAR: bitmap = new BitmapImage(new Uri(@"\Images\Bonus\Star.png", UriKind.Relative)); break; case EObjectName.STAR_BLOCK: bitmap = new BitmapImage(new Uri(@"\Images\Bonus\StarBlock.png", UriKind.Relative)); break; case EObjectName.BLOCK: bitmap = new BitmapImage(new Uri(@"\Images\Other\Block.png", UriKind.Relative)); break; case EObjectName.BRICK: bitmap = new BitmapImage(new Uri(@"\Images\Other\Brick.png", UriKind.Relative)); break; case EObjectName.CLOUD: bitmap = new BitmapImage(new Uri(@"\Images\Other\Cloud.png", UriKind.Relative)); break; case EObjectName.BAR: bitmap = new BitmapImage(new Uri(@"\Images\Other\Bar.png", UriKind.Relative)); break; case EObjectName.GODOWN_BAR: bitmap = new BitmapImage(new Uri(@"\Images\Other\GoDownBar.png", UriKind.Relative)); break; case EObjectName.GOUP_BAR: bitmap = new BitmapImage(new Uri(@"\Images\Other\GoUpBar.png", UriKind.Relative)); break; case EObjectName.HORIZONTAL_BAR: bitmap = new BitmapImage(new Uri(@"\Images\Other\HorizontalBar.png", UriKind.Relative)); break; case EObjectName.CARNIVOROUSFLOWER: bitmap = new BitmapImage(new Uri(@"\Images\Other\CarnivorousFlower.png", UriKind.Relative)); break; case EObjectName.CARNIVOROUSFLOWER_PIPE: bitmap = new BitmapImage(new Uri(@"\Images\Other\CarnivorousFlowerPipe.png", UriKind.Relative)); break; case EObjectName.PIPE: bitmap = new BitmapImage(new Uri(@"\Images\Other\Pipe.png", UriKind.Relative)); break; case EObjectName.CREEP_PIPE_1: bitmap = new BitmapImage(new Uri(@"\Images\Other\CreepPipe1.png", UriKind.Relative)); break; case EObjectName.CREEP_PIPE_2: bitmap = new BitmapImage(new Uri(@"\Images\Other\CreepPipe2.png", UriKind.Relative)); break; case EObjectName.CREEP_UP_PIPE_1: bitmap = new BitmapImage(new Uri(@"\Images\Other\CreepUpPipe1.png", UriKind.Relative)); break; case EObjectName.CREEP_UP_PIPE_2: bitmap = new BitmapImage(new Uri(@"\Images\Other\CreepUpPipe2.png", UriKind.Relative)); break; case EObjectName.HORIZONTAL_PIPE_1: bitmap = new BitmapImage(new Uri(@"\Images\Other\HorizontalPipe1.png", UriKind.Relative)); break; case EObjectName.HORIZONTAL_PIPE_2: bitmap = new BitmapImage(new Uri(@"\Images\Other\HorizontalPipe2.png", UriKind.Relative)); break; case EObjectName.LEFT_LAND: bitmap = new BitmapImage(new Uri(@"\Images\Other\LeftLand.png", UriKind.Relative)); break; case EObjectName.LAND: bitmap = new BitmapImage(new Uri(@"\Images\Other\Land.png", UriKind.Relative)); break; case EObjectName.RIGHT_LAND: bitmap = new BitmapImage(new Uri(@"\Images\Other\RightLand.png", UriKind.Relative)); break; case EObjectName.FENCE: bitmap = new BitmapImage(new Uri(@"\Images\Other\Fence.png", UriKind.Relative)); break; case EObjectName.GRASS: bitmap = new BitmapImage(new Uri(@"\Images\Other\Grass.png", UriKind.Relative)); break; case EObjectName.MOUNTAIN: bitmap = new BitmapImage(new Uri(@"\Images\Other\Mountain.png", UriKind.Relative)); break; case EObjectName.SIGN: bitmap = new BitmapImage(new Uri(@"\Images\Other\Sign.png", UriKind.Relative)); break; case EObjectName.LAMP: bitmap = new BitmapImage(new Uri(@"\Images\Other\Lamp.png", UriKind.Relative)); break; case EObjectName.TREE: bitmap = new BitmapImage(new Uri(@"\Images\Other\Tree.png", UriKind.Relative)); break; case EObjectName.BIG_TREE: bitmap = new BitmapImage(new Uri(@"\Images\Other\Tree2.png", UriKind.Relative)); break; case EObjectName.TOWER: bitmap = new BitmapImage(new Uri(@"\Images\Other\Tower.png", UriKind.Relative)); break; case EObjectName.MACHINE: bitmap = new BitmapImage(new Uri(@"\Images\Other\Machine.png", UriKind.Relative)); break; case EObjectName.TURTLE2: bitmap = new BitmapImage(new Uri(@"\Images\Other\Turtle2.png", UriKind.Relative)); break; case EObjectName.SPRING: bitmap = new BitmapImage(new Uri(@"\Images\Other\Spring.png", UriKind.Relative)); break; case EObjectName.FLAG_POSITION: bitmap = new BitmapImage(new Uri(@"\Images\Other\FlagPosition.png", UriKind.Relative)); break; default: break; } return(bitmap); }