Esempio n. 1
0
        public CForceField(CTank owner, int lifetime) : base()
        {
            this.images = new List <Image> {
                Properties.Resources.forcefield1, Properties.Resources.forcefield2
            };

            this.owner = owner;

            this.owner.Invincible = true;

            this.lifeTime = lifetime;

            this.Width = 32;

            this.Height = 32;

            this.X = owner.X;

            this.Y = owner.Y;

            this.Transparent = true;

            this.imageChangeInterval = 2;

            this.destroyAfterApear = false;

            // Setting drawing priority:
            this.DrawPriority = 10;
        }
Esempio n. 2
0
        // Creates tank portal:
        void CreateTankPortal(CTank tank)
        {
            CTankPortal portal = null;

            // Creating portal:
            switch (tank.TankID)
            {
            case Tanks.Player1: portal = new CTankPortal(0, PlayerRespawnPoints[0].X, PlayerRespawnPoints[0].Y, tank); break;

            case Tanks.Player2: portal = new CTankPortal(0, PlayerRespawnPoints[1].X, PlayerRespawnPoints[1].Y, tank); break;

            default:
            {
                portal = new CTankPortal(100, EnemyRespawnPoints[RespawnPointIndex].X, EnemyRespawnPoints[RespawnPointIndex].Y, tank);

                RespawnPointIndex++;
            } break;
            }

            // Setting coordinates for tank:
            portal.Tank.X = portal.X;

            portal.Tank.Y = portal.Y;

            // Cleaning position for portal:
            ClearPositionForObject(portal);

            // Adding portal to objects:
            AddObject(portal);
        }
Esempio n. 3
0
 // ********************** //
 //  Methods :
 // ********************** //
 // Constructor:
 public CTankPortal(int pause, int x, int y, CTank tank)
 {
     // Setting images:
     this.images = new List <Image> {
         Properties.Resources.tankportal_1, Properties.Resources.tankportal_2, Properties.Resources.tankportal_3, Properties.Resources.tankportal_4,
         Properties.Resources.tankportal_3, Properties.Resources.tankportal_2, Properties.Resources.tankportal_1, Properties.Resources.tankportal_2,
         Properties.Resources.tankportal_3, Properties.Resources.tankportal_4, Properties.Resources.tankportal_3, Properties.Resources.tankportal_2,
         Properties.Resources.tankportal_1, Properties.Resources.tankportal_2, Properties.Resources.tankportal_3, Properties.Resources.tankportal_4
     };
     // Setting tank:
     Tank = tank;
     // Setting position:
     this.X = x;
     this.Y = y;
     // Setting dimensions:
     this.Width  = 32;
     this.Height = 32;
     // Setting image change interval:
     this.imageChangeInterval = 6;
     // Set it transparent:
     this.Transparent = true;
     // Pause before apearing:
     PauseBeforeApear = pause;
     //
     Visible = false;
 }
        // *********************** //
        // 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++;
            }
        }
        // Checks if bonus is taken by someone:
        object OnCheck_IsBonusTaken(CBonus bonus)
        {
            int mapX = (int)(bonus.X / cellSize);

            int mapY = (int)(bonus.Y / cellSize);

            CTank bonustank = null;

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    bonustank = (mapMain[mapX + i, mapY + j] as CTankPlayer);

                    if (bonustank != null)
                    {
                        return(bonustank);
                    }
                }
            }

            return(null);
        }
        // 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));
        }
Esempio n. 7
0
 public static CForceField CreateForceField(CTank owner, int lifetime)
 {
     return(new CForceField(owner, lifetime));
 }