示例#1
0
文件: Main.cs 项目: 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);
 }
示例#2
0
文件: Main.cs 项目: fiahil/Zappy
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (server.IsConnected())
                server.Update();

            base.Update(gameTime);

            if (Keyboard.GetState().IsKeyDown(Keys.Escape) || !server.IsConnected() || GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.Y))
                this.Exit();

            Vector2 test = GamePad.GetState(PlayerIndex.One).ThumbSticks.Left * 5;

            this.dot.X += test.X;
            this.dot.Y -= test.Y;

            for (Player P = null; (P = this.plist.First(p => p.State == Player.States.FINISHED)) != null; )
            {
                this.plist.Remove(P);
            }
            if (Mouse.GetState().RightButton == ButtonState.Pressed || GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.B))
            {
                if (Mouse.GetState().RightButton == ButtonState.Pressed)
                    this.dot = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
                foreach (Player elt in this.plist)
                {
                    Point p;
                    Point off;

                    server.SendDatas("pin " + elt.Id + "\n");
                    off.X = (elt.getPos().X + 1) * (this.map.getSquare().Width / 2);
                    off.Y = (elt.getPos().X) * (this.map.getSquare().Height / 2);

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

                    Rectangle bound = new Rectangle((int)(p.X + (int)(42 * (this.map.getSquare().Width / 155.0))), (int)(p.Y - (int)(19 * (this.map.getSquare().Height / 58.0))), (int)(elt.getBounds().Width * (this.map.getSquare().Width / 155.0)), (int)(elt.getBounds().Height * (this.map.getSquare().Height / 58.0)));

                    if (bound.Contains(new Point((int)this.dot.X, (int)this.dot.Y)))
                    {
                        this.inventory_details = elt;
                        this.inventory_timer = gameTime.TotalGameTime + TimeSpan.FromSeconds(10);
                    }
                }
            }

            if (this.inventory_timer <= gameTime.TotalGameTime && this.inventory_details != null)
            {
                this.inventory_details = null;
            }
        }
示例#3
0
文件: Main.cs 项目: fiahil/Zappy
 public void unplug()
 {
     this.inventory_details = null;
 }