Sign in to follow this  

problem selection a model

This topic is 1265 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i can selection a model when i click in a button like this example i click in the button say Maria and the helmet change the color our posicion to yellow and when click in start say you choose Maria and if i select any button it is in groupbox say you must select a characters

this is my code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

using System.Threading;
using XRpgLibrary;

using TomShane.Neoforce.Controls;

namespace TomShane.Neoforce.Central.Code
{
    public class Characterse : BaseGameState
    {
        //string texto;

       // private LoginClient cliente;
        private Manager NeoManager;
        public Model model;
        public Matrix[] modelTransforms;
        //private string texto;

        private string tex;

        private ImageBox image;
        private SideBarPanel pnlRes = null;
        

    
        private Label ServerSection = null;
       
        private Button create = null;
        private Button start = null;
        private Button ok = null;
        private Button delete = null;
        private Button Quit = null;
       
        private StackPanel group1 = null;
        private Button btnFirst = null;
        private Label nome = null;
        private GroupPanel groupo=null;
        private Button btnFirst1 = null;
        private Label nome1 = null;
        private GroupPanel groupo1 = null;
        private Button btnFirst2 = null;
        private Label nome2 = null;
        private GroupPanel groupo2 = null;
        private Label nome3 = null;
        private GroupPanel groupo3 = null;
        private Button btnFirst3 = null;
        private Label nome4 = null;
        private GroupPanel groupo4 = null;
        private Button btnFirst4 = null;
        private Label nome5 = null;
        private GroupPanel groupo5 = null;
        private Button btnFirst5 = null;
        private Label nome6 = null;
        private GroupPanel groupo6 = null;
        private Button btnFirst6 = null;
        private Label nome7 = null;
        private GroupPanel groupo7 = null;
        private Button btnFirst7 = null;
        string charact0=null;
        string charact1=null;
        string charact2=null;
        string charact3=null;
        string charact4=null;
        string charact5=null;
        string charact6=null;
        string charact7=null;
        //public Texture2D ImageBox { get { return image.Image; } set { image.Image = value; } }

        public Characterse(Game game, GameStateManager manager)
            : base(game, manager)
        {
          
            System.Console.WriteLine("OLA");

        }


        protected override void LoadContent()
        {



            NeoManager = new Manager(Game);
            NeoManager.AutoCreateRenderTarget = true;
            NeoManager.AutoUnfocus = true;
            NeoManager.Initialize();


            base.LoadContent();
            InitRes();
            model = Game.Content.Load<Model>("helmet");
            modelTransforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(modelTransforms);

         

        }
        public override void Initialize()
        {



            base.Initialize();

          
        }
        public override void Update(GameTime gameTime)
        {




            base.Update(gameTime);
            NeoManager.Update(gameTime);

        }
        public override void Draw(GameTime gameTime)
        {

            NeoManager.BeginDraw(gameTime);

            GraphicsDevice.Clear(Color.CornflowerBlue);
            
            NeoManager.EndDraw();

            Matrix view = Matrix.CreateLookAt(
            new Vector3(200, 300, 900),
            new Vector3(0, 50, 0),
            Vector3.Up);
            Matrix projection = Matrix.CreatePerspectiveFieldOfView(
            MathHelper.ToRadians(45),
            GraphicsDevice.Viewport.AspectRatio,
            0.1f, 10000.0f);
            // Calculate the starting world matrix
            Matrix baseWorld = Matrix.CreateScale(0.4f) *
            Matrix.CreateRotationY(MathHelper.ToRadians(180));
            foreach (ModelMesh mesh in model.Meshes)
            {
                // Calculate each mesh's world matrix
                Matrix localWorld = modelTransforms[mesh.ParentBone.Index]
                * baseWorld;
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    BasicEffect e = (BasicEffect)part.Effect;
                    // Set the world, view, and projection
                    // matrices to the effect
                    e.World = localWorld;
                    e.View = view;
                    e.Projection = projection;
                    e.EnableDefaultLighting();
                }
                mesh.Draw();
            }

            base.Draw(gameTime);
        }


        private void InitRes()
        {
            
          string[] ola = new string[8] {"Maria","torradeira","OLA","aspirador" ,"","","",""};

            for (int i = 0; i <=ola.Length; i++)
            {
                System.Console.WriteLine(ola.Length);
                 charact0 = ola[0];
                 charact1 = ola[1];
                charact2=ola[2];
                charact3 = ola[3];
                charact4=ola[4];
                charact5=ola[5];
                charact6=ola[6];
                charact7=ola[7];
            
                }
                pnlRes = new SideBarPanel(NeoManager);
            pnlRes.Init();
            pnlRes.Passive = true;
           
            pnlRes.Left = 16;
            pnlRes.Top = 16;
            pnlRes.Width = 400;
            pnlRes.Height = 200;
            pnlRes.CanFocus = false;

            ServerSection = new Label(NeoManager);
            ServerSection.Init();

            ServerSection.Width = 120;
            ServerSection.Parent = pnlRes;
            ServerSection.Top = pnlRes.Left + 10;
            ServerSection.Left = 400;
            ServerSection.Text = "Character Selection";
            NeoManager.Add(ServerSection);
          /*  image = new ImageBox(NeoManager);
            image.Init();
            image.Parent = pnlRes;
            image.Top = pnlRes.Left + 100;
            image.Left = 400;
            image.Width = 400;
            image.Height = 100;

           
          /*  image.SizeMode = SizeMode.Normal;
            image.Image = NeoManager.Content.Load<Texture2D>("Content\\Images\\Caption");
            NeoManager.Add(image);
            */
            ok = new Button(NeoManager);
            ok.Init();
            ok.Width = 100;
            ok.Parent = pnlRes;
            ok.Left = pnlRes.Left + 120;
            ok.Top = pnlRes.Top + 740;
            ok.Text = "Select Server";
            NeoManager.Add(ok);
            start = new Button(NeoManager);
            start.Init();
            start.Width = 100;
            start.Parent = pnlRes;
            start.Left = pnlRes.Left + 340;
            start.Top = pnlRes.Top + 740;
            start.Text = "Start";
            start.Click += new Controls.EventHandler(btnStart_Click);
            NeoManager.Add(start);

            create = new Button(NeoManager);
            create.Init();
            create.Width = 100;
            create.Parent = pnlRes;
            create.Left = pnlRes.Left + 450;
            create.Top = pnlRes.Top + 740;
            create.Text = "Create";
            create.Click += new Controls.EventHandler(btncreate_Click);
            NeoManager.Add(create);

            delete = new Button(NeoManager);
            delete.Init();
            delete.Width = 100;
            delete.Parent = pnlRes;
            delete.Left = pnlRes.Left + 560;
            delete.Top = pnlRes.Top + 740;
            delete.Text = "Delete";
            NeoManager.Add(delete);
            Quit = new Button(NeoManager);
            Quit.Init();
            Quit.Width = 100;
            Quit.Parent = pnlRes;
            Quit.Left = pnlRes.Left + 670;
            Quit.Top = pnlRes.Top + 740;
            Quit.Text = "Quit";
            Quit.Click += new Controls.EventHandler(btnExit_Click);
            NeoManager.Add(Quit);


          group1 = new StackPanel(NeoManager,Orientation.Horizontal);
            group1.Init();
            group1.Parent = pnlRes;
         
            group1.Init();
            group1.Parent = pnlRes;
            group1.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
            group1.Top = 690;
            group1.Left = pnlRes.Top + 60; ;
            group1.Width = 100;
            //group1.Height = 100;
            NeoManager.Add(group1);
            groupo = new GroupPanel(NeoManager);
            groupo.Init();
            groupo.Parent = group1;

            groupo.Top = 660;
            groupo.Left = pnlRes.Top + 60;
            groupo.Width = 100;
            groupo.Text = "";
            NeoManager.Add(groupo);
          
            
            btnFirst = new Button(NeoManager);
            btnFirst.Init();
            btnFirst.Parent = groupo;
            btnFirst.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
            btnFirst.Top = 660;
            btnFirst.Left = pnlRes.Top + 60 ;
            btnFirst.Width = 100;
            btnFirst.Text =charact0;
            NeoManager.Add(btnFirst);
            nome = new Label(NeoManager);
            nome.Init();
            nome.Parent = groupo;
            nome.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
            nome.Top = 680;
            nome.Left = pnlRes.Top + 60;
            nome.Width = 100;
            nome.Height = 25;
            nome.Text = "PDS\n"+"24";
            nome.BackColor = new Color(1, 1, 60);
            NeoManager.Add(nome);
            
            /////
            
            groupo1 = new GroupPanel(NeoManager);
            groupo1.Init();
            groupo1.Parent = group1;

            groupo1.Top = 660;
            groupo1.Left = pnlRes.Top +groupo.Width+ 70;
            groupo1.Width = 100;
            groupo1.Text = "";
            NeoManager.Add(groupo1);
            btnFirst1 = new Button(NeoManager);
            btnFirst1.Init();
            btnFirst1.Parent = groupo1;
            btnFirst1.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
            btnFirst1.Top = 660;
            btnFirst1.Left = pnlRes.Top + groupo.Width + 70;
            btnFirst1.Width = 100;
            btnFirst1.Text = charact1;
            NeoManager.Add(btnFirst1);
            nome1 = new Label(NeoManager);
            nome1.Init();
            nome1.Parent = groupo1;
            nome1.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
            nome1.Top = 680;
            nome1.Left = pnlRes.Top + groupo.Width + 70;
            nome1.Width = 100;
            nome1.Height = 25;
            nome1.Text = "d";
            nome1.BackColor = new Color(1, 1, 60);
            NeoManager.Add(nome1);
       ///////////////////////////////////////////////////////////////////////////////////////////

            groupo2 = new GroupPanel(NeoManager);
            groupo2.Init();
            groupo2.Parent = group1;

            groupo2.Top = 660;
            groupo2.Left = pnlRes.Top + groupo1.Width + 179;
            groupo2.Width = 100;
            groupo2.Text = "";
            NeoManager.Add(groupo2);
            btnFirst2 = new Button(NeoManager);
            btnFirst2.Init();
            btnFirst2.Parent = groupo2;

            btnFirst2.Top = 660;
            btnFirst2.Left = pnlRes.Top + groupo1.Width + 179;
            btnFirst2.Width = 100;
            btnFirst2.Text = charact2;
            NeoManager.Add(btnFirst2);
            nome2 = new Label(NeoManager);
            nome2.Init();
            nome2.Parent = groupo2;
    
            nome2.Top = 680;
            nome2.Left = pnlRes.Top + groupo1.Width + 179;
            nome2.Width = 100;
            nome2.Height = 25;
            nome2.Text = "dsad";
            nome2.BackColor = new Color(1, 1, 60);
            NeoManager.Add(nome2);

            groupo3 = new GroupPanel(NeoManager);
            groupo3.Init();
            groupo3.Parent = group1;

            groupo3.Top = 660;
            groupo3.Left = pnlRes.Top + groupo1.Width + 290;
            groupo3.Width = 100;
            groupo3.Text = "";
            NeoManager.Add(groupo3);
            btnFirst3 = new Button(NeoManager);
            btnFirst3.Init();
            btnFirst3.Parent = groupo3;

            btnFirst3.Top = 660;
            btnFirst3.Left = pnlRes.Top + groupo2.Width + 290;
            btnFirst3.Width = 100;
            btnFirst3.Text = charact3;
            NeoManager.Add(btnFirst3);
            nome3 = new Label(NeoManager);
            nome3.Init();
            nome3.Parent = groupo3;

            nome3.Top = 680;
            nome3.Left = pnlRes.Top + groupo2.Width + 290;
            nome3.Width = 100;
            nome3.Height = 25;
            nome3.Text = "dsad";
            nome3.BackColor = new Color(1, 1, 60);
            NeoManager.Add(nome3);

            groupo4 = new GroupPanel(NeoManager);
            groupo4.Init();
            groupo4.Parent = group1;

            groupo4.Top = 660;
            groupo4.Left = pnlRes.Top + groupo3.Width + 399;
            groupo4.Width = 100;
            groupo4.Text ="";
            NeoManager.Add(groupo4);
            btnFirst4 = new Button(NeoManager);
            btnFirst4.Init();
            btnFirst4.Parent = groupo4;

            btnFirst4.Top = 660;
            btnFirst4.Left = pnlRes.Top + groupo3.Width + 399;
            btnFirst4.Width = 100;
            btnFirst4.Text = charact4;
            NeoManager.Add(btnFirst4);
            nome4 = new Label(NeoManager);
            nome4.Init();
            nome4.Parent = groupo4;

            nome4.Top = 680;
            nome4.Left = pnlRes.Top + groupo3.Width + 399;
            nome4.Width = 100;
            nome4.Height = 25;
            nome4.Text = "dsad";
            nome4.BackColor = new Color(1, 1, 60);
            NeoManager.Add(nome4);

          groupo5 = new GroupPanel(NeoManager);
            groupo5.Init();
            groupo5.Parent = group1;

            groupo5.Top = 660;
            groupo5.Left = pnlRes.Top + groupo4.Width + 510;
            groupo5.Width = 100;
            groupo5.Text ="";
            NeoManager.Add(groupo5);
            btnFirst5 = new Button(NeoManager);
            btnFirst5.Init();
            btnFirst5.Parent = groupo5;

            btnFirst5.Top = 660;
            btnFirst5.Left = pnlRes.Top + groupo4.Width + 510;
            btnFirst5.Width = 100;
            btnFirst5.Text = charact5;
            NeoManager.Add(btnFirst5);
            nome5 = new Label(NeoManager);
            nome5.Init();
            nome5.Parent = groupo5;

            nome5.Top = 680;
            nome5.Left = pnlRes.Top + groupo4.Width + 510;
            nome5.Width = 100;
            nome5.Height = 25;
            nome5.Text = "dsad";
            nome5.BackColor = new Color(1, 1, 60);
            NeoManager.Add(nome5);

            groupo6 = new GroupPanel(NeoManager);
            groupo6.Init();
            groupo6.Parent = group1;

            groupo6.Top = 660;
            groupo6.Left = pnlRes.Top + groupo5.Width + 620;
            groupo6.Width = 100;
            groupo6.Text ="";
            NeoManager.Add(groupo6);
            btnFirst6 = new Button(NeoManager);
            btnFirst6.Init();
            btnFirst6.Parent = groupo6;

            btnFirst6.Top = 660;
            btnFirst6.Left = pnlRes.Top + groupo5.Width + 620;
            btnFirst6.Width = 100;
            btnFirst6.Text = charact6;
            NeoManager.Add(btnFirst6);
            nome6 = new Label(NeoManager);
            nome6.Init();
            nome6.Parent = groupo6;

            nome6.Top = 680;
            nome6.Left = pnlRes.Top + groupo5.Width + 620;
            nome6.Width = 100;
            nome6.Height = 25;
            nome6.Text = "dsad";
            nome6.BackColor = new Color(1, 1, 60);
            NeoManager.Add(nome6);
          /* */
            groupo7 = new GroupPanel(NeoManager);
            groupo7.Init();
            groupo7.Parent = group1;

            groupo7.Top = 660;
            groupo7.Left = pnlRes.Top + groupo5.Width + 730;
            groupo7.Width = 100;
            groupo7.Text ="";
            NeoManager.Add(groupo7);
            btnFirst7 = new Button(NeoManager);
            btnFirst7.Init();
            btnFirst7.Parent = groupo7;

            btnFirst7.Top = 660;
            btnFirst7.Left = pnlRes.Top + groupo6.Width + 730;
            btnFirst7.Width = 100;
            btnFirst7.Text = charact7;
            NeoManager.Add(btnFirst7);
            nome7 = new Label(NeoManager);
            nome7.Init();
            nome7.Parent = groupo7;

            nome7.Top = 680;
            nome7.Left = pnlRes.Top + groupo6.Width + 730;
            nome7.Width = 100;
            nome7.Height = 25;
            nome7.Text = "dsad";
            nome7.BackColor = new Color(1, 1, 60);
            NeoManager.Add(nome7);
        /////////////////////////////////////////////////////////////////////////////////////////////    
            if (btnFirst.Text.Equals("")) {
                btnFirst.Hide();
                nome.Hide();
            }  if (btnFirst1.Text.Equals(""))
            {
                btnFirst1.Hide();
                nome1.Hide();

            }
             if (btnFirst2.Text.Equals(""))
            {
                btnFirst2.Hide();
                nome2.Hide();
            }
             if (btnFirst3.Text.Equals(""))
            {
                btnFirst3.Hide();
                nome3.Hide();
            }
             if (btnFirst4.Text.Equals(""))
            {
                btnFirst4.Hide();
                nome4.Hide();
            }
             if (btnFirst5.Text.Equals(""))
            {
                btnFirst5.Hide();
                nome5.Hide();
            }
             if (btnFirst6.Text.Equals(""))
            {
                btnFirst6.Hide();
                nome6.Hide();
            }
             if (btnFirst7.Text.Equals(""))
            {
                btnFirst7.Hide();
                nome7.Hide();
            }
        }

        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////    
        void btnExit_Click(object sender, Controls.EventArgs e)
        {

            System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Do You Want Exit", "", System.Windows.Forms.MessageBoxButtons.YesNo);
            if (dialogResult == System.Windows.Forms.DialogResult.Yes)
            {
                System.Windows.Forms.Application.Exit();

            }


        }
        void btncreate_Click(object sender, Controls.EventArgs e)
        {

            StateManager.ChangeState(GameRef.createchar);

        }
        void btnStart_Click(object sender, Controls.EventArgs e)
        {

            /*  World ola = new World(Manager, tex);


              ola.Init();
              ola.StayOnTop = true;
              ola.Visible = false;
              ola.Width = 900;
              ola.Height = 800;
              ola.CloseButtonVisible = true;
              ola.Center();
              ola.Movable = false;
              ola.Shadow = false;
              delete.Hide();
              create.Hide();
              start.Hide();
              ServerSection.Hide();
              Quit.Hide();
              ok.Hide();
              group1.Hide();
              btnFirst.Hide();
              ola.Show();
              */

        }
    }


    ////////////////////////////////////////////////////////////////////////////

    ////////////////////////////////////////////////////////////////////////////    



}

Share this post


Link to post
Share on other sites

This topic is 1265 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this