Ejemplo n.º 1
0
 public Switch(Menu parent, int index, bool value, Action<bool> action)
     : base(parent, parent.screenmanager)
 {
     this.index = index;
     this.font = parent.font_option;
     this.action = action;
     SetValue(value);
 }
Ejemplo n.º 2
0
        public static Font Build(Texture2D texture)
        {
            Texture2D clone = new Texture2D(texture.GraphicsDevice, texture.Width, texture.Height);

            Color[] data = new Color[texture.Width * texture.Height];
            texture.GetData<Color>(data);

            Font font = new Font();
            font.regions = CreateRegionsFromTexture(clone, data);
            font.texture = clone;
            font.height = font.regions[0].height;

            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == clip_color)
                    data[i] = Color.Transparent;
            }

            clone.SetData<Color>(data);

            return font;
        }
Ejemplo n.º 3
0
        public void AddString(Font font, string text, float x, float y, float z, float scale, float kerning, float rotation_x, float rotation_y, float rotation_z, Color color)
        {
            float a, b, c, d, e, f;

            float half_width = font.GetStringLength(text, scale, kerning) / 2;
            float half_height = font.regions[0].height / 2.0f * scale;

            Matrix matrix = Matrix.Identity;
            if (rotation_z != 0 || rotation_x != 0 || rotation_y != 0)
            {
                a = (float)Math.Cos(rotation_x);
                b = (float)Math.Sin(rotation_x);

                c = (float)Math.Cos(rotation_y);
                d = (float)Math.Sin(rotation_y);

                e = (float)Math.Cos(rotation_z);
                f = (float)Math.Sin(rotation_z);

                matrix.M11 = (c * e);
                matrix.M12 = (c * f);
                matrix.M13 = -d;
                matrix.M21 = (e * b * d - a * f);
                matrix.M22 = ((e * a) + (f * b * d));
                matrix.M23 = (b * c);
                matrix.M31 = (e * a * d + b * f);
                matrix.M33 = (a * c);
                matrix.M32 = -(b * e - f * a * d);
            }

            matrix.M41 = x + half_width;
            matrix.M42 = y + half_height;
            matrix.M43 = z;

            TextureRegion region; float offset = 0;
            for (int i = 0; i < text.Length; i++)
            {
                a = offset - half_width;
                b = -half_height;
                c = z;

                d = (((a * matrix.M11) + (b * matrix.M21)) + (c * matrix.M31)) + matrix.M41;
                e = (((a * matrix.M12) + (b * matrix.M22)) + (c * matrix.M32)) + matrix.M42;
                f = (((a * matrix.M13) + (b * matrix.M23)) + (c * matrix.M33)) + matrix.M43;

                region = font.regions[font.char_set.IndexOf(text[i])];
                Add(region, color, d, e, f, region.width * scale, region.height * scale, rotation_x, rotation_y, rotation_z);
                offset += region.width * scale + kerning;
            }
        }
Ejemplo n.º 4
0
 public void AddString(Font font, string text, float x, float y, float z, float scale, Color color)
 {
     AddString(font, text, x, y, 0, scale, 0, 0, 0, 0, color);
 }
Ejemplo n.º 5
0
 public void AddString(Font font, string text, float x, float y, float z)
 {
     AddString(font, text, x, y, z, 1, 0, 0, 0, 0, Color.White);
 }
Ejemplo n.º 6
0
 public void AddString(Font font, string text, float x, float y, Color color)
 {
     AddString(font, text, x, y, 0, 1, 0, 0, 0, 0, color);
 }
Ejemplo n.º 7
0
        public static void Load(ContentManager content)
        {
            background_music = content.Load<SoundEffect>("music/background");
            droplet_sound = content.Load<SoundEffect>("music/droplet");

            bubble_texture = content.Load<Texture2D>("textures/bubble_small");
            bubble_reflection_texture = content.Load<Texture2D>("textures/bubble_reflection_small");
            title_texture = content.Load<Texture2D>("textures/title");
            ray_texture = content.Load<Texture2D>("textures/bg-light-0001");
            logo_texture = content.Load<Texture2D>("textures/logo");
            instructions_texture = content.Load<Texture2D>("textures/instructions");

            instructions_texture_region = new TextureRegion(instructions_texture, 0, 0, 813, 360);
            logo_texture_region = new TextureRegion(logo_texture, 0, 0, 340, 270);
            white_texture_region = new TextureRegion(title_texture, 17 * 16 + 8, 8, 1, 1);
            particle_texture_region = new TextureRegion(title_texture, 18 * 16+1, 1, 14, 14);
            bubble_reflection_texture_region = new TextureRegion(bubble_reflection_texture, 0, 0, 128, 128);
            bubble_texture_region = new TextureRegion(bubble_texture, 0, 0, bubble_texture.Width, bubble_texture.Height);
            controls_region = new TextureRegion(title_texture, 0, 96, 512, 320);
            hud_on = new TextureRegion(title_texture, 96, 416, 96, 96);
            hud_off = new TextureRegion(title_texture, 0, 416, 96, 96);

            arial10px_font = FontProcessor.Build(content.Load<Texture2D>("fonts/arial10px"));
            description_font = FontProcessor.Build(content.Load<Texture2D>("fonts/aharoni15px_bold"));
            option_font = FontProcessor.Build(content.Load<Texture2D>("fonts/aharoni28px_bold"));
            title_font = FontProcessor.Build(content.Load<Texture2D>("fonts/aharoni48px_bold"));

            spriterenderer_material = content.Load<Effect>("shaders/spriterenderer/default");
            postprocessor_blur = content.Load<Effect>("shaders/postprocessor/dof_blur");
            postprocessor_dof = content.Load<Effect>("shaders/postprocessor/dof");
            postprocessor_scale = content.Load<Effect>("shaders/postprocessor/dof_scale");
            postprocessor_extract = content.Load<Effect>("shaders/postprocessor/bloom_extract");
            postprocessor_bloom = content.Load<Effect>("shaders/postprocessor/bloom_combine");

            box_model = content.Load<Model>("models/box");
            rock_model = content.Load<Model>("models/rock");
            skybox_model = content.Load<Model>("models/skybox");
            seaurchin_model = content.Load<Model>("models/urchin");
            fish_model = content.Load<Model>("models/nemo");
            octopus_model = content.Load<Model>("models/octopus");
            starfish_model = content.Load<Model>("models/starfish");

            name_to_object_mapping = new Dictionary<string, object>();
            object_to_name_mapping = new Dictionary<object, string>();

            Add("models/box", box_model);
            Add("models/rock", rock_model);
            Add("models/skybox", skybox_model);
            Add("models/urchin", seaurchin_model);
            Add("models/nemo", fish_model);
            Add("models/octopus", octopus_model);
            Add("models/starfish", starfish_model);
            Add("textures/bg-light-0001", ray_texture);
        }
Ejemplo n.º 8
0
        public Menu(Screen parent, ScreenManager manager)
            : base(parent, manager)
        {
            transition_time = 0.3f;

            font_title = Resources.title_font;
            font_option = Resources.option_font;
            font_description = Resources.description_font;
        }