Beispiel #1
0
        public static void useVehicle(Player player, Vehicule item, Controles controles)
        {
            player.usingVehicle = true;
            item.position       = player.position;
            item.isOnMap        = false;
            player.size         = item.size;

            {
            }
            for (int i = 0; i < player.ItemList.Count; i++)
            {
                if (player.ItemList[i].type == objectType.weapon)
                {
                    player.ItemList[i].isOnMap = false;
                }
            }
            if (item.vehiculeType == vehiculeType.Hornet)
            {
                item.position = player.position;
                item.useHornet(player, item, controles);
            }
            if (item.vehiculeType == vehiculeType.Banshee)
            {
                item.useBanshee(player, item, controles);
            }
            if (item.vehiculeType == vehiculeType.Warthog)
            {
                item.useWarthog(player, item, controles);
            }
        }
Beispiel #2
0
        public void quitVehicule(Perso perso, Vehicule vehicule)
        {
            Physics.Fall(vehicule);
            //vehicule.position = perso.position + (new Vector2(10, -20));
            if (perso.GetType() == typeof(Player))
            {
                perso.image = TexturesGame.PlayerTab[0];
            }
            if (perso.GetType() == typeof(Enemy))
            {
                perso.image = TexturesGame.IATab[0];
            }
            perso.position   += new Vector2(0, -20);
            perso.size        = new Vector2(TexturesGame.PlayerTab[0][0].Width, TexturesGame.PlayerTab[0][0].Height);
            perso.currentItem = null;
            vehicule.isOnMap  = true;
            for (int i = 0; i < perso.ItemList.Count; i++)
            {
                if (perso.ItemList[i].type == objectType.weapon)
                {
                    perso.ItemList[i].isOnMap = true;
                    perso.currentWeapon       = (Weapon)perso.ItemList[i];
                }
            }

            perso.pV           = perso.pVMax;
            perso.usingVehicle = false;
            perso.nearitem.Clear();
        }
Beispiel #3
0
        public void useWarthog(Perso perso, Vehicule vehicule, Controles controles)
        {
            perso.image            = TexturesGame.itemTab[2];
            perso.vitesseMax       = 10;
            perso.currentItem.name = "Hornet";

            if (controles.StayRight())
            {
                Physics.MoveRight(perso);
                Physics.MoveRight(perso);
                Physics.MoveRight(perso);
            }
            else if (controles.StayLeft())
            {
                Physics.MoveLeft(perso);
                Physics.MoveLeft(perso);
                Physics.MoveLeft(perso);
            }
            else
            {
                Physics.Deccelarate(perso);
            }

            if (controles.StayUp() && perso.speed.Y >= -10)
            {
                perso.speed.Y = (-1f + perso.speed.Y) - 1.2f;
            }

            if (controles.StayDown() && !controles.Up() && perso.speed.Y >= -20)
            {
                perso.speed.Y = -1f;
                //if(Perso.speed.X<0)
            }
        }
Beispiel #4
0
        public void useBanshee(Perso Perso, Vehicule vehicule, Controles controles)
        {
            Perso.image                 = TexturesGame.itemTab[1];
            Perso.vitesseMax            = 15;
            Perso.currentWeapon.isOnMap = false;
            //Perso.currentWeapon = Perso.currentItem.VehicleGun[0];
            Perso.currentItem.name = "Banshee";

            if (controles.StayRight())
            {
                Perso.speed.X = 9;
            }
            else if (controles.StayLeft())
            {
                Perso.speed.X = -9;
            }
            else
            {
                if (Perso.direction == Direction.left)
                {
                    Perso.speed.X = -3;
                }
                if (Perso.direction == Direction.right)
                {
                    Perso.speed.X = 3;
                }
            }

            if (controles.StayUp() && Perso.speed.Y >= -10)
            {
                Perso.speed.Y = (-1f + Perso.speed.Y) - 1.2f;
            }

            if (controles.StayDown() && !controles.Up() && Perso.speed.Y >= -20)
            {
                Perso.speed.Y = -0.8f;
                //if(Perso.speed.X<0)
            }
            if (controles.Action())
            {
                int i = Perso.currentItem.VehicleGun.IndexOf(Perso.currentWeapon);
                if (Perso.currentItem.VehicleGun.Count <= i + 1)
                {
                    Perso.currentWeapon = Perso.currentItem.VehicleGun[0];
                }
                else
                {
                    Perso.currentWeapon = Perso.currentItem.VehicleGun[i + 1];
                }
            }
        }
