示例#1
0
        public void Update(double mousseCoef, Controles controles)
        {
            rectangle = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y);
            Rectangle mouseRectangle = new Rectangle((int)(controles.mouse.X * mousseCoef), (int)(controles.mouse.Y * mousseCoef), 1, 1);

            if (mouseRectangle.Intersects(rectangle))
            {
                if (colour.A == 255)
                {
                    down = false;
                }
                if (colour.A == 160) // bouton transparent
                {
                    down = true;
                }
                if (down)
                {
                    colour.A += 5;
                }
                else
                {
                    colour.A -= 5;
                }
                if (controles.Click())
                {
                    isCliked = true;
                }
            }
            else if (colour.A < 255) // s'il est pas revenu à l'état norma
            {
                colour.A += 5;       // alors on augmente sa visibilité
                isCliked  = false;
            }
        }
示例#2
0
        public void Update(Controles controles)
        {
            rectangle = new Rectangle((int)position.X, (int)position.Y, (int)font.MeasureString(text).X, (int)font.MeasureString(text).Y);
            Rectangle mouse = new Rectangle((int)controles.cursorPosition.X - 2, (int)controles.cursorPosition.Y - 2, (int)controles.cursorPosition.X + 2, (int)controles.cursorPosition.Y + 2);

            if (mouse.Intersects(rectangle) && controles.Click() && IsEditable)
            {
                IsEdited = true;
            }
            if (IsEdited)
            {
                if (controles.Enter())
                {
                    IsEdited = false;
                    IsFinish = true;
                }
                else
                {
                    String tmp = text;
                    InputEvents.UpdateText(controles, ref tmp);
                    text = tmp;
                    cursor.Update(text, true);
                }
            }
            else
            {
                cursor.Update(text, false);
            }
            if (controles.Enter() && IsEdited)
            {
                IsEdited = false;
            }
        }
示例#3
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;
            }
        }