Exemplo n.º 1
0
        public static void BubblesWaterAnimation(SceneManager sceneMgr, Vector3 pos, string baseName, int count, Vector2 range, Vector2 size)
        {
            Vector2 sizeRand;
            string  name;

            for (uint i = 0; i < count; i++)
            {
                float   h       = Mogre.Math.RangeRandom(-20, -5);
                float   angle   = Mogre.Math.RangeRandom(-10, 10);
                Vector2 rand    = ViewHelper.RandomVector2(range.x, range.y);
                Vector3 posView = new Vector3(pos.x + rand.x, pos.y + h, pos.z + rand.y);
                name = EffectsManager.BuildSpriteEffectName(sceneMgr.RootSceneNode, EffectsManager.EffectType.BUBBLES, baseName + "_bubbles_" + i);
                NodeAnimation.NodeAnimation node = EffectsManager.Singleton.GetEffect(name);
                if (!EffectsManager.Singleton.EffectExists(name) || (node != null && node.Ended))
                {
                    sizeRand = size * Math.RangeRandom(0.9f, 1.1f);
                    VisibilityNodeAnimation ani = EffectsManager.Singleton.RectangularEffect(sceneMgr, sceneMgr.RootSceneNode,
                                                                                             baseName + "_bubbles_" + i,
                                                                                             EffectsManager.EffectType.BUBBLES, posView,
                                                                                             sizeRand, new Quaternion(new Radian(new Degree(90)), Vector3.UNIT_X) * new Quaternion(new Radian(new Degree(angle)), Vector3.UNIT_Y), false);

                    ani.Duration  = Mogre.Math.RangeRandom(ani.Duration, 2 * ani.Duration);
                    ani.TimeScale = Mogre.Math.RangeRandom(0.5f, 1.5f);
                }
            }
        }
Exemplo n.º 2
0
        protected virtual void GunFireDo(Vector3 localPos, Vector2 expSize, float baseWidth)
        {
            Quaternion orient, trailOrient;

            orient       = new Quaternion(-Math.HALF_PI, Vector3.UNIT_Y);
            trailOrient  = new Quaternion(-Math.HALF_PI, Vector3.UNIT_Y);
            trailOrient *= new Quaternion(-Math.HALF_PI, Vector3.UNIT_X);



            EffectsManager.Singleton.RectangularEffect(sceneMgr, this.gunNode, "GunHit" + localPos,
                                                       EffectsManager.EffectType.GUNHIT2,
                                                       localPos, expSize,
                                                       orient, false);


            float  trailWidth = baseWidth * Math.RangeRandom(1.0f, 1.1f);
            string trailName  = EffectsManager.BuildSpriteEffectName(this.gunNode, EffectsManager.EffectType.GUNTRAIL, "GunTrail" + localPos);
            bool   showTrail  = EffectsManager.Singleton.EffectEnded(trailName) || !EffectsManager.Singleton.EffectExists(trailName);


            showTrail |= (Math.RangeRandom(0.0f, 1.0f) > 0.95f); // czasem przerwij efekt i zacznij od poczatku
            showTrail  = false;


            Vector3 trailBase = new Vector3(localPos.x, 0.0f, localPos.z - trailWidth * 0.5f);

            if (showTrail)
            {
                EffectsManager.Singleton.RectangularEffect(sceneMgr, this.gunNode, "GunTrail" + localPos,
                                                           EffectsManager.EffectType.GUNTRAIL,
                                                           trailBase - new Vector3(0, -1.0f, Math.RangeRandom(0.2f, 3.0f)),
                                                           new Vector2(trailWidth, 1.2f),
                                                           trailOrient, false);
            }

            orient      *= new Quaternion(Math.HALF_PI, Vector3.UNIT_X);
            trailOrient *= new Quaternion(Math.HALF_PI, Vector3.UNIT_X);
            EffectsManager.Singleton.RectangularEffect(sceneMgr, this.gunNode, "GunHitTop" + localPos,
                                                       EffectsManager.EffectType.GUNHIT2,
                                                       localPos, expSize,
                                                       orient, false);


            if (showTrail)
            {
                EffectsManager.Singleton.RectangularEffect(sceneMgr, this.gunNode, "GunTrailTop" + localPos,
                                                           EffectsManager.EffectType.GUNTRAIL,
                                                           trailBase - new Vector3(0, -1.0f, Math.RangeRandom(0.2f, 3.0f)),
                                                           new Vector2(trailWidth, 1.2f),
                                                           trailOrient, false);
            }
        }
