Exemplo n.º 1
0
 public VA_SummonPlayer(VisualEntity visual, Color color)
 {
     Frames = DefaultFrames;
     Visual = visual;
     Visual.GetComponent <Renderer>().material.color = color;
     Visual.transform.localScale = new Vector3(0, 0, 0);
 }
Exemplo n.º 2
0
    public VA_HealSelf(VisualEntity visual, int amount)
    {
        Frames      = DefaultFrames * 1.5f;
        Visual      = visual;
        SourceColor = Visual.GetComponent <Renderer>().material.color;

        BobExtraScale  = 1 + ((float)amount / 10);
        BobSourceScale = Visual.transform.localScale;
        BobTargetScale = new Vector3(BobSourceScale.x * BobExtraScale, BobSourceScale.y * BobExtraScale, BobSourceScale.z * BobExtraScale);
    }
Exemplo n.º 3
0
 public override void OnStart()
 {
     base.OnStart();
     Visual.GetComponent <Renderer>().material.color = Color.yellow;
 }
Exemplo n.º 4
0
        static void InitializeGame()
        {
            mats = new Material[]
            {
                Material.FromJSON(Settings.MaterialDirPath + "\\rustediron.mat.json"),
                Material.FromJSON(Settings.MaterialDirPath + "\\iron.mat.json"),
                Material.FromJSON(Settings.MaterialDirPath + "\\granite.mat.json"),
                Material.FromJSON(Settings.MaterialDirPath + "\\grass.mat.json"),
                Material.FromJSON(Settings.MaterialDirPath + "\\redplastic.mat.json")
            };

            uint skyTex = Texture.LoadHDR(Settings.TextureDirPath + "\\sky2.hdr", true);
            uint skyEnv = Texture.LoadHDR(Settings.TextureDirPath + "\\skyenv2.hdr");

            uint       tex    = Texture.FromColor(Color.FromHex("#7FFF00"));
            StaticMesh crate1 = new StaticMesh(Settings.ModelsDirPath + "\\Crate1.obj");
            StaticMesh crate2 = new StaticMesh(Settings.ModelsDirPath + "\\Crate1.obj");

            Material material = new Material("phong");

            material.SetUniform(0, tex);
            Material material2 = new Material("phong");

            material2.SetUniform(0, tex);
            Material material3 = new Material("phong");

            material3.SetUniform(0, tex);
            Material material4 = Material.FromJSON(Settings.MaterialDirPath + "\\rustediron.mat.json");
            Material material5 = Material.FromJSON(Settings.MaterialDirPath + "\\iron.mat.json");

            VisualEntity crate1Ent = new VisualEntity(crate1, material4);
            VisualEntity crate2Ent = new VisualEntity(crate2, material5);

            sun = Entity.NewWithComponent(out DirectionalLight sunLight);
            sunLight.Direction = new Vector3(1f, 0.8f, 0.5f);

            var catTrans = crate1Ent.GetComponent <Transform>();

            catTrans.Position += Vector3.UnitY * -10f + Vector3.UnitX * -5f;
            catTrans.Scale    *= 1f;

            Entity camEnt = Entity.NewWithComponent(out PerspectiveCamera camera);

            camEnt.AddComponent <CameraController>();
            Camera.Main     = camera;
            camera.Position = new Vector3(0f, 0f, 20f);
            camera.FarPlane = 512f;

            mWorld = WorldManager.CreateWorld();
            mWorld.skySettings.SetColor(Color.GRAY);
            mWorld.skySettings.gamma    = 2.2f;
            mWorld.skySettings.exposure = 16f;
            mWorld.skySettings.ambient  = 0.2f;
            mWorld.skySettings.hdrTex   = skyTex;
            mWorld.skySettings.hdrEnv   = skyEnv;

            phys = mWorld.PhysicsWorld;
            //phys.Gravity = new Vector3(0f, -2f, 0f);

            var crateBody = phys.CreateRigidBody(crate1Ent.Transform.Position);

            crateBody.AddCollisionShape(new BoxShape(1.1f));
            crate1Ent.AddComponent(crateBody);

            var crate2Body = phys.CreateRigidBody(crate2Ent.Transform.Position);

            crate2Body.AddCollisionShape(new BoxShape(1.1f));
            crate2Ent.AddComponent(crate2Body);

            mWorld.AddEntity(camEnt);
            mWorld.AddEntity(sun);
            mWorld.AddEntity(crate1Ent);
            mWorld.AddEntity(crate2Ent);

            // for now just keep the music in Models directory
            AudioClip clip  = new AudioClip(Settings.ModelsDirPath + "\\ChillingMusic.wav");
            Entity    music = new Entity();

            music.AddComponent(clip);
            mWorld.AddEntity(music);
            clip.Play();
            clip.Looped = true;

            shotSound = new AudioClip(Settings.ModelsDirPath + "\\shot.wav");

            visuals = new VisualEntity[50];
            for (int i = 0; i < visuals.Length; i++)
            {
                StaticMesh m = new StaticMesh(Settings.ModelsDirPath + "\\Crate1.obj");
                visuals[i] = new VisualEntity(m, mats[i % mats.Length]);
                VisualEntity visual = visuals[i];
                visual.Transform.Position = Random.UnitSphere * 20;
                var bdy = phys.CreateRigidBody(visual.Transform.Position);
                bdy.AddCollisionShape(new BoxShape(1.1f));
                visual.AddComponent(bdy);

                var cb        = phys.CreateCollisionBody(visual.Transform.Position);
                var trigShape = new BoxShape(1.6f, true);
                trigShape.CollisionEvent += TrigShape_CollisionEvent;
                cb.AddCollisionShape(trigShape);
                visual.AddComponent(cb);

                mWorld.AddEntity(visual);
            }

            StaticMesh   floor       = new StaticMesh(Settings.ModelsDirPath + "\\Crate1.obj");
            Material     floorMat    = Material.FromJSON(Settings.MaterialDirPath + "\\mahogfloor.mat.json");
            VisualEntity floorVisual = new VisualEntity(floor, floorMat);

            floorVisual.Transform.Position = new Vector3(0f, -30f, 0f);
            floorVisual.Transform.Scale    = new Vector3(100f, 0.2f, 100f);

            var floorBody = phys.CreateRigidBody(floorVisual.Transform.Position, floorVisual.Transform.Rotation);

            floorBody.AddCollisionShape(new BoxShape(50f, 0.1f, 50f));
            floorBody.Type = BodyType.Static;
            floorVisual.AddComponent(floorBody);
            mWorld.AddEntity(floorVisual);

            Entity iblEnt = Entity.NewWithComponent(out IBLProbe iblProbe);

            iblProbe.Position = Vector3.Zero;
            mWorld.AddEntity(iblEnt);

            EventManager.UpdateEvent += Update;
        }