Beispiel #5
0
        public void useHornet(Perso Perso, Vehicule vehicule, Controles controles)
        {
            Perso.currentWeapon.isOnMap = false;
            Perso.image            = TexturesGame.itemTab[0];
            Perso.vitesseMax       = 20;
            Perso.currentItem.name = "Hornet";
            for (int i = 0; i < Perso.objetTouched.Count; i++)
            {
                if (Perso.objetTouched[i].GetType() == typeof(Enemy))
                {
                    //Enemy eny =(Enemy)Perso.objetTouched[i];
                    //  ((Enemy)(Perso.objetTouched[i])).pV = 0;
                }
            }
            if (controles.StayRight())
            {
                Perso.speed.X = 13;
            }
            else if (controles.StayLeft())
            {
                Perso.speed.X = -13;
            }
            else
            {
                Physics.Deccelarate(Perso);
            }

            if (controles.StayUp() && Perso.speed.Y >= -10)
            {
                Perso.speed.Y = (-1f + Perso.speed.Y) - 1.2f;
            }

            if (controles.StayDown() && !controles.Up() && Perso.speed.Y >= -20)
            {
                Perso.speed.Y = -1f;
                //if(Perso.speed.X<0)
            }
            if (controles.Action())
            {
                int i = Perso.currentItem.VehicleGun.IndexOf(Perso.currentWeapon);
                if (Perso.currentItem.VehicleGun.Count <= i + 1)
                {
                    Perso.currentWeapon = Perso.currentItem.VehicleGun[0];
                }
                else
                {
                    Perso.currentWeapon = Perso.currentItem.VehicleGun[i + 1];
                }
            }
        }
Beispiel #6
0
        private static void KeyEvents(Player player, Map map, Controles controles, Sound sound)
        {
            #region Deplacements

            if (controles.StayRight() && !player.usingVehicle)
            {
                Physics.MoveRight(player);
            }
            else if (controles.StayLeft() && !player.usingVehicle)
            {
                Physics.MoveLeft(player);
            }
            else
            {
                Physics.Deccelarate(player);
            }

            if (controles.Up() && player.usingVehicle == false)
            {
                Physics.Jump(player);
            }

            if (player.climb && controles.StayUp() && player.usingVehicle == false)
            {
                Physics.Climb(player);
            }
            if (player.usingVehicle)
            {
                useVehicle(player, (Vehicule)player.currentItem, controles);
                // ControleVehicle(player, player.currentItem, controles);
            }

            #endregion Deplacements

            if (controles.Score())
            {
                player.scoreKey = true;
            }
            else
            {
                player.scoreKey = false;
            }
            if (controles.Reload() && player.currentWeapon.weaponType != cadenceType.none)
            {
                player.Reload();
                if (player.currentWeapon.name == "ShotGun")
                {
                    sound.Play(SoundsName.arme);
                }
                else
                {
                    sound.Play(SoundsName.reload);
                }
            }

            if ((controles.Drop() && (player.nearitem.Count > 0)) && player.usingVehicle == false)
            {
                for (int i = 0; i < player.nearitem.Count; i++)
                {
                    if (player.nearitem[i].type == objectType.vehicule)
                    {
                        player.pVMax      += 400;
                        player.pV          = player.pVMax;
                        player.currentItem = player.nearitem[i];

                        useVehicle(player, (Vehicule)player.nearitem[i], controles);
                        player.currentWeapon = player.currentItem.VehicleGun[0];
                    }
                    player.nearitem.Clear();
                }
            }

            if (controles.Lacher() && (player.currentItem != null))
            {
                if (player.currentItem.type == objectType.vehicule)
                {
                    Vehicule currentvehicule = (Vehicule)player.currentItem;
                    currentvehicule.quitVehicule(player, currentvehicule);
                }
                player.currentWeapon.isOnMap = true;
            }
        }
