Ejemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            if (Visible)
            {
                if (collisionDetect())
                {
                    SimplePlayerSprite otherSprite = (SimplePlayerSprite)Game.Components.FirstOrDefault(pl => pl.GetType() == typeof(SimplePlayerSprite));
                    Visible = false;
                    IHubProxy proxy = Game.Services.GetService <IHubProxy>();
                    proxy.Invoke("Collected", new Object[]
                    {
                        otherSprite.pData.playerID,
                        collectableData
                    });
                    Scoreboard sc = (Scoreboard)Game.Components.FirstOrDefault(pl => pl.GetType() == typeof(Scoreboard));
                    foreach (PlayerData p in sc.players)
                    {
                        if (p.playerID == otherSprite.pData.playerID)
                        {
                            p.Score += collectableData.worth;
                        }
                    }
                }
            }

            base.Update(gameTime);
        }
Ejemplo n.º 2
0
        public override void Update(GameTime gameTime)
        {
            SimplePlayerSprite p = (SimplePlayerSprite)Game.Components.FirstOrDefault(c => c.GetType() == typeof(SimplePlayerSprite));

            if (p != null)
            {
                //cannot convert point to vector2

                //follow(p.Position, Game.GraphicsDevice.Viewport);
                //// Make sure the player stays in the bounds
                //p.Position = Vector2.Clamp(p.Position, Vector2.Zero,
                //                                new Vector2(_worldBound.X - p.Image.Width,
                //                                            _worldBound.Y - p.Image.Height));
            }
            base.Update(gameTime);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            new InputEngine(this);

            //new Vector2(tileMap.GetLength(1) * tileWidth, tileMap.GetLength(0) * tileHeight));
            serverConnection = new HubConnection("https://rad302gameass.azurewebsites.net");
            //serverConnection = new HubConnection("http://localhost:55712/");
            serverConnection.StateChanged += ServerConnection_StateChanged;
            proxy = serverConnection.CreateHubProxy("GameHub");
            serverConnection.Start();
            cam         = new Camera(Vector2.Zero, new Vector2(v.Width, v.Height));
            Playerimage = Content.Load <Texture2D>("Player 1");
            player      = new SimplePlayerSprite(this, PlayerInfo, Playerimage,
                                                 new Point(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2));
            totalPlayers.Add(player);
            base.Initialize();
        }
Ejemplo n.º 4
0
        public bool collisionDetect()
        {
            SimplePlayerSprite otherSprite = (SimplePlayerSprite)Game.Components.FirstOrDefault(pl => pl.GetType() == typeof(SimplePlayerSprite));

            if (!Visible)
            {
                return(false);
            }


            if (bounds.Intersects(otherSprite.CollisionRect))
            {
                InCollision = true;
                return(true);
            }
            else
            {
                InCollision = false;
                return(false);
            }
        }