예제 #1
0
        // *********************************
        // Methods:
        // *********************************

        // Hit method:
        public virtual void Hit(CProjectile p)
        {
            if (onHit != null)
            {
                onHit(this);
            }
        }
예제 #2
0
 public override void Hit(CProjectile p)
 {
     if (p.ProjectileType == ProjectileTypes.Max)
     {
         this.Destroyed = true;
     }
 }
예제 #3
0
        // *********************************
        // Methods:
        // *********************************

        // If brick is hit by the bomb:
        public override void Hit(CProjectile p)
        {
            // If projectile type is Max then destroying it:
            if (p.ProjectileType == ProjectileTypes.Max)
            {
                this.State = (int)BrickState.Destroyed;                                         //this.Destroyed = true;
            }
            else if (!this.Fortified)
            {
                // Getting side index:
                int index = (int)p.Direction;

                // Check if brick has already been hit from this side:
                if (++hits[index] >= 2)
                {
                    State = (int)BrickState.Destroyed;
                }

                // If not then change it's state:
                else
                {
                    State &= comparators[index];

                    base.Hit(p);
                }
            }
        }
예제 #4
0
        public override void Hit(CProjectile p)
        {
            base.Hit(p);

            if (this.Armour > 0)
            {
                SetImages();
            }
        }
예제 #5
0
        public override void Hit(CProjectile p)
        {
            if (IsBonus)
            {
                OnCreateBonus(this, new EventArgs());

                IsBonus = false;
            }

            base.Hit(p);
        }
예제 #6
0
        // Hit method:
        public override void Hit(CProjectile p)
        {
            if (!this.Invincible)
            {
                if (--this.Armour <= 0)
                {
                    this.Destroyer = p.Owner;

                    this.Destroyed = true;
                }
            }
        }
        // *********************** //
        // On Shoot handlers:
        // *********************** //

        // On shoot:
        void OnShoot_Tank(CTank sender)
        {
            // Check if tank can shoot:
            if (sender.ProjectileLimit > sender.ProjectilesInFlight)
            {
                // Creating projectile:
                var projectile = new CProjectile(sender.X, sender.Y, sender.Direction, sender.ProjectileType);

                // Setting owner:
                projectile.Owner = sender;

                // Adding object:
                AddObject(projectile);

                // Decreasing projectile limit for sender:
                //sender.ProjectileLimit--;

                sender.ProjectilesInFlight++;
            }
        }
예제 #8
0
 public override void Hit(CProjectile p)
 {
     this.Destroyed = true;
 }
        // *********************** //
        // On Check handlers:
        // *********************** //

        // On target hit:
        bool OnCheck_IsTargetHit(CProjectile p)
        {
            // fill target coordinates:
            // there are 4 hit coordinates, each one is in the corner of projectile:
            int[] x = { 0, 0, 0, 0 };

            int[] y = { 0, 0, 0, 0 };

            x[0] = (int)((p.X + 3) / cellSize);

            x[1] = x[0];

            x[2] = (int)((p.X + 4) / cellSize);;

            x[3] = x[2];

            y[0] = (int)((p.Y + 3) / cellSize);

            y[1] = (int)((p.Y + 4) / cellSize);

            y[2] = y[0];

            y[3] = y[1];

            // Targets:
            IGameObject[] destroyable = new IGameObject[4];

            // hit flag:
            bool object_hit = false;

            // Check targets on map:
            for (int i = 0; i < 4; i++)
            {
                // Getting object:
                var o = this.mapMain[x[i], y[i]];

                // Check if it shoud be hit:
                if ((o != null) && (o != p.Owner) && (o != this.emptyArea) && !(o is CWater))
                {
                    // Enemies cant kill each other:
                    if (!((o is CTankEnemy) && (p.Owner is CTankEnemy)))
                    {
                        if (!destroyable.Contains(o))
                        {
                            // Detecting a hit:
                            object_hit = true;

                            p.Explode = true;

                            if (!((p.Owner is CTankPlayer) && (o is CTankPlayer)))
                            {
                                // Hitting object:
                                o.Hit(p);

                                // Blowing up projectile:
                                if ((o.Destroyed) && (o is CTankEnemy))
                                {
                                    (p.Owner as CTankPlayer).AddHit((o as CTank).TankID);
                                }

                                p.Explode = ((o as CTank != null) && (o as CTank).Invincible) ? false : true;

                                //if ((o as CTank != null) && (o as CTank).Invincible) p.Explode = false;

                                // Adding to targets:
                                destroyable[i] = o;
                            }
                        }
                    }
                }
            }
            ;

            return(object_hit);
        }