Exemplo n.º 1
0
 /// <summary>
 /// Setzt das 3D-Hintergrundbild
 /// </summary>
 /// <param name="filename">Skybox-Textur</param>
 /// <param name="red">Rotfärbung</param>
 /// <param name="green">Grünfärbung</param>
 /// <param name="blue">Blaufärbung</param>
 /// <param name="intensity">Helligkeit</param>
 /// <param name="isFile">false, falls der Pfad Teil der EXE-Datei ist</param>
 public void SetTextureSkybox(string filename, float red = 1, float green = 1, float blue = 1, float intensity = 1, bool isFile = true)
 {
     if (GLWindow.CurrentWindow._multithreaded)
     {
         Action a = () => SetTextureSkyboxInternal(filename, red, green, blue, intensity, isFile);
         HelperGLLoader.AddCall(this, a);
     }
     else
     {
         SetTextureSkyboxInternal(filename, red, green, blue, intensity, isFile);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Setzt die Textur
 /// </summary>
 /// <param name="filename">Bilddatei</param>
 /// <param name="isFile">false, wenn die Datei Teil der EXE ist (Eingebettete Ressource)</param>
 public void SetTexture(string filename, bool isFile = true)
 {
     if (GLWindow.CurrentWindow._multithreaded)
     {
         Action a = () => SetTextureInternal(filename, isFile);
         HelperGLLoader.AddCall(this, a);
     }
     else
     {
         SetTextureInternal(filename, isFile);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Setzt das Hintergrundbild (2D)
 /// </summary>
 /// <param name="filename">Textur</param>
 /// <param name="repeatX">Wiederholung Breite</param>
 /// <param name="repeatY">Wiederholung Höhe</param>
 /// <param name="clipX">Regelt, wie viel der Bildbreite genutzt wird (1 = 100%)</param>
 /// <param name="clipY">Regelt, wie viel der Bildhöhe genutzt wird (1 = 100%)</param>
 /// <param name="isFile">false, falls der Pfad Teil der EXE-Datei ist</param>
 public void SetTextureBackground(string filename, float repeatX = 1, float repeatY = 1, float clipX = 1, float clipY = 1, bool isFile = true)
 {
     if (GLWindow.CurrentWindow._multithreaded)
     {
         Action a = () => SetTextureBackgroundInternal(filename, repeatX, repeatY, clipX, clipY, isFile);
         HelperGLLoader.AddCall(this, a);
     }
     else
     {
         SetTextureBackgroundInternal(filename, repeatX, repeatY, clipX, clipY, isFile);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Explosionskonstruktormethode
        /// </summary>
        /// <param name="position">Position der Explosion</param>
        /// <param name="particleCount">Anzahl der Partikel</param>
        /// <param name="particleSize">Größe der Partikel</param>
        /// <param name="radius">Radius der Explosion</param>
        /// <param name="durationInSeconds">Dauer der Explosion in Sekunden</param>
        /// <param name="type">Art der Explosion</param>
        /// <param name="glow">Glühfarbe der Explosion</param>
        /// <param name="texture">Textur der Explosion (optional)</param>
        public Explosion(Vector3 position, int particleCount, float particleSize, float radius, float durationInSeconds, ExplosionType type, Vector4 glow, string texture = null)
        {
            _currentWorld = GLWindow.CurrentWindow.CurrentWorld;

            if (_currentWorld == null)
            {
                throw new Exception("World is null. Cannot create Explosion in an empty world.");
            }


            if (type == ExplosionType.Cube || type == ExplosionType.CubeRingY || type == ExplosionType.CubeRingZ)
            {
                _model = KWEngine.GetModel("KWCube");
            }
            else if (type == ExplosionType.Sphere || type == ExplosionType.SphereRingY || type == ExplosionType.SphereRingZ)
            {
                _model = KWEngine.GetModel("KWSphere");
            }
            else if (type == ExplosionType.Star || type == ExplosionType.StarRingY || type == ExplosionType.StarRingZ)
            {
                _model = KWEngine.KWStar;
            }
            else if (type == ExplosionType.Heart || type == ExplosionType.HeartRingY || type == ExplosionType.HeartRingZ)
            {
                _model = (KWEngine.KWHeart);
            }
            else if (type == ExplosionType.Skull || type == ExplosionType.SkullRingY || type == ExplosionType.SkullRingZ)
            {
                _model = (KWEngine.KWSkull);
            }
            else
            {
                _model = (KWEngine.KWDollar);
            }

            _type         = type;
            Glow          = glow;
            Position      = position;
            _amount       = particleCount >= 4 && particleCount <= MAX_PARTICLES ? particleCount : particleCount < 4 ? 4 : MAX_PARTICLES;
            _spread       = radius > 0 ? radius : 10;
            _duration     = durationInSeconds > 0 ? durationInSeconds : 2;
            _particleSize = particleSize > 0 ? particleSize : 1f;

            for (int i = 0, arrayIndex = 0; i < _amount; i++, arrayIndex += 4)
            {
                if ((int)type < 100)
                {
                    int randomIndex  = HelperRandom.GetRandomNumber(0, AxesCount - 1);
                    int randomIndex2 = HelperRandom.GetRandomNumber(0, AxesCount - 1);
                    int randomIndex3 = HelperRandom.GetRandomNumber(0, AxesCount - 1);
                    _directions[arrayIndex]     = Axes[randomIndex].X;
                    _directions[arrayIndex + 1] = Axes[randomIndex2].Y;
                    _directions[arrayIndex + 2] = Axes[randomIndex3].Z;
                    _directions[arrayIndex + 3] = HelperRandom.GetRandomNumber(0.1f, 1.0f);
                }
                else if ((int)type >= 100 && (int)type < 1000)
                {
                    _directions[arrayIndex]     = 0;
                    _directions[arrayIndex + 1] = 1;
                    _directions[arrayIndex + 2] = 0;
                    _directions[arrayIndex + 3] = HelperRandom.GetRandomNumber(0.01f, 1.0f);
                }
                else
                {
                    _directions[arrayIndex]     = 0;
                    _directions[arrayIndex + 1] = 0;
                    _directions[arrayIndex + 2] = 1;
                    _directions[arrayIndex + 3] = HelperRandom.GetRandomNumber(0.01f, 1.0f);
                }
            }
            int  texId        = -1;
            bool textureFound = false;

            if (texture != null && texture.Length > 0)
            {
                textureFound = KWEngine.CustomTextures[_currentWorld].TryGetValue(texture, out texId);
            }
            if (textureFound)
            {
                _textureId = texId;
            }
            else
            {
                if (texture != null)
                {
                    Action a = () => SetTexture(texture);
                    HelperGLLoader.AddCall(this, a);
                }
            }
        }