Ejemplo n.º 1
0
        public void Shoot(Controles controles, Camera camera, Shot shots, Sound sound, List <Animate> animationList, List <ParticleEngine> particle)
        {
            Random rnd = new Random();

            currentWeapon.animationn();
            Vector2 dir    = Vector2.Normalize(new Vector2(controles.cursorPosition.X - currentWeapon.position.X + camera.Xcurrent + camera.Xspecial, controles.cursorPosition.Y - currentWeapon.position.Y + camera.Ycurrent + camera.Yspecial));
            Vector2 oriTir = currentWeapon.position + (dir * currentWeapon.image[0].Width);

            if (direction == Direction.left)
            {
                oriTir.X += 15;
            }
            else
            {
                oriTir.X -= 15;
            }

            double angle = Math.Atan2(controles.cursorPosition.Y + camera.Ycurrent + camera.Yspecial - (currentWeapon.position + (dir * currentWeapon.image[0].Width / 2)).Y, controles.cursorPosition.X + camera.Xcurrent + camera.Xspecial - (currentWeapon.position + (dir * currentWeapon.image[0].Width / 2)).X);

            currentWeapon.Update(this, angle, controles);

            Vector2 destiArm = currentWeapon.position + (dir * currentWeapon.image[0].Width / 2);
            double  armangle = Math.Atan2(destiArm.Y - arm.position.Y,
                                          destiArm.X - arm.position.X);

            arm.Update(this, armangle, dir);

            if (currentWeapon.weaponType == cadenceType.none && controles.Click())
            {
                shots.tirList.Add(new Tirs(currentWeapon.ammoTexture, (int)(currentWeapon.damage * attaque), oriTir, dir * 40, currentWeapon.range, id, angle, currentWeapon.nTexture, currentWeapon.tirtype));
                sound.Play(currentWeapon.shotSound);
                if (currentWeapon.count2 < 7 && direction == Direction.right)
                {
                    currentWeapon.count2 = 2;
                }
                if (currentWeapon.count2 < 7 && direction == Direction.left)
                {
                    currentWeapon.count2 = 3;
                }
            }
            if (currentWeapon.weaponType == cadenceType.semiAuto)
            {
                currentWeapon.autoTirs += currentWeapon.cadence;
                if (currentWeapon.autoTirs > 1 && controles.Click() && currentWeapon.currentAmo > 0)
                {
                    int numX = rnd.Next(-currentWeapon.accuracy - accuracy, currentWeapon.accuracy + accuracy);
                    int numY = rnd.Next(-currentWeapon.accuracy - accuracy, currentWeapon.accuracy + accuracy);
                    dir = Vector2.Normalize(new Vector2(controles.cursorPosition.X - currentWeapon.position.X + camera.Xcurrent + camera.Xspecial + numX, controles.cursorPosition.Y - currentWeapon.position.Y + camera.Ycurrent + camera.Yspecial + numY));
                    shots.tirList.Add(new Tirs(currentWeapon.ammoTexture, (int)(currentWeapon.damage * attaque), oriTir, dir * 40, currentWeapon.range, id, angle, currentWeapon.nTexture, currentWeapon.tirtype));
                    sound.Play(currentWeapon.shotSound);

                    currentWeapon.currentAmo--;
                    currentWeapon.autoTirs = 0;
                }
            }
            else if (currentWeapon.weaponType == cadenceType.auto && controles.StayClick() && currentWeapon.currentAmo > 0)
            {
                currentWeapon.autoTirs += currentWeapon.cadence;
                if (currentWeapon.autoTirs > 1)
                {
                    for (int i = 0; i < currentWeapon.autoTirs - 1; i++)
                    {
                        int numX = rnd.Next(-currentWeapon.accuracy - accuracy, currentWeapon.accuracy + accuracy);
                        int numY = rnd.Next(-currentWeapon.accuracy - accuracy, currentWeapon.accuracy + accuracy);
                        dir = Vector2.Normalize(new Vector2(controles.cursorPosition.X - currentWeapon.position.X + camera.Xcurrent + camera.Xspecial + numX, controles.cursorPosition.Y - currentWeapon.position.Y + camera.Ycurrent + camera.Yspecial + numY));
                        shots.tirList.Add(new Tirs(currentWeapon.ammoTexture, (int)(currentWeapon.damage * attaque), oriTir, dir * 40, currentWeapon.range, id, angle, currentWeapon.nTexture, currentWeapon.tirtype));

                        currentWeapon.currentAmo--;
                    }
                    sound.Play(currentWeapon.shotSound);
                    currentWeapon.autoTirs = 0;
                }
            }
            else if (currentWeapon.weaponType == cadenceType.rafales && controles.StayClick() && currentWeapon.currentAmo > 0)
            {
                if (currentWeapon.rafalstirs < 3)
                {
                    currentWeapon.autoTirs += currentWeapon.cadence;
                    if (currentWeapon.autoTirs > 1)
                    {
                        currentWeapon.rafalstirs++;
                        for (int i = 0; i < currentWeapon.autoTirs - 1; i++)
                        {
                            int numX = rnd.Next(-currentWeapon.accuracy - accuracy, currentWeapon.accuracy + accuracy);
                            int numY = rnd.Next(-currentWeapon.accuracy - accuracy, currentWeapon.accuracy + accuracy);
                            dir = Vector2.Normalize(new Vector2(controles.cursorPosition.X - currentWeapon.position.X + camera.Xcurrent + camera.Xspecial + numX, controles.cursorPosition.Y - currentWeapon.position.Y + camera.Ycurrent + camera.Yspecial + numY));
                            shots.tirList.Add(new Tirs(currentWeapon.ammoTexture, (int)(currentWeapon.damage * attaque), oriTir, dir * 40, currentWeapon.range, id, angle, currentWeapon.nTexture, currentWeapon.tirtype));
                            sound.Play(currentWeapon.shotSound);

                            currentWeapon.currentAmo--;
                        }
                        currentWeapon.autoTirs = 0;
                    }
                }
            }
            else
            {
                currentWeapon.rafalstirs = 0;
            }
        }