Beispiel #7
0
        public void Hit(int dammage, ref List <Explosion> listExplose, List <ParticleEngine> particles, Sound sound, Map mapWorld, ContentManager Content, List <Vector2> explose)
        {
            if (hitable)
            {
                lifePoint -= dammage;
                if (lifePoint <= 0)
                {
                    bloque  = false;
                    draw    = false;
                    alive   = false;
                    hitable = false;

                    if (type == objectType.explosif)
                    {
                        listExplose.Add(new Explosion(position, map, particles, sound));
                    }
                    else if (type == objectType.caisse)
                    {
                        switch (contentIndex)
                        {
                        case 2:
                            mapWorld.Items.Add(new Item(new Texture2D[1] {
                                TexturesGame.bonusTab[0]
                            }, new Vector2(position.X, position.Y - 40), new Vector2(0, 0), true, Direction.right, new Vector2(30, 30), objectType.champi, 300));
                            break;

                        case 3:
                            mapWorld.Items.Add(new Item(new Texture2D[1] {
                                TexturesGame.bonusTab[1]
                            }, new Vector2(position.X, position.Y - 40), new Vector2(0, 0), true, Direction.stop, new Vector2(30, 30), objectType.vie, 300));
                            break;

                        case 4:
                            mapWorld.Items.Add(new Item(new Texture2D[1] {
                                TexturesGame.bonusTab[2]
                            }, new Vector2(position.X, position.Y - 40), new Vector2(0, 0), true, Direction.stop, new Vector2(30, 30), objectType.chargeur, 300));
                            break;

                        case 5:

                            Vehicule Hornet = new Vehicule(vehiculeType.Hornet, new Vector2(position.X, position.Y - 150), 2, 20, new Vector2(3, 3), Direction.stop, true, new Vector2(182, 120), TexturesGame.itemTab[0], 0);
                            Hornet.name = "Hornet";
                            Hornet.VehicleGun.Add(new Weapon(4000, "Others/Munitions/bullet", "AK47", 110, 0.1f, cadenceType.auto, 2500, 150, 150, 15, 120, Vector2.Zero, Vector2.Zero, "hornet_right", true, 0, Content, SoundsName.fusil, tirTypes.bullet, false, 2, 0));
                            Hornet.VehicleGun[0].weaponName = "Hornet Gun";
                            Hornet.VehicleGun.Add(new Weapon(4000, "Others/Munitions/rpgammo22", "AK47", 300, 0.05f, cadenceType.semiAuto, 500, 6, 6, 8, 200, Vector2.Zero, Vector2.Zero, "hornet_right", true, 0, Content, SoundsName.rocket, tirTypes.explosive, false, 2, 0));
                            Hornet.VehicleGun[1].weaponName = "Hornet Rocket";
                            mapWorld.itemList.Add(Hornet);
                            break;

                        case 6:
                            Vehicule Banshee = new Vehicule(vehiculeType.Banshee, new Vector2(position.X, position.Y - 150), 1, 20, new Vector2(3, 2), Direction.stop, true, new Vector2(147, 117), TexturesGame.itemTab[1], 0);
                            Banshee.name = "Banshee";
                            Banshee.VehicleGun.Add(LoadWeapons.LoadBansheeBomb(Content));
                            Banshee.VehicleGun.Add(LoadWeapons.LoadBansheeGun(Content));
                            mapWorld.itemList.Add(Banshee);
                            break;

                        case 7:
                            listExplose.Add(new Explosion(position, map, particles, sound));

                            break;

                        case 8:
                            mapWorld.Items.Add(new Item(new Texture2D[1] {
                                TexturesGame.bonusTab[3]
                            }, new Vector2(position.X, position.Y - 40), new Vector2(0, 0), true, Direction.right, new Vector2(30, 30), objectType.etoile, 300));
                            break;

                        case 9:
                            mapWorld.Items.Add(new Item(new Texture2D[1] {
                                TexturesGame.bonusTab[4]
                            }, new Vector2(position.X, position.Y - 40), new Vector2(0, 0), true, Direction.right, new Vector2(30, 30), objectType.UnlimitedAmmo, 300));
                            break;

                        case 10:
                            mapWorld.Items.Add(new Item(new Texture2D[1] {
                                TexturesGame.bonusTab[5]
                            }, new Vector2(position.X, position.Y - 40), new Vector2(0, 0), true, Direction.right, new Vector2(30, 30), objectType.attaqueUp, 300));
                            break;

                        case 11:
                            mapWorld.Items.Add(new Item(new Texture2D[1] {
                                TexturesGame.bonusTab[6]
                            }, new Vector2(position.X, position.Y - 40), new Vector2(0, 0), true, Direction.right, new Vector2(30, 30), objectType.defenseUp, 300));
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        mapWorld.particleEngine.Add(new ParticleEngine(7, position + new Vector2(38, 38), new Vector2(0, 1), 5, TexturesGame.test[1], 60, 38, 0, 38, 0, 0.5f, false));
                        this.type = objectType.nothing;
                    }
                }
            }
        }