Ejemplo n.º 1
0
        protected void collide_against_map_block(map_block target)
        {
            if (position.Y < target.position.Y)
                return;

            var direction = Vector3.Normalize(target.position - position_);
            var distance = Vector3.Distance(position_, target.position);
            var margin_factor = 1.01f;
            position_ += direction * (distance * margin_factor);
            update_bounding();
        }
Ejemplo n.º 2
0
        protected void generate_map_block(GameTime gameTime)
        {
            if ((map_block_loader_params_.time += gameTime.ElapsedGameTime.TotalSeconds) < 0.05)
                return;
            map_block_loader_params_.time = 0;

            map_block_loader_params_.h = map_image_data[map_block_loader_params_.z * map_image.Width + map_block_loader_params_.x].R * 0.025f;

            var p = new Vector3(map_block.floor_length * (float)map_block_loader_params_.x, 20, map_block.floor_length * -(float)map_block_loader_params_.z) { };
            Debug.WriteLine("new block; position = " + p);
            var c = new map_block(Game, camera) { position = p, height = map_block_loader_params_.h };
            c.Initialize();
            components.Add(c);

            ++map_block_loader_params_.x;

            if (map_block_loader_params_.x >= map_image.Width)
            {
                ++map_block_loader_params_.z;
                map_block_loader_params_.x = 0;
                if (map_block_loader_params_.z >= map_image.Height)
                {
                    on_update_first -= generate_map_block;
                    return;
                }
            }
        }