Exemplo n.º 3
0
        protected void WaterSplashes(int splashesCount, LevelTile tile)
        {
            Vector2 v = UnitConverter.LogicToWorldUnits(new PointD(Mathematics.IndexToPosition(tile.TileIndex), 1.5f));
            string  name;

            for (uint i = 0; i < splashesCount; i++)
            {
                Vector2 rand    = ViewHelper.RandomVector2(8, 8);
                Vector3 posView = new Vector3(v.x + rand.x, v.y, 0 + rand.y);
                name = EffectsManager.BuildSpriteEffectName(sceneMgr.RootSceneNode, EffectsManager.EffectType.SUBMERGE, tile.GetHashCode() + "_" + i);
                if (!EffectsManager.Singleton.EffectExists(name) || EffectsManager.Singleton.EffectEnded(name))
                {
                    EffectsManager.Singleton.RectangularEffect(sceneMgr, sceneMgr.RootSceneNode,
                                                               tile.GetHashCode() + "_" + i,
                                                               EffectsManager.EffectType.SUBMERGE, posView,
                                                               new Vector2(25, 25), Quaternion.IDENTITY, false);
                }

                name = EffectsManager.BuildSpriteEffectName(sceneMgr.RootSceneNode, EffectsManager.EffectType.WATERIMPACT1, "WaterImpact1_" + tile.GetHashCode() + "_" + i);
                if (!EffectsManager.Singleton.EffectExists(name))
                {
                    EffectsManager.Singleton.WaterImpact(sceneMgr, sceneMgr.RootSceneNode, posView, new Vector2(20, 32), false, tile.GetHashCode() + "_" + i);
                }


                EffectsManager.EffectType type;
                if (((uint)tile.GetHashCode() + i) % 2 == 0)
                {
                    type = EffectsManager.EffectType.EXPLOSION2_SLOW;
                }
                else
                {
                    type = EffectsManager.EffectType.EXPLOSION1_SLOW;
                }

                name = EffectsManager.BuildSpriteEffectName(sceneMgr.RootSceneNode, type, (tile.GetHashCode() + i).ToString());
                if (!EffectsManager.Singleton.EffectExists(name))
                {
                    if (Math.RangeRandom(0, 1) > 0.8f)
                    {
                        EffectsManager.Singleton.Sprite(sceneMgr, sceneMgr.RootSceneNode, posView + ViewHelper.UnsignedRandomVector3(0, 10, 0), new Vector2(15, 15) + ViewHelper.RandomVector2(5, 5),
                                                        type, false,
                                                        (tile.GetHashCode() + i).ToString());
                    }
                }
            }
        }
Exemplo n.º 4
0
        public static void SinkingWaterAnimation(SceneManager sceneMgr, Vector3 pos, string baseName, int count, Vector2 range, Vector2 size)
        {
            string  name;
            Vector2 sizeRand;

            for (uint i = 0; i < count; i++)
            {
                Vector2 rand    = ViewHelper.RandomVector2(range.x, range.y);
                Vector3 posView = new Vector3(pos.x + rand.x, pos.y, pos.z + rand.y);
                name = EffectsManager.BuildSpriteEffectName(sceneMgr.RootSceneNode, EffectsManager.EffectType.SUBMERGE, baseName + "_" + i);
                NodeAnimation.NodeAnimation node = EffectsManager.Singleton.GetEffect(name);
                if (!EffectsManager.Singleton.EffectExists(name) || (node != null && node.getPercent() > 0.6f))
                {
                    sizeRand = size * Math.RangeRandom(0.9f, 1.1f);
                    VisibilityNodeAnimation ani = EffectsManager.Singleton.RectangularEffect(sceneMgr, sceneMgr.RootSceneNode,
                                                                                             baseName + "_" + i,
                                                                                             EffectsManager.EffectType.SUBMERGE, posView,
                                                                                             sizeRand, Quaternion.IDENTITY, false);
                    ani.Duration  = Mogre.Math.RangeRandom(ani.Duration, 2 * ani.Duration);
                    ani.TimeScale = Mogre.Math.RangeRandom(0.5f, 1.5f);
                }
            }
        }
Exemplo n.º 5
0
        public void OnShipSinking(LevelTile shipTile)
        {
            LevelTile tile = shipTile;
            Vector2   v    = UnitConverter.LogicToWorldUnits(new PointD(Mathematics.IndexToPosition(tile.TileIndex), 1.5f));
            string    name;

            SinkingWaterAnimation(sceneMgr, new Vector3(v.x, v.y, 0), tile.GetHashCode().ToString(), 3, new Vector2(6, 6), new Vector2(25, 25));
            if (!EngineConfig.LowDetails)
            {
                BubblesWaterAnimation(sceneMgr, new Vector3(v.x, v.y, 0), shipTile.GetHashCode().ToString(), 8, new Vector2(6, 6), new Vector2(6, 6));
                BubblesWaterAnimation(sceneMgr, new Vector3(v.x, v.y, 0), shipTile.GetHashCode() + "2", 8, new Vector2(10, 10), new Vector2(20, 20));
            }

            // zgaœ ogieñ - pierwotnie mia³o byæ realizowane przez LevelView.OnShipUnderWater. Z przyczyn technicznych realizowane jest tutaj
            for (uint i = 0; i < 6; i++)
            {
                name = EffectsManager.BuildSpriteEffectName(staticNode, EffectsManager.EffectType.FIRE, i.ToString());
                NodeAnimation.NodeAnimation node = EffectsManager.Singleton.GetEffect(name);
                if (node != null && node.FirstNode._getDerivedPosition().y < 0.0f)
                {
                    EffectsManager.Singleton.NoSprite(sceneMgr, staticNode, EffectsManager.EffectType.FIRE, i);
                }
            }
        }