コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenGLBox_Resize(object sender, EventArgs e)
        {
            if (Batch == null || Heads == null)
            {
                return;
            }

            OpenGLBox.MakeCurrent();
            Display.ViewPort = new Rectangle(Point.Empty, OpenGLBox.Size);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenGLBox_Load(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            OpenGLBox.MakeCurrent();
            Display.Init();
            Display.RenderState.ClearColor = Color.Black;

            Heads = ResourceManager.CreateAsset <TileSet>("Heads");

            Batch = new SpriteBatch();
        }
コード例 #3
0
        /// <summary>
        /// Rebuild properties panel
        /// </summary>
        void RebuildProperties()
        {
            if (this.DesignMode)
            {
                return;
            }

            ProfessionsBox.Hero = Hero;

            if (Hero == null)
            {
                StrengthBox.Ability     = null;
                IntelligenceBox.Ability = null;
                WisdomBox.Ability       = null;
                DexterityBox.Ability    = null;
                ConstitutionBox.Ability = null;
                CharismaBox.Ability     = null;

                ArmorClassBox.Text = "0";

                HPBox.HitPoint = null;

                NameBox.Text  = "";
                FoodBox.Value = 0;
            }
            else
            {
                QuiverBox.Value         = Hero.Quiver;
                StrengthBox.Ability     = Hero.Strength;
                IntelligenceBox.Ability = Hero.Intelligence;
                WisdomBox.Ability       = Hero.Wisdom;
                DexterityBox.Ability    = Hero.Dexterity;
                ConstitutionBox.Ability = Hero.Constitution;
                CharismaBox.Ability     = Hero.Charisma;

                RaceBox.SelectedItem      = Hero.Race;
                AlignmentBox.SelectedItem = Hero.Alignment;

                ArmorClassBox.Text = Hero.ArmorClass.ToString();

                HPBox.HitPoint = Hero.HitPoint;
                FoodBox.Value  = Hero.Food;
                NameBox.Text   = Hero.Name;
            }

            // Repaint
            OpenGLBox.Invalidate();
        }
コード例 #4
0
        /// <summary>
        /// Previous Hero face
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PreviousFaceBox_Click(object sender, EventArgs e)
        {
            if (Hero == null || Heads == null)
            {
                return;
            }

            int id = Hero.Head - 1;

            if (id <= 0)
            {
                id = Heads.Count - 1;
            }

            Hero.Head = id;
            OpenGLBox.Invalidate();
        }
コード例 #5
0
        /// <summary>
        /// Next hero face
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NextFaceBox_Click(object sender, EventArgs e)
        {
            if (Hero == null || Heads == null)
            {
                return;
            }

            int id = Hero.Head + 1;

            if (id >= Heads.Count)
            {
                id = 0;
            }

            Hero.Head = id;
            OpenGLBox.Invalidate();
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DecorationForm_Load(object sender, System.EventArgs e)
        {
            OpenGLBox.MakeCurrent();
            Display.ViewPort = new Rectangle(Point.Empty, OpenGLBox.Size);
            Display.RenderState.ClearColor = Color.Black;
            Display.RenderState.Blending   = true;
            Display.BlendingFunction(BlendingFactorSource.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            Batch = new SpriteBatch();

            // Collect all Tileset definition
            List <string> list = ResourceManager.GetAssets <TileSet>();

            BackgroundTileSetBox.Items.AddRange(list.ToArray());


            // Background tileset
            if (list.Contains(DecorationSet.BackgroundTileset))
            {
                BackgroundTileSetBox.SelectedItem = DecorationSet.BackgroundTileset;
            }
            else if (BackgroundTileSetBox.Items.Count > 0)
            {
                ChangeBackgroundTileSet((string)BackgroundTileSetBox.Items[0]);
                BackgroundTileSetBox.SelectedIndex = 0;
            }


            // Decoration TileSet
            list = ResourceManager.GetAssets <TileSet>();
            TilesetBox.Items.AddRange(list.ToArray());
            if (list.Contains(DecorationSet.TileSetName))
            {
                TilesetBox.SelectedItem = DecorationSet.TileSetName;
            }

            //list = ResourceManager.GetAssets<TileSet>();
            ItemTileSetBox.Items.AddRange(list.ToArray());


            OpenGLBox.MouseWheel += new MouseEventHandler(OpenGLBox_MouseWheel);

            DrawTimer.Start();
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenGLBox_Paint(object sender, PaintEventArgs e)
        {
            if (Batch == null || Heads == null)
            {
                return;
            }

            OpenGLBox.MakeCurrent();
            Display.ClearBuffers();

            if (Heads != null && Batch != null && Hero != null)
            {
                Batch.Begin();
                Batch.DrawTile(Heads, Hero.Head, Point.Empty);
                Batch.End();
            }


            OpenGLBox.SwapBuffers();
        }
コード例 #8
0
        /// <summary>
        /// Form closing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DecorationForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (DrawTimer != null)
            {
                DrawTimer.Dispose();
            }
            DrawTimer = null;

            if (Batch != null)
            {
                Batch.Dispose();
            }
            Batch = null;

            if (BgTileSet != null)
            {
                BgTileSet.Dispose();
            }
            BgTileSet = null;

            if (DecorationSet != null)
            {
                DecorationSet.Dispose();
            }
            DecorationSet = null;

            if (ItemTileset != null)
            {
                ItemTileset.Dispose();
            }
            ItemTileset = null;

            if (OpenGLBox != null)
            {
                OpenGLBox.Dispose();
            }
            OpenGLBox = null;
        }
コード例 #9
0
        /// <summary>
        /// Render the scene
        /// </summary>
        void RenderScene()
        {
            OpenGLBox.MakeCurrent();
            Display.ClearBuffers();

            Batch.Begin();

            // Background
            Batch.DrawTile(BgTileSet, 0, Point.Empty);

            // Render the walls
            if (DisplayWallBox.Checked)
            {
                foreach (TileDrawing tmp in DisplayCoordinates.GetWalls(ViewPositionBox.Position))
                {
                    Batch.DrawTile(BgTileSet, tmp.ID, tmp.Location, Color.White, 0.0f, tmp.Effect, 0.0f);
                }
            }


            #region Draw the decoration
            if (Decoration != null && DecorationSet.Tileset != null)
            {
                DecorationSet.Draw(Batch, (int)DecorationIdBox.Value, ViewPositionBox.Position);

                Tile tile = DecorationSet.Tileset.GetTile(Decoration.GetTileId(ViewPositionBox.Position));
                if (tile != null)
                {
                    Point     start = Decoration.GetLocation(ViewPositionBox.Position);
                    Rectangle rect  = new Rectangle(start, tile.Size);

                    // Red rectangle around tile
                    if (rect.Contains(OpenGLBox.PointToClient(Control.MousePosition)) && !ItemsModeSelected)
                    {
                        Batch.DrawRectangle(rect, Color.Red);
                    }
                }

                TileLocationBox.Text = Decoration.GetLocation(ViewPositionBox.Position).ToString();
            }
            else
            {
                TileLocationBox.Text = "";
            }
            #endregion


            #region Display item
            if (ItemsModeSelected && ItemTileset != null &&
                (ViewPositionBox.Position == ViewFieldPosition.L ||
                 ViewPositionBox.Position == ViewFieldPosition.H ||
                 ViewPositionBox.Position == ViewFieldPosition.C))
            {
                // Offset the item locations according to the distance
                Vector2 vect = DisplayCoordinates.GetMonsterScaleFactor(ViewPositionBox.Position);
                Point   loc  = Decoration.PrepareLocation(ViewPositionBox.Position);
                loc.Offset((int)(Decoration.ItemLocation.X * vect.X), (int)(Decoration.ItemLocation.Y * vect.Y));


                Batch.DrawTile(ItemTileset, (int)ItemIdBox.Value, loc,
                               DisplayCoordinates.GetDistantColor(ViewPositionBox.Position), 0.0f,
                               DisplayCoordinates.GetItemScaleFactor(ViewPositionBox.Position), SpriteEffects.None, 0.0f);

                ItemPositionBox.Text = Decoration.ItemLocation.ToString();
            }
            #endregion

            Batch.End();

            OpenGLBox.SwapBuffers();
        }