Exemplo n.º 1
0
        internal bool EarnCoin()
        {
            if (!GameBase.HasLogin)
            {
                return(true);
            }

            pSprite coin = coinSingular.Clone();

            coin.Position = InputManager.CursorPosition / GameBase.WindowManager.Ratio;
            coin.Depth    = 0.99f;
            coin.FadeOut(1500);

            spriteManagerDialog.Add(coin);
            physics.Add(coin, new Vector2((float)RNG.NextDouble() * 100, (float)RNG.NextDouble() * -100));

            pSprite coinShine = coinSingular.Clone();

            coinShine.Additive  = true;
            coinShine.OnUpdate += delegate { coinShine.Position = coin.Position; };
            coinShine.FadeOut(500);

            spriteManagerDialog.Add(coinShine);

            AudioEngine.PlaySample(@"coins-earn", 80);

            Count++;

            pWebRequest snr = new pWebRequest(string.Format(General.WEB_ROOT + "/web/coins.php?action=earn&u={0}&h={1}&c={2}&cs={3}", ConfigManager.sUsername, ConfigManager.sPassword, Count, Checksum));

            snr.Finished += snr_onFinish;
            snr.Perform();

            return(true);
        }
        internal void Add(EngineObject engineObject)
        {
            updateManager.Add(engineObject);
            physicsManager.Add(engineObject);
            renderingManager.Add(engineObject);
            eventsManager.Add(engineObject);

            addedObjects.Add(engineObject);
        }
Exemplo n.º 3
0
 private void ProcessAddition(Entity e)
 {
     pm.Add(e);
     rm.Add(e);
     entities.Add(e);
     if (e.Emitter != null)
     {
         bulletShooters.Add(e);
     }
 }
Exemplo n.º 4
0
 public override void Physics(PhysicsManager physicsManager)
 {
     physicsManager.Add(player);
 }
Exemplo n.º 5
0
        protected override void Update(GameTime gameTime)
        {
            _inputManager.CaptureMouse = this.IsActive && _inputManager.MouseState.RightButton == ButtonState.Pressed;
#if WINDOWS
            _physics.Enabled = !Program.Proxy.IsPaused;
#endif

#if WINDOWS || WINDOWS_PHONE
            foreach (Keys k in _inputManager.KeysPressed)
            {
                switch (k)
                {
                case Keys.Space:
                    SpawnSelectedObject();
                    break;

                case Keys.R:
                    SpawnRagdoll();
                    break;

                case Keys.N:
                    if (!_physics.Enabled)
                    {
                        _physics.Integrate((float)gameTime.ElapsedGameTime.TotalSeconds);
                    }
                    break;

                case Keys.D0:
                case Keys.D1:
                case Keys.D2:
                case Keys.D3:
                case Keys.D4:
                case Keys.D5:
                case Keys.D6:
                case Keys.D7:
                case Keys.D8:
                case Keys.D9:
                    CreateScene(k - Keys.D0);
                    break;

                case Keys.Escape:
                case Keys.Q:
                    this.Exit();
                    break;
                }
            }

            // object picking
            if (_inputManager.WasPressed(MouseButton.MiddleButton))
            {
                Segment s;
                s.P1 = GraphicsDevice.Viewport.Unproject(new Vector3(_inputManager.MouseState.X, _inputManager.MouseState.Y, 0f),
                                                         _viewManager.Projection, _viewManager.View, Matrix.Identity);
                s.P2 = GraphicsDevice.Viewport.Unproject(new Vector3(_inputManager.MouseState.X, _inputManager.MouseState.Y, 1f),
                                                         _viewManager.Projection, _viewManager.View, Matrix.Identity);
                float   scalar;
                Vector3 point;
                var     c = _physics.BroadPhase.Intersect(ref s, out scalar, out point);
                if (c != null && c is BodySkin)
                {
                    _pickedObject = ((BodySkin)c).Owner;

                    _pickedForce = new GrabConstraint(_pickedObject, point);
                    _physics.Add(_pickedForce);
                    _pickedDistance        = scalar;
                    _pickedObject.IsActive = true;
                }
            }
            else if (_inputManager.MouseState.MiddleButton == ButtonState.Pressed && _pickedObject != null)
            {
                Segment s;
                s.P1 = GraphicsDevice.Viewport.Unproject(new Vector3(_inputManager.MouseState.X, _inputManager.MouseState.Y, 0f),
                                                         _viewManager.Projection, _viewManager.View, Matrix.Identity);
                s.P2 = GraphicsDevice.Viewport.Unproject(new Vector3(_inputManager.MouseState.X, _inputManager.MouseState.Y, 1f),
                                                         _viewManager.Projection, _viewManager.View, Matrix.Identity);
                Vector3 diff, point;
                Vector3.Subtract(ref s.P2, ref s.P1, out diff);
                Vector3.Multiply(ref diff, _pickedDistance, out diff);
                Vector3.Add(ref s.P1, ref diff, out point);
                _pickedForce.WorldPoint = point;
                _pickedObject.IsActive  = true;
            }
            else if (_pickedObject != null)
            {
                _physics.Remove(_pickedForce);
                _pickedObject = null;
            }
#else
            if (_inputManager.WasPressed(Buttons.RightShoulder))
            {
                CreateScene(++curScene);
            }
            if (_inputManager.WasPressed(Buttons.LeftShoulder))
            {
                CreateScene(curScene == 0 ? 0 : --curScene);
            }
            if (_inputManager.WasPressed(Buttons.A))
            {
                SpawnSelectedObject();
            }
            if (_inputManager.WasPressed(Buttons.B))
            {
                SpawnRagdoll();
            }
            if (_inputManager.WasPressed(Buttons.X))
            {
                _physics.Enabled = !_physics.Enabled;
            }
            if (_inputManager.WasPressed(Buttons.Y))
            {
                _physics.Integrate((float)gameTime.ElapsedGameTime.TotalSeconds);
            }
            if (_inputManager.WasPressed(Buttons.Back))
            {
                this.Exit();
            }
#endif
            UpdateFps(gameTime);

            base.Update(gameTime);
        }
Exemplo n.º 6
0
        public override void Ready()
        {
            manager = GetManager<PhysicsManager>();
            manager.Add(this);

            transformComponent = GetComponent<TransformComponent>();
            transform = new PhysicsTransform(transformComponent.Transform);
            transformComponent.Transform = transform;

            CreateBody();
            transform.Body = body;

            if (def.Speed != 0)
            {
                float velocityX = (float)Math.Cos(PhysicsManager.DegreesToRadians(transform.Rotation)) * def.Speed;
                float velocityY = (float)Math.Sin(PhysicsManager.DegreesToRadians(transform.Rotation)) * def.Speed;

                body.LinearVelocity = new Vector2(velocityX, velocityY);
            }
        }