Exemplo n.º 1
0
        public GamePage()
        {
            InitializeComponent();

            // Obtenir le gestionnaire de contenu de l’application
            contentManager = (Application.Current as App).Content;

            // Créer un minuteur pour cette page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;

            this.map = new Map(this);
            server = new Network();
            this.plist = new List<Player>();
            this.elist = new List<Egg>();
            this.tlist = new List<string>();
            this.lbc = new Queue<string>();
            this.screen = new Microsoft.Xna.Framework.Rectangle(0, 0, 800, 480);
            this.inventory_details = null;
            this.inventory_timer = TimeSpan.Zero;
            this.dot = new Vector2(640, 360);
            this.end = false;
            this.winner = "toto";
        }
Exemplo n.º 2
0
Arquivo: Main.cs Projeto: fiahil/Zappy
 public Main()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     this.map = new Map(this);
     this.Components.Add(this.map);
     server = new Network();
     this.plist = new List<Player>();
     this.elist = new List<Egg>();
     this.tlist = new List<string>();
     this.lbc = new Queue<string>();
     this.screen = new Rectangle(0, 0, 1280, 720);
     this.inventory_details = null;
     this.inventory_timer = TimeSpan.Zero;
     this.dot = new Vector2(640, 360);
 }
Exemplo n.º 3
0
Arquivo: Egg.cs Projeto: fiahil/Zappy
        public void Draw(GameTimerEventArgs gameTime, Rectangle square, Rectangle screen, SpriteBatch sb, Map map)
        {
            Point p;
            Point off;

            double factX = ((this.egg.getBounds().Width * 0.45) * (square.Width / 155.0));
            double factY = ((this.egg.getBounds().Height * 0.45) * (square.Height / 58.0));

            off.X = (this.pos.X + 1) * (square.Width / 2);
            off.Y = (this.pos.X) * (square.Height / 2);

            p.X = -this.pos.Y * (square.Width / 2) + off.X + square.X + ((int)map.getSize().Y - 1) * (square.Width / 2);
            p.Y = this.pos.Y * (square.Height / 2) + off.Y + square.Y - ((int)map.getSize().Y - 1) * (square.Height / 2);

            Rectangle tar = new Rectangle((int)(p.X + (int)(117 * (square.Width / 155.0))), (int)(p.Y + (int)(38 * (square.Height / 58.0))), (int)factX, (int)factY);
            if (screen.Intersects(tar))
                this.egg.Draw(sb, tar);
        }
