Example #1
0
    public Effet(GameObject gameobject,GraphicEffect effet,float ofade_speed)
    {
        typeEffet = effet;

        refGameobject = gameobject;

        ofade_speed = fade_speed;
        effectEnded = false;
    }
Example #2
0
        public override void Initialize()
        {
            ReflectRS = Scene.CreateRenderSurfaceEx(-1, -1, CONST_TV_RENDERSURFACEFORMAT.TV_TEXTUREFORMAT_DEFAULT, true, true, 1);
            ReflectRS.SetBackgroundColor(Globals.RGBA(0f, 0f, 0.1906f, 1f));

            RefractRS = Scene.CreateRenderSurfaceEx(-1, -1, CONST_TV_RENDERSURFACEFORMAT.TV_TEXTUREFORMAT_DEFAULT, true, true, 1);
            RefractRS.SetBackgroundColor(Globals.RGBA(0f, 0f, 0.1906f, 1f));

            mesh = Core.Scene.CreateMeshBuilder();
            mesh.AddFloor(Helpers.GetDUDVTextureFromResource(Core, Resources.water), -256, -256, 256, 256, -3, 2, 2);
            mesh.SetPosition(Position.x, Position.y, Position.z);
            mesh.SetScale(Scale.x, Scale.y, Scale.z);

            plane = new TV_PLANE(Globals.Vector3(0, 1, 0), 3f);
            GraphicEffect.SetWaterReflection(mesh, ReflectRS, RefractRS, 0, plane);
        }
Example #3
0
 // Token: 0x06008BF8 RID: 35832 RVA: 0x0028DFE8 File Offset: 0x0028C1E8
 public void ClearGraphicEffect(GraphicEffect e)
 {
     if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_ClearGraphicEffectGraphicEffect_hotfix != null)
     {
         this.m_ClearGraphicEffectGraphicEffect_hotfix.call(new object[]
         {
             this,
             e
         });
         return;
     }
     BJLuaObjHelper.IsSkipLuaHotfix = false;
     if (this.m_graphic != null)
     {
         this.m_graphic.ClearEffect(e);
     }
 }
Example #4
0
 // Token: 0x06008BF7 RID: 35831 RVA: 0x0028DF3C File Offset: 0x0028C13C
 public void SetGraphicEffect(GraphicEffect e, float param1 = 0f, float param2 = 0f)
 {
     if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_SetGraphicEffectGraphicEffectSingleSingle_hotfix != null)
     {
         this.m_SetGraphicEffectGraphicEffectSingleSingle_hotfix.call(new object[]
         {
             this,
             e,
             param1,
             param2
         });
         return;
     }
     BJLuaObjHelper.IsSkipLuaHotfix = false;
     if (this.m_graphic != null)
     {
         this.m_graphic.SetEffect(e, param1, param2);
     }
 }
