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(); } }
protected void preInitOnScene() { soldierModel = sceneMgr.CreateEntity("Soldier" + soldierID.ToString(), "Soldier.mesh"); soldierNode = sceneMgr.RootSceneNode.CreateChildSceneNode("SoldierNode" + soldierID.ToString(), new Vector3(-1000000, -1000000, 0)); if (EngineConfig.SoundEnabled) { float rand = Math.RangeRandom(0.0f, 5.0f); if (rand >= 0 && rand < 1.0) { dieSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_SOLDIER_DIE_1, soldierNode, false, false); dieSound.SetBaseGain(3.5f); } else if (rand >= 1 && rand < 2.0) { dieSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_SOLDIER_DIE_2, soldierNode, false, false); dieSound.SetBaseGain(4.0f); } else if (rand >= 2 && rand < 3.0) { dieSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_SOLDIER_DIE_3, soldierNode, false, false); dieSound.SetBaseGain(3.0f); } else if (rand >= 3 && rand < 4.0) { dieSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_SOLDIER_DIE_4, soldierNode, false, false); dieSound.SetBaseGain(2.0f); } else { dieSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_SOLDIER_DIE_5, soldierNode, false, false); dieSound.SetBaseGain(2.0f); } dieSound.SetReferenceDistance(60); // make it a bit louder but dissapear faster // prepareToFireSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_MISSILE_LOCK, soldierNode, true, false); } soldierNode.AttachObject(soldierModel); soldierNode.Scale(1.3f, 1.35f, 1.3f); runAnimationState = soldierModel.GetAnimationState("run"); die1AnimationState = soldierModel.GetAnimationState("die1"); die2AnimationState = soldierModel.GetAnimationState("die2"); prepareToFireAnimationState = soldierModel.GetAnimationState("prepareToFire"); soldierNode.SetVisible(false); if (EngineConfig.DisplayingMinimap) { if (minimapItem == null) { minimapItem = new MinimapItem(soldierNode, framework.MinimapMgr, "Cube.mesh", new ColourValue(0.97f, 1.0f, 0.66f), soldierModel); minimapItem.ScaleOverride = new Vector2(4, 7); // stala wysokosc bunkra, niezale¿na od bounding box } minimapItem.Refresh(); minimapItem.Hide(); } }