Beispiel #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());
                    }
                }
            }
        }
Beispiel #2
0
        public void ClearLevel()
        {
            // Removing objects from ProcessableObjects:
            ProcessableObjects.Clear();

            // Remove objects from container:
            AllGameObjects.Clear();
        }
        void OnBonusTake_Clock(object sender, EventArgs e)
        {
            // Finding and destroying clock bonuses currently active:
            var clockBonus = ProcessableObjects.Find(p => (p is CBonusClock) && (p != (e as BonusEventArgs).Bonus));

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

            AllGameObjects.EnemiesEnabled = false;
        }
Beispiel #4
0
        private void InitializeLevel()
        {
            AddObject(new CGameObject(Properties.Resources.background, 0, 0, 494, 452)
            {
                Transparent = true
            });

            cursor = new CConstructionCursor(16, 16, this.minimumXY, this.maximumXY);

            AddObject(cursor);

            ProcessableObjects.Add(cursor);
        }
Beispiel #5
0
        void CreateLevelCurtain()
        {
            // Creating curtain:
            levelCurtain = new CLevelCurtain(this.LevelNumber);

            // Settting event handlers:
            levelCurtain.OnHalfCompleted += LoadMap;

            levelCurtain.OnCompleted += this.InitializeLevel;

            levelCurtain.OnCompleted += this.OnComplete_LevelCurtain;

            // Adding to processable objects:
            ProcessableObjects.Add(levelCurtain);

            // Adding to key receivers:
            KeyEventReceivers.Add(levelCurtain);
        }
Beispiel #6
0
        // *********************************
        // Methods:
        // *********************************
        // - - - - - - - - - -
        // Managing objects :
        // - - - - - - - - - -

        // This method sets object on a map:
        protected override void AddObject(CGameObject o)
        {
            // Adding to all objects:
            AllGameObjects.Add(o);

            // if it is processable then add it to corresponding list:
            if (o is IProcessable)
            {
                ProcessableObjects.Add((IProcessable)o);
            }

            if ((o is CIconEnemy) || (o is ClevelFlag) || (o is CPlayerIcon))
            {
                StatisticObjects.Add(o);
            }

            // Set event handlers:
            SetEventHandlers(o);

            //Add to map:
            CGameObject[,] map;

            // Choosing the right map:
            map = (o is CProjectile) ? mapProjectiles : mapMain;

            // check if transparent:
            if (!o.Transparent)
            {
                int x, y, width, height;

                GetDimensionsOnMap(o, out x, out y, out width, out height);

                // Put on the map:
                for (int i = 0; i < width; i++)
                {
                    for (int j = 0; j < height; j++)
                    {
                        map[x + j, y + i] = o;
                    }
                }
            }
        }
        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);
            }
        }
Beispiel #8
0
        // This method removes object from map:
        protected override void RemoveObject(CGameObject o)
        {
            // Removing from all objects:
            AllGameObjects.Remove(o);

            //
            if (o is IProcessable)
            {
                ProcessableObjects.Remove((IProcessable)o);
            }

            if ((o is CIconEnemy) || (o is ClevelFlag) || (o is CPlayerIcon))
            {
                StatisticObjects.Remove(o);
            }

            // Removing from map:
            CGameObject[,] map;

            // Choosing the right map:
            map = (o is CProjectile) ? mapProjectiles : mapMain;

            // if object is not transparent then removing it:
            if (!o.Transparent)
            {
                int x, y, width, height;

                GetDimensionsOnMap(o, out x, out y, out width, out height);

                // Removing from map:
                for (int i = 0; i < width; i++)
                {
                    for (int j = 0; j < height; j++)
                    {
                        map[x + j, y + i] = null;
                    }
                }
            }
        }
Beispiel #9
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));
        }
Beispiel #11
0
 public void ProcessLevel()
 {
     ProcessableObjects.ForEach(p => p.ProcessObject());
 }