Пример #1
0
        public void Update(float frameTime)
        {
            // ApplyGravity(frameTime);
            ApplyMovement(frameTime);

            var ray = new Ray(Position + new Vector3(0, CameraHeight, 0), _viewDirection);

            if (_collisionController.CollidesWithWorld(ray, 5.0f, out var hit))
            {
                var worldPos = new WorldPosition(hit);
                DebugDrawManager.AddElement(new DebugDrawCube(worldPos.BBox(Vector3.One)), 100);

                if (_playerState.Attack1)
                {
                    if (!_blockDestoryCooldown.IsRunning)
                    {
                        _blockController.DestroyBlock(worldPos);
                        _blockDestoryCooldown.Start();
                    }
                    else
                    {
                        if (_blockDestoryCooldown.ElapsedMilliseconds > 200)
                        {
                            _blockDestoryCooldown.Reset();
                        }
                    }
                }
            }

            UpdateCamera();
        }
Пример #2
0
        public Color4 GetLightAt(Vector3 position)
        {
            // Cast a ray from each light to the position
            foreach (var light in _lights)
            {
                var maxDistance = (position - light.Position).Length;

                var ray = new Ray(position, light.Position - position);

                DebugDrawManager.AddElement(new DebugDrawLine(ray, maxDistance), 10000);

                if (!_collisionController.CollidesWithWorld(ray, maxDistance, out var hit))
                {
                    return(light.Color);
                }
            }
            return(new Color4(100, 100, 100, 255));
        }