private void AddIcon(int houseIndex, MissionSet set, short regionID, string[] unitDescriptions)
        {
            if (regionID <= 0 || houseIndex < 0 || houseIndex > _iconSprite.Length)
            {
                return;
            }

            if (ParentForm is GameForm f)
            {
                // regionIDs are one-based
                int regIndex = regionID - 1;

                SpriteBox sp = new SpriteBox();
                // Add first
                _missionBoxes.Add(sp);
                spTerritories.Controls.Add(sp);

                sp.BaseImage = _iconSprite[houseIndex];
                sp.Click    += (o, e) => { AudioEngine.Click(); f.Push(new MissionBriefingScreen(set, unitDescriptions), TransitionStyle.FADE_BLACK); };

                float2 iconLoc = _centers[regIndex];
                float2 sz      = spTerritories.Size.ToFloat2() / _territoryBitmapSize.ToFloat2() * _iconSprite[houseIndex].Size.ToFloat2() * ICON_SCALE;
                float2 loc     = spTerritories.Size.ToFloat2() * iconLoc / _territoryBitmapSize.ToFloat2() - sz / 2;

                sp.Location = loc.ToPoint();
                sp.Size     = sz.ToSize();
            }
        }
Esempio n. 2
0
            EbVector3 calPosition(SpriteBox cal_box, SpriteBox center_box)
            {
                EbVector3 center_box_new_size = new EbVector3(center_box.mFixedWidth, center_box.mFixedHeight, 0);

                center_box_new_size *= 0.5f;
                EbVector3 cal_box_new_size = new EbVector3(cal_box.mFixedWidth, cal_box.mFixedHeight, 0);

                cal_box_new_size *= 0.5f;

                return(center_box_new_size + cal_box_new_size);
            }
Esempio n. 3
0
    public override void OnInspectorGUI()
    {
        SpriteBox sbox = (SpriteBox)target;

        base.OnInspectorGUI();
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("ResizeToSet"))
        {
            sbox.resizeToSet();
        }
        if (GUILayout.Button("ResizeToOriginal"))
        {
            sbox.resizeToOriginal();
        }
        EditorGUILayout.EndHorizontal();
    }
Esempio n. 4
0
        // TODO make load/unload methods for spriteboxes etc.

        public SpriteSet(string bitmapName, int topLeftCornerX, int topLeftCornerY, int nbColumns, int nbRows, int spriteWidth, int spriteHeight)
        {
            BitmapName = bitmapName;
            var nbSprites = nbColumns * nbRows;

            SpriteWidth  = spriteWidth;
            SpriteHeight = spriteHeight;
            SpriteBoxes  = new SpriteBox[nbSprites];
            var i = 0;
            var bottomRightCornerX = topLeftCornerX + (nbColumns * spriteWidth);
            var bottomRightCornerY = topLeftCornerY + (nbRows * spriteHeight);

            for (int y = topLeftCornerY; y < bottomRightCornerY; y += spriteHeight)
            {
                for (int x = topLeftCornerX; x < bottomRightCornerX; x += spriteWidth)
                {
                    var box = new SpriteBox(x, y, x + spriteWidth, y + spriteHeight);
                    SpriteBoxes[i] = box;
                    i++;
                }
            }
        }
Esempio n. 5
0
            //-------------------------------------------------------------------------
            public void setScale(float x_scale, float y_scale, float fixed_scale, SpriteBox center_box)
            {
                if (mHorizontalScale && mVerticalScale)
                {
                    mStillSprite.setScale(x_scale, y_scale);
                }
                else if (mHorizontalScale)
                {
                    mStillSprite.setScale(x_scale, fixed_scale);
                }
                else if (mVerticalScale)
                {
                    mStillSprite.setScale(fixed_scale, y_scale);
                }

                if (this != center_box)
                {
                    mOffset = calPosition(this, center_box);
                }
                else
                {
                }
            }