Example #5
0
        public void LoadLevel(string fileName)
        {
            // Set fade in effect
            GraphicEffect.FadeIn();
            CleanScene();
            var scenesToLoad = new Dictionary <string, bool>();

            string sceneFile = string.Empty;

            if (File.Exists(fileName))
            {
                sceneFile = fileName;
            }
            else if (File.Exists(Path.Combine(Application.StartupPath, fileName)))
            {
                sceneFile = Path.Combine(Application.StartupPath, fileName);
            }

            // First add scene file since we will generate mini map from it.
            scenesToLoad.Add(sceneFile, true);
            // Add global.xml if it exists.
            var globalScene = Path.Combine(new FileInfo(sceneFile).Directory.FullName, "global.xml");

            if (File.Exists(globalScene))
            {
                scenesToLoad.Add(globalScene, false);
            }

            foreach (var scene in scenesToLoad)
            {
                var xDoc = XDocument.Load(scene.Key);

                #region Mesh
                var meshQuery = from e in xDoc.Descendants("Objects")
                                from i in e.Descendants("Object")
                                where Helpers.GetBool(i.Element("IsAnimated").Value) == false
                                select new
                {
                    Name            = i.Element("Name").Value,
                    FileName        = i.Element("FileName").Value,
                    Visible         = Helpers.GetBool(i.Element("Visible").Value),
                    Position        = Helpers.GetVector3D(i.Element("Position").Value),
                    Rotation        = Helpers.GetVector3D(i.Element("Rotation").Value),
                    Scale           = Helpers.GetVector3D(i.Element("Scale").Value),
                    Mass            = Helpers.GetFloat(i.Element("Mass").Value),
                    StaticFriction  = Helpers.GetFloat(i.Element("StaticFriction").Value),
                    KineticFriction = Helpers.GetFloat(i.Element("KineticFriction").Value),
                    Softness        = Helpers.GetFloat(i.Element("Softness").Value),
                    Bounciness      = Helpers.GetFloat(i.Element("Bounciness").Value),
                    Bounding        = Helpers.GetBoundingType(i.Element("Bounding").Value),
                    ScriptEnabled   = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script          = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters      = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in meshQuery)
                {
                    var entity = new Mesh(Core)
                    {
                        Name            = e.Name,
                        FileName        = e.FileName,
                        Visible         = e.Visible,
                        Position        = e.Position,
                        Rotation        = e.Rotation,
                        Scale           = e.Scale,
                        Mass            = e.Mass,
                        StaticFriction  = e.StaticFriction,
                        KineticFriction = e.KineticFriction,
                        Softness        = e.Softness,
                        Bounciness      = e.Bounciness,
                        Bounding        = e.Bounding,
                        ScriptEnabled   = e.ScriptEnabled,
                        Script          = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <Mesh>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region Trigger
                var triggerQuery = from e in xDoc.Descendants("Triggers")
                                   from i in e.Descendants("Trigger")
                                   select new
                {
                    Name          = i.Element("Name").Value,
                    Position      = Helpers.GetVector3D(i.Element("Position").Value),
                    Rotation      = Helpers.GetVector3D(i.Element("Rotation").Value),
                    Scale         = Helpers.GetVector3D(i.Element("Scale").Value),
                    Color         = Helpers.GetVector3D(i.Element("Color").Value),
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in triggerQuery)
                {
                    var entity = new Trigger(Core)
                    {
                        Name          = e.Name,
                        Position      = e.Position,
                        Rotation      = e.Rotation,
                        Scale         = e.Scale,
                        Color         = Globals.RGBA(e.Color.x / 255f, e.Color.y / 255f, e.Color.z / 255f, 1),
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <Trigger>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region DirectionalLight
                var directionalLightQuery = from e in xDoc.Descendants("Lights")
                                            from i in e.Descendants("Directional")
                                            where Helpers.GetBool(i.Element("Visible").Value) == true
                                            select new
                {
                    Name          = i.Element("Name").Value,
                    Direction     = Helpers.GetVector3D(i.Element("Direction").Value),
                    Color         = Helpers.GetVector3D(i.Element("Color").Value),
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in directionalLightQuery)
                {
                    var entity = new DirectionalLight(Core)
                    {
                        Name          = e.Name,
                        Direction     = e.Direction,
                        Color         = System.Drawing.Color.FromArgb((int)e.Color.x, (int)e.Color.y, (int)e.Color.z),
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <DirectionalLight>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region PointLight
                var pointLightQuery = from e in xDoc.Descendants("Lights")
                                      from i in e.Descendants("Point")
                                      where Helpers.GetBool(i.Element("Visible").Value) == true
                                      select new
                {
                    Name          = i.Element("Name").Value,
                    Position      = Helpers.GetVector3D(i.Element("Position").Value),
                    Radius        = Helpers.GetFloat(i.Element("Radius").Value),
                    Color         = Helpers.GetVector3D(i.Element("Color").Value),
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in pointLightQuery)
                {
                    var entity = new PointLight(Core)
                    {
                        Name          = e.Name,
                        Position      = e.Position,
                        Radius        = e.Radius,
                        Color         = System.Drawing.Color.FromArgb((int)e.Color.x, (int)e.Color.y, (int)e.Color.z),
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <PointLight>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region Particle
                var particleQuery = from e in xDoc.Descendants("Particles")
                                    from i in e.Descendants("Particle")
                                    select new
                {
                    Name          = i.Element("Name").Value,
                    FileName      = i.Element("FileName").Value,
                    Position      = Helpers.GetVector3D(i.Element("Position").Value),
                    Rotation      = Helpers.GetVector3D(i.Element("Rotation").Value),
                    Scale         = Helpers.GetVector3D(i.Element("Scale").Value),
                    Visible       = Helpers.GetBool(i.Element("Visible").Value),
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in particleQuery)
                {
                    var entity = new Particle(Core)
                    {
                        Name          = e.Name,
                        FileName      = e.FileName,
                        Position      = e.Position,
                        Rotation      = e.Rotation,
                        Scale         = e.Scale,
                        Visible       = e.Visible,
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <Particle>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region Sound
                var soundQuery = from e in xDoc.Descendants("Sounds")
                                 from i in e.Descendants("Sound")
                                 select new
                {
                    Name          = i.Element("Name").Value,
                    FileName      = i.Element("FileName").Value,
                    Position      = Helpers.GetVector3D(i.Element("Position").Value),
                    Volume        = Helpers.GetFloat(i.Element("Volume").Value),
                    Stopped       = Helpers.GetBool(i.Element("Stopped").Value),
                    Loop          = Helpers.GetBool(i.Element("Loop").Value),
                    Is3D          = Helpers.GetBool(i.Element("Is3D").Value),
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in soundQuery)
                {
                    var entity = new Sound(Core)
                    {
                        Name          = e.Name,
                        FileName      = e.FileName,
                        Position      = e.Position,
                        Volume        = e.Volume * Helpers.GameSettings.FXVolume / 100f,
                        Stopped       = e.Stopped,
                        Loop          = e.Loop,
                        Is3D          = e.Is3D,
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <Sound>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region SkySphere
                var skySphereQuery = from e in xDoc.Descendants("Sky")
                                     from i in e.Descendants("SkySphere")
                                     select new
                {
                    Rotation      = Helpers.GetVector3D(i.Element("Rotation").Value),
                    Scale         = Helpers.GetVector3D(i.Element("Scale").Value),
                    PolyCount     = Helpers.GetInt(i.Element("PolyCount").Value),
                    FileName      = i.Element("Texture").Value,
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in skySphereQuery)
                {
                    var entity = new SkySphere(Core)
                    {
                        Rotation      = e.Rotation,
                        Scale         = e.Scale,
                        PolyCount     = e.PolyCount,
                        FileName      = e.FileName,
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <SkySphere>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region SkyBox
                var skyBoxQuery = from e in xDoc.Descendants("Sky")
                                  from i in e.Descendants("SkyBox")
                                  select new
                {
                    FrontTexture  = i.Element("FrontTexture").Value,
                    BackTexture   = i.Element("BackTexture").Value,
                    LeftTexture   = i.Element("LeftTexture").Value,
                    RightTexture  = i.Element("RightTexture").Value,
                    TopTexture    = i.Element("TopTexture").Value,
                    BottomTexture = i.Element("BottomTexture").Value,
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in skyBoxQuery)
                {
                    var entity = new SkyBox(Core)
                    {
                        FrontTexture  = e.FrontTexture,
                        BackTexture   = e.BackTexture,
                        LeftTexture   = e.LeftTexture,
                        RightTexture  = e.RightTexture,
                        TopTexture    = e.TopTexture,
                        BottomTexture = e.BottomTexture,
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <SkyBox>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region Water
                var waterQuery = from e in xDoc.Descendants("WaterPlanes")
                                 from i in e.Descendants("Water")
                                 select new
                {
                    Position      = Helpers.GetVector3D(i.Element("Position").Value),
                    Scale         = Helpers.GetVector3D(i.Element("Scale").Value),
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in waterQuery)
                {
                    var entity = new Water(Core)
                    {
                        Position      = e.Position,
                        Scale         = e.Scale,
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <Water>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                // Generate minimap for scene file (not global).
                if (scene.Value == true)
                {
                    var fi        = new FileInfo(scene.Key);
                    var imageFile = Path.Combine(fi.DirectoryName, fi.Name.Replace(fi.Extension, ".png"));
                    //if (!File.Exists(imageFile))
                    {
                        var minimap = Helpers.CreateMinimap(gameObjects);
                        minimap.Save(imageFile, ImageFormat.Png);
                        minimap.Dispose();
                    }
                }

                // Get some information about the scene.
                skySphereExist = gameObjects.FindAll(o => o.GetType().Equals(typeof(SkySphere))).Count > 0;
                skyBoxExist    = gameObjects.FindAll(o => o.GetType().Equals(typeof(SkyBox))).Count > 0;
                waterExists    = Helpers.GetGameObjects <Water>(gameObjects).Count > 0;
            }
        }