Exemplo n.º 1
0
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            radio.SendMessage("SYSTEM", "BEGIN LOAD CONTENT " + DateTime.Now);

            base.LoadContent(GraphicInfo, factory, contentManager);

            reciever.MessageHandler += new Action <PloobsEngine.MessageSystem.Message>(reciever_MessageHandler);

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                ///Physic info (position, rotation and scale are set here)
                BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                tmesh.isMotionLess = true;
                ///Forward Shader (look at this shader construction for more info)
                ForwardXNABasicShader shader = new ForwardXNABasicShader();
                ///Deferred material
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                ///The object itself
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                ///Add to the world
                this.World.AddObject(obj);
            }

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            radio.SendMessage("SYSTEM", "END LOAD CONTENT " + DateTime.Now);
        }
    private void createobjs(int minus = 0)
    {
        int numColumns = 7 - minus;
        int numRows    = 7 - minus;
        int numHigh    = 7 - minus;

        float separation = 3;

        for (int i = 0; i < numRows; i++)
        {
            for (int j = 0; j < numColumns; j++)
            {
                for (int k = 0; k < numHigh; k++)
                {
                    SimpleModel sm = new SimpleModel(GraphicFactory, "..\\Content\\Model\\cubo");
                    sm.SetTexture(GraphicFactory.CreateTexture2DColor(1, 1, StaticRandom.RandomColor()), TextureType.DIFFUSE);
                    MaterialDescription md = MaterialDescription.DefaultBepuMaterial();
                    md.Bounciness = 1;
                    BoxObject pi = new BoxObject(new Vector3(separation * i, k * separation, separation * j), 1, 1, 1, 1, new Vector3(1), Matrix.Identity, md);
                    pi.Entity.AngularDamping = 0f;
                    ForwardXNABasicShader shader = new ForwardXNABasicShader();
                    IMaterial             mat    = new ForwardMaterial(shader);
                    IObject obj5 = new IObject(mat, sm, pi);
                    this.World.AddObject(obj5);
                    shader.BasicEffect.EnableDefaultLighting();
                }
            }
        }
    }
Exemplo n.º 3
0
        private void CreateScene0()
        {
            var holder = new BoxObject(this, boxModel, new Vector3(5, 1, 1), Matrix.Identity, new Vector3(-10, -5, 5));

            holder.PhysicsBody.Immovable = true;
            Components.Add(holder);

            for (var i = 0; i < 5; i++)
            {
                var obj = new SphereObject(this, sphereModel, 0.5f, Matrix.Identity, new Vector3(-12 + i, -8, 5));
                obj.PhysicsBody.CollisionSkin.SetMaterialProperties(0, new MaterialProperties(1.0f, 0.2f, 0.2f));
                obj.PhysicsBody.AllowFreezing = false;

                var maxDist1 = new ConstraintMaxDistance(holder.PhysicsBody, new Vector3(-2 + i, -0.5f, 0.5f), obj.PhysicsBody, Vector3.Up * 0.5f, 3f);
                var maxDist2 = new ConstraintMaxDistance(holder.PhysicsBody, new Vector3(-2 + i, -0.5f, -0.5f), obj.PhysicsBody, Vector3.Up * 0.5f, 3f);
                maxDist1.EnableConstraint();
                maxDist2.EnableConstraint();

                Components.Add(obj);

                if (i == 4)
                {
                    obj.PhysicsBody.MoveTo(new Vector3(-6, -6, 5), Matrix.Identity);
                }
                if (i == 3)
                {
                    obj.PhysicsBody.MoveTo(new Vector3(-7, -6, 5), Matrix.Identity);
                }
            }
        }
Exemplo n.º 4
0
    // 取可以放置方块的空位置
    public List <Vector2> GetTwoNullPosition()
    {
        List <Vector2> list = new List <Vector2>();

        if (m_BoxList.Count == 0)
        {
            return(list);
        }
        IOrderedEnumerable <BoxObject> order = m_BoxList.OrderBy(p => p.y);
        BoxObject small = order.FirstOrDefault();
        BoxObject big   = order.LastOrDefault();

        Debug.Log("small big " + small.y + "," + big.y);
        for (int y = small.y; y <= big.y + 1; y++)
        {
            for (int x = 1; x < levelWidth - 1; x++)
            {
                if (this[x, y] == null && !IsNullNeightBoxs(x, y))
                {
                    list.Add(new Vector2(x, y));
                }
            }
        }
        return(list);
    }
Exemplo n.º 5
0
        private void CreateScene3()
        {
            var chainBoxes = new List <BoxObject>();

            for (var i = 0; i < 25; i++)
            {
                var boxObject = new BoxObject(this, boxModel, Vector3.One, Matrix.Identity, new Vector3(i, 25 - i, 0));
                if (i == 0)
                {
                    boxObject.PhysicsBody.Immovable = true;
                }
                chainBoxes.Add(boxObject);
            }

            for (var i = 1; i < 25; i++)
            {
                var hingeJoint = new HingeJoint();
                hingeJoint.Initialise(chainBoxes[i - 1].PhysicsBody, chainBoxes[i].PhysicsBody, Vector3.Backward, new Vector3(0.5f, -0.5f, 0.0f), 0.5f, 90.0f, 90.0f, 0.0f, 0.2f);
                hingeJoint.EnableController();
                hingeJoint.EnableHinge();
            }

            foreach (var obj in chainBoxes)
            {
                Components.Add(obj);
            }
        }
Exemplo n.º 6
0
        public NovelInput(string upperText)
        {
            var text = new Text("", Cache.GetFont("fonts/arial"))
            {
                FillColor     = Color.Black,
                CharacterSize = 25
            };

            BoxObject   = new BoxObject(text);
            InputObject = new InputObject(text, new Vector2f(), new Style());
            InputObject.EnterHandler = () =>
            {
                var scene = Abstracts.Scene.Find(Scene);

                if (scene != null)
                {
                    scene.Args = InputObject.Text.DisplayedString;
                    Game.Scene = scene;
                }
                else
                {
                    Game.Scene = Abstracts.Scene.Find(Game.DefaultScene);
                }
            };


            Text = upperText;

            BoxObject.UpperText = Text;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer);

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc);
            dlines = new DebugLines();
            ddrawer.AddShape(dlines);

            Picking pick = new Picking(this, 2000);

            pick.OnPickedLeftButton += new OnPicked(pick_OnPickedLeftButton);

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                ///Physic info (position, rotation and scale are set here)
                BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                tmesh.isMotionLess = true;
                ///Forward Shader (look at this shader construction for more info)
                ForwardXNABasicShader shader = new ForwardXNABasicShader();
                ///Deferred material
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                ///The object itself
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                ///Add to the world
                this.World.AddObject(obj);
            }

            wh = new WaypointHandler();
            wh.LoadConnectedWaypoints("waypoints.xml");
            start = wh.CurrentWaypointsCollection.GetWaypointsList()[0];

            {
                ///Procedural yellow diffuse texture
                SimpleModel sm = new SimpleModel(factory, "Model\\block");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE);
                ///physic Ghost object(no collision)
                GhostObject           pi  = new GhostObject(start.WorldPos, Matrix.Identity, new Vector3(5));
                ForwardXNABasicShader s   = new ForwardXNABasicShader();
                ForwardMaterial       mat = new ForwardMaterial(s);
                IObject obj4 = new IObject(mat, sm, pi);
                this.World.AddObject(obj4);
            }

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            {
                SimpleModel sm = new SimpleModel(factory, "Model\\block");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
                GhostObject           pi  = new GhostObject(start.WorldPos, Matrix.Identity, new Vector3(5));
                ForwardXNABasicShader s   = new ForwardXNABasicShader();
                ForwardMaterial       mat = new ForwardMaterial(s);
                IObject obj4 = new IObject(mat, sm, pi);
                obj4.OnUpdate += new OnUpdate(obj4_OnUpdate);
                this.World.AddObject(obj4);
            }
        }
Exemplo n.º 8
0
    public ItemObject GetBoxContents_BoxStars(int index)
    {
        BoxStars1 = PlayerController.Instance.starBoxes[PlayerController.player.numStarBoxesOpened];
        Dictionary <float, ItemObject> dic = new Dictionary <float, ItemObject>();

        double prob = 0;
        int    sumWeightsOfItems = BoxStars1.itemWights.Take(BoxAd.itemWights.Length).Sum();

        for (int i = 0; i < BoxStars1.items.Length; i++)
        {
            prob += (float)BoxStars1.itemWights[i] / (float)sumWeightsOfItems;
            dic.Add((float)prob, BoxStars1.items[i]);
        }

        float rand = Random.Range(0.0f, 1.0f);

        List <float> dicKeys = new List <float>(dic.Keys);

        if (rand < dicKeys[0])
        {
            return(dic[dicKeys[0]]);
        }
        for (int y = 1; y < dic.Count - 1; y++)
        {
            if (rand >= dicKeys[y - 1] && rand < dicKeys[y])
            {
                return(dic[dicKeys[y]]);
            }
        }

        var item = dic[dicKeys[dic.Count - 1]];

        return(item);
    }
    private void createobjs( int minus = 0)
    {

        int numColumns = 7 - minus;
        int numRows = 7 - minus;
        int numHigh = 7 - minus;

        float separation = 3;
        for (int i = 0; i < numRows; i++)
            for (int j = 0; j < numColumns; j++)
                for (int k = 0; k < numHigh; k++)
                {
                    SimpleModel sm = new SimpleModel(GraphicFactory, "..\\Content\\Model\\cubo");
                    sm.SetTexture(GraphicFactory.CreateTexture2DColor(1, 1, StaticRandom.RandomColor()), TextureType.DIFFUSE);
                    MaterialDescription md = MaterialDescription.DefaultBepuMaterial();
                    md.Bounciness = 1;
                    BoxObject pi = new BoxObject(new Vector3(separation * i, k * separation, separation * j), 1, 1, 1, 1, new Vector3(1), Matrix.Identity, md);
                    pi.Entity.AngularDamping = 0f;
                    ForwardXNABasicShader shader = new ForwardXNABasicShader();
                    IMaterial mat = new ForwardMaterial(shader);
                    IObject obj5 = new IObject(mat, sm, pi);
                    this.World.AddObject(obj5);
                    shader.BasicEffect.EnableDefaultLighting();
                 
                }
    }
