Esempio 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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            ContentContainer.LoadContent(Content);

            objectInspector = new ObjectInspector(this);

            gameEffect = Content.Load <Effect>("Effect\\effect");
            tex        = Content.Load <Texture2D>("character");
            font       = Content.Load <SpriteFont>("File");


            Map = new Map(Content, GraphicsDevice);


            SetUpVertices();
            player = new Player(Vector2.Zero);
            Engine.GameUtility.Physic.Point circle = new Engine.GameUtility.Physic.Point(new Vector2(positionOnPlane.X, positionOnPlane.Z));
            player.CollisionObject              = circle;
            player.CollisionObject.OnCollision += new CollideDetected(delegate(ICollider item)
            {
                if (item.GetType() == typeof(Polygon))
                {
                    MessageBox.Show("Collide", "Circle<>Linse", new string[] { "walsiw" });
                }
            });
            player.CollisionObject.OnCollision += new CollideDetected(EventMethod);
            Director.InstanceDirector.Camera.SetDevice(this.GraphicsDevice);


            model = Content.Load <Model>("robot");



            BiStableKey tempKey = new BiStableKey(Keys.Space);

            tempKey.action += new ClickTrigger(delegate
            {
                IMapElement el = Map.GetMapElementByName <IMapElement>(objectInspector.selectedID);
                if (el != null)
                {
                    Map.GetMapElementByName <IMapElement>(objectInspector.selectedID).Position = new Vector2(positionOnPlane.X, positionOnPlane.Z);
                }
                else
                {
                    IFloor floor = Map.GetMapElementByName <IFloor>(objectInspector.selectedID);
                    floor.FloorPolygon
                    .AddPoint(new VertexPositionColor(positionOnPlane + new Vector3(0, 1, 0), Color.BlueViolet));
                }
            });

            keys.Add(tempKey);


            // MapWriter.Write(jsonSerialize);
        }
Esempio n. 2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            ContentContainer.LoadContent(Content);

            gameEffect = Content.Load <Effect>("Effect\\effect");
            tex        = Content.Load <Texture2D>("character");
            font       = Content.Load <SpriteFont>("File");

            Map = new Map(Content, GraphicsDevice);


            SetUpVertices();
            player = new Player(Vector2.Zero);
            Engine.GameUtility.Physic.Point circle = new Engine.GameUtility.Physic.Point(new Vector2(positionOnPlane.X, positionOnPlane.Z));
            player.CollisionObject              = circle;
            player.CollisionObject.OnCollision += new CollideDetected(delegate(ICollider item)
            {
                if (item.GetType() == typeof(Polygon))
                {
                    MessageBox.Show("Collide", "Circle<>Linse", new string[] { "walsiw" });
                }
            });

            player.CollisionObject.OnCollision += new CollideDetected(EventMethod);
            Director.InstanceDirector.Camera.SetDevice(GraphicsDevice);

            model = Content.Load <Model>("robot");

            StreamReader MapWriter = new StreamReader("pasta\\Map0.json");
            Map          objectMap = JsonConvert.DeserializeObject <Map>(MapWriter.ReadToEnd(),
                                                                         new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.Objects
            });

            MapWriter.Close();
            Map = objectMap;
            Map.InitTestGame(player);


            BiStableKey key = new BiStableKey(Keys.Up);

            key.action += new ClickTrigger(delegate
            {
                foreach (PlayerClass otherPl in OtherPlayerList)
                {
                    otherPl.interstepAdd += 0.01f;
                }
            });
            keys.Add(key);

            BiStableKey key2 = new BiStableKey(Keys.Down);

            key2.action += new ClickTrigger(delegate
            {
                foreach (PlayerClass otherPl in OtherPlayerList)
                {
                    otherPl.interstepAdd -= 0.01f;
                }
            });
            keys.Add(key2);


            BiStableKey key3 = new BiStableKey(Keys.Right);

            key3.action += new ClickTrigger(delegate
            {
                movePacketInterval += 10;
            });
            keys.Add(key3);

            BiStableKey key4 = new BiStableKey(Keys.Left);

            key4.action += new ClickTrigger(delegate
            {
                foreach (PlayerClass otherPl in OtherPlayerList)
                {
                    movePacketInterval -= 10;
                }
            });
            keys.Add(key4);
            // MapWriter.Write(jsonSerialize);
        }