Ejemplo n.º 1
0
        private void GameInitilaztion()
        {
            GameObject plane = new GameObject();
            int        size  = 100;

            plane.AddComponent(new Entity(Terrain.GenerateTerrain(size), ""));
            plane.isStatic  = true;
            plane.transform = new Transform(size / 2, 2, size / 2);
            plane.AddComponent(new RigidEntity(plane.transform.position));
            MainScene.AddGameObject(plane);

            for (int i = 0; i < 100; i++)
            {
                GameObject obj = new GameObject();
                obj.AddComponent(new Entity(Geometries.Cube, ""));
                obj.transform.position = new Vector3(Randomize.RangeFloat(1, 10), Randomize.RangeFloat(1, 10), Randomize.RangeFloat(1, 10));
                obj.GetComponent <Entity>().model.shineDamper  = 0.1f;
                obj.GetComponent <Entity>().model.reflectivity = 0.1f;
                obj.GetComponent <Entity>().model.luminosity   = 0.8f;
                obj.AddComponent(new RigidEntity(obj.transform.position));
                obj.AddComponent(new RaycastTarget(1, onClick: () =>
                {
                    obj.SetColour(Color.Red);
                    lockToMouseObject = obj;
                }, onLoseFocus: () =>
                {
                    obj.SetColour(Color.White);
                    if (lockToMouseObject == obj)
                    {
                        lockToMouseObject = null;
                    }
                }));
                MainScene.AddGameObject(obj);
            }

            SunLight.gameObject.transform = new Transform(0, 25, 0, 0, 0, 0, 2f, 2f, 2f);
            SunLight.gameObject.AddComponent(new Entity(Geometries.Sphere));
            SunLight.gameObject.GetComponent <Entity>().model.luminosity = 1;

            MainCamera.gameObject.transform = new Transform(0, 4, 10);

            float offset = 30;

            ProfilerScreen.AddComponent(new Sprite("grid"));
            ProfilerScreen.transform.localScale = new Vector3(0.6f, 0.2f, 0.5f);
            ProfilerScreen.transform.position   = new Vector3(0, 7 + offset, 0);
            ProfilerScreen.GetComponent <Sprite>().UIConstriant = UIPosition.Left;
            MainScene.AddGameObject(ProfilerScreen);

            text1.AddComponent(new Text("FPS", font, 8));
            text1.transform.position = new Vector3(0, -35 + offset, 0);
            text1.GetComponent <Text>().UIConstriant = UIPosition.Left;
            MainScene.AddGameObject(text1);

            text2.AddComponent(new Text("Memory", font, 8));
            text2.transform.position = new Vector3(0, -43 + offset, 0);
            text2.GetComponent <Text>().UIConstriant = UIPosition.Left;
            MainScene.AddGameObject(text2);
        }
