示例#1
0
        // - - - - - - - - -
        // Level processor :
        // - - - - - - - - -

        // Processing level objects:
        public void ProcessLevel()
        {
            ProcessableObjects.ForEach(p => p.ProcessObject());

            if (levelStarted)
            {
                // Adding enemy:
                if ((AllGameObjects.EnemiesCount < 4) && (AllGameObjects.TankPortalsCount < 1) && (this.EnemyTanksLeft > 0))
                {
                    var bonus = enemyTanksLeft % 10 == 0 ? true : false;

                    CreateTankPortal(CObjectCreator.CreateTank(EnemyTanks[enemyTanksLeft - 1], bonus));

                    EnemyTanksLeft--;
                }

                if ((EnemyTanksLeft == 0) && (AllGameObjects.EnemiesCount == 0))
                {
                    if (timeoutToNextLevel-- == 0)
                    {
                        OnComplete_Level(this, new EventArgs());
                    }
                }
            }
        }
示例#2
0
        // 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);
            }
        }
示例#4
0
        // - - - - - - - - -
        // 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);
            }
        }
示例#6
0
        void CreateBonus()
        {
            // Removing previous bonus:
            var bonus = ProcessableObjects.Find(p => {
                if (p is CBonus)
                {
                    return(!(p as CBonus).Taken);
                }

                else
                {
                    return(false);
                }
            }
                                                );

            if (bonus != null)
            {
                RemoveObject((CGameObject)bonus);
            }

            // Creating random bonus at random position:
            AddObject(CObjectCreator.CreateBonus(random.Next(16, 400), random.Next(16, 400), (Bonuses)random.Next(0, 6)));
        }
        // On Force field activation:
        void OnActivate_ForceField(CTank sender, int time)
        {
            // Finding and destroying senders current forsfield if any:
            var forcefield = ProcessableObjects.Find(p => {
                if (p is CForceField)
                {
                    if ((p as CForceField).Owner == sender)
                    {
                        return(true);
                    }
                }

                return(false);
            });

            //
            if (forcefield != null)
            {
                (forcefield as CForceField).Destroyed = true;
            }

            // Adding new forcefield:
            AddObject(CObjectCreator.CreateForceField((CTank)sender, time));
        }
示例#8
0
        // *********************************
        // 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;
                }
            }
        }
        // *********************** //
        // Other handlers:
        // *********************** //

        // Shows points:
        void OnShow_Points(object sender, EventArgs e)
        {
            var go = sender as IGameObject;

            AddObject(CObjectCreator.CreatePoints(go.X, go.Y, (e as PointsEventArgs).Points));
        }