Exemple #1
0
        /// <summary>
        /// Statek jest pod powierzchnią wody
        /// </summary>
        /// <param name="tile"></param>
        //void OnShipUnderWater(ShipTile tile);


        /// <summary>
        /// Statek zatonął
        /// </summary>
        /// <param name="tile"></param>
        public void OnShipSunk(BeginShipTile tile)
        {
            AddJob(MethodBase.GetCurrentMethod().Name, new object[] { tile });
        }
Exemple #2
0
        protected override void initOnScene()
        {
            String meshName; //Nazwa modelu


            positionNode = sceneMgr.CreateSceneNode(mainNode.Name + "Static");



            //       float maxX = (Math.Abs(count) - 1) * LevelView.TileWidth / 16;


            if (tileViews != null)
            {
                positionNode.Translate(new Vector3(UnitConverter.LogicToWorldUnits(tileViews[0].LevelTile.TileIndex), -(tileViews[0].LevelTile as ShipTile).Depth, 0));
                positionNode.SetDirection(Vector3.UNIT_X);
            }


            animationNode = positionNode.CreateChildSceneNode(mainNode.Name + "Animation");
            staticNode    = animationNode.CreateChildSceneNode(mainNode.Name + "StaticNode");

            Vector3 localTranslation;
            Vector3 batteryBasePositon;



            mainNode.AddChild(positionNode);

            TypeOfEnemyShip type;

            if (backgroundDummy)
            {
                type = backgroundDummyShipType;
            }
            else
            {
                BeginShipTile begin = tileViews[0].LevelTile as BeginShipTile;
                type = begin.TypeOfEnemyShip;
            }

            switch (type)
            {
            case TypeOfEnemyShip.PatrolBoat:
                meshName           = "PatrolBoat.mesh";
                batteryBasePositon = new Vector3(0, 8.5f, -18.0f);
                localTranslation   = Vector3.ZERO;
                buildFloatAnimation(animationNode, 10, false);
                break;

            case TypeOfEnemyShip.WarShip:
                meshName           = "Warship.mesh";
                batteryBasePositon = new Vector3(0, 14.5f, -50.0f);
                localTranslation   = Vector3.ZERO;
                buildFloatAnimation(animationNode, 10, true);
                break;

            case TypeOfEnemyShip.Submarine:
                meshName           = "Submarine.mesh";
                batteryBasePositon = new Vector3(0, 8.5f, -18.0f);
                localTranslation   = new Vector3(0, 0, -15);   // okret ma srodek ciezkosci w srodku zeby animacja fajniej wygladala. Trzeba przesunac

                if (!EngineConfig.UseHydrax)
                {
                    localTranslation = new Vector3(0, 3.0f, 0);     // woda nie jest przezroczysta wiec nie widac drania
                }
                buildFloatAnimation(animationNode, 10, false);
                break;

            default:
                return;
            }

            compositeModel             = sceneMgr.CreateEntity(name, meshName);
            compositeModel.CastShadows = EngineConfig.ShadowsQuality > 0;
            staticNode.AttachObject(compositeModel);
            staticNode.Translate(localTranslation);
            float dist;

            if (backgroundDummy)
            {
                switch (type)
                {
                case TypeOfEnemyShip.PatrolBoat:
                    dist = UnitConverter.RandomGen.NextDouble() >= 0.5 ? -200.0f : 50.0f;
                    mainNode.Translate(new Vector3(dist, -1.5f, UnitConverter.LogicToWorldUnits(firstTileIndex) + 160));
                    break;

                case TypeOfEnemyShip.Submarine:
                    dist = UnitConverter.RandomGen.NextDouble() >= 0.5 ? -100.0f : 40.0f;
                    mainNode.Translate(new Vector3(dist, -4, UnitConverter.LogicToWorldUnits(firstTileIndex) + 120));
                    break;

                case TypeOfEnemyShip.WarShip:
                    dist = -700.0f;
                    mainNode.Translate(new Vector3(dist, -2, UnitConverter.LogicToWorldUnits(firstTileIndex) + 300));
                    break;
                }

                return;
            }

            bool rocketBatterySet = false;

            // elementy na statku sa animowalne wiec nie beda w static geometry
            count = tileViews.Count;
            for (int i = 0; i < count; i++)
            {
                tileViews[i].initOnScene(positionNode, i + 1, tileViews.Count);


                if (!rocketBatterySet && (tileViews[i] is ShipBunkerTileView) && (tileViews[i] as ShipBunkerTileView).HasRockets)
                {
                    rocketBatterySet = true;
                    for (int k = -3; k <= 3; k++)
                    {
                        Entity    rocketBatteryEntity = sceneMgr.CreateEntity(name + "_RocketBattery" + k, "Bazooka.mesh");
                        SceneNode rocketBatteryNode   = staticNode.CreateChildSceneNode(rocketBatteryEntity.Name + "Node", batteryBasePositon + new Vector3(k * 0.4f, 0, 0));
                        rocketBatteryNode.SetScale(3, 3, 3);
                        rocketBatteryNode.Pitch(new Radian(new Degree(30)));
                        rocketBatteryNode.AttachObject(rocketBatteryEntity);
                    }
                }
            }

            string soundFile = SoundManager3D.C_SHIP_SINKING;

            if (Mogre.Math.RangeRandom(0, 1) > 0.5f)
            {
                soundFile = SoundManager3D.C_SHIP_SINKING_2;
            }
            dieSound = SoundManager3D.Instance.CreateSoundEntity(soundFile, mainNode, false, false);
            dieSound.SetBaseGain(0.25f);

            submergingSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_SHIP_SUBMERGING, mainNode, false, false);
            submergingSound.SetBaseGain(0.25f);

            emergingSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_SHIP_EMERGING, mainNode, false, false);
            emergingSound.SetBaseGain(0.25f);


            // minimapa
            if (EngineConfig.DisplayingMinimap)
            {
                minimapItem =
                    new MinimapItem(staticNode, framework.MinimapMgr, "ShipMinimap.mesh",
                                    new ColourValue(0.092f, 0.262f, 0.49f), compositeModel);

                minimapItem.ScaleOverride = new Vector2(0, 15); // stala wysokosc, niezale¿na od bounding box
                minimapItem.Refresh();
            }
        }
 public void OnShipSunk(BeginShipTile tile)
 {
 }