Schmup.Hero.Update C# (CSharp) Method

Update() public method

public Update ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
return void
        public override void Update(GameTime gameTime)
        {
            // Gestion du changement de vitesse
            // TODO : A améliorer! Celui qui a fait ça doit être en train de consommer du LSD.
            bool speedChange;

            speedChange = Input.isActionDone(Input.Action.SpeedChange, false);
            if (speedChange)
            {
                if (speedType)
                {
                    speedType = false;
                    currentSpeed = speed1;
                }
                else
                {
                    speedType = true;
                    currentSpeed = speed2;
                }
            }

            // Gestion du déplacement
            if (Input.isActionDone(Input.Action.Up,true))
            {
                if (Input.isActionDone(Input.Action.Right, true))
                {
                    Position.X += currentSpeed / (float) Math.Sqrt(2);
                    Position.Y -= currentSpeed / (float) Math.Sqrt(2);
                }
                else if (Input.isActionDone(Input.Action.Left, true))
                {
                    Position.X -= currentSpeed / (float) Math.Sqrt(2);
                    Position.Y -= currentSpeed / (float) Math.Sqrt(2);
                }
                else
                {
                    Position.Y -= currentSpeed;
                }
            }
            else if (Input.isActionDone(Input.Action.Down, true))
            {
                if (Input.isActionDone(Input.Action.Right, true))
                {
                    Position.X += currentSpeed / (float) Math.Sqrt(2);
                    Position.Y += currentSpeed / (float) Math.Sqrt(2);
                }
                else if (Input.isActionDone(Input.Action.Left, true))
                {
                    Position.X -= currentSpeed / (float) Math.Sqrt(2);
                    Position.Y += currentSpeed / (float) Math.Sqrt(2);
                }
                else
                {
                    Position.Y += currentSpeed;
                }
            }
            else if (Input.isActionDone(Input.Action.Left, true))
            {
                Position.X -= currentSpeed;
            }
            else if (Input.isActionDone(Input.Action.Right, true))
            {
                Position.X += currentSpeed;
            }

            // Gestion des bordures
            // TODO : Mettre des variables globales

            if (Position.X < 0)
            {
                Position.X = 0;
            }
            if (Position.Y < 0)
            {
                Position.Y = 0;
            }
            if (Position.X > 800)
            {
                Position.X = 800;
            }
            if (Position.Y > 480)
            {
                Position.Y = 480;
            }

            // Gestion des tirs
            if (Input.isActionDone(Input.Action.Shoot, true))
            {
                if (speedType)
                {
                    WeakShoot();
                }
                else
                {
                    StrongShoot();
                }
            }

            // Gestion des pouvoirs

            if (Input.isActionDone(Input.Action.Power, false))
            {
                PowerShoot();
            }

            // Mise à jour de la position pour les ennemis
            //world.Hero.Position = this.Position;

            // Possibilité de sommaire
            if (Input.isActionDone(Input.Action.Confirm, false))
            {
                System.Console.Write("Charge tirée ");
                System.Console.Write(0);
                System.Console.WriteLine(" fois");
            }

            // Gestion des armes
            weakShots.Check();
            strongShots.Check();

            base.Update(gameTime);
        }