Exemplo n.º 10
0
        private void print_op()
        {
            int index = comboBox1.SelectedIndex + 1;

            print_rec      print    = new print_rec();
            CrystalReport2 cr       = new CrystalReport2();
            TextObject     visit_id = (TextObject)cr.ReportDefinition.Sections["Section1"].ReportObjects["Text1"];

            BoxObject box = (BoxObject)cr.ReportDefinition.Sections["Section1"].ReportObjects["Box1"];


            if (index == 1)
            {
                box.FillColor = Color.WhiteSmoke;
            }
            else if (index == 2)
            {
                box.FillColor = Color.Blue;
            }
            else if (index == 3)
            {
                box.FillColor = Color.Green;
            }
            else if (index == 4)
            {
                box.FillColor = Color.Yellow;
            }
            else if (index == 5)
            {
                box.FillColor = Color.Orange;
            }
            else if (index == 6)
            {
                box.FillColor = Color.Red;
            }

            string query = "SELECT MAX(id) FROM visits";

            try
            {
                MySqlConnection conn = connection_config.GetDBConnection();
                conn.Open();
                MySqlCommand    command = new MySqlCommand(query, conn);
                MySqlDataReader reader  = command.ExecuteReader();

                while (reader.Read())
                {
                    visit_id.Text = (reader.GetString(0));
                }
                conn.Close();
                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            print.crystalReportViewer1.ReportSource = cr;
            print.Show();
        }
Exemplo n.º 11
0
        private PhysicObject SpawnPrimitive(Vector3 pos, Matrix ori)
        {
            int          prim = random.Next(3);
            PhysicObject physicObj;

            float a = 1.0f + (float)random.NextDouble() * 1.0f;
            float b = a + (float)random.NextDouble() * 0.5f;
            float c = 2.0f / a / b;

            switch (prim)
            {
            case 0:
                physicObj = new BoxObject(this, boxModel, new Vector3(a, b, c), ori, pos);
                break;

            case 1:
                physicObj = new SphereObject(this, sphereModel, 0.5f, ori, pos);
                break;

            case 2:
                physicObj = new CapsuleObject(this, capsuleModel, 0.5f, 1f, ori, pos);
                break;

            default:
                physicObj = new SphereObject(this, sphereModel, (float)random.Next(5, 15), ori, pos);
                break;
            }
            return(physicObj);
        }
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            #region Models

            {
                ///Need to load the height, the normal texture and the difuse texture
                SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block", "..\\Content\\Textures\\color_map");
                sm.SetTexture("Textures\\normal_map", TextureType.BUMP);
                sm.SetCubeTexture(factory.GetTextureCube("Textures//cubemap"), TextureType.ENVIRONMENT);

                BoxObject pi = new BoxObject(new Vector3(200, 110, 0), 1, 1, 1, 5, new Vector3(100, 100, 100), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                DeferredEnvironmentCustomShader DeferredEnvironmentCustomShader = new DeferredEnvironmentCustomShader(false, true, false);
                DeferredEnvironmentCustomShader.SpecularIntensity = 0.2f;
                DeferredEnvironmentCustomShader.SpecularPower     = 30;
                DeferredEnvironmentCustomShader.ShaderId          = ShaderUtils.CreateSpecificBitField(true);
                IMaterial mat  = new DeferredMaterial(DeferredEnvironmentCustomShader);
                IObject   obj3 = new IObject(mat, sm, pi);
                this.World.AddObject(obj3);
            }

            {
                SimpleModel          simpleModel = new SimpleModel(factory, "Model//cenario");
                TriangleMeshObject   tmesh       = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                DeferredCustomShader shader      = new DeferredCustomShader(false, false, false, false);
                DeferredMaterial     fmaterial   = new DeferredMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            #endregion

            #region NormalLight
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.5f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion

            CameraFirstPerson cam = new CameraFirstPerson(MathHelper.ToRadians(10), MathHelper.ToRadians(-10), new Vector3(200, 150, 250), GraphicInfo);
            this.World.CameraManager.AddCamera(cam);

            new LightThrowBepu(this.World, GraphicFactory);

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
        }
Exemplo n.º 13
0
    void FindClosestObject()
    {
        //Öncelikle çevremizde olan tüm Colliderları, belirli radius(yarıçap), içerisinde bir diziye çekiyoruz.
        Collider[] colliders = Physics.OverlapSphere(transform.position, 20f);

        //İlk başta targetimiz olmadığı için collider içerisinden ilk olanı seçiyoruz ve atıyoruz.
        if (target == null)
        {
            target = colliders[0].GetComponent <BoxObject>();
        }

        //Collider dizimizden bir döngü başlatıyoruz.
        for (int i = 1; i < colliders.Length; i++)
        {
            //Aktif olan Box'u alıyoruz
            BoxObject currentBox = colliders[i].GetComponent <BoxObject>();

            //Eğer bulduğumuz collider BoxObject ve Contesterlarımız farklı ise buraya giriyor.
            if (currentBox != null && contesterTypeHolder != currentBox.ContesterTypeHolder)
            {
                //Eğer şuan ki aktif BoxObject'imizin mesafesi daha az ise buraya giriyor.
                if (Vector3.Distance(transform.position, currentBox.transform.position) <= Vector3.Distance(transform.position, target.transform.position))
                {
                    target = currentBox;
                }
                else if (Vector3.Distance(transform.position, target.transform.position) <= 2f)
                {
                    target = currentBox;
                }
                //Target'e ulaşmışsak ve aynı döngü içinde kalmak istemiyorsak. Pozisyonumuz ve target için bir sınır koyuyoruz.
            }
        }
        //navMeshAgent'ın Varış Noktasını(Destination) ayarlıyoruz.
        navMeshAgent.destination = target.transform.position;
    }
Exemplo n.º 14
0
 private void CreateScene4(int dim)
 {
     for (var x = 0; x < dim; x++)
     {
         var obj = new BoxObject(this, boxModel, Vector3.One, Matrix.Identity, new Vector3(0, x * 1.01f - 14.0f, 25));
         Components.Add(obj);
     }
 }
Exemplo n.º 15
0
    private void onBoxSizeChange(List <DataChange> changes)
    {
        BoxObject bb = (BoxObject)state;

        this.transform.localScale = new Vector3(bb.halfSize.x, bb.halfSize.y, bb.halfSize.z);

        updateTime();
    }
Exemplo n.º 16
0
        protected IObject DefaultBoxObj(String modelName, Vector3 position, Vector3?scale = null, float mass = 10, Matrix?orientation = null)
        {
            SimpleModel     simpleModel = new SimpleModel(GraphicFactory, modelName);
            BoxObject       tmesh       = new BoxObject(position, 1, 1, 1, mass, scale, orientation);
            ForwardMaterial fmaterial   = ForwardMaterial.DefaultForwardMaterial();

            return(new IObject(fmaterial, simpleModel, tmesh));
        }
Exemplo n.º 17
0
        public override void Initialize()
        {
            //Erstellt ein Objekt in der Scene.
            BoxObject box0 = new BoxObject(new Vector3(0, -1.5f, -5),             //Position
                               new Vector3(46, 0.2f, 1),                          //Kantenlängen
                               0f);

            Scene.Add(box0);
        }
Exemplo n.º 18
0
 public void RandomGenCubes()
 {
     for (int i = 0; i < count; i++)
     {
         Vector3   pos        = Random.insideUnitSphere * 5000f;
         Vector3   randomSize = (2 * Random.insideUnitSphere - Vector3.one) * 100f;
         BoxObject obj        = GameObject.Instantiate(prefab, pos, Quaternion.identity);
         obj.transform.localScale = randomSize;
     }
 }
Exemplo n.º 19
0
    void AddBox(ComBox box, int x, int y)
    {
        BoxObject bo = new BoxObject(x, y, box.index);

        if (box != null)
        {
            bo.gameObject = box.gameObject;
        }
        m_BoxList.Add(bo);
    }
Exemplo n.º 20
0
        public NovelText()
        {
            var text = new Text("", Cache.GetFont("fonts/arial"))
            {
                FillColor = Color.Black,
                CharacterSize = 25
            };

            BoxObject = new BoxObject(text);
            TextObject = new AnimatedTextObject(text, new Vector2f());
        }
Exemplo n.º 21
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel          simpleModel = new SimpleModel(factory, "Model//cenario");
                TriangleMeshObject   tmesh       = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader      = new DeferredNormalShader();
                DeferredMaterial     fmaterial   = new DeferredMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            {
                SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                BoxObject            pi     = new BoxObject(new Vector3(100, 40, 0), 1, 1, 1, 25, new Vector3(100, 10, 100), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader = new DeferredNormalShader();
                IMaterial            mat    = new DeferredMaterial(shader);
                IObject obj3 = new IObject(mat, sm, pi);
                this.World.AddObject(obj3);
            }



            #region NormalLight
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.5f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion


            CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo);
            cam.MoveSpeed *= 5;
            this.World.CameraManager.AddCamera(cam);

            //this.RenderTechnic.AddPostEffect(new PloobsEngine.SceneControl.SimpleMotionBlurPostEffect());
            this.RenderTechnic.AddPostEffect(new MotionBlurCompletePostEffect());

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grasscube");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
        }
Exemplo n.º 22
0
        private void CreateScene6()
        {
            for (var i = 0; i < 10; i += 2)
            {
                var boxObj0 = new BoxObject(this, boxModel, new Vector3(1, 1f, 3), Matrix.Identity, new Vector3(0, i * 1f - 14, 1));
                var boxObj1 = new BoxObject(this, boxModel, new Vector3(1, 1f, 3), Matrix.Identity, new Vector3(1, i * 1f - 14, 1));
                var boxObj2 = new BoxObject(this, boxModel, new Vector3(1, 1f, 3), Matrix.Identity, new Vector3(2, i * 1f - 14, 1));
                Components.Add(boxObj0);
                Components.Add(boxObj1);
                Components.Add(boxObj2);

                var boxObj3 = new BoxObject(this, boxModel, new Vector3(3, 1f, 1), Matrix.Identity, new Vector3(1, i * 1f + 1f - 14, 0));
                var boxObj4 = new BoxObject(this, boxModel, new Vector3(3, 1f, 1), Matrix.Identity, new Vector3(1, i * 1f + 1f - 14, 1));
                var boxObj5 = new BoxObject(this, boxModel, new Vector3(3, 1f, 1), Matrix.Identity, new Vector3(1, i * 1f + 1f - 14, 2));
                Components.Add(boxObj3);
                Components.Add(boxObj4);
                Components.Add(boxObj5);
            }

            for (var i = 0; i < 10; i++)
            {
                var cyl = new CylinderObject(this, 0.5f, 1.0f, new Vector3(5, i * 1.01f - 14.2f, 0), cylinderModel);
                Components.Add(cyl);
            }

            RagdollObject rgd;


            for (var e = 0; e < 2; e++)
            {
                for (var i = 0; i < 2; i++)
                {
                    rgd          = new RagdollObject(this, capsuleModel, sphereModel, boxModel, RagdollObject.RagdollType.Simple, 1.0f);
                    rgd.Position = new Vector3(e * 2, -14, 10 + i * 2);
                    rgd.PutToSleep();
                }
            }


            for (var x = 0; x < 8; x++)
            {
                for (var y = 0; y < 3; y++)
                {
                    if (y % 2 == 0)
                    {
                        Components.Add(new BoxObject(this, boxModel, new Vector3(1, 1, 1), Matrix.Identity, new Vector3(x * 1.01f - 10.0f, y * 1.01f - 14.5f, 0)));
                    }
                    else
                    {
                        Components.Add(new BoxObject(this, boxModel, new Vector3(1, 1, 1), Matrix.Identity, new Vector3(x * 1.01f - 10.5f, y * 1.01f - 14.5f, 0)));
                    }
                }
            }
        }
Exemplo n.º 23
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel          simpleModel = new SimpleModel(factory, "Model//cenario");
                TriangleMeshObject   tmesh       = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader      = new DeferredNormalShader();
                DeferredMaterial     fmaterial   = new DeferredMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            {
                SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                BoxObject            pi     = new BoxObject(new Vector3(100, 40, 0), 1, 1, 1, 25, new Vector3(100, 10, 100), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader = new DeferredNormalShader();
                IMaterial            mat    = new DeferredMaterial(shader);
                IObject obj3 = new IObject(mat, sm, pi);
                this.World.AddObject(obj3);
            }

            #region NormalLight
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.5f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion

            //SBlurPost hsv = new SBlurPost(1, SurfaceFormat.HdrBlendable);
            //hsv.ImageSamplerState = SamplerState.PointClamp;
            //this.RenderTechnic.AddPostEffect(hsv);

            DownSamplePostEffect DownSamplePostEffect = new Post.DownSamplePostEffect();
            this.RenderTechnic.AddPostEffect(DownSamplePostEffect);

            CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo);
            cam.MoveSpeed *= 5;
            this.World.CameraManager.AddCamera(cam);

            LightThrowBepu lt = new LightThrowBepu(this.World, factory);
        }