Exemplo n.º 4
0
        public void Draw(GameTimerEventArgs gameTime, Rectangle square, Rectangle screen, SpriteBatch sb, Map map)
        {
            Point p;
            Point off;

            if (this.st == States.DEAD && this.dead == false)
            {
                this.deadTimer = gameTime.TotalTime + TimeSpan.FromSeconds(5);
                this.dead = true;
            }
            if (this.st == States.DEAD || this.st == States.FINISHED)
            {
                if (this.deadTimer >= gameTime.TotalTime)
                {
                    double factX = (this.sdead.getBounds().Width * (square.Width / 155.0));
                    double factY = (this.sdead.getBounds().Height * (square.Height / 58.0));

                    off.X = (this.pos.X + 1) * (square.Width / 2);
                    off.Y = (this.pos.X) * (square.Height / 2);

                    p.X = -this.pos.Y * (square.Width / 2) + off.X + square.X + ((int)map.getSize().Y - 1) * (square.Width / 2);
                    p.Y = this.pos.Y * (square.Height / 2) + off.Y + square.Y - ((int)map.getSize().Y - 1) * (square.Height / 2);
                    Rectangle tar = new Rectangle((int)(p.X + (int)(42 * (square.Width / 155.0))), (int)(p.Y - (int)(19 * (square.Height / 58.0))), (int)factX, (int)factY);
                    if (screen.Intersects(tar))
                        this.sdead.Draw(sb, tar);
                }
                else
                    this.st = States.FINISHED;
            }
            else
            {
                Rectangle tar = Rectangle.Empty;
                double factX = 0.0;
                double factY = 0.0;

                if (this.st == States.TAKE || this.st == States.DROP)
                {
                    factX = (this.stake[(int)this.dir].getBounds().Width * (square.Width / 155.0));
                    factY = (this.stake[(int)this.dir].getBounds().Height * (square.Height / 58.0));

                    off.X = (this.pos.X + 1) * (square.Width / 2);
                    off.Y = (this.pos.X) * (square.Height / 2);

                    p.X = -this.pos.Y * (square.Width / 2) + off.X + square.X + ((int)map.getSize().Y - 1) * (square.Width / 2);
                    p.Y = this.pos.Y * (square.Height / 2) + off.Y + square.Y - ((int)map.getSize().Y - 1) * (square.Height / 2);
                    tar = new Rectangle((int)(p.X + (int)(42 * (square.Width / 155.0))), (int)(p.Y - (int)(19 * (square.Height / 58.0))), (int)factX, (int)factY);
                    if (screen.Intersects(tar))
                        this.stake[(int)this.dir].Draw(sb, tar);
                }
                else if (this.st == States.INCANT)
                {
                    factX = (this.sincant.getBounds().Width * (square.Width / 155.0));
                    factY = (this.sincant.getBounds().Height * (square.Height / 58.0));

                    off.X = (this.pos.X + 1) * (square.Width / 2);
                    off.Y = (this.pos.X) * (square.Height / 2);

                    p.X = -this.pos.Y * (square.Width / 2) + off.X + square.X + ((int)map.getSize().Y - 1) * (square.Width / 2);
                    p.Y = this.pos.Y * (square.Height / 2) + off.Y + square.Y - ((int)map.getSize().Y - 1) * (square.Height / 2);
                    tar = new Rectangle((int)(p.X + (int)(42 * (square.Width / 155.0))), (int)(p.Y - (int)(19 * (square.Height / 58.0))), (int)factX, (int)factY);
                    if (screen.Intersects(tar))
                        this.sincant.Draw(sb, tar);
                }
                else if (this.st == States.FORK)
                {
                    factX = (this.sfork[(int)this.dir].getBounds().Width * (square.Width / 155.0));
                    factY = (this.sfork[(int)this.dir].getBounds().Height * (square.Height / 58.0));

                    off.X = (this.pos.X + 1) * (square.Width / 2);
                    off.Y = (this.pos.X) * (square.Height / 2);

                    p.X = -this.pos.Y * (square.Width / 2) + off.X + square.X + ((int)map.getSize().Y - 1) * (square.Width / 2);
                    p.Y = this.pos.Y * (square.Height / 2) + off.Y + square.Y - ((int)map.getSize().Y - 1) * (square.Height / 2);
                    tar = new Rectangle((int)(p.X + (int)(42 * (square.Width / 155.0))), (int)(p.Y - (int)(19 * (square.Height / 58.0))), (int)factX, (int)factY);
                    if (screen.Intersects(tar))
                        this.sfork[(int)this.dir].Draw(sb, tar);
                }
                else if (this.st == States.INCANT)
                {
                    factX = (this.sincant.getBounds().Width * (square.Width / 155.0));
                    factY = (this.sincant.getBounds().Height * (square.Height / 58.0));

                    off.X = (this.pos.X + 1) * (square.Width / 2);
                    off.Y = (this.pos.X) * (square.Height / 2);

                    p.X = this.pos.Y * (square.Width / 2) + off.X + square.X;
                    p.Y = -this.pos.Y * (square.Height / 2) + off.Y + square.Y;
                    tar = new Rectangle((int)(p.X + (int)(42 * (square.Width / 155.0))), (int)(p.Y - (int)(19 * (square.Height / 58.0))), (int)factX, (int)factY);
                    if (screen.Intersects(tar))
                        this.sincant.Draw(sb, tar);
                }
                else
                {
                    factX = (this.player[(int)this.dir].getBounds().Width * (square.Width / 155.0));
                    factY = (this.player[(int)this.dir].getBounds().Height * (square.Height / 58.0));

                    off.X = (this.pos.X + 1) * (square.Width / 2);
                    off.Y = (this.pos.X) * (square.Height / 2);

                    p.X = -this.pos.Y * (square.Width / 2) + off.X + square.X + ((int)map.getSize().Y - 1)* (square.Width / 2);
                    p.Y = this.pos.Y * (square.Height / 2) + off.Y + square.Y - ((int)map.getSize().Y - 1) * (square.Height / 2);
                    tar = new Rectangle((int)(p.X + (int)(42 * (square.Width / 155.0))), (int)(p.Y - (int)(19 * (square.Height / 58.0))), (int)factX, (int)factY);
                    if (screen.Intersects(tar))
                        this.player[(int)this.dir].Draw(sb, tar);
                }
                if (screen.Intersects(tar))
                {
                    factX = (this.slvl[this.lvl - 1].getBounds().Width * (square.Width / 155.0));
                    factY = (this.slvl[this.lvl - 1].getBounds().Height * (square.Height / 58.0));
                    if (this.dir == Direction.NORTH || dir == Direction.WEST)
                        this.slvl[this.lvl - 1].Draw(sb, new Rectangle((int)(p.X + (int)(35 * (square.Width / 155.0))), (int)(p.Y - (int)(30 * (square.Height / 58.0))), (int)factX, (int)factY));
                    else
                        this.slvl[this.lvl - 1].Draw(sb, new Rectangle((int)(p.X + (int)(48 * (square.Width / 155.0))), (int)(p.Y - (int)(30 * (square.Height / 58.0))), (int)factX, (int)factY));
                    if (this.broadcast != null)
                    {
                        this.broacastTimer = gameTime.TotalTime + TimeSpan.FromSeconds(2);
                        this.broadcast = null;
                    }
                    if (this.broacastTimer >= gameTime.TotalTime)
                    {
                        factX = (this.sbroadcast[0].getBounds().Width * (square.Width / 155.0));
                        factY = (this.sbroadcast[0].getBounds().Height * (square.Height / 58.0));
                        if (this.dir == Direction.NORTH || dir == Direction.WEST)
                            this.sbroadcast[0].Draw(sb, new Rectangle((int)(p.X + (int)(78 * (square.Width / 155.0))), (int)(p.Y - (int)(25 * (square.Height / 58.0))), (int)factX, (int)factY));
                        else
                            this.sbroadcast[1].Draw(sb, new Rectangle((int)(p.X + (int)(35 * (square.Width / 155.0))), (int)(p.Y - (int)(25 * (square.Height / 58.0))), (int)factX, (int)factY));

                    }
                }
            }
        }
Exemplo n.º 5
0
Arquivo: Elt.cs Projeto: fiahil/Zappy
 public bool isInPolygon(Vector2 p, Rectangle square, Map map)
 {
     Vector2 pos = new Vector2(-(this.p.Y + 1) * (square.Width / 2) + square.X + ((this.p.X + 1) * (square.Width / 2)) + (map.getSize().Y) * (square.Width / 2),
                               (this.p.Y + 1) * (square.Height / 2) + square.Y + ((this.p.X + 1) * (square.Height / 2)) - (map.getSize().Y) * (square.Height / 2));
     Polygon target = new Polygon(new Vector2[]
         {
             new Vector2((pos.X) + square.Width / 2, (pos.Y)),
             new Vector2((pos.X) + square.Width, (pos.Y) + square.Height / 2),
             new Vector2((pos.X) + square.Width / 2, (pos.Y) + square.Height),
             new Vector2((pos.X), (pos.Y) + square.Height / 2)
         });
     return target.Contains(p);
 }