Esempio n. 6
0
        protected override void OnInitialize()
        {
            SpriteFont font = game.Content.Load <SpriteFont>("default");

            background = new SpriteBox(game);

            background.Renderer = new DisortSpriteRenderer(background,
                                                           minX: -5.0f,
                                                           maxX: 5.0f,
                                                           minY: -5.0f,
                                                           maxY: 5.0f);

            background.Sprite        = new Sprite(game.Content.Load <Texture2D>("taustatemp"));
            background.SizeBehaviour = Gui.SizeBehaviour.OverwriteBoth;
            background.Size          = new Vector2(105f);
            background.Position      = new Vector2(-5f, -5f);

            background.DisableFocusing();

            root      = new Canvas(game);
            root.Size = new Vector2(100f);
            root.Add(background);

            grid = new Grid(game)
            {
                Rows    = 6,
                Columns = 4
            };

            grid.SetRowHeight(0, 25f);
            grid.SetRowHeight(1, 25f);
            grid.SetRowHeight(2, 10f);
            grid.SetRowHeight(3, 10f);
            grid.SetRowHeight(4, 10f);

            grid.SetColumnWidth(0, 5f);

            root.Add(grid);

            header = new Label(game)
            {
                Font          = font,
                Text          = "Massacre simulator 3000",
                Brush         = new Brush(Color.White),
                SizeBehaviour = SizeBehaviour.OverwriteBoth,
                Size          = new Vector2(100f, 55f)
            };

            start = new Button(game)
            {
                // TODO: continue tai start riippuen siitä onko pelissä jo save file.
                Text                    = "Start",
                TextColor               = Color.White,
                Font                    = font,
                SizeBehaviour           = Gui.SizeBehaviour.OverwriteBoth,
                VerticalAlingment       = Vertical.Center,
                HorizontalAlingment     = Horizontal.Left,
                Brush                   = new Gui.Brush(Color.Transparent),
                TextSize                = new Vector2(55f, 45f),
                Size                    = new Vector2(25f, 100f),
                TextHorizontalAlingment = Horizontal.Left
            };

            start.MouseButtonDown += start_MouseButtonDown;
            start.ButtonPressed   += start_ButtonPressed;

            options = new Button(game)
            {
                Text                    = "Options",
                TextColor               = Color.White,
                Font                    = font,
                SizeBehaviour           = Gui.SizeBehaviour.OverwriteBoth,
                VerticalAlingment       = Vertical.Center,
                HorizontalAlingment     = Horizontal.Left,
                Brush                   = new Gui.Brush(Color.Transparent),
                TextSize                = new Vector2(55f, 45f),
                Size                    = new Vector2(25f, 100f),
                TextHorizontalAlingment = Horizontal.Left
            };

            options.MouseButtonDown += options_MouseButtonDown;
            options.ButtonPressed   += options_ButtonPressed;

            exit = new Button(game)
            {
                Text                    = "Exit",
                TextColor               = Color.White,
                Font                    = font,
                SizeBehaviour           = Gui.SizeBehaviour.OverwriteBoth,
                VerticalAlingment       = Vertical.Center,
                HorizontalAlingment     = Horizontal.Left,
                Brush                   = new Gui.Brush(Color.Transparent),
                TextSize                = new Vector2(45f, 45f),
                Size                    = new Vector2(25f, 100f),
                TextHorizontalAlingment = Horizontal.Left
            };

            exit.MouseButtonDown += exit_MouseButtonDown;
            exit.ButtonPressed   += exit_ButtonPressed;

            grid.SetColumnWidth(1, 50f);

            grid.Add(header, 0, 1);
            grid.Add(start, 2, 1);
            grid.Add(options, 3, 1);
            grid.Add(exit, 4, 1);

            SetContent(root);
        }
Esempio n. 7
0
            EbVector3 calPosition(SpriteBox cal_box, SpriteBox center_box)
            {
                EbVector3 center_box_new_size = new EbVector3(center_box.mFixedWidth, center_box.mFixedHeight, 0);
                center_box_new_size *= 0.5f;
                EbVector3 cal_box_new_size = new EbVector3(cal_box.mFixedWidth, cal_box.mFixedHeight, 0);
                cal_box_new_size *= 0.5f;

                return center_box_new_size + cal_box_new_size;
            }
Esempio n. 8
0
            //-------------------------------------------------------------------------
            public void setScale(float x_scale, float y_scale, float fixed_scale, SpriteBox center_box)
            {
                if (mHorizontalScale && mVerticalScale)
                {
                    mStillSprite.setScale(x_scale, y_scale);
                }
                else if (mHorizontalScale)
                {
                    mStillSprite.setScale(x_scale, fixed_scale);
                }
                else if (mVerticalScale)
                {
                    mStillSprite.setScale(fixed_scale, y_scale);
                }

                if (this != center_box)
                {
                    mOffset = calPosition(this, center_box);
                }
                else
                {

                }
            }
Esempio n. 9
0
 public void SetImage()
 {
     SpriteBox.Image    = Image;
     SpriteBox.SizeMode = PictureBoxSizeMode.StretchImage;
     SpriteBox.Refresh();
 }