Exemplo n.º 24
0
        protected IObject CreateBoxMeshModelU(String fileName, Vector3 position, Matrix orientation, float xlengh, float ylengh, float zlengh, Vector3 scale, float mass = 10)
        {
            SimpleModel simpleModel = new SimpleModel(graphicFactory, fileName);
            ///Physic info (position, rotation and scale are set here)
            BoxObject tmesh = new BoxObject(position, xlengh, ylengh, zlengh, mass, scale, orientation, MaterialDescription.DefaultBepuMaterial());
            ///Shader info (must be a deferred type)
            DeferredNormalShader shader = new DeferredNormalShader();
            ///Material info (must be a deferred type also)
            DeferredMaterial fmaterial = new DeferredMaterial(shader);

            ///The object itself
            return(new IObject(fmaterial, simpleModel, tmesh));
        }
Exemplo n.º 25
0
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            RasterizerState          = new RasterizerState();
            RasterizerState.FillMode = FillMode.WireFrame;

            ///Forward Shader (look at this shader construction for more info)
            TerrainMaterial material = new TerrainMaterial(factory, "Terrain//HeightMap");
            ///The object itself
            TerrainObject to  = new TerrainObject(factory, Vector3.Zero, Matrix.Identity, material.Model.GetHeights(), MaterialDescription.DefaultBepuMaterial());
            IObject       obj = new IObject(material, null, to);

            ///Add to the world
            this.World.AddObject(obj);

            ///add a camera
            RotatingCamera cam = new RotatingCamera(this, new Vector3(-200, -100, -300));

            this.World.CameraManager.AddCamera(cam);

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubeMap");

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);


            {
                Texture2D   t           = factory.CreateTexture2DColor(1, 1, Color.Red);
                SimpleModel simpleModel = new SimpleModel(factory, "Model/block");
                simpleModel.SetTexture(t);
                ///Forward Shader (look at this shader construction for more info)
                ForwardXNABasicShader shader = new ForwardXNABasicShader();
                ///Forward material
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                for (int i = 0; i < 10; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        ///Physic info (position, rotation and scale are set here)
                        BoxObject tmesh = new BoxObject(new Vector3(j * 10 + 200, 100, i * 10 + 200), 1, 1, 1, 10, Vector3.One * 2, Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                        ///The object itself
                        obj = new IObject(fmaterial, simpleModel, tmesh);
                        ///Add to the world
                        this.World.AddObject(obj);
                        objs.Add(obj);
                        tmesh.isMotionLess = true;
                    }
                }
                shader.BasicEffect.EnableDefaultLighting();
            }
        }
        public BoxObject RightHand()
        {
            RenderMaterial gruen = new RenderMaterial();
            gruen.Diffuse = Color.Green.ToVector4();


            BoxObject rightHand = new BoxObject(new Vector3(0, 0, 0), new Vector3(0.1f, 0.1f, 0f), 0f);
            rightHand.RenderMaterial = gruen;
            rightHand.RenderMaterial.Transparency = 0.3f;
            
            scene.Add(rightHand);
            
            return rightHand;
        }
Exemplo n.º 27
0
        private void LoadBackground(string bildname)
        {
            RenderMaterial hintergrundsbild = new RenderMaterial();
            hintergrund = new BoxObject(pos,
                                        new Vector3(110, 35, 0),
                                        0f);

            hintergrundsbild.Texture = Core.Content.Load<Texture2D>(bildname);
            hintergrundsbild.Diffuse = Color.White.ToVector4();
            hintergrundsbild.EnableGlow = false;
            hintergrund.RenderMaterial = hintergrundsbild;

            scene.Add(hintergrund);
        }
        public BoxObject LeftHand()
        {

            RenderMaterial rot = new RenderMaterial();
            rot.Diffuse = Color.Red.ToVector4();

            BoxObject leftHand = new BoxObject(new Vector3(0, 0, 0), new Vector3(0.1f, 0.1f, 0f), 0f);
            leftHand.RenderMaterial = rot;
            leftHand.RenderMaterial.Transparency = 0.3f;

            scene.Add(leftHand);

            return leftHand;
        }
Exemplo n.º 29
0
    //取有方块的最下面一行
    public ComBox GetBottomBox()
    {
        if (m_BoxList.Count == 0)
        {
            return(null);
        }
        BoxObject tmp = m_BoxList.OrderByDescending(p => p.y).FirstOrDefault();

        if (tmp != null)
        {
            return(tmp.gameObject.GetComponent <ComBox> ());
        }
        return(null);
    }
Exemplo n.º 30
0
        private void CreateScene7()
        {
            Matrix rotM = Matrix.CreateRotationY(0.5f);

            for (int i = 0; i < 15; i += 2)
            {
                BoxObject boxObj0 = new BoxObject(this, boxModel, new Vector3(1, 1, 4), rotM, new Vector3(0, i - 10, 25));
                BoxObject boxObj2 = new BoxObject(this, boxModel, new Vector3(1, 1, 4), rotM, new Vector3(2, i - 10, 25));
                this.Components.Add(boxObj0); this.Components.Add(boxObj2);

                BoxObject boxObj3 = new BoxObject(this, boxModel, new Vector3(4, 1, 1), rotM, new Vector3(1, i + 1 - 10, 24));
                BoxObject boxObj5 = new BoxObject(this, boxModel, new Vector3(4, 1, 1), rotM, new Vector3(1, i + 1 - 10, 26));
                this.Components.Add(boxObj3); this.Components.Add(boxObj5);
            }
        }
        public BoxObject showObjects(string bild)
        {
            
            Vector3 vector = new Vector3(0, 2.0f, -6);

            RenderMaterial bildobjekte = new RenderMaterial();
            BoxObject blende = new BoxObject(vector, new Vector3(4, 0.8f, 0), 0f);
            bildobjekte.Texture = Core.Content.Load<Texture2D>(bild);
            bildobjekte.Diffuse = Color.White.ToVector4();
            blende.RenderMaterial = bildobjekte;

            scene.Add(blende);
            return blende;
            
        }
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer);

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc);
            dlines = new DebugLines();
            ddrawer.AddShape(dlines);

            Picking pick = new Picking(this, 2000);

            pick.OnPickedLeftButton += new OnPicked(pick_OnPickedLeftButton);

            wh = new WaypointHandler();

            SimpleModel simpleModel = new SimpleModel(factory, "Model//block");

            simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
            ///Physic info (position, rotation and scale are set here)
            BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());

            tmesh.isMotionLess = true;
            ///Forward Shader (look at this shader construction for more info)
            ForwardXNABasicShader shader = new ForwardXNABasicShader();
            ///Deferred material
            ForwardMaterial fmaterial = new ForwardMaterial(shader);
            ///The object itself
            IObject obj = new IObject(fmaterial, simpleModel, tmesh);

            ///Add to the world
            this.World.AddObject(obj);

            {
                InputPlayableKeyBoard ipk = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Microsoft.Xna.Framework.Input.Keys.Space);
                ipk.KeyStateChange += new KeyStateChange(ipk_KeyStateChange);
                this.BindInput(ipk);
            }

            {
                InputPlayableKeyBoard ipk = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Microsoft.Xna.Framework.Input.Keys.Enter);
                ipk.KeyStateChange += new KeyStateChange(ipk_KeyStateChange2);
                this.BindInput(ipk);
            }

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Exemplo n.º 33
0
    GameObject createObject(ObjectState ob)
    {
        GameObject    gameOb;
        bool          isBox         = ob.GetType().Equals(typeof(BoxObject));
        PrimitiveType primitiveType = isBox ? PrimitiveType.Cube : PrimitiveType.Sphere;

        if (ob.mesh != null)
        {
            UnityEngine.Object prefab = Resources.Load(ob.mesh); // Assets/Resources/Prefabs/prefab1.FBX
            if (prefab == null)
            {
                gameOb = GameObject.CreatePrimitive(primitiveType);
                Debug.Log("Couldnt find " + ob.mesh);
            }
            else
            {
                gameOb = (GameObject)Instantiate(prefab);
            }
        }
        else
        {
            gameOb = GameObject.CreatePrimitive(primitiveType);
        }
        gameOb.name = "Object (" + ob.uID + ")" + ob.GetType().ToString();
        Vector3 size;

        if (isBox)
        {
            BoxObject boxState = (BoxObject)ob;

            size = new Vector3(boxState.halfSize.x, boxState.halfSize.y, boxState.halfSize.z);
        }
        else
        {
            SphereObject boxState = (SphereObject)ob;
            size = new Vector3(boxState.radius * 2, boxState.radius * 2, boxState.radius * 2);
        }

        //size.Scale(new Vector3(2, 2, 2));
        if (ob.type == "QuixBox")
        {
            Debug.Log("Este 2" + size);
        }
        gameOb.transform.localScale = size;
        gameOb.transform.parent     = ServerObjects.transform;
        return(gameOb);
    }
Exemplo n.º 34
0
 static void Main(string[] args)
 {
     Console.OutputEncoding = Encoding.Unicode;
     ConsoleManager cm = new ConsoleManager();
     //Canvas canvas = new Canvas(ConsoleColor.Gray);
     GridContainer container = new GridContainer();
     var SmallBox1 = new BoxObject(4, 4);
     var SmallBox2 = new BoxObject(4, 4);
     var SmallBox3 = new BoxObject(4, 4);
     var SmallBox4 = new BoxObject(15, 15);
     var BigBox1 = new BoxObject(40, 40) { BoxChars = BoxObject.Presets.BoxChars.DoubleLine };
     var BigBox2 = new BoxObject(40, 40) { BoxChars = BoxObject.Presets.BoxChars.DoubleHorizontalSingleVertical };
     var BigBox3 = new BoxObject(40, 40) { BoxChars = BoxObject.Presets.BoxChars.SingleHorizontalDoubleVertical };
     cm.AddObject(container);
     container.AddChild(SmallBox1);
     container.AddChild(SmallBox2);
     container.AddChild(SmallBox3);
     Console.ReadLine();
     for (int i = 0; i < 20; i++ )
         SmallBox2.UpdateSize = new Point(i, i);
     for (int i = 20; i >= 4; i--)
         SmallBox2.UpdateSize = new Point(i, i);
     Console.ReadLine();
     SmallBox2.UpdateSize = new Point(50, 50);
     GridContainer container2 = new GridContainer();
     Console.ReadLine();
     SmallBox2.AddChild(container2);
     Console.ReadLine();
     container2.AddChild(new TextObject("This is an embedded element."));
     Console.ReadLine();
     container2.AddChild(SmallBox1);
     Console.ReadLine();
     container2.AddChild(BigBox1);
     Console.ReadLine();
     container2.AddChild(BigBox2);
     Console.ReadLine();
     container2.AddChild(BigBox3);
     Console.ReadLine();
     BigBox1.AddChild(SmallBox4);
     Console.ReadLine();
     SmallBox4.AddChild(new TextObject("Hello World"));
     Console.ReadLine();
     container.RemoveChild(BigBox1);
     Console.ReadLine();
 }
Exemplo n.º 35
0
    void Instance(GameObject obj, BoxObject box, EnemyParam.Level level = EnemyParam.Level.Mob)
    {
        var instance = MonoBehaviour.Instantiate(obj);

        instance.transform.position = box.Obj.transform.position;
        var enemy = new Enemy();

        box.Enemy = enemy;
        box.Enemy.EnemyParam.Obj      = instance;
        box.Enemy.EnemyParam.Renderer = instance.GetComponent <Renderer>();
        instance.tag = "Enemy";
        if (level == EnemyParam.Level.LastBoss)
        {
            instance.name = "last_boss";
        }
        box.IsEnemyInstance = false;
        box.Enemy.Ini(level);
    }
Exemplo n.º 36
0
        public static void Convert(BoxObject content, Board board)
        {
            var converted = content.Id - 1;

            switch (content.Between)
            {
            case "X":
                board.Container[converted].InnerContent = Panel.X;
                break;

            case "O":
                board.Container[converted].InnerContent = Panel.O;
                break;

            default:
                board.Container[converted].InnerContent = Panel.Empty;
                break;
            }
        }
Exemplo n.º 37
0
    // Update is called once per frame
    void Update()
    {
        var parent = transform.parent;

        var parentRenderer = parent.GetComponent <Renderer>();
        var renderer       = GetComponent <Renderer>();

        box = GetComponentInParent <BoxObject>();

        renderer.sortingLayerID = parentRenderer.sortingLayerID;
        renderer.sortingOrder   = parentRenderer.sortingOrder + 1;

        var spriteTransform = parent.transform;
        var text            = GetComponent <TextMeshPro>();
        var pos             = spriteTransform.position;

        if (box.health < 100)
        {
            text.fontSize = 250;
        }
        else if (box.health >= 100)
        {
            text.fontSize = 200;
        }
        else if (box.health >= 1000)
        {
            text.fontSize = 165;
        }
        else if (box.health >= 10000)
        {
            text.fontSize = 150;
        }

        if (box.health >= 1000)
        {
            var floating = (float)box.health / 1000;
            text.text = "" + floating.ToString("f1") + "K";
        }
        else
        {
            text.text = "" + box.health;
        }
    }
Exemplo n.º 38
0
    protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
    {
        base.LoadContent(GraphicInfo, factory, contentManager);

        #region Models

        createobjs();

        ///Some Physic World Parameters
        ///No accuracy (speed up the simulation) and no gravity
        BepuPhysicWorld physicWorld = this.World.PhysicWorld as BepuPhysicWorld;        
        physicWorld.Space.Solver.IterationLimit = 1; //Essentially no sustained contacts, so don't need to worry about accuracy.            


        {
            SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo");
            sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
            MaterialDescription md = MaterialDescription.DefaultBepuMaterial();
            md.Bounciness = 1;
            BoxObject pi = new BoxObject(new Vector3(0,-30,0), 1, 1, 1, 1, new Vector3(50,1,50), Matrix.Identity, md);
            pi.isMotionLess = true;
            pi.Entity.AngularDamping = 0f;
            ForwardXNABasicShader shader = new ForwardXNABasicShader();
            IMaterial mat = new ForwardMaterial(shader);
            IObject obj5 = new IObject(mat, sm, pi);
            this.World.AddObject(obj5);
            shader.BasicEffect.EnableDefaultLighting();
        }

        #endregion

   

        cam = new RotatingCamera(this);        
        this.World.CameraManager.AddCamera(cam);
        
    }
Exemplo n.º 39
0
 public static BoxObject Box(Vector3 Position, Vector3 Dimension, float Masse)
 {
     //Erstellt ein Objekt in der Scene.
     BoxObject box = new BoxObject(Position, Dimension, Masse);
     return box;
 }
        public void einausblender(BoxObject Ob, BoxObject changer, int state, float time)
        {
            // 1=ObjSp1  11=WafSp1  12=TexSp1 2=ObjSp2  21=WafSp2  22=TexSp2  0=else
            
            if (state == 0)
            {
                rausblend(Ob, Ob.Position.X);
                rausblend(changer,changer.Position.X);
            }
            if (state == 1)
            {
                reinblend(Ob, level.getSpieler1Pos());
                reinblend(changer, level.getSpieler1Pos() + 3.5f);
                overblend(Ob, "Bau"); //Anzeige soll Bauobjekte Anzeigen
                overblend(changer,"ChangerDummy"); //Rechts soll Waffe zum wechseln zum Waffenmenu angezeigt werden
            }
            if (state == 11)
            {
                overblend(Ob, "WaffenMenüDummy"); //Anzeige soll Waffenauswahl anzeigen
                overblend(changer,"Bau"); //Rechts soll Obj zum wechseln zum Objmenu angezeigt werden
            }
            if (state == 12)
            {
                rausblend(changer, changer.Position.X);
                overblend(Ob, "Material");
            }
            if (state == 2)
            {
                reinblend(changer, level.getSpieler2Pos() + 3.5f);
                reinblend(Ob, level.getSpieler2Pos());
                overblend(Ob, "Bau"); //Anzeige soll Bauobjekte Anzeigen
                overblend(changer,"pist"); //Rechts soll Waffe zum wechseln zum Waffenmenu angezeigt werden
            }
            if (state == 21)
            {
                overblend(Ob, "pist"); //Anzeige soll Waffenauswahl anzeigen
                overblend(changer,"Bau"); //Rechts soll Obj zum wechseln zum Objmenu angezeigt werden
            }
            if (state == 22)
            {
                rausblend(changer,changer.Position.X);
                overblend(Ob, "Material");
            }


        }
 private void reinblend(BoxObject box, float x)
 {
     //TODO: einblenden
     if (lastR) { }//box.Visible = true; }
     box.Physics.Position = new Vector3(x, 3f, -6f);
     lastR = false;
 }
        public override void Initialize()
        {
            base.Initialize();
            
            //Kinect initialisieren
            Scene.InitKinect();

            Scene.Physics.ForceUpdater.Gravity = new Vector3(0,-5.0f,0);            //Definierte Schwerkraft

            //Kamera
            cam = new CameraObject(new Vector3(0,0,0),                 //Position
                                                new Vector3(0,-1,-5));              //Blickpunkt
            Scene.Add(cam);
            Scene.Camera=cam;
            cameraMovement = new CameraMovement(cam);

            //Objecte
            startObjects = new StartObjects(Scene, level);
            Objektverwaltung.setObjektverwaltung(Scene,level);



            //Hände bekommen transparente Box
            rightHand = startObjects.RightHand();
            leftHand = startObjects.LeftHand();

            weiterSym = startObjects.Weiter();

            currentState = States.Menu;                                            //Anfangszustand
        }
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            
            
            switch (currentState)
            {
                     
                #region Menu
		 
	            case States.Menu: 

                    //Platz für ein Menu
                    //Menu();
                    prewState = States.Menu;
                    currentState = States.Start;
                    break;

                    #endregion

                #region Start
                //Start: Objekte werden geladen, Kamera wird erstellt, danach Camto1
                case States.Start:

                    startObjects.LoadStartObjects(level.getLevel());

                    //Zeigt das Baumenü mit den Objekten und Texturen die der Spieler wählen kann, benötigt Name des Bildes
                    auswahlanzeige = startObjects.showObjects("Bau");
                    objWafC = startObjects.LoadObjWafC();

                    //setzt die Variable PosX1 auf die Position bevor er in den nächsten State wechselt
                    PosX1 = Scene.Camera.Position.X;
                    Zeit1 = gameTime.TotalGameTime.Milliseconds + gameTime.TotalGameTime.Seconds * 1000 + gameTime.TotalGameTime.Minutes * 60 * 1000; //Zeit zwischenspeichern
                    aktuallisiereZeit(gameTime);

                    //danach Kamera an Spielerposition 1 bewegen
                    prewState = States.Start;
                    currentState = States.Camto1;

                    break;

                #endregion

                #region Camto1
                //Camto1: Kamera wird an die Linke Position bewegt
                case States.Camto1:
                    aktuallisiereZeit(gameTime);
                    weiterSym.Visible = false;
                    detecting = false;  //Kinect deaktiviert

                    //Variable wird für nächste Schussphasen zurückgesetzt
                    firedWaffen = 0;                        
                    
                    //Kamera wird bewegt
                    cameraMovement.move(zeit,3000,PosX1, level.getSpieler1Pos());

                #region Übergangsbedingungen
                    //Wenn die Spielerposition 1 erreicht wurde startet die Bauphase/Schussphase
                    if (Scene.Camera.Position.X == level.getSpieler1Pos())
                    {
                        //setzt die Variable PosX1 auf die Position bevor er in den nächsten State wechselt 
                        PosX1 = Scene.Camera.Position.X;
                        Zeit1 = gameTime.TotalGameTime.Milliseconds + gameTime.TotalGameTime.Seconds * 1000 + gameTime.TotalGameTime.Minutes * 60 * 1000; //Zeit zwischenspeichern
                        aktuallisiereZeit(gameTime);

                        //Wenn wir aus der Startphase kommen, -> Bauphase 1
                        if (prewState == States.Start)
                        {
                            prewState = States.Camto1;
                            currentState = States.Bauphase1O;
                        }

                        //Wenn wir aus der Bauphase von Spieler2 kommen, -> Schussphase 1
                        else if (prewState == States.Bauphase2O)
                        {
                            prewState = States.Camto1;
                            currentState = States.Schussphase1;
                        }

                        //Wenn wir aus der Schussphase von Spieler2 kommen
                        else if (prewState == States.Schussphase2)
                        {
                            //Ist die Schussphase durch -> Bauphase 1
                            if (schussphasenDurch)
                            {
                                prewState = States.Camto1;
                                currentState = States.Schussphase1;
                                /* schussphasenDurch wird auf true gesetzt, damit nach der nächsten Schussphase wieder in die Bauphase gewechselt wird.
                                 * Schussphase2 sagt also schussphaseDurch= true, will aber erst noch Schussphase 1
                                 */

                            }
                            //sonst Schussphase 1
                            else
                            {
                                prewState = States.Camto1;
                                currentState = States.Bauphase1O;
                            }
                        }
                    } 
                #endregion

                    break;

                #endregion

                #region Objektemenüs
                case States.Bauphase2O:

                case States.Bauphase1O:
                    aktuallisiereZeit(gameTime);
                    detecting = true;               //Kinect aktiv
                    if (!weiterSym.Visible)
                    {
                        weiterSym.Visible = true;
                    }
                    float pos;
                    

                    #region Spieler &  Spielerposition
                    if (currentState == States.Bauphase1O)
                    {
                        gamer = spieler1;
                        pos = level.getSpieler1Pos();
                        weiterSym.Position = new Vector3(pos+1.13f, -0.7f, -2f);
                    }
                    else
                    {
                        gamer = spieler2;
                        pos = level.getSpieler2Pos();
                        weiterSym.Position = new Vector3(pos + 1.13f, -0.7f, -2f);
                    }
                    #endregion

                    #region Objekt erzeugen und mit Hand positionieren
                    if (!showWaffe)
                    {
                        if (getObj && objInHand == false && auswahl != 0 && auswahl < 5)    //"klick" und das Objekt wurde noch nicht erstellt und linke hand befindet sich auf auswahlfeld
                        {
                            objInHand = true;                                               //soll jetzt der Hand folgen
                            aktuellesObj = Objektverwaltung.createObj(auswahl, gamer, pos); //aktuelles Objekt wird erzeugt
                        }

                        if (objInHand)//Ausrichten des Obj
                        {
                            Vector3 rH = new Vector3(rightHand.Position.X, rightHand.Position.Y, -5f); //Handvektor ohne Tiefenveränderung
                            aktuellesObj.setPosition(rH);                 //Objektposition wird auf Handgelegt

                            Objektverwaltung.orientObj(aktuellesObj, leftHand.Position.X, leftHand.Position.Y);

                            rightHand.Visible = false;                  //Anzeige der rechten Hand deaktiviert
                        }

                        if (klick && objInHand == true)                //wenn sich ein Objekt in der Hand befindet und erneut geklickt wird
                        {
                            rightHand.Visible = true;                   //Rechte Hand wird wieder angezeigt
                            klick = false;
                            objInHand = false;                          //Bekommt nicht mehr die Posiotion der hand -> fällt

                            if (currentState == States.Bauphase1O)
                            {
                                prewState = States.Bauphase1O;              //Statewechsel
                                currentState = States.Bauphase1T;
                            }
                            else
                            {
                                prewState = States.Bauphase2O;
                                currentState = States.Bauphase2T;
                            }
                        }
                    }
                    #endregion

                    #region Waffe erzeugen und mit Hand positionieren
                    if (showWaffe)
                    {


                        if (getObj && objInHand == false && auswahl != 0 && auswahl < 5)    //"klick" und die Waffe wurde noch nicht erstellt und linke hand befindet sich auf auswahlfeld
                        {
                            objInHand = true;                                                   //soll jetzt der Hand folgen

                            aktuelleWaffe = Objektverwaltung.createWaffe(auswahl, gamer, rightHand.Position);  //aktuelles Objekt wird erzeugt
                            if (spieler1 == gamer)
                            {
                                spieler1.setWaffen(aktuelleWaffe);                                          //Waffe der Waffenliste des Spieler hinzufügen
                            }
                            else
                            {
                                spieler2.setWaffen(aktuelleWaffe);
                            }
                        }

                        
                        if (objInHand && showWaffe == true)                                              //Ausrichten der Waffe
                        {
                            Vector3 rH = new Vector3(rightHand.Position.X, rightHand.Position.Y, -5f);  //Handvektor ohne Tiefenveränderung
                            aktuelleWaffe.setPosition(rH);                                              //Waffenposition wird auf Handgelegt
                            
                            rightHand.Visible = false;                                                  //Anzeige der rechten Hand deaktiviert
                            
                        }

                        if (klick && objInHand)                                                         //wenn sich ein Objekt in der Hand befindet und erneut geklickt wird
                        {
                            rightHand.Visible = true;                                                   //Rechte Hand wird wieder angezeigt
                            klick = false;
                            objInHand = false;
                            
                        }

                    }
                    
                    #endregion

                    #region Wechsel von der Objekt zur Waffenauswahl
                    if (klick&&objInHand == false && auswahl == 5 && showWaffe == false) //"klick" und das Objekt wurde noch nicht erstellt und linke hand befindet sich auf auswahlfeld
                    {
                        showWaffe = true;
                    }
                    else if (klick && objInHand == false &&  auswahl == 5 && showWaffe)
                    {
                        showWaffe = false;
                    }
                    #endregion
                    
                    #region Übergangsbedingungen
                    //Wenn Spieler nicht ausreichend Geld hat (oder auf weiter Klickt => in Kinect realisiert)
                    if (gamer.getMoney() < level.getMinMoney() && objInHand == false)
                    {
                        PosX1 = Scene.Camera.Position.X;
                        Zeit1 = gameTime.TotalGameTime.Milliseconds + gameTime.TotalGameTime.Seconds * 1000 + gameTime.TotalGameTime.Minutes * 60 * 1000; //Zeit zwischenspeichern
                        aktuallisiereZeit(gameTime);

                        if (currentState == States.Bauphase1O)
                        {
                            prewState = States.Bauphase1O;
                            if (spieler2.getMoney() < level.getMinMoney() && spieler2.getMoney() < spieler1.getMoney())
                            {
                                currentState = States.Schussphase1;
                            }
                            else
                            {
                                currentState = States.Camto2;
                            }
                        }
                        else //Bauphase2O
                        {
                            prewState = States.Bauphase2O;
                            if (spieler1.getMoney() < spieler2.getMoney())
                            {
                                currentState = States.Schussphase2;
                            }
                            else
                            {
                                currentState = States.Camto1;
                            }
                        }
                    }
                    #endregion
                    
                    break;

                #endregion

                #region Texturenmenüs
                //Bauphase, Spiele 1, Objekte erstellen
                case States.Bauphase1T:
                case States.Bauphase2T:
                    aktuallisiereZeit(gameTime);
                    Objektverwaltung.firstMaterial(aktuellesObj, auswahl);
                    weiterSym.Visible = false;

                    if (currentState == States.Bauphase1T)
                    {
                        gamer = spieler1;
                    }
                    else 
                    {
                        gamer = spieler2;
                    }

                    if (klick) //Übergang wird mit klick erzeugt
                    {
                        #region Kosten dem Spieler abziehen
                        if (aktuellesObj.getMaterial() == "MHolz")
                        { } //kostenlos
                        else if (aktuellesObj.getMaterial() == "MStein")
                        {
                            gamer.setMoney(spieler1.getMoney() - 50);
                        }
                        else if (auswahl == 3)
                        {
                            gamer.setMoney(spieler1.getMoney() - 100);
                        }
                        else if (auswahl == 4)
                        {
                            gamer.setMoney(spieler1.getMoney() - 200);
                        }
                        #endregion

                        if (currentState == States.Bauphase1T)
                        {
                            prewState = States.Bauphase1T;
                            currentState = States.Bauphase1O;
                        }
                        else
                        {
                            prewState = States.Bauphase2T;
                            currentState = States.Bauphase2O;
                        }
                    }
                    break;

                #endregion

                #region Camto2
                //Kamera wird an die Rechte Positon bewegt
                case States.Camto2:
                    aktuallisiereZeit(gameTime);
                    detecting = false;               //Kinect deaktiviert
                    weiterSym.Visible = false;

                    //Variable wird für nächste Schussphasen zurückgesetzt
                    firedWaffen = 0; 

                    //Kamera wird bewegt
                    cameraMovement.move(zeit, 3000, PosX1, level.getSpieler2Pos());

                #region Übergangsbedingungen
                    //Wenn die Spielerposition 2 erreicht wurde startet die Bauphase/Schussphase
                    if (Scene.Camera.Position.X == level.getSpieler2Pos())
                    {
                        //setzt die Variable PosX1 auf die Position bevor er in den nächsten State wechselt 
                        PosX1 = Scene.Camera.Position.X;
                        Zeit1 = gameTime.TotalGameTime.Milliseconds + gameTime.TotalGameTime.Seconds * 1000 + gameTime.TotalGameTime.Minutes * 60 * 1000; //Zeit zwischenspeichern
                        aktuallisiereZeit(gameTime);

                        //Wenn wir aus der Bauphase1 kommen -> Bauphase 2 (ohne Geld, aber mehr Geld als Sp1 Schussphase2)
                        if (prewState == States.Bauphase1O)
                        {
                            //Spieler2 hat genug Geld zum Bauen
                            if (spieler2.getMoney() >= level.getMinMoney())
                            {
                                prewState = States.Camto2;
                                currentState = States.Bauphase2O;
                            }
                            //Spieler zwei hat nicht genug Geld aber mehr als Spieler1 -> Schussphase 2
                            else if (spieler2.getMoney() > spieler1.getMoney())
                            {
                                prewState = States.Camto2;
                                currentState = States.Schussphase2;
                            }
                        }
                        //Wenn wir aus der Schussphase1 kommen, muss Schussphase 2 starten 
                        else if (prewState == States.Schussphase1)
                        {
                            prewState = States.Camto2;
                            currentState = States.Schussphase2;
                        }

                    }
                #endregion

                    break;

                #endregion

                #region Schussphasen
                //Schussphasen
                case States.Schussphase2:
                case States.Schussphase1:

                    
                    aktuallisiereZeit(gameTime);
                    detecting = true;               //Kinect aktiv
                    weiterSym.Visible = false;
                    int xR;

                    if (currentState == States.Schussphase1)
                    {
                        gamer = spieler1;
                        xR = 1;
                    }
                    else
                    {
                        gamer = spieler2;
                        xR = -1;
                    }
                    #region Schussfunktion //shoot Funktion TODO: "auslagern"
                    if (gamer.getWaffen() != 0)
                    {   
                        aktuelleWaffe = Objektverwaltung.getWaffe(gamer, firedWaffen);
                        aktuelleWaffe.setWinkel(rightHand.Position.Y);//Setzt Winkel der Kanone in Waffen

                        if (klick==true)
                        {
                           float schusswinkel,x,y,velocity;
                           Vector3 spawnpoint = new Vector3 ( rightHand.Position.X+1,rightHand.Position.Y-1, rightHand.Position.Z); //Spawnposition nur Vorübergehend sollte am Objekt sein!
                           bullet = new SphereObject(new Vector3(aktuelleWaffe.getPosition().X, aktuelleWaffe.getPosition().Y,rightHand.Position.Z), 0.1f, 10, 10, 0.05f);
                           Vector3 shootdirection = new Vector3();
                           Scene.Add(bullet);
                            
                           schusswinkel = aktuelleWaffe.getWinkel();
                           x=(float)Math.Cos(schusswinkel);
                           y=(float)Math.Sin(schusswinkel);
                           shootdirection = new Vector3(x,y,0);
                           if (gamer == spieler1)
                           {
                               velocity = leftHand.Position.Y * 10f;
                               bullet.Physics.LinearVelocity = shootdirection * velocity;


                           }
                           else
                           {
                               velocity = leftHand.Position.Y * 10f;
                               shootdirection.X = shootdirection.X * (-1f);
                               bullet.Physics.LinearVelocity = shootdirection * velocity;
                           }


                           firedWaffen++;
                           bulletInAir = true;
                           
                           
                        }
        
                        
                        
                    }
                    
                    
                    if (bulletInAir)
                    {
                       
                        cameraMovement.chaseBullet(bullet.Position, cam.Position);
                        
                        bullet.Collided +=new EventHandler<CollisionArgs>(bulletCollidedHandler);

                        //Partikel Effekte FUNKTIONIERT NOCH NICHT
                        ParticleEffect effect = new ParticleEffect()
                        {
                            Emitters = new EmitterCollection()
                                {   
                                    new SphereEmitter
                                    {
                                        Name="Flame",
                                        Budget = 100,
                                        Term = 0.5f,
                                        ReleaseQuantity = 8,
                                        Enabled = true,
                                        ReleaseSpeed = new Range(5f,5f),
                                        ReleaseColour = new ColourRange
                                        {
                                            Red = new Range(0.9f,1f),
                                            Green = new Range(0.5f,0.5f),
                                            Blue = new Range(0f,0f),
                                        },
                                        ReleaseOpacity = new Range(1f,1f),
                                        ReleaseScale = new Range(2f,2f),
                                        ReleaseRotation = new RotationRange
                                        {
                                            Pitch = new Range(0f,0f),
                                            Yaw = new Range(0f,0f),
                                            Roll = new Range(-3.14f,3.14f),
                                        },
                                        ParticleTexture = Core.Content.Load<Texture2D>("Flames"),
                                        BlendMode = EmitterBlendMode.Add,
                                        Radius = 3f,
                                        Shell = true,
                                        Radiate = true,                        
                                        BillboardStyle = ProjectMercury.BillboardStyle.Spherical,
                                        Modifiers = new ModifierCollection
                                        {
                                            new OpacityInterpolator2
                                            {
                                                InitialOpacity = 0.5f,                                
                                                FinalOpacity = 0f,
                                            },
                                            new RotationModifier
                                            {
                                                RotationRate = new Vector3(0,0,1)
                                            }
                                        },
                                        Controllers = new ControllerPipeline
                                        {
                                            new CooldownController
                                            {
                                                CooldownPeriod = 0.02f,
                                            },
                                        }
                                    }
                                }
                        };

                        ParticleObject particle = new ParticleObject(bullet.Position, effect);
                        
                       


                    }
                    
                    #endregion

                    #region Übergangsbedingungen
                    //Wenn alle Waffen abgefeuert wurden...
                    if (firedWaffen == gamer.getWaffen())
                    {
                        //setzt die Variable PosX1 auf die Position bevor er in den nächsten State wechselt 
                        PosX1 = Scene.Camera.Position.X;
                        Zeit1 = gameTime.TotalGameTime.Milliseconds + gameTime.TotalGameTime.Seconds * 1000 + gameTime.TotalGameTime.Minutes * 60 * 1000; //Zeit zwischenspeichern
                        aktuallisiereZeit(gameTime);

                        //Wenn die Schussphase durch ist, beginnt die Bauphase
                        if (schussphasenDurch)
                        {
                            if (currentState == States.Schussphase1)
                            {
                                prewState = States.Schussphase1;
                                schussphasenDurch = false;
                                currentState = States.Bauphase1O;
                            }
                            else
                            {
                                prewState = States.Schussphase2;
                                schussphasenDurch = false;
                                currentState = States.Camto1;
                            }
                        }

                        //Sonst in die andere Schussphase wechseln
                        else
                        {
                            if (currentState == States.Schussphase1)
                            {
                                prewState = States.Schussphase1;
                                schussphasenDurch = true;           //nach der Schussphase2 ist die Schussphase beendet
                                currentState = States.Camto2;
                            }
                            else
                            {
                                prewState = States.Schussphase2;
                                schussphasenDurch = true;           //nach der Schussphase1 ist die Schussphase beendet
                                currentState = States.Camto1;
                            }
                        }
                    }

                    #endregion


                    break;

                #endregion

                #region End
                //Ende des Spiels
                case States.End:
                    //noch leer



                    //neues Spiel, alle vorherigen Objekte werden gelöscht
                    Scene.RemoveAllSceneObjects();  
                    break;

                #endregion

                
            }




            #region Objekt-/ Texturauswahl ein-/ausblenden
            if (currentState != States.Menu && currentState != States.Start && currentState != States.End)
            {
                if (currentState == States.Bauphase1O)
                {
                    if (showWaffe)
                    {
                        startObjects.einausblender(auswahlanzeige, objWafC, 11, zeit);
                    }
                    else
                    {
                        startObjects.einausblender(auswahlanzeige, objWafC, 1, zeit);
                    }
                }
                else if (currentState == States.Bauphase1T)
                {
                    showWaffe = false;
                    startObjects.einausblender(auswahlanzeige, objWafC, 12, zeit);
                }
                else if (currentState == States.Bauphase2O)
                {
                    if (showWaffe)
                    {
                        startObjects.einausblender(auswahlanzeige, objWafC, 21, zeit);
                    }
                    else
                    {
                        startObjects.einausblender(auswahlanzeige, objWafC, 2, zeit);
                    }
                }
                else if (currentState == States.Bauphase2T)
                {
                    showWaffe = false;
                    startObjects.einausblender(auswahlanzeige, objWafC, 22, zeit);
                }
                else
                {
                    startObjects.einausblender(auswahlanzeige, objWafC, 0, zeit);
                }
            }



            #endregion

            #region Kinect
            if (detecting)
            {
                if (Scene.Kinect.SkeletonDataReady)
                {
                    List<NOVA.Components.Kinect.Skeleton> skeletons = new List<NOVA.Components.Kinect.Skeleton>(Scene.Kinect.Skeletons);

                    //Aktives Skelett finden
                    foreach (NOVA.Components.Kinect.Skeleton skeleton in skeletons)
                    {
                        if (skeleton.TrackingState == SkeletonTrackingState.Tracked && skeleton.Joints.Count != 0)
                        {
                            //Box auf Hand, Klick auf Weiter
                           #region Detektion der rechten Hand

                            if (skeleton.Joints[JointType.HandRight].TrackingState == JointTrackingState.Tracked)
                            {
                                //Position der rechten Hand des Spielers in Bildschirmkoodinaten
                                Vector2 screenPos = skeleton.Joints[JointType.HandRight].ScreenPosition;
                                Vector2 normScreenPos = new Vector2(screenPos.X, screenPos.Y);
                                screenPos.X = screenPos.X * Scene.Game.Window.ClientBounds.Width;
                                screenPos.Y *= Scene.Game.Window.ClientBounds.Height;

                                //parallele Ebene zum Bildschirm erzeugen in der die Kugel transformiert wird
                                Plane plane2 = new Plane(Vector3.Forward, -4f);

                                //Weltkoordinatenpunk finden
                                Vector3 worldPos2 = Helpers.Unproject(screenPos, plane2);

                                #region Box auf Hand
                                //Position der Kugel setzen
                                rightHand.Position = worldPos2;
                                #endregion

                                #region getObj
                                if (normScreenPos.X >= 0.2f && normScreenPos.X <= 0.8f && normScreenPos.Y <= 0.1f)
                                {
                                    getObj = true;
                                }
                                else {getObj = false; }
                                #endregion

                                #region WEITER klick
                                //Wenn sich die rechte Hand in der oberen, rechten Ecke befindet & KLICK -> Klick auf WEITER
                                if (normScreenPos.X >= 0.9f && normScreenPos.Y >= 0.9f)
                                {
                                    //setzt die Variable PosX1 auf die Position bevor er in den nächsten State wechselt 
                                    PosX1 = Scene.Camera.Position.X;
                                    Zeit1 = gameTime.TotalGameTime.Milliseconds + gameTime.TotalGameTime.Seconds * 1000 + gameTime.TotalGameTime.Minutes * 60 * 1000; //Zeit zwischenspeichern
                                    aktuallisiereZeit(gameTime);

                                    if (currentState == States.Bauphase1O)
                                    {
                                        prewState = States.Bauphase1O;

                                        //wenn Spieler2 über genügend Geld zum bauen verfügt, Bauphase Spieler 2
                                        //Wenn Spieler2 mehr Geld besitzt fängt er die Schussphase2 an
                                        if (spieler2.getMoney() >= level.getMinMoney() || spieler2.getMoney() > spieler1.getMoney())
                                        {
                                            currentState = States.Camto2;
                                        }
                                        //wenn Spieler2 nicht über genügend Geld zum bauen verfügt, und Spieler1 mehr Geld hat beginnt Schussphase1
                                        else
                                        {
                                            currentState = States.Schussphase1;
                                        }

                                    }
                                    else if (currentState == States.Bauphase2O)
                                    {
                                        prewState = States.Bauphase2O;

                                        //Wenn Spieler2 mehr Geld besitzt fängt er die Schussphase2 an
                                        if (spieler2.getMoney() > spieler1.getMoney())
                                        {
                                            currentState = States.Schussphase2;
                                        }
                                        //sonst Spieler 1
                                        else
                                        {
                                            currentState = States.Camto1;
                                        }

                                    }
                                    else
                                    {
                                        return;
                                    }
                                }
                                #endregion

                                

                            }
                            #endregion

                            //Box auf Hand, Auswahl Textur/ Objekt
                            #region Detektion der linken Hand
                            if (skeleton.Joints[JointType.HandLeft].TrackingState == JointTrackingState.Tracked)
                            {
                                //Position der linken Hand des Spielers in Bildschirmkoodinaten
                                screenPos = skeleton.Joints[JointType.HandLeft].ScreenPosition;
                                Vector2 normScreenPos = new Vector2(screenPos.X, screenPos.Y);
                                screenPos.X = screenPos.X * Scene.Game.Window.ClientBounds.Width;
                                screenPos.Y *= Scene.Game.Window.ClientBounds.Height;

                                //parallele Ebene zum Bildschirm erzeugen in der die Kugel transformiert wird
                                Plane plane2 = new Plane(Vector3.Forward, -1f);

                                //Weltkoordinatenpunk finden
                                Vector3 worldPos2 = Helpers.Unproject(screenPos, plane2);

                                #region Box auf Hand
                                //Position der Kugel setzen
                                leftHand.Position = worldPos2;
                                #endregion

                                #region Auswahl Textur/ Objekt
                                auswahl = Auswahl.auswahl(normScreenPos);

                                #endregion
                            }
                           
                            #endregion

                            //Hintergrundsbild verschieben
                            #region Detektion des Kopfes
                            if (skeleton.Joints[JointType.Head].TrackingState == JointTrackingState.Tracked)
                            {
                                //Position des Kopfes des Spielers in Bildschirmkoodinaten
                                Vector2 screenPos = skeleton.Joints[JointType.Head].ScreenPosition;
                                Vector2 normScreenPos = new Vector2(screenPos.X / Scene.Game.Window.ClientBounds.Width, screenPos.Y / Scene.Game.Window.ClientBounds.Height);

                                //Hintergrund bewegen
                                startObjects.MoveBackground(normScreenPos.X - 0.5f, normScreenPos.Y - 0.5f);
                                


                            }
                            
                            #endregion

                        }
                    }

                }
            }
            else
            {
                
            }
            #endregion

            

            objState = currentState; //Am Ende jenden Updates wird der State angeglichen

            Objektverwaltung.refreshObj(spieler1,spieler2); //Entfernt Objekte ohne LP
         
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
      
        }
Exemplo n.º 44
0
 private void LoadBox(Vector3 position, Vector3 dimension, float masse)
 {
     //Erstellt ein Objekt in der Scene.
     BoxObject box = new BoxObject(position,             //Position
                        dimension,                          //Kantenlängen
                        masse);
     Scene.Add(box);
 }
 private void rausblend(BoxObject box, float x)
 {
     //TODO: rausblenden
     if (lastR == false) { }//box.Visible = false; }
     box.Position = new Vector3(x, 4f, -6f);
     lastR = true;
 }
        public static Waffen createWaffe(int auswahl, Spieler spieler, Vector3 posi)//TODO
        {
            Controller newcon;
            RevoluteJoint revolute;
            Waffen dasobj;
            Vector3 startort = new Vector3(posi.X,posi.Y, -5f);

            if (auswahl == 1)//Kanone
            {
                Vector3 diff = new Vector3(0.095f, 0.1828f, 0);
                ModelObject Kanonenrohr = new ModelObject(startort + diff, Quaternion.Identity, new Vector3(0.1f, 0.1f, 0.1f), CollisionType.ExactMesh, " ", "Kanonenrohr", 0.001f);
                Kanonenrohr.RenderMaterial.Diffuse = new Vector4(1, 1, 1, 1);
                scene.Add(Kanonenrohr);

                ModelObject Kanonenhalterung = new ModelObject(startort, Quaternion.Identity, new Vector3(0.1f, 0.1f, 0.1f), CollisionType.ExactMesh, " ", "Kanonenhalterung", 1f);
                Kanonenhalterung.RenderMaterial.Diffuse = new Vector4(1, 1, 1, 1);
                scene.Add(Kanonenhalterung);

                newcon = new Controller(new Vector3(0, 0, 0));// Neuer Controller an der Position 0/0/0
                newcon.Add(Kanonenrohr);
                newcon.Add(Kanonenhalterung);

                revolute = new RevoluteJoint(Kanonenhalterung.Physics, Kanonenrohr.Physics, Kanonenhalterung.Position + new Vector3(0, 1, 0), Vector3.Backward);
                /*revolute.Limit.IsActive = true;
                revolute.Limit.MinimumAngle = -MathHelper.Pi;
                revolute.Limit.MaximumAngle = 0;*/
                scene.Physics.Add(revolute);

                revolute.Motor.IsActive = true;
                revolute.Motor.Settings.Mode = BEPUphysics.Constraints.TwoEntity.Motors.MotorMode.Servomechanism;
                revolute.Motor.Settings.Servo.Goal = -MathHelper.Pi / 4;
            }
            else //TEMPORÄR
            {
                BoxObject Box = new BoxObject(startort, new Vector3(0.4f, 0.25f, 0.3f), 0.001f);
                scene.Add(Box);//Standbox

                BoxObject Lat = new BoxObject(startort + new Vector3(0 , 0.35f , 0), new Vector3(0.35f, 0.1f, 0.1f), 0.00001f);
                scene.Add(Lat);//KanonenRohr

                newcon = new Controller(startort);
                newcon.Add(Box);
                newcon.Add(Lat);
                scene.Add(newcon);

                revolute = new RevoluteJoint(Box.Physics, Lat.Physics, Box.Position + new Vector3(0, 0.32f, 0), Vector3.Backward);
                /*revolute.Limit.IsActive = true;
                revolute.Limit.MinimumAngle = -MathHelper.Pi;
                revolute.Limit.MaximumAngle = 0;*/
                scene.Physics.Add(revolute);

                revolute.Motor.IsActive = true;
                revolute.Motor.Settings.Mode = BEPUphysics.Constraints.TwoEntity.Motors.MotorMode.Servomechanism;
                revolute.Motor.Settings.Servo.Goal = MathHelper.Pi / 6;
                
            }

            //TODO z-Achse sperren

            
            //scene.Add(newcon);
            dasobj = new Waffen( newcon, revolute, 1, (float)Math.PI / 4, 5f);
            spieler.setWaffen(dasobj);
            return dasobj;

        }
        private static BoxObject buildbox(Vector3 startort, Vector3 dimension)
        {
            BoxObject box = new BoxObject(startort, //Position
                    dimension,               //Kantenlänge der Latte
                    1f);

            return box;
        }
Exemplo n.º 48
0
        // Create object in room upon user click
        private void MakeSpaceObject(string texName, Image tex, DrawPoint mp)
        {
            texName = texName.Replace(".png", "");

            string[] lastname_ary= (string[])texName.Split('\\');
            string lastname = lastname_ary[lastname_ary.Length-1];

            string texStripName = texName.Replace(lastname,"strips\\"+lastname) + "_strip";

            //int numberOfFrames = SpaceObject.GetNumberOfFrames(texName);

            Vector2 screenposition = Conversion.DrawPointToVector2(mp);
            Vector2 gameposition = new Vector2(screenposition.X / CASSWorld.SCALE, screenposition.Y / CASSWorld.SCALE);

            if (rb_AnimationObjects.Checked)
            {
                AnimationObject ao;
                // TODO : i'm not a fan of these ifs, since the only thing that's changing are those last two numbers
                //        having to do with the animation. is there a way they could be passed in, or even better,
                //        derived from the strip image?
                if (lastname == "fan")
                    ao = new AnimationObject(world.World, texStripName, texName, tex.Width, tex.Height, 20, 7);
                else if (lastname == "broken_platform")
                    ao = new AnimationObject(world.World, texStripName, texName, tex.Width, tex.Height, 20, 8);
                else if (lastname == "light" || lastname == "fire")
                {
                    ao = new AnimationObject(world.World, texStripName, texName, tex.Width, tex.Height, 20, 8,false, false);
                    //ao.RemoveFromWorld();
                    //world.World.DestroyBody(ao.Body);
                }
                else if (lastname == "rollingpin")
                {
                    ao = new AnimationObject(world.World, texStripName, texName, tex.Width, tex.Height, 20, 8, true, true);
                }
                else
                {
                    ao = new AnimationObject(world.World, texStripName, texName, tex.Width, tex.Height, 20, 8);
                }
                ao.Position = gameposition;
                world.AddObject(ao);
            }
            else if (rb_BoxObjects.Checked)
            {
                BoxObject bo;
                bo = new BoxObject(world.World, texName, 0, .5f, 0, 1, false);
                bo.Position = gameposition;
                world.AddObject(bo);
            }
            else if (rb_CircleObjects.Checked)
            {
                CircleObject co;
                co = new CircleObject(world.World, texName, 1, .5f, 0, 1);
                co.Position = gameposition;
                world.AddObject(co);
            }
            else if (rb_WinDoorObject.Checked)
            {
                WinDoorObject so;
                // HACK - hard-coded for the win-door
                so = new WinDoorObject(world.World, texStripName, texName, tex.Width, tex.Height, 20, 5);
                so.Position = gameposition;
                world.AddObject(so);
            }
            else if (rb_PistonObject.Checked)
            {
                PistonObject po;
                Console.WriteLine("{0}", gameposition);
                po = new PistonObject(world.World, .5f, .5f, 12f, 13f, 9.7f, 12.6f, .01f, .1f, gameposition);
                po.Position = gameposition;
                world.AddObject(po);
            }
            else if(rb_SeeSawObject.Checked)
            {
                SeeSawObject ss;
                ss = new SeeSawObject(world.World, texName, 1.5f, gameposition);
                ss.Position = gameposition;
                world.AddObject(ss);

            }
            else if (rb_SwitchObject.Checked)
            {
                SwitchObject ss1;
             //       ss1 = new SwitchObject(world.World, "Art\\Objects\\SwitchObjects\\button_strip","Art\\Objects\\SwitchObjects\\button", 181, 84, 20, 2);
                //brokenMovingPlatform1 = new SwitchObject(World, "broken_strip", "broken_moving_platform", 89, 32, 20, 8);
             //       ss1.Position = gameposition;
              //  world.AddObject(ss1);

                if (lastname == "button")
                {
                    ss1 = new SwitchObject(world.World, "Art\\Objects\\SwitchObjects\\button_strip", "Art\\Objects\\SwitchObjects\\button", 181, 84, 20, 2);

                    ss1.Position = gameposition;
                    world.AddObject(ss1);
                }
                else if (lastname == "death")
                {

                    DeathPlatform ss2;
                    ss2 = new DeathPlatform(world.World, "Art\\Objects\\SwitchObjects\\button_death_strip", "Art\\Objects\\SwitchObjects\\death", 181, 84, 20, 2);

                    //brokenMovingPlatform1 = new SwitchObject(World, "broken_strip", "broken_moving_platform", 89, 32, 20, 8);
                    ss2.Position = gameposition;
                    world.AddObject(ss2);
                }
                else
                {
                    FailButtonObject ss2;
                    ss2 = new FailButtonObject(world.World, "Art\\Objects\\SwitchObjects\\button_strip", "Art\\Objects\\SwitchObjects\\fail_button", 181, 84, 20, 2);

                    //brokenMovingPlatform1 = new SwitchObject(World, "broken_strip", "broken_moving_platform", 89, 32, 20, 8);
                    ss2.Position = gameposition;
                    world.AddObject(ss2);
                }

            }
            else if (rb_HoleObject.Checked)
            {
                HoleObject ss;
                ss = new HoleObject(world.World, "Art\\Objects\\HoleObjects\\hole_strip", "Art\\Objects\\HoleObjects\\hole");
                //hole1 = new HoleObject(World, "Art\\Objects\\HoleObjects\\hole_strip", "Art\\Objects\\HoleObjects\\hole");
                ss.Position = gameposition;
                world.AddObject(ss);

            }
            else if (rb_MovingPlatform.Checked)
            {
                MovingObject ss;
              //  ss = new MovingObject(world.World, "Art\\Objects\\MovingPlatformObjects\\moving_platform", 1000, 0.5f, 0, 1, false, null, new Vector2(0, -11500), 4.5f, 14.2f);
               // movPlatform1 = new MovingObject(World, "moving platform", 1000f, .5f, 0, 1, false, brokenMovingPlatform1, new Vector2(0, -11500), 4.5f, 14.2f);
               // ss.Position = gameposition;
              //  world.AddObject(ss);

                if (lastname == "moving_platform")
                    ss = new MovingObject(world.World, "Art\\Objects\\MovingPlatformObjects\\moving_platform", 0, 0.5f, 0, 1, false, null, new Vector2(0, -11500), 4.5f, 14.2f);
                else if (lastname == "gate")
                {
                    SwitchObject ssfine;
                    ssfine = new SwitchObject(world.World, "Art\\Objects\\SwitchObjects\\button_strip", "Art\\Objects\\SwitchObjects\\button", 181, 84, 20, 2);
                    ss = new MovingObject(world.World, "Art\\Objects\\MovingPlatformObjects\\gate", 0, 0.5f, 0, 1, false, ssfine, new Vector2(0, -11500), 4.5f, 14.2f);
                    //brokenMovingPlatform1 = new SwitchObject(World, "broken_strip", "broken_moving_platform", 89, 32, 20, 8);
                    ssfine.Position = gameposition;
                    world.AddObject(ssfine);
                }
                else
                {

                    SwitchObject ss1;
                    ss1 = new SwitchObject(world.World, "Art\\Objects\\SwitchObjects\\button_strip", "Art\\Objects\\SwitchObjects\\button", 181, 84, 20, 2);
                    ss = new MovingObject(world.World, "Art\\Objects\\MovingPlatformObjects\\switchmoving_platform", 0, 0.5f, 0, 1, false, ss1, new Vector2(0, -11500), 4.5f, 14.2f);
                    //brokenMovingPlatform1 = new SwitchObject(World, "broken_strip", "broken_moving_platform", 89, 32, 20, 8);
                    ss1.Position = gameposition;
                    world.AddObject(ss1);
                }

                ss.Position = gameposition;
                world.AddObject(ss);

            }
            else if (rb_HorizontalMovingPlatform.Checked)
            {
                HorizontalMovingObject ss;
              //  ss = new HorizontalMovingObject(world.World, "Art\\Objects\\HorizontalMovingPlatformObjects\\moving_platform", 0, 0.5f, 0, 1, false, null, new Vector2(0, -11500), 4.5f, 14.2f);
               // movPlatform2 = new HorizontalMovingObject(World, "Art\\Objects\\HorizontalMovingPlatformObjects\\moving_platform", 0f, 0.5f, 0, 1, false, null, new Vector2(0, -11500), 32f, 38f);

                if (lastname == "moving_platform")
                    ss = new HorizontalMovingObject(world.World, "Art\\Objects\\HorizontalMovingPlatformObjects\\moving_platform", 0, 0.5f, 0, 1, false, null, new Vector2(0, -11500), 4.5f, 14.2f);
                else
                {

                    SwitchObject ss1;
                    ss1 = new SwitchObject(world.World, "Art\\Objects\\SwitchObjects\\button_strip", "Art\\Objects\\SwitchObjects\\button", 181, 84, 20, 2);
                    ss = new HorizontalMovingObject(world.World, "Art\\Objects\\HorizontalMovingPlatformObjects\\switchmoving_platform", 0, 0.5f, 0, 1, false, ss1, new Vector2(0, -11500), 4.5f, 14.2f);
                    //brokenMovingPlatform1 = new SwitchObject(World, "broken_strip", "broken_moving_platform", 89, 32, 20, 8);
                    ss1.Position = gameposition;
                    world.AddObject(ss1);
                }

                ss.Position = gameposition;
                world.AddObject(ss);

            }
            else if (rb_PaintedObjects.Checked)
            {
                switch (lastname)
                {
                    case "block_long":
                        InstasteelObject io;
                        io = new InstasteelObject(world.World, texName, 580, 1, .5f, 0, 1, false);
                        io.Position = gameposition;
                        world.AddObject(io);
                        break;
                    case "disk_long":
                        InstasteelCircleObject ico;
                        ico = new InstasteelCircleObject(world.World, texName, 480, 1, .5f, 0, 1);
                        ico.Position = gameposition;
                        world.AddObject(ico);
                        break;
                    case "line_long":
                        InstasteelObject ilo;
                        ilo = new InstasteelObject(world.World, texName, 190, 1, .5f, 0, 1, false);
                        ilo.Position = gameposition;
                        world.AddObject(ilo);
                        break;
                    default:
                        break;
                }
            }
                /*
            else if (rb_PaintedObjects.Checked)
            {
                PaintedObject po;
                List<Vector2> blobs = new List<Vector2>();
                float radius;
                float sidelength;
                Vector2 centeroff;
                switch (lastname)
                {
                    case "line_short":
                        float linelength_short = (30f/60f) * 1.2f;
                        blobs.Add(gameposition + new Vector2(linelength_short/2f, 0f));
                        blobs.Add(gameposition + new Vector2(-linelength_short/2f, 0f));
                        centeroff = new Vector2(0,0);
                        break;
                    case "line":
                        float linelength = 1.2f;
                        blobs.Add(gameposition + new Vector2(linelength/2, 0f));
                        blobs.Add(gameposition + new Vector2(-linelength/2f, 0f));
                        centeroff = new Vector2(0,0);
                        break;
                    case "line_long":
                        float linelength_long = (200f/60f) * 1.2f;
                        blobs.Add(gameposition + new Vector2(linelength_long/2f, 0f));
                        blobs.Add(gameposition + new Vector2(-linelength_long/2f, 0f));
                        centeroff = new Vector2(0,0);
                        break;
                    case "disk_short":
                        radius =  (30f/60f) *0.6f;
                        blobs = paintedCircle(radius, gameposition); // radius of 0.6f
                        centeroff = -1 * new Vector2(radius, radius);
                        centeroff = new Vector2(0,0);
                        break;
                    case "disk_small":
                        radius =  (40f/60f) *0.6f;
                        blobs = paintedCircle(radius, gameposition); // radius of 0.6f
                        centeroff = -1 * new Vector2(radius, radius);
                        centeroff = new Vector2(0,0);
                        break;
                    case "disk":
                        radius =  0.6f;
                        blobs = paintedCircle(radius, gameposition); // radius of 0.6f
                        centeroff = -1 * new Vector2(radius, radius);
                        centeroff = new Vector2(0,0);
                        break;
                    case "disk_long":
                        radius =  (150f/60f) * 0.6f;
                        blobs = paintedCircle(radius, gameposition); // radius of 0.6f
                        centeroff = -1 * new Vector2(radius, radius);
                        centeroff = new Vector2(0,0);
                        break;
                    case "block_short":
                        sidelength =  (30f/60f) *0.6f;
                        blobs = paintedSquare((30f/60f) * 1.2f, gameposition); // sidelength of 1.2f
                        centeroff = -1 * new Vector2(sidelength, sidelength);
                        break;
                    case "block_small":
                        sidelength =  (40f/60f) *0.6f;
                        blobs = paintedSquare((40f/60f) * 1.2f, gameposition); // sidelength of 1.2f
                        centeroff = -1 * new Vector2(sidelength, sidelength);
                        break;
                    case "block":
                        sidelength =  0.6f;
                        blobs = paintedSquare(1.2f, gameposition); // sidelength of 1.2f
                        centeroff = -1 * new Vector2(sidelength, sidelength);
                        break;
                    case "block_long":
                        sidelength =  (150f/60f) * 0.6f;
                        blobs = paintedSquare((150f/60f) * 1.2f, gameposition); // sidelength of 1.2f
                        centeroff = -1 * new Vector2(sidelength, sidelength);
                        break;
                    default:
                        blobs.Add(gameposition + new Vector2(0.6f, 0f));
                        blobs.Add(gameposition + new Vector2(-0.6f, 0f));
                        centeroff = new Vector2(0,0);
                        break;
                }
                po = new PaintedObject(world.World, "paint", "paintedsegment", blobs);
                po.TextureFilename = "Art\\Objects\\PaintedObjects\\" + lastname;
                po.Position = gameposition + centeroff;
                world.AddObject(po);
            }
            */
            else if (rb_BackgroundObjects.Checked)
            {
                BackgroundObject bo;
                bo = new BackgroundObject(world.World, world, texName,gameposition);
                bo.Position = gameposition;
                world.AddObject(bo);

            }

                /*
            else if (rb_Player.Checked)
            {
                mp.X -= (int)((texture.Width * Constants.PLAYER_SCALE) / 2);
                mp.Y -= (int)((texture.Height * Constants.PLAYER_SCALE) / 2);

                world.player = new Player(
                    Conversion.DrawPointToVector2(mp),
                    currdir + "\\" + texName + ".tri"
                    );

                world.CurrentRoom = currentlySelectedRoom;
                world.player.TextureName = texName;
            }
            */
        }
Exemplo n.º 49
0
        private void LoadBackground()
        {
            Vector3 pos = new Vector3(0, 0, -11);
            hintergrund = new BoxObject(pos,
                                        new Vector3(56, 10, 0),
                                        0f);

            hintergrundsbild.Texture = Core.Content.Load<Texture2D>("himmel");
            hintergrundsbild.Diffuse = Color.White.ToVector4();
            hintergrundsbild.EnableGlow = true;
            hintergrund.RenderMaterial = hintergrundsbild;

            Scene.Add(hintergrund);
        }
 private void overblend(BoxObject box, string bild)
 {
     if (box.RenderMaterial.Texture.Name != bild)
     {
         RenderMaterial xmenu = new RenderMaterial();
         xmenu.Texture = Core.Content.Load<Texture2D>(bild);
         xmenu.Diffuse = Color.Gray.ToVector4();
         box.RenderMaterial = xmenu;
     }
 }