Ejemplo n.º 2
0
        private void GameInitilaztion()
        {
            GameObject plane = new GameObject();
            int        size  = 100;

            plane.AddComponent(new Entity(Terrain.GenerateTerrain(size), ""));
            plane.isStatic  = true;
            plane.transform = new Transform(size / 2, 0, size / 2);
            plane.AddComponent(new RigidEntity(plane.transform.position));
            MainScene.AddGameObject(plane);

            target.AddComponent(new Entity("alduin", "alduin_img"));
            target.transform.localScale = new Vector3(0.02f, 0.02f, 0.02f);
            target.transform.position   = new Vector3(-10, 5, 0);
            target.GetComponent <Entity>().model.hasTransparency = true;
            target.AddComponent(new RaycastTarget(5 / 0.02f, null, () => { Targeting = !Targeting; player.transform.rotation = new Vector3(0, player.transform.LookAt(target.transform.position).Y - 180, 0); }, null));
            MainScene.AddGameObject(target);

            for (int i = 0; i < 200; i++)
            {
                GameObject obj = new GameObject();
                obj.AddComponent(new Entity(Geometries.Sphere, ""));
                obj.SetColour(new Vector3(Randomize.RangeFloat(0f, 1f), Randomize.RangeFloat(0f, 1f), Randomize.RangeFloat(0f, 1f)));
                obj.transform.position   = new Vector3(Randomize.RangeFloat(-50f, 50f), Randomize.RangeFloat(0.5f, 50f), Randomize.RangeFloat(-50f, 50f));
                obj.transform.localScale = new Vector3(Randomize.RangeFloat(0.5f, 2f));
                obj.GetComponent <Entity>().model.reflectivity = 0.5f;
                obj.AddComponent(new RigidEntity(obj.transform.position));
                MainScene.AddGameObject(obj);
            }

            player.AddComponent(new Entity("witcher", "witcher_img"));
            player.transform.localScale = new Vector3(2, 2, 2);
            player.GetComponent <Entity>().model.hasTransparency = true;
            MainScene.AddGameObject(player);

            SunLight.gameObject.transform = new Transform(-200, 2000, -200, 0, 0, 0, 2f, 2f, 2f);
            SunLight.gameObject.AddComponent(new Entity(Geometries.Sphere));
            SunLight.gameObject.GetComponent <Entity>().model.luminosity = 1;

            MainCamera.gameObject.transform = new Transform(0, 4, 10);

            var healthbar = new GameObject();

            healthbar.AddComponent(new Sprite("healthbar"));
            healthbar.transform.position   = new Vector3(5, -10, 0);
            healthbar.transform.localScale = new Vector3(0.8f, 100f / 256f * 0.8f, 0.5f);
            healthbar.GetComponent <Sprite>().UIConstriant = UIPosition.TopLeft;
            MainScene.AddGameObject(healthbar);

            var minimap = new GameObject();

            minimap.AddComponent(new Sprite("minimap"));
            minimap.transform.position   = new Vector3(-15, -10, 0);
            minimap.transform.localScale = new Vector3(0.8f, 128f / 256f * 0.8f, 0.5f);
            minimap.GetComponent <Sprite>().UIConstriant = UIPosition.TopRight;
            MainScene.AddGameObject(minimap);

            var questText = new GameObject();

            questText.AddComponent(new Text("Ladies of the Wood", font, 6));
            questText.SetColour(new Vector3(216f / 255f, 150f / 255f, 63f / 255f));
            questText.transform.position = new Vector3(45f, -55, 0);
            questText.GetComponent <Text>().UIConstriant = UIPosition.TopRight;
            MainScene.AddGameObject(questText);

            var questDes1 = new GameObject();

            questDes1.AddComponent(new Text("Strange women lying", font, 4));
            questDes1.SetColour(new Vector3(249f / 255f, 212f / 255f, 144f / 255f));
            questDes1.transform.position = new Vector3(50f, -62, 0);
            questDes1.GetComponent <Text>().UIConstriant = UIPosition.TopRight;
            MainScene.AddGameObject(questDes1);

            var questDes2 = new GameObject();

            questDes2.AddComponent(new Text("in ponds distributing", font, 4));
            questDes2.SetColour(new Vector3(249f / 255f, 212f / 255f, 144f / 255f));
            questDes2.transform.position = new Vector3(50f, -65, 0);
            questDes2.GetComponent <Text>().UIConstriant = UIPosition.TopRight;
            MainScene.AddGameObject(questDes2);

            var questDes3 = new GameObject();

            questDes3.AddComponent(new Text("swords is no basis for", font, 4));
            questDes3.SetColour(new Vector3(249f / 255f, 212f / 255f, 144f / 255f));
            questDes3.transform.position = new Vector3(50f, -68, 0);
            questDes3.GetComponent <Text>().UIConstriant = UIPosition.TopRight;
            MainScene.AddGameObject(questDes3);

            var questDes4 = new GameObject();

            questDes4.AddComponent(new Text("a system of government", font, 4));
            questDes4.SetColour(new Vector3(249f / 255f, 212f / 255f, 144f / 255f));
            questDes4.transform.position = new Vector3(50f, -71, 0);
            questDes4.GetComponent <Text>().UIConstriant = UIPosition.TopRight;
            MainScene.AddGameObject(questDes4);

            float offset = 30;

            ProfilerScreen.AddComponent(new Sprite("grid"));
            ProfilerScreen.transform.localScale = new Vector3(0.6f, 0.2f, 0.5f);
            ProfilerScreen.transform.position   = new Vector3(0, 7 + offset, 0);
            ProfilerScreen.GetComponent <Sprite>().UIConstriant = UIPosition.Left;
            MainScene.AddGameObject(ProfilerScreen);

            text1.AddComponent(new Text("FPS", font, 8));
            text1.transform.position = new Vector3(0, -35 + offset, 0);
            text1.GetComponent <Text>().UIConstriant = UIPosition.Left;
            MainScene.AddGameObject(text1);

            text2.AddComponent(new Text("Memory", font, 8));
            text2.transform.position = new Vector3(0, -43 + offset, 0);
            text2.GetComponent <Text>().UIConstriant = UIPosition.Left;
            MainScene.AddGameObject(text2);
        }