Esempio n. 10
0
        protected override void OnInitialize()
        {
            // 100% koko.
            Size = new Vector2(100f);
            SpriteFont font = game.Content.Load <SpriteFont>("guifont");

            // Root ja background init.
            root = new Canvas(game)
            {
                Brush = new Brush(Color.Transparent),
                Size  = SizeInPixels
            };

            background = new SpriteBox(game)
            {
                Size = new Vector2(100f, 200f),

                Sprite = new Sprite(game.Content.Load <Texture2D>("taustatemp"))
                {
                    Size = new Vector2(1280f, 720f)
                },

                Brush = new Brush(Color.White)
            };

            background.DisableFocusing();

            root.Add(background);

            // Grid init.
            grid = new Grid(game)
            {
                Rows    = 3,
                Columns = 6,
            };

            grid.SetColumnWidth(0, 15f);
            grid.SetColumnWidth(5, 15f);
            grid.SetRowHeight(0, 15f);
            grid.SetRowHeight(2, 15f);

            root.Add(grid);

            // Player label inits.
            p1Label = new Label(game)
            {
                Font                = font,
                Text                = "Connected (P1)",
                SizeBehaviour       = SizeBehaviour.OverwriteBoth,
                VerticalAlingment   = Vertical.Top,
                HorizontalAlingment = Horizontal.Center,
                SizeValueType       = Gui.SizeValueType.Fixed,
                DrawOrder           = 1
            };

            p1Label.Size = font.MeasureString(p1Label.Text) * 0.75f;

            p2Label = new Label(game)
            {
                Font                = font,
                Text                = "Not connected",
                SizeBehaviour       = SizeBehaviour.OverwriteBoth,
                VerticalAlingment   = Vertical.Top,
                HorizontalAlingment = Horizontal.Center,
                SizeValueType       = Gui.SizeValueType.Fixed,
                DrawOrder           = 1
            };

            p2Label.Size = font.MeasureString(p2Label.Text) * 0.75f;

            p3Label = new Label(game)
            {
                Font                = font,
                Text                = "Not connected",
                SizeBehaviour       = SizeBehaviour.OverwriteBoth,
                VerticalAlingment   = Vertical.Top,
                HorizontalAlingment = Horizontal.Center,
                SizeValueType       = Gui.SizeValueType.Fixed,
                DrawOrder           = 1
            };

            p3Label.Size = font.MeasureString(p3Label.Text) * 0.75f;

            p4Label = new Label(game)
            {
                Font                = font,
                Text                = "Not connected",
                SizeBehaviour       = SizeBehaviour.OverwriteBoth,
                VerticalAlingment   = Vertical.Top,
                HorizontalAlingment = Horizontal.Center,
                SizeValueType       = Gui.SizeValueType.Fixed,
                DrawOrder           = 1
            };

            p4Label.Size = font.MeasureString(p4Label.Text) * 0.75f;

            Labels = new []
            {
                p2Label,
                p3Label,
                p4Label
            };

            grid.Add(p1Label, 1, 1);
            grid.Add(p2Label, 1, 2);
            grid.Add(p3Label, 1, 3);
            grid.Add(p4Label, 1, 4);

            // Player box init.
            Texture2D texture = game.Content.Load <Texture2D>("slot");

            p1Box = new SpriteBox(game)
            {
                Sprite = new Sprite(texture),
                Margin = new Margin(left: 10f, right: 10f, top: -15f, bottom: 5f)
            };

            p2Box = new SpriteBox(game)
            {
                Sprite = new Sprite(texture),
                Margin = new Margin(left: 10f, right: 10f, top: -15f, bottom: 5f)
            };

            p3Box = new SpriteBox(game)
            {
                Sprite = new Sprite(texture),
                Margin = new Margin(left: 10f, right: 10f, top: -15f, bottom: 5f)
            };

            p4Box = new SpriteBox(game)
            {
                Sprite = new Sprite(texture),
                Margin = new Margin(left: 10f, right: 10f, top: -15f, bottom: 5f)
            };

            grid.Add(p1Box, 1, 1);
            grid.Add(p2Box, 1, 2);
            grid.Add(p3Box, 1, 3);
            grid.Add(p4Box, 1, 4);

            grid.UpdateLayout(new GuiLayoutEventArgs());

            // Start and go back buttons init.
            start = new Button(game)
            {
                Font                = font,
                Text                = "Start",
                SizeValueType       = Gui.SizeValueType.Fixed,
                SizeBehaviour       = Gui.SizeBehaviour.OverwriteBoth,
                HorizontalAlingment = Horizontal.Center,
                VerticalAlingment   = Vertical.Center,
                Brush               = new Brush(Color.Transparent),
                Size                = new Vector2(100f)
            };

            start.TextSize = font.MeasureString(start.Text) * 1.25f;

            goBack = new Button(game)
            {
                Font                = font,
                Text                = "Go back",
                SizeValueType       = Gui.SizeValueType.Fixed,
                SizeBehaviour       = Gui.SizeBehaviour.OverwriteBoth,
                HorizontalAlingment = Horizontal.Center,
                VerticalAlingment   = Vertical.Center,
                Brush               = new Brush(Color.Transparent),
                Size                = new Vector2(100f)
            };

            goBack.TextSize = font.MeasureString(goBack.Text) * 1.25f;

            grid.Add(start, 2, 0);
            grid.Add(goBack, 2, 5);

            start.MouseButtonDown  += button_MouseButtonDown;
            goBack.MouseButtonDown += button_MouseButtonDown;

            start.ButtonPressed  += start_ButtonPressed;
            goBack.ButtonPressed += goBack_ButtonPressed;

            SetContent(root);
        }
Esempio n. 11
0
        private void LoadProject(GameScreen screen, CatalystProject2D project)
        {
            // First load any pathing ledges
            if (project.Paths.Count > 0)
            {
                Paths.AddRange(project.Paths);
            }

            // Loop thru our objects and reload them
            foreach (VisualObject vo in project.SceneObjects)
            {
                if (vo is VisualObjectGroup)
                {
                    VisualObjectGroup group = vo as VisualObjectGroup;

                    foreach (VisualObject o in group.Objects)
                    {
                        if (o is Sprite && o.GetType() != typeof(SpriteBox))
                        {
                            Sprite sprite = o as Sprite;
                            sprite.AssetFolder = AssetFolder;
                            sprite.Game        = Game;

                            sprite.Texture = screen.Content.Load <Texture2D>(Path.GetFileNameWithoutExtension(o.AssetName));

                            sprite.GameScreen = this;

                            // Re-attach any nodes
                            if (!string.IsNullOrEmpty(sprite.AttachedPathingNodeName))
                            {
                                sprite.AttachedPathingNode = GetPath(sprite.AttachedPathingNodeName);
                            }
                        }

                        if (o is SpriteBox)
                        {
                            SpriteBox sprite = o as SpriteBox;
                            sprite.AssetFolder = AssetFolder;
                            sprite.Game        = Game;
                            sprite.GameScreen  = this;

                            // Re-attach any nodes
                            if (!string.IsNullOrEmpty(sprite.AttachedPathingNodeName))
                            {
                                sprite.AttachedPathingNode = GetPath(sprite.AttachedPathingNodeName);
                            }
                        }

                        if (o is ParticleEmitter)
                        {
                            ParticleEmitter emitter = o as ParticleEmitter;
                            emitter.AssetFolder = AssetFolder;
                            emitter.Game        = Game;

                            emitter.Texture = screen.Content.Load <Texture2D>(Path.GetFileNameWithoutExtension(o.AssetName));

                            emitter.GameScreen = this;
                        }
                    }

                    group.Game = Game;

                    AddVisualObject(group);
                }

                if (vo is Actor)
                {
                    Actor a = vo as Actor;

                    a.Game            = Game;
                    a.GameScreen      = this;
                    a.ClipPlayer.Game = Game;
                    a.AssetFolder     = AssetFolder;

                    a.ClipPlayer.Texture = screen.Content.Load <Texture2D>(Path.GetFileNameWithoutExtension(a.SpriteSheetFileName));

                    AddVisualObject(a);

                    continue;
                }

                if (vo is Button)
                {
                    Button button = vo as Button;
                    button.Game        = Game;
                    button.GameScreen  = this;
                    button.AssetFolder = AssetFolder;

                    button.Texture = screen.Content.Load <Texture2D>(Path.GetFileNameWithoutExtension(button.AssetName));

                    AddVisualObject(button);

                    continue;
                }

                // Make sure its a sprite and not the spritebox
                if (vo is Sprite && vo.GetType() != typeof(SpriteBox))
                {
                    Sprite sprite = vo as Sprite;
                    sprite.Game        = Game;
                    sprite.GameScreen  = this;
                    sprite.AssetFolder = AssetFolder;

                    sprite.Texture = screen.Content.Load <Texture2D>(Path.GetFileNameWithoutExtension(sprite.AssetName));

                    // Re-attach any nodes
                    if (!string.IsNullOrEmpty(sprite.AttachedPathingNodeName))
                    {
                        sprite.AttachedPathingNode = GetPath(sprite.AttachedPathingNodeName);
                    }

                    AddVisualObject(sprite);
                }

                if (vo is SpriteBox)
                {
                    SpriteBox sprite = vo as SpriteBox;
                    sprite.AssetFolder = AssetFolder;
                    sprite.Game        = Game;
                    sprite.GameScreen  = this;

                    // Re-attach any nodes
                    if (!string.IsNullOrEmpty(sprite.AttachedPathingNodeName))
                    {
                        sprite.AttachedPathingNode = GetPath(sprite.AttachedPathingNodeName);
                    }

                    AddVisualObject(sprite);
                }

                if (vo is ParticleEmitter)
                {
                    ParticleEmitter emitter = vo as ParticleEmitter;
                    emitter.Game        = Game;
                    emitter.GameScreen  = this;
                    emitter.AssetFolder = AssetFolder;

                    emitter.Texture = screen.Content.Load <Texture2D>(Path.GetFileNameWithoutExtension(emitter.AssetName));

                    AddVisualObject(emitter);
                }
            }
        }