Class used to make multiple players and hold individual information
Exemplo n.º 1
0
 /// <summary>
 /// Dit is de constructor van de vehicle class. 
 /// </summary>
 public Vehicle(int x, int y,VehicleType t, Player t2)
 {
     vehicletype = t;
     StartPositionX = x;
     StartPositionY = y;
     player = t2;
     Base.gameTasks.Add(CheckShooting);
     Base.gameTasks.Add(CheckCollision);
 }
Exemplo n.º 2
0
        public async void Collision(Player p) {
            if(!p.Immune && game.CircleCollision(p.rect, rect)) {
                p.PlayEffectSound("spinout");
                Active = false;
                p.Hit = true;

                await Task.Delay(1500);
                p.Hit = false;
                game.BananaItems.Remove(this);
            }
        }
Exemplo n.º 3
0
 private void CheckIfStuck(Player player)
 {
     if(_lastX != player.Car.Position.X || _lastY != player.Car.Position.Y)
     {
         _lastMovement = DateTime.Now;
         _lastX = player.Car.Position.X;
         _lastY = player.Car.Position.Y;
     }
     else if(DateTime.Now.Subtract(_lastMovement).TotalSeconds >= 1)
     {
          player.Car.TurnLeft();
     }
 }
Exemplo n.º 4
0
 private void TurnRandom(Player player)
 {
     int chance = _random.Next(50);
        if (chance <= 5)
        {
        player.Car.TurnLeft();
        }
        else if (chance >= 45)
        {
        player.Car.TurnRight();
        }
        else if(chance == 30)
        {
        player.Car.Break();
        }
 }
Exemplo n.º 5
0
 public HorsePower(int x, int y, Player _player)
     : base(x, y, VehicleType.HorsePower, _player)
 {
     fuelCapacity = 140;
     fuel = fuelCapacity;
     maxSpeed = 4;
     acceleration = 0.025f;
     deceleration = 0.05f;
     turnSpeed = 2.6f;
     bitmap = Bitmaps.Vehicles.HorsePowerBody;
     vehicleSizeX = bitmap.Width;
     vehicleSizeY = bitmap.Height;
     weapon = new HorsePowerWeapon(_player);
     relativeWeaponPos.X = 0;
     relativeWeaponPos.Y = 0;
     maxHealth = 90;
     health = maxHealth;
     ramDamage = 40;
     sideDamageMultiplier = 1.5f;
     grassMultiplier = 0.6f;
 }
Exemplo n.º 6
0
        public void SpinItemBox(Player p) {
            p.PlayItemBoxSound();
            p.HasItem = true;
            Thread t = new Thread(() => {
                for(int i = 0; i < 50; i++) {
                    switch(rand.Next(4)) {
                        case 0:
                            p.ItemFrame.Image = Banana;
                            current = PowerupItem.Banana;
                            break;
                            
                        case 1:
                            p.ItemFrame.Image = Mushroom;
                            current = PowerupItem.Mushroom;
                            break;

                        case 2:
                            p.ItemFrame.Image = Shell;
                            current = PowerupItem.Shell;
                            break;
                        case 3:
                            p.ItemFrame.Image = RedShell;
                            current = PowerupItem.RedShell;
                            break;
                    }
                    Thread.Sleep(80);

                }
                p.currentPowerup = current;

            });

            t.IsBackground = true;
            t.Start();


        }
Exemplo n.º 7
0
        public void CheckItems(Player a, PictureBox b)
        {

            if (a.X + a.Width >= b.Location.X &&
                a.X <= b.Location.X + b.Size.Width &&
                a.Y + a.Height >= b.Location.Y &&
                a.Y <= b.Location.Y + b.Size.Height &&
                b.Visible == true)
            {
                b.Visible = false;
                GetItem();
                boost(a);
            }
        }
Exemplo n.º 8
0
 public void Borders(Player a)
 {
     if (a.X >= form.ClientSize.Width - p1.Width && a.SpeedX >= 0)
     {
         a.Speed = 0;
         a.X -= 10;
     }
     if (a.X <= 0)
     {
         a.Speed = 0;
         a.X += 10;
     }
     if (a.Y >= form.ClientSize.Height - a.Height && a.SpeedY >= 0)
     {
         a.Speed = 0;
         a.Y -= 10;
     }
     if (a.Y <= 0)
     {
         a.Speed = 0;
         a.Y += 10;
     }
 }
Exemplo n.º 9
0
 public void Collision(Game game, Player p) {
     rect = new Rectangle(X, Y, 42, 42);
     if(game.CircleCollision(p.rect, rect) && !Hit && !Disabled && !p.HasItem) {
         Hit = true;
         Disabled = true;
         Enable();
         SpinItemBox(p);
     }
 }
Exemplo n.º 10
0
 public Tank(int x, int y, Player _player)
     : base(x,y, VehicleType.Tank, _player)
 {
     fuelCapacity = 95;
     fuel = fuelCapacity;
     maxSpeed = 4f;
     acceleration = 0.05f;
     deceleration = 0.05f;
     turnSpeed = 2;
     name = "Tank";
     bitmap = Bitmaps.Vehicles.TankBody;
     vehicleSizeX = bitmap.Width * 2;
     vehicleSizeY = bitmap.Height * 2;
     weapon = new TankWeapon(_player);
     relativeWeaponPos.X = 0;
     relativeWeaponPos.Y = 0;
     maxHealth = 200;
     health = maxHealth;
     ramDamage = 100;
     sideDamageMultiplier = 1.1f;
     grassMultiplier = 0.9f;
     engineSound = AudioFiles.Tank;
 }
Exemplo n.º 11
0
 public LAPV(int x, int y, Player _player)
     : base(x, y, VehicleType.LAPV, _player)
 {
     fuelCapacity = 100;
     fuel = fuelCapacity;
     maxSpeed = 2.5f;
     acceleration = 0.05f;
     deceleration = 0.03f;
     turnSpeed = 4f;
     bitmap = Bitmaps.Vehicles.LAPVBody;
     vehicleSizeX = Convert.ToInt32(bitmap.Width * 1.5f);
     vehicleSizeY = Convert.ToInt32(bitmap.Height * 1.5f);
     weapon = new LAPVWeapon(_player);
     relativeWeaponPos.X = 0;
     relativeWeaponPos.Y = 0;
     maxHealth = 120;
     health = maxHealth;
     ramDamage = 80;
     sideDamageMultiplier = 1.1f;
     grassMultiplier = 0.8f;
     engineSound = AudioFiles.LAPVSound;
 }
Exemplo n.º 12
0
        public Racegame(MainMenu main, Character c1, Character c2, Map map)
        {
            InitializeComponent();
            this.main = main;
            this.map = map;
            StartTimer.Enabled = true;
            int checkpointCounter = 0;
            this.InterfaceBar = Interface;
            this.Decotimer = DecoTimer;
            player1Head.BackColor = Color.FromArgb(64, 72, 56);
            player2Head.BackColor = Color.FromArgb(64, 72, 56);

            player1Head.Image = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "heads/" + c1 + "R.png")));
            player2Head.Image = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "heads/" + c2 + "L.png")));

            List<Powerup> Powerups = new List<Powerup>();
            List<Location> RespawnPoints = new List<Location>();
            List<Decoration> Decorations = new List<Decoration>();
            Location p1Start = new Location(0, 0, 0);
            Location p2Start = new Location(0, 0, 0);

            switch (map)
            {

                case Map.Bowser_Castle:
                    checkpointCounter = 10;
                    Powerups.Add(new Powerup(438, 326));
                    Powerups.Add(new Powerup(418, 278));
                    p1Start = new Location(931, 312, -270);
                    p2Start = new Location(871, 264, -270);

                    RespawnPoints.Add(new Location(348, 558, -90));
                    RespawnPoints.Add(new Location(348, 558, -90));
                    RespawnPoints.Add(new Location(348, 558, -90));
                    RespawnPoints.Add(new Location(348, 558, -90));
                    RespawnPoints.Add(new Location(284, 449, 0));
                    RespawnPoints.Add(new Location(383, 642, -180));
                    RespawnPoints.Add(new Location(348, 558, -90));
                    RespawnPoints.Add(new Location(348, 558, -90));
                    RespawnPoints.Add(new Location(348, 558, -90));
                    RespawnPoints.Add(new Location(348, 558, -90));
                    // 646, 54; 300, 572; 608, 712; 828, 558

                    Decorations.Add(new Decoration(DecorationType.FireBall, 646, 54));
                    Decorations.Add(new Decoration(DecorationType.FireBall, 300, 572));
                    Decorations.Add(new Decoration(DecorationType.FireBall, 608, 712));
                    Decorations.Add(new Decoration(DecorationType.FireBall, 828, 558));

                    Soundtrack = "sounds/Bowser Castle.wav";
                    intro = "sounds/Bowser Castle intro.wav";
                    IntroLength = 3680;
                    break;

                case Map.Choco_Island:
                    checkpointCounter = 10;
                    Powerups.Add(new Powerup(724, 626));
                    Powerups.Add(new Powerup(786, 596));
                    p1Start = new Location(390, 274, -90);
                    p2Start = new Location(458, 314, -90);

                    Decorations.Add(new Decoration(DecorationType.Piranha, 278, 102));
                    Decorations.Add(new Decoration(DecorationType.Piranha, 48, 676));
                    Decorations.Add(new Decoration(DecorationType.Piranha, 368, 546));
                    Decorations.Add(new Decoration(DecorationType.Piranha, 883, 166));
                    Decorations.Add(new Decoration(DecorationType.Piranha, 946, 670));

                    Soundtrack = "sounds/Choco Island.wav";
                    intro = "sounds/Choco Island intro.wav";
                    IntroLength = 1400;
                    break;

                case Map.Donut_Plains:
                    checkpointCounter = 10;
                    Powerups.Add(new Powerup(836,258));
                    Powerups.Add(new Powerup(928,244));
                    p1Start = new Location(96, 456, -90);
                    p2Start = new Location(169, 492, -90);

                    RespawnPoints.Add(new Location(138, 375, -90));
                    RespawnPoints.Add(new Location(195, 172, 0));
                    RespawnPoints.Add(new Location(412, 161, 0));
                    RespawnPoints.Add(new Location(701, 158, 0));
                    RespawnPoints.Add(new Location(752, 321, -180));
                    RespawnPoints.Add(new Location(449, 324, -180));
                    RespawnPoints.Add(new Location(526, 452, -330));
                    RespawnPoints.Add(new Location(800, 527, -315));
                    RespawnPoints.Add(new Location(629, 648, -165));
                    RespawnPoints.Add(new Location(359, 559, -180));

                    Decorations.Add(new Decoration(DecorationType.Mole, 100, 658));
                    Decorations.Add(new Decoration(DecorationType.Mole, 888, 146));

                    Soundtrack = "sounds/Donut Plains.wav";
                    intro = "sounds/Donut Plains intro.wav";
                    IntroLength = 210;
                    break;

                case Map.Ghost_Valley:
                    checkpointCounter = 10;
                    Powerups.Add(new Powerup(344, 224));
                    Powerups.Add(new Powerup(418, 202));
                    p1Start = new Location(338, 650, -180);
                    p2Start = new Location(388, 590, -180);

                    RespawnPoints.Add(new Location(205, 646, -180));
                    RespawnPoints.Add(new Location(47, 450, -90));
                    RespawnPoints.Add(new Location(98, 143, 0));
                    RespawnPoints.Add(new Location(352, 281, -270));
                    RespawnPoints.Add(new Location(356, 479, 0));
                    RespawnPoints.Add(new Location(602, 474, -45));
                    RespawnPoints.Add(new Location(743, 301, -90));
                    RespawnPoints.Add(new Location(900, 301, -270));
                    RespawnPoints.Add(new Location(760, 654, -180));
                    RespawnPoints.Add(new Location(552, 627, -180));

                    Decorations.Add(new Decoration(DecorationType.Ghost, 188, 248));
                    Decorations.Add(new Decoration(DecorationType.Ghost, 554, 385));
                    Decorations.Add(new Decoration(DecorationType.Ghost, 644, 52));
                    Decorations.Add(new Decoration(DecorationType.Ghost, 792, 547));

                    Soundtrack = "sounds/Ghost Valley.wav";
                    intro = "sounds/Ghost Valley intro.wav";
                    IntroLength = 6170;
                    break;

                case Map.Koopa_Beach:
                    checkpointCounter = 10;
                    Powerups.Add(new Powerup(846, 236));
                    Powerups.Add(new Powerup(768, 216));
                    p1Start = new Location(116, 254, -90);
                    p2Start = new Location(183, 284, -90);

                    RespawnPoints.Add(new Location(155, 179, -60));
                    RespawnPoints.Add(new Location(279, 105, 0));
                    RespawnPoints.Add(new Location(593, 121, -330));
                    RespawnPoints.Add(new Location(508, 121, -300));
                    RespawnPoints.Add(new Location(865, 420, -270));
                    RespawnPoints.Add(new Location(760, 569, -180));
                    RespawnPoints.Add(new Location(539, 508, -180));
                    RespawnPoints.Add(new Location(296, 539, -180));
                    RespawnPoints.Add(new Location(92, 567, -105));
                    RespawnPoints.Add(new Location(116, 345, -90));

                    Decorations.Add(new Decoration(DecorationType.Red_Fish, 386, 324));
                    Decorations.Add(new Decoration(DecorationType.Red_Fish, 688, 458));
                    Decorations.Add(new Decoration(DecorationType.Red_Fish, 890, 706));

                    Soundtrack = "sounds/Koopa Beach.wav";
                    intro = "sounds/Koopa Beach intro.wav";
                    IntroLength = 15220;
                    break;

                case Map.Rainbow_Road:
                    checkpointCounter = 10;
                    Powerups.Add(new Powerup(694, 217));
                    Powerups.Add(new Powerup(767, 274));
                    p1Start = new Location(23, 344, -90);
                    p2Start = new Location(102, 392, -90);

                    RespawnPoints.Add(new Location(66, 238, -90));
                    RespawnPoints.Add(new Location(291, 115, 0));
                    RespawnPoints.Add(new Location(718, 139, -270));
                    RespawnPoints.Add(new Location(575, 325, -180));
                    RespawnPoints.Add(new Location(293, 367, -270));
                    RespawnPoints.Add(new Location(566, 481, 0));
                    RespawnPoints.Add(new Location(879, 646, -180));
                    RespawnPoints.Add(new Location(538, 615, -180));
                    RespawnPoints.Add(new Location(255, 654, -180));
                    RespawnPoints.Add(new Location(65, 550, -90));

                    Decorations.Add(new Decoration(DecorationType.Star, 302, 234));
                    Decorations.Add(new Decoration(DecorationType.Star, 902, 200));
                    Decorations.Add(new Decoration(DecorationType.Star, 738, 588));

                    Soundtrack = "sounds/Rainbow Road.wav";
                    intro = "sounds/Rainbow Road intro.wav";
                    IntroLength = 12760;
                    break;

                case Map.Standard:
                    checkpointCounter = 3;
                    Powerups.Add(new Powerup(562, 380));
                    Powerups.Add(new Powerup(614, 416));
                    p1Start = new Location(532, 86, 0);
                    p2Start = new Location(502, 156, 0);

                    Decorations.Add(new Decoration(DecorationType.Piranha, 117, 183));
                    Decorations.Add(new Decoration(DecorationType.Piranha, 248, 510));

                    Soundtrack = "sounds/Mario Circuit.wav";
                    intro = "sounds/Mario Circuit intro.wav";
                    IntroLength = 10280;
                    break;

                case Map.Vanilla_Lake:
                    checkpointCounter = 10;
                    Powerups.Add(new Powerup(388, 134));
                    Powerups.Add(new Powerup(426, 188));
                    p1Start = new Location(806, 437, -90);
                    p2Start = new Location(877, 406, -90);

                    RespawnPoints.Add(new Location(821, 330, -90));
                    RespawnPoints.Add(new Location(712, 135, -180));
                    RespawnPoints.Add(new Location(485, 169, -180));
                    RespawnPoints.Add(new Location(222, 198, -240));
                    RespawnPoints.Add(new Location(171, 446, -270));
                    RespawnPoints.Add(new Location(132, 634, 0));
                    RespawnPoints.Add(new Location(389, 636, 0));
                    RespawnPoints.Add(new Location(648, 636, -15));
                    RespawnPoints.Add(new Location(760, 576, -45));
                    RespawnPoints.Add(new Location(819, 432, -90));

                    Decorations.Add(new Decoration(DecorationType.Blue_Fish, 370, 428));
                    Decorations.Add(new Decoration(DecorationType.Blue_Fish, 620, 338));

                    Soundtrack = "sounds/Vanilla lake.wav";
                    intro = "sounds/Vanilla lake intro.wav";
                    IntroLength = 29270;
                    break;

            }

            p2 = new Player("Player 2", c2, this, null, Keys.Up, Keys.Down, Keys.Right, Keys.Left, Keys.ControlKey, FuelBox2, Player2Box, Fueladder2, Speed2, checkpointCounter, p2Start);
            p1 = new Player("Player 1", c1, this, null, Keys.W, Keys.S, Keys.D, Keys.A, Keys.ShiftKey, FuelBox, Player1Box, Fueladder, Speed1, checkpointCounter, p1Start);
            Game game = new Game(main, this, this, p1, p2, map, Soundtrack, intro, IntroLength, FinishMessage, 3, Powerups, RespawnPoints, Decorations);
            this.game = game;
            this.BackgroundImage = game.circuit;
            this.Opacity = 0;
        }
Exemplo n.º 13
0
        public Game(MainMenu main, Racegame rg, Form form, Player p1, Player p2, Map map, string soundtrack, string intro, int introlength, Label FinishMessage, int checkpointAmount, List<Powerup> Powerups, List<Location> RespawnPoints, List<Decoration> Decorations)
        {
            this.p1 = p1;
            this.p2 = p2;
            this.map = map;
            this.form = form;
            this.main = main;
            this.FinishMessage = FinishMessage;
            this.rg = rg;
            this.Powerups = Powerups;
            this.RespawnPoints = RespawnPoints;
            this.Decorations = Decorations;
            this.Intro = intro;
            this.Introlength = introlength;
            this.Soundtrack = soundtrack;
            for(int i = 0; i < checkpointAmount; i++) {
                checkpointPoints += 255 - i * 10;
            }

            p1.FuelTimer.Interval = 17;
            p1.FuelTimer.Tick += new System.EventHandler(this.Fueladder_Tick);

            p2.FuelTimer.Interval = 17;
            p2.FuelTimer.Tick += new System.EventHandler(this.Fueladder2_Tick);

            switch(map) {
                // Loads correct colormaps and background for every map.
                case Map.Standard:
                    circuit = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Standard/circuit.png")));
                    colormap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Standard/colormap.png")));
                    checkpoints = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Standard/checkpoints.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    wallmap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Standard/wallmap.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    break;
                case Map.Donut_Plains:
                    circuit = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Donut_Plains/circuit.png")));
                    colormap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Donut_Plains/colormap.png")));
                    checkpoints = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Donut_Plains/checkpoints.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    wallmap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Donut_Plains/wallmap.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    break;
                case Map.Ghost_Valley:
                    circuit = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Ghost_Valley/circuit.png")));
                    colormap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Ghost_Valley/colormap.png")));
                    checkpoints = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Ghost_Valley/checkpoints.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    wallmap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Ghost_Valley/wallmap.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    break;
                case Map.Bowser_Castle:
                    circuit = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Bowsers_Castle/circuit.png")));
                    colormap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Bowsers_Castle/colormap.png")));
                    checkpoints = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Bowsers_Castle/checkpoints.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    wallmap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Bowsers_Castle/wallmap.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    break;
                case Map.Choco_Island:
                    circuit = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Choco_Island/circuit.png")));
                    colormap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Choco_Island/colormap.png")));
                    checkpoints = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Choco_Island/checkpoints.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    wallmap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Choco_Island/wallmap.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    break;
                case Map.Koopa_Beach:
                    circuit = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Koopa_Beach/circuit.png")));
                    colormap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Koopa_Beach/colormap.png")));
                    checkpoints = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Koopa_Beach/checkpoints.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    break;
                case Map.Vanilla_Lake:
                    circuit = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Vanilla_Lake/circuit.png")));
                    colormap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Vanilla_Lake/colormap.png")));
                    checkpoints = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Vanilla_Lake/checkpoints.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    wallmap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Vanilla_Lake/wallmap.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    break;
                case Map.Rainbow_Road:
                    circuit = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Rainbow_Road/circuit.png")));
                    colormap = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Rainbow_Road/colormap.png")));
                    checkpoints = new Bitmap(Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Rainbow_Road/checkpoints.png")), new Size(form.ClientSize.Width, form.ClientSize.Height));
                    break; 
            }
        }
Exemplo n.º 14
0
 public async void boost(Player a)
 {
     if (a == p1)
     {
         p1.FuelTimer.Enabled = true;
     }
     else
     {
         p2.FuelTimer.Enabled = true;
     }
     a.Speed = 20;
     a.MaxSpeed *= 2;
     await WaitMethod2();
     if(a.Speed >= 14) { 
     a.Speed = 14;
 }
     a.MaxSpeed /= 2;
     if (a == p1)
     {
         p1.FuelTimer.Enabled = false;
     }
     else
     {
         p2.FuelTimer.Enabled = false;
     }
 }
Exemplo n.º 15
0
        public async void Collision(Player p)
        {
            if (!p.Immune && game.CircleCollision(p.rect, rect))
            {
                Active = false;
                p.Hit = true;

                await Task.Delay(1000);
                p.Hit = false;
                game.RedShellItems.Remove(this);

            }

        }
Exemplo n.º 16
0
        public void Move(Bitmap image, Player player, Player player2, Map map)
        {

            xCenter = (int)(X + 42 / 2);
            yCenter = (int)(Y + (42 / 2));
            System.Drawing.Color col = image.GetPixel(xCenter, yCenter);
            switch (getColor(col.R, col.G, col.B))
            {
                case ColorHandler.Gat:
                    Active = false;
                    game.RedShellItems.Remove(this);
                    break;
            } 
            xDistancePlayer = Convert.ToInt32(xCenter - (player.X + player.Width / 2));
            yDistancePlayer = Convert.ToInt32(yCenter - (player.Y + player.Height / 2));
            xDistancePlayer2 = Convert.ToInt32(xCenter - (player2.X + player2.Width / 2));
            yDistancePlayer2 = Convert.ToInt32(yCenter - (player2.Y + player2.Height / 2));
            if (startchecked == false)
            {
                if (xCenter >= xmin[0] && xCenter <= xmax[0] && yCenter >= ymin[0] && yCenter <= ymax[0])
                {
                    reached[0] = false;
                    reached[1] = false;
                    reached[2] = false;
                    reached[3] = false;
                    reached[4] = false;
                    calc[0] = true;

                }
                else if (xCenter >= xmin[1] && xCenter <= xmax[1] && yCenter >= ymin[1] && yCenter <= ymax[1])
                {
                    reached[0] = true;
                    reached[1] = false;
                    reached[2] = false;
                    reached[3] = false;
                    reached[4] = false;
                    calc[1] = true;

                }
                else if (xCenter >= xmin[2] && xCenter <= xmax[2] && yCenter >= ymin[2] && yCenter <= ymax[2])
                {
                    reached[0] = true;
                    reached[1] = true;
                    reached[2] = false;
                    reached[3] = false;
                    reached[4] = false;
                    calc[2] = true;
                }
                else if (xCenter >= xmin[3] && xCenter <= xmax[3] && yCenter >= ymin[3] && yCenter <= ymax[3])
                {
                    reached[0] = true;
                    reached[1] = true;
                    reached[2] = true;
                    reached[3] = false;
                    reached[4] = false;
                    calc[3] = true;

                }
                else if (xCenter >= xmin[4] && xCenter <= xmax[4] && yCenter >= ymin[4] && yCenter <= ymax[4])
                {
                    reached[0] = true;
                    reached[1] = true;
                    reached[2] = true;
                    reached[3] = true;
                    reached[4] = false;
                    calc[4] = true;

                }
                else if (xCenter >= xmin[5] && xCenter <= xmax[5] && yCenter >= ymin[5] && yCenter <= ymax[5])
                {
                    reached[0] = true;
                    reached[1] = true;
                    reached[2] = true;
                    reached[3] = true;
                    reached[4] = true;
                    calc[5] = true;

                }
                else if (xCenter >= xmin[6] && xCenter <= xmax[6] && yCenter >= ymin[6] && yCenter <= ymax[6])
                {
                    reached[0] = true;
                    reached[1] = true;
                    reached[2] = true;
                    reached[3] = true;
                    reached[4] = true;
                    reached[5] = true;
                    reached[6] = false;
                    reached[7] = false;
                    reached[8] = false;
                    reached[9] = false;
                    calc[6] = true;

                }
                else if (xCenter >= xmin[7] && xCenter <= xmax[7] && yCenter >= ymin[7] && yCenter <= ymax[7])
                {
                    reached[0] = true;
                    reached[1] = true;
                    reached[2] = true;
                    reached[3] = true;
                    reached[4] = true;
                    reached[5] = true;
                    reached[6] = true;
                    reached[7] = false;
                    reached[8] = false;
                    reached[9] = false;

                    calc[7] = true;

                }
                else if (xCenter >= xmin[8] && xCenter <= xmax[8] && yCenter >= ymin[8] && yCenter <= ymax[8])
                {
                    reached[0] = true;
                    reached[1] = true;
                    reached[2] = true;
                    reached[3] = true;
                    reached[4] = true;
                    reached[5] = true;
                    reached[6] = true;
                    reached[7] = true;
                    reached[8] = false;
                    reached[9] = false;

                    calc[8] = true;

                }
                else if (xCenter >= xmin[9] && xCenter <= xmax[9] && yCenter >= ymin[9] && yCenter <= ymax[9])
                {
                    reached[0] = true;
                    reached[1] = true;
                    reached[2] = true;
                    reached[3] = true;
                    reached[4] = true;
                    reached[5] = true;
                    reached[6] = true;
                    reached[7] = true;
                    reached[8] = true;
                    reached[9] = false;
                    calc[9] = true;

                }
                else if (xCenter >= xmin[10] && xCenter <= xmax[10] && yCenter >= ymin[10] && yCenter <= ymax[10])
                {
                    reached[0] = true;
                    reached[1] = true;
                    reached[2] = true;
                    reached[3] = true;
                    reached[4] = true;
                    reached[5] = true;
                    reached[6] = true;
                    reached[7] = true;
                    reached[8] = true;
                    reached[9] = true;
                    calc[10] = true;

                }
                if (map == Map.Choco_Island)
                {
                    if (xCenter >= xminextra[0] && xCenter <= xmaxextra[0] && yCenter >= yminextra[0] && yCenter <= ymaxextra[0])
                    {
                        reached[0] = false;
                        reached[1] = false;
                        reached[2] = false;
                        reached[3] = false;
                        reached[4] = false;
                        reached[5] = false;
                        reached[6] = false;
                        reached[7] = false;
                        reached[8] = false;
                        reached[9] = false;
                        calc[0] = true;

                    }
                    else if (xCenter >= xminextra[1] && xCenter <= xmaxextra[1] && yCenter >= yminextra[1] && yCenter <= ymaxextra[1])
                    {
                        reached[0] = true;
                        reached[1] = false;
                        reached[2] = false;
                        reached[3] = false;
                        reached[4] = false;
                        reached[5] = false;
                        reached[6] = false;
                        reached[7] = false;
                        reached[8] = false;
                        reached[9] = false;
                        calc[1] = true;

                    }
                    else if (xCenter >= xminextra[2] && xCenter <= xmaxextra[2] && yCenter >= yminextra[2] && yCenter <= ymaxextra[2])
                    {
                        reached[0] = true;
                        reached[1] = false;
                        reached[2] = false;
                        reached[3] = false;
                        reached[4] = false;
                        reached[5] = false;
                        reached[6] = false;
                        reached[7] = false;
                        reached[8] = false;
                        reached[9] = false;
                        calc[1] = true;
                    }
                    else if (xCenter >= xminextra[3] && xCenter <= xmaxextra[3] && yCenter >= yminextra[3] && yCenter <= ymaxextra[3])
                    {
                        reached[0] = true;
                        reached[1] = true;
                        reached[2] = true;
                        reached[3] = false;
                        reached[4] = false;
                        reached[5] = false;
                        reached[6] = false;
                        reached[7] = false;
                        reached[8] = false;
                        reached[9] = false;
                        calc[3] = true;

                    }
                }
                
                startchecked = true;
            }

                if (targetchecked == false)
                {
                    if (Math.Abs(xDistancePlayer) > Math.Abs(xDistancePlayer2) && Math.Abs(yDistancePlayer) > Math.Abs(yDistancePlayer2))
                    {
                        targetplayer = true;
                    }
                    else if (Math.Abs(xDistancePlayer) < Math.Abs(xDistancePlayer2)&& Math.Abs(yDistancePlayer) < Math.Abs(yDistancePlayer2))
                    {
                        targetplayer2 = true;
                    }
                    targetchecked = true;
                }

                if (reached[0] == false &&
                    attackplayer == false && attackplayer2 == false)
                {
                     xDistances[0] = xCenter - points[0].X;
                     yDistances[0] = yCenter - points[0].Y;
                if (calc[0] == true)
                    {
                        truexDistances[0] = (xDistances[0]);
                        trueyDistances[0] = (yDistances[0]);
                        calc[0] = false;
                    }
                    X -= truexDistances[0] / 30;
                    Y -= trueyDistances[0] / 30;
                    if (xDistances[0] > -20 && xDistances[0] < 20 && yDistances[0] > -20 && yDistances[0] < 20)
                    {
                        reached[0] = true;
                        calc[1] = true;

                    }
                }
                else if (reached[0] == true && reached[1] == false &&
                    attackplayer == false && attackplayer2 == false)
                {
                    xDistances[1] = xCenter - points[1].X;
                    yDistances[1] = yCenter - points[1].Y;
                    if (calc[1] == true)
                    {
                        truexDistances[1] = xDistances[1];
                        trueyDistances[1] = yDistances[1];
                        calc[1] = false;
                    }
                    X -= truexDistances[1] / 30;
                    Y -= trueyDistances[1] / 30;
                    if (xDistances[1] > -20 && xDistances[1] < 20 && yDistances[1] > -20 && yDistances[1] < 20)
                    {
                        reached[1] = true;
                        calc[2] = true;

                    }
                }
                else if (reached[0] == true && reached[1] == true && reached[2] == false &&
                    attackplayer == false && attackplayer2 == false)
                {
                    xDistances[2] = xCenter - points[2].X;
                    yDistances[2] = yCenter - points[2].Y;
                    if (calc[2] == true)
                    {
                        truexDistances[2] = xDistances[2];
                        trueyDistances[2] = yDistances[2];
                        calc[2] = false;
                    }
                    X -= truexDistances[2] / 30;
                    Y -= trueyDistances[2] / 30;
                    if (xDistances[2] > -20 && xDistances[2] < 20 && yDistances[2] > -20 && yDistances[2] < 20)
                    {
                        reached[2] = true;
                        calc[3] = true;

                    }
                }

                else if (reached[0] == true && reached[1] == true && reached[2] == true
        && reached[3] == false &&
                    attackplayer == false && attackplayer2 == false)
                {
                    xDistances[3] = xCenter - points[3].X;
                    yDistances[3] = yCenter - points[3].Y;
                    if (calc[3] == true)
                    {
                        truexDistances[3] = xDistances[3];
                        trueyDistances[3] = yDistances[3];
                        calc[3] = false;
                    }
                    X -= truexDistances[3] / 30;
                    Y -= trueyDistances[3] / 30;
                    if (xDistances[3] > -20 && xDistances[3] < 20 && yDistances[3] > -20 && yDistances[3] < 20)
                    {
                        reached[3] = true;
                        calc[4] = true;

                    }
                }
                else if (reached[0] == true && reached[1] == true && reached[2] == true
        && reached[3] == true && reached[4] == false &&
                    attackplayer == false && attackplayer2 == false)
                {
                    xDistances[4] = xCenter - points[4].X;
                    yDistances[4] = yCenter - points[4].Y;
                if (xDistances[4] > -20 && xDistances[4] < 20 && yDistances[4] > -20 && yDistances[4] < 20)
                {
                    reached[4] = true;
                    calc[5] = true;

                }
                if (calc[4] == true)
                    {
                        truexDistances[4] = xDistances[4];
                        trueyDistances[4] = yDistances[4];
                        calc[4] = false;
                    }
                    X -= truexDistances[4] / 30;
                    Y -= trueyDistances[4] / 30;
                }
                else if (reached[0] == true && reached[1] == true && reached[2] == true
     && reached[3] == true && reached[4] == true && reached[5] == false &&
                    attackplayer == false && attackplayer2 == false)
                {
                    xDistances[5] = xCenter - points[5].X;
                    yDistances[5] = yCenter - points[5].Y;
                if (xDistances[5] > -20 && xDistances[5] < 20 && yDistances[5] > -20 && yDistances[5] < 20)
                {
                    reached[5] = true;
                    calc[6] = true;

                }
                if (calc[5] == true)
                    {
                        truexDistances[5] = xDistances[5];
                        trueyDistances[5] = yDistances[5];
                        calc[5] = false;
                    }
                    X -= truexDistances[5] / 30;
                    Y -= trueyDistances[5] / 30;



                }
                else if (reached[0] == true && reached[1] == true && reached[2] == true
    && reached[3] == true && reached[4] == true && reached[5] == true && reached[6] == false
       &&
        attackplayer == false && attackplayer2 == false)
                {
                    xDistances[6] = xCenter - points[6].X;
                    yDistances[6] = yCenter - points[6].Y;
                if (xDistances[6] > -20 && xDistances[6] < 20 && yDistances[6] > -20 && yDistances[6] < 20)
                {
                    reached[6] = true;
                    calc[7] = true;

                }
                if (calc[6] == true)
                    {
                        truexDistances[6] = xDistances[6];
                        trueyDistances[6] = yDistances[6];
                        calc[6] = false;
                    }
                    X -= truexDistances[6] / 30;
                    Y -= trueyDistances[6] / 30;



                }
                else if (reached[0] == true && reached[1] == true && reached[2] == true
    && reached[3] == true && reached[4] == true && reached[5] == true && reached[6] == true
        && reached[7] == false &&
        attackplayer == false && attackplayer2 == false)
                {
                    xDistances[7] = xCenter - points[7].X;
                    yDistances[7] = yCenter - points[7].Y;
                    if (calc[7] == true)
                    {
                        truexDistances[7] = xDistances[7];
                        trueyDistances[7] = yDistances[7];
                        calc[7] = false;
                    }
                    X -= truexDistances[7] / 30;
                    Y -= trueyDistances[7] / 30;
                    if (xDistances[7] > -20 && xDistances[7] < 20 && yDistances[7] > -20 && yDistances[7] < 20)
                    {
                        reached[7] = true;
                        calc[8] = true;

                    }


                }
                else if (reached[0] == true && reached[1] == true && reached[2] == true
    && reached[3] == true && reached[4] == true && reached[5] == true && reached[6] == true
        && reached[7] == true && reached[8] == false &&
        attackplayer == false && attackplayer2 == false)
                {
                    xDistances[8] = xCenter - points[8].X;
                    yDistances[8] = yCenter - points[8].Y;
                if (xDistances[8] > -20 && xDistances[8] < 20 && yDistances[8] > -20 && yDistances[8] < 20)
                {
                    reached[8] = true;
                    calc[9] = true;

                }
                if (calc[8] == true)
                    {
                        truexDistances[8] = xDistances[8];
                        trueyDistances[8] = yDistances[8];
                        calc[8] = false;
                    }
                    X -= truexDistances[8] / 30;
                    Y -= trueyDistances[8] / 30;
                }
                else if (reached[0] == true && reached[1] == true && reached[2] == true
    && reached[3] == true && reached[4] == true && reached[5] == true && reached[6] == true
        && reached[7] == true && reached[8] == true && reached[9] == false &&
        attackplayer == false && attackplayer2 == false)
                {
                    xDistances[9] = xCenter - points[9].X;
                    yDistances[9] = yCenter - points[9].Y;
                if (xDistances[9] > -20 && xDistances[9] < 20 && yDistances[9] > -20 && yDistances[9] < 20)
                {
                    reached[9] = true;
                    calc[10] = true;
                }
                if (calc[9] == true)
                    {
                        truexDistances[9] = xDistances[9];
                        trueyDistances[9] = yDistances[9];
                        calc[9] = false;
                    }
                    X -= truexDistances[9] / 30;
                    Y -= trueyDistances[9] / 30;
                }
                else if (reached[0] == true && reached[1] == true && reached[2] == true
    && reached[3] == true && reached[4] == true && reached[5] == true && reached[6] == true
    && reached[7] == true && reached[8] == true && reached[9] == true &&
    attackplayer == false && attackplayer2 == false)
                {
                    xDistances[10] = xCenter - points[10].X;
                    yDistances[10] = yCenter - points[10].Y;
                if (xDistances[10] > -20 && xDistances[10] < 20 && yDistances[10] > -20 && yDistances[10] < 20)
                {
                    reached[10] = true;
                    reached[0] = false;
                    reached[1] = false;
                    reached[2] = false;
                    reached[3] = false;
                    reached[4] = false;
                    reached[5] = false;
                    reached[6] = false;
                    reached[7] = false;
                    reached[8] = false;
                    reached[9] = false;
                    reached[10] = false;
                    calc[0] = true;
                }
                if (calc[10] == true)
                    { 
                        truexDistances[10] = xDistances[10];
                        trueyDistances[10] = yDistances[10];
                        calc[10] = false;
                    Console.WriteLine("Reset");
                }
                    X -= truexDistances[10] / 30;
                    Y -= trueyDistances[10] / 30;

            }


            if (targetplayer == true)
            {
                if (attackplayer == false)
                {
                    {
                        if (xDistancePlayer <= 150 && xDistancePlayer >= -150 && yDistancePlayer <= 150 && yDistancePlayer >= -150)
                        {
                            attackplayer = true;
                        }
                    }
                }
                if (attackplayer == true)
                {
                    X -= xDistancePlayer / 8;
                    Y -= yDistancePlayer / 8;

                }

            }
            if (targetplayer2 == true)
            {
                if (attackplayer2 == false)
                {
                    {
                        if (xDistancePlayer2 <= 150 && xDistancePlayer2 >= -150 && yDistancePlayer2 <= 150 && yDistancePlayer2 >= -150)
                        {
                            attackplayer2 = true;
                        }
                    }
                }
                if (attackplayer2 == true)
                {
                    X -= xDistancePlayer2 / 8;
                    Y -= yDistancePlayer2 / 8;

                }

            }
        }
Exemplo n.º 17
0
        public void Draw(Graphics g, Bitmap image, Player player, Player player2, Map map)
        {
            if (!Active) return;
            rect = new Rectangle((int)X, (int)Y, 42, 42);
            g.DrawImage(RedShell_Image, rect);
            Move(image, player, player2, map);

        }
Exemplo n.º 18
0
 public void Speed(Player a, Label b)
 {
     
     //double speed = Math.Sqrt(Math.Pow(a.SpeedX, 2) + Math.Pow(a.SpeedY, 2));
     double speed =  (149 / 14) * Math.Abs(a.Speed);
     b.Width = Convert.ToInt32(speed);
 }
Exemplo n.º 19
0
 public HorsePowerWeapon(Player s)
     : base(s)
 {
     damage = 2;
     fireRate = 1;
     turnSpeed = 3;
     timeout = 4;
     weaponSprite = Bitmaps.Bullets.Vlam;
     soundPlayer = AudioFiles.Flame;
 }
Exemplo n.º 20
0
 private void FinishCheck(Player a, Player b)
 {
     if(a.GameEnded == true ||
         b.GameEnded == true)
     {
         racefinished = true;
     }
 }
Exemplo n.º 21
0
 public LAPVWeapon(Player s)
     : base(s)
 {
     weaponSprite = Bitmaps.Vehicles.LAPVWeapon;
     damage = 15;
     fireRate = 5;
     turnSpeed = 3;
     BulletSprite = Bitmaps.Bullets.RegularBullet;
     weaponSizeX = weaponSprite.Width * 2;
     weaponSizeY = weaponSprite.Height * 2;
     soundPlayer = AudioFiles.MGSound;
 }
Exemplo n.º 22
0
 public Jackass(int x, int y, Player _player)
     : base(x,y,VehicleType.Jackass, _player)
 {
     fuelCapacity = 120;
     fuel = fuelCapacity;
     maxSpeed = 5f;
     acceleration = 0.06f;
     deceleration = 0.02f;
     turnSpeed = 6f;
     bitmap = Bitmaps.Vehicles.Jackass;
     vehicleSizeX = Convert.ToInt32(bitmap.Width * 1.5f);
     vehicleSizeY = Convert.ToInt32(bitmap.Height * 1.5f);
     weapon = null;
     maxHealth = 75;
     health = maxHealth;
     ramDamage = 200;
     sideDamageMultiplier = 2f;
     grassMultiplier = 0.4f;
     engineSound = AudioFiles.Winkelwagen;
 }
Exemplo n.º 23
0
 public MotorfietsWeapon(Player s)
     : base(s)
 {
     weaponSprite = Bitmaps.Vehicles.MotorfietsWeapon;
     damage = 3;
     fireRate = 13;
     turnSpeed = 4;
     weaponSizeX = Convert.ToInt32(weaponSprite.Width * 1.5f);
     weaponSizeY = Convert.ToInt32(weaponSprite.Height * 1.5f);
     soundPlayer = AudioFiles.Gunshot2;
     BulletSprite = Bitmaps.Bullets.RegularBullet;
 }
Exemplo n.º 24
0
 public Motorfiets(int x, int y, Player _player)
     : base(x, y, VehicleType.Motorfiets, _player)
 {
     fuelCapacity = 70;
     fuel = fuelCapacity;
     maxSpeed = 6f;
     acceleration = 0.07f;
     deceleration = 0.02f;
     turnSpeed = 7f;
     bitmap = Bitmaps.Vehicles.MotorfietsBody;
     vehicleSizeX = bitmap.Width;
     vehicleSizeY = bitmap.Height;
     weapon = new MotorfietsWeapon(_player);
     relativeWeaponPos.X = 0;
     relativeWeaponPos.Y = 0;
     maxHealth = 60;
     health = maxHealth;
     ramDamage = 30;
     sideDamageMultiplier = 2;
     grassMultiplier = 0.4f;
     engineSound = AudioFiles.Motor;
 }
Exemplo n.º 25
0
 public TankWeapon(Player s)
     : base(s)
 {
     weaponSprite = Bitmaps.Vehicles.TankWeapon;
     damage = 75;
     fireRate = 100;
     turnSpeed = 3f;
     turning = "false";
     BulletSprite = Bitmaps.Bullets.RoundBullet;
     soundPlayer = AudioFiles.TankShot;
 }
Exemplo n.º 26
0
 public Weapons(Player t)
 {
     player = t;
 }
Exemplo n.º 27
0
 public void Fueling(Player a, PictureBox b)
 {
     //adjusts fuelbar size to amount of fuel player has.
     a.Fuel -= Math.Abs(Convert.ToInt16(a.Speed));
     Size fuelboxsize = new Size(a.Fuel * 72 / 7500, 12);
     b.Size = fuelboxsize;
     if(a.Fuel <= 2500) {
         b.BackColor = Color.Yellow; //when player is almost out of fuel, fuelbar turns yellow as a warning.
     }else {
         b.BackColor = Color.Red;
     }
     if (a.Fuel <= 0 && !a.GameEnded)
     {
         a.MaxSpeed = 2;
     }
 }
Exemplo n.º 28
0
 public void CreatePlayers(Enums.VehicleType player1Vehicle, Enums.VehicleType player2Vehicle)
 {
     player1 = null;
     player2 = null;
     player1 = new Player(1);
     player1.CreateVehicle(player1Vehicle, SpawnPointP1);
     player1.vehicle.StartDraw();
     player1.vehicle.StartWeaponDraw();
     player2 = new Player(2);
     player2.CreateVehicle(player2Vehicle, SpawnPointP2);
     player2.vehicle.StartDraw();
     player2.vehicle.StartWeaponDraw();
     Base.gameTasks.Add(player1.vehicle.Appelnoot);
     Base.gameTasks.Add(player2.vehicle.Appelnoot);
 }
Exemplo n.º 29
0
 public MotorfietsWeapon(Player s)
     : base(s)
 {
     weaponSprite = Bitmaps.Vehicles.MotorfietsWeapon;
     damage = 10;
     fireRate = 20;
     turnSpeed = 4;
     weaponSprite = Bitmaps.Bullets.RoundBullet;
 }