// NEW LoadMapFromFile: void CreateMap() { // Getting map from container: int[] map = ((this.LevelNumber) == 1 && (this.constructionMap != null)) ? this.constructionMap : CMapContainer.GetMap(this.LevelNumber); // Creating level objects: for (int i = 0; i < 26; i++) { for (int j = 0; j < 26; j++) { var go = (StaticObjects)map[i * 26 + j];//File.ReadByte(); if (go != StaticObjects.Empty) { int x = (i + 1) * 16; int y = (j + 1) * 16; var new_go = CObjectCreator.CreateStaticObject(go, x, y); //SetEventHandlers((CGameObject)new_go); AddObject((CGameObject)new_go); } } } }
void OnBonusExpire_Spade(object sender, EventArgs e) { for (int i = 0; i < 8; i++) { var grObject = CObjectCreator.CreateStaticObject(StaticObjects.Brick, hqXs[i], hqYs[i]); ClearPositionForObject(grObject); AddObject((CGameObject)grObject); } }
// - - - - - - - - - // Creators : // - - - - - - - - - // Set HQ on map: void CreateHQ() { // Creating fortification for eagle: for (int i = 0; i < 8; i++) { var brick = CObjectCreator.CreateStaticObject(StaticObjects.Brick, hqXs[i], hqYs[i]); if (CheckPosition(brick)) { AddObject((CGameObject)brick); } } // Creating and adding Eagle: var eagle = new CEagle(); ClearPositionForObject(eagle); // Adding Eagle: this.AddObject((CGameObject)eagle); }
void OnBonusTake_Spade(object sender, EventArgs e) { var spadeBonus = ProcessableObjects.Find(p => (p is CBonusSpade) && (p != (e as BonusEventArgs).Bonus)); if (spadeBonus != null) { RemoveObject((CGameObject)spadeBonus); } //this.hQ.ReceiveFortification(); for (int i = 0; i < 8; i++) { var grObject = CObjectCreator.CreateStaticObject(StaticObjects.Iron, hqXs[i], hqYs[i]); ClearPositionForObject(grObject); ((e as BonusEventArgs).Bonus as CBonusSpade).HQobjects.Add(grObject); AddObject((CGameObject)grObject); } }
// ********************************* // Methods: // ********************************* private void SetBlock(Blocks block, float x, float y) { int blockmap = 0; StaticObjects object_id = StaticObjects.Brick; int mapX = (int)(x / 16) - 1; int mapY = (int)(y / 16) - 1;; switch (block) { case Blocks.WallFull: blockmap = 0x0F; object_id = StaticObjects.Brick; break; case Blocks.WallUp: blockmap = 0x0C; object_id = StaticObjects.Brick; break; case Blocks.WallDown: blockmap = 0x03; object_id = StaticObjects.Brick; break; case Blocks.WallLeft: blockmap = 0x0A; object_id = StaticObjects.Brick; break; case Blocks.WallRight: blockmap = 0x05; object_id = StaticObjects.Brick; break; case Blocks.IronFull: blockmap = 0x0F; object_id = StaticObjects.Iron; break; case Blocks.IronUp: blockmap = 0x0C; object_id = StaticObjects.Iron; break; case Blocks.IronDown: blockmap = 0x03; object_id = StaticObjects.Iron; break; case Blocks.IronLeft: blockmap = 0x0A; object_id = StaticObjects.Iron; break; case Blocks.IronRight: blockmap = 0x05; object_id = StaticObjects.Iron; break; case Blocks.Garden: blockmap = 0x0F; object_id = StaticObjects.Garden; break; case Blocks.Ice: blockmap = 0x0F; object_id = StaticObjects.Ice; break; case Blocks.Water: blockmap = 0x0F; object_id = StaticObjects.Water; break; default: blockmap = 0x00; object_id = StaticObjects.Empty; break; } int comparator = 0x08; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { if (tileMap[mapX + j, mapY + i] != null) { RemoveObject(tileMap[mapX + j, mapY + i]); } if ((comparator & blockmap) != 0) { CGameObject new_object = (CGameObject)CObjectCreator.CreateStaticObject(object_id, (float)((x + (j * 16))), (float)((y + (i * 16)))); AddObject(new_object); tileMap[mapX + j, mapY + i] = new_object; mapBuffer[mapY + j + (mapX + i) * 26] = (int)object_id; } else { tileMap[mapX + j, mapY + i] = null; } comparator >>= 1; } } }