Ejemplo n.º 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            //Set up the reference grid and sample camera
            grid = new SampleGrid();
            grid.GridColor = Color.LimeGreen;
            grid.GridScale = 10.0f;
            grid.GridSize = 32;
            grid.LoadGraphicsContent(graphics.GraphicsDevice);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            font = Content.Load<SpriteFont>("Fonts/Courier New");

            mDottedLine = Content.Load<Texture2D>("DottedLine");

            foreach (Dictionary<string,string> item in assets)
            {
                GameObject t = new GameObject();
                t.model = Content.Load<SkinnedModel>(item["assets_model"]);

                t.id = int.Parse(item["assets_id"]);

                t.position.X = float.Parse(item["assets_position_x"]);
                t.position.Y = float.Parse(item["assets_position_y"]);
                t.position.Z = float.Parse(item["assets_position_z"]);

                t.assignPosition.X = float.Parse(item["assets_position_x"]);
                t.assignPosition.Y = float.Parse(item["assets_position_y"]);
                t.assignPosition.Z = float.Parse(item["assets_position_z"]);

                t.scale = float.Parse(item["assets_scale"]);
                t.rotation = float.Parse(item["assets_rotation"]);

                t.assignRotation = float.Parse(item["assets_rotation"]);

                t.radius = float.Parse(item["assets_radius"]);

                t.health = float.Parse(item["assets_health"]);
                t.hitspeed = float.Parse(item["assets_hitspeed"]);

                t.init();
                model.Add(t);
            }
            /*
            foreach (string item in models)
            {
                GameObject t = new GameObject();
                t.model = Content.Load<SkinnedModel>(item);

                t.init();
                model.Add(t);
            }*/
            Vector3 randPos = getFreePos(assets);
            //System.Diagnostics.Trace.WriteLine(randPos);
            tmodel.model = Content.Load<SkinnedModel>("Models/biped");
            tmodel.position = new Vector3(0f, 0f, -150f);
            tmodel.scale = 2f;

            tmodel.position = tmodel.assignPosition = tmodel.prevPosition = randPos;
            if (arguments.Length > 0)
            {

                tmodel.model = model[int.Parse(arguments[0])].model;
                tmodel.position = model[int.Parse(arguments[0])].position;
                tmodel.prevPosition = model[int.Parse(arguments[0])].position;
                tmodel.assignPosition = model[int.Parse(arguments[0])].position;
                tmodel.scale = model[int.Parse(arguments[0])].scale;
                tmodel.rotation = model[int.Parse(arguments[0])].rotation;
                tmodel.assignRotation = model[int.Parse(arguments[0])].rotation;
                tmodel.id = model[int.Parse(arguments[0])].id;
                model.RemoveAt(int.Parse(arguments[0]));
            } else {

            lastId = connect.insertquery("INSERT INTO `runecrafter_assets` (`assets_model` ,`assets_position_x` ,`assets_position_y` ,`assets_position_z` ,`assets_scale` ,`assets_radius` ,`assets_health` ,`assets_hitspeed`) " +
                                "VALUES (" +
                                "'Models/biped', '" + randPos.X + "', '" + randPos.Y + "', '" + randPos.Z + "', '2', '10', '5', '2'" +
                                ");");
            tmodel.id = Convert.ToInt32( lastId);
             }
            tmodel.init();

            //model[0].position = new Vector3(50f, 0f, 50f);

            //grid requires a projection matrix to draw correctly
            grid.ProjectionMatrix = camera.cameraProjection;

            //Set the grid to draw on the x/z plane around the origin
            grid.WorldMatrix = Matrix.Identity;
        }