/// <summary> /// CreatePrefabObjectBuilder /// </summary> /// <param name="prefabCategory"></param> /// <returns></returns> public MyMwcObjectBuilder_PrefabBase CreatePrefabObjectBuilder(MyMwcObjectBuilderTypeEnum prefabType, int prefabId, MyMwcObjectBuilder_Prefab_AppearanceEnum textureEnum) { MyGameplayProperties gameplayProperties = MyGameplayConstants.GetGameplayProperties(prefabType, prefabId, MyMwcObjectBuilder_FactionEnum.Euroamerican); MyPrefabConfiguration prefabConfig = MyPrefabConstants.GetPrefabConfiguration(prefabType, prefabId); MyMwcVector3Short pos = new MyMwcVector3Short(0, 0, 0); MyMwcObjectBuilder_PrefabBase objBuilder = MyMwcObjectBuilder_Base.CreateNewObject(prefabType, prefabId) as MyMwcObjectBuilder_PrefabBase; objBuilder.PositionInContainer = pos; objBuilder.AnglesInContainer = Vector3.Zero; objBuilder.PrefabHealthRatio = MyGameplayConstants.HEALTH_RATIO_MAX; objBuilder.PrefabMaxHealth = null; objBuilder.FactionAppearance = textureEnum; objBuilder.IsDestructible = gameplayProperties.IsDestructible; if (prefabConfig.DisplayHud) { objBuilder.PersistentFlags |= MyPersistentEntityFlags.DisplayOnHud; } return(objBuilder); }
public void Init() { Init(MyModelsEnum.RemoteCamera, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Remote_Camera, MyUniversalLauncherConstants.USE_SPHERE_PHYSICS); // initialize gameplay properties here: m_gameplayProperties = MyGameplayConstants.GetGameplayProperties(MyMwcObjectBuilderTypeEnum.SmallShip_Tool, (int)MyMwcObjectBuilder_SmallShip_Tool_TypesEnum.REMOTE_CAMERA, MyMwcObjectBuilder_FactionEnum.None); Debug.Assert(m_gameplayProperties != null); if (m_gameplayProperties != null) { MaxHealth = m_gameplayProperties.MaxHealth; Health = m_gameplayProperties.MaxHealth; } //Physics.RigidBody.RaiseFlag(RigidBodyFlag.RBF_COLDET_THROUGH_VOXEL_TRIANGLES); m_canByAffectedByExplosionForce = true; UseProperties = new MyUseProperties(MyUseType.Solo, MyUseType.None, MyTextsWrapperEnum.NotificationYouCanTake); UseProperties.Init(MyUseType.Solo, MyUseType.None, 0, 1, false); }
public static MyInventoryItem CreateInventoryItemFromObjectBuilder(MyMwcObjectBuilder_Base objectBuilder, float amount) { float maxAmount = MyGameplayConstants.GetGameplayProperties(objectBuilder, MyMwcObjectBuilder_FactionEnum.Euroamerican).MaxAmount; float amountToAdd = Math.Min(maxAmount, amount); int objectBuilderId = objectBuilder.GetObjectBuilderId().HasValue ? objectBuilder.GetObjectBuilderId().Value : 0; MyGuiHelperBase guiHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(objectBuilder.GetObjectBuilderType(), objectBuilderId); MyCommonDebugUtils.AssertDebug(guiHelper != null); //warning: use default faction for get gameplay properties for inventory item MyGameplayProperties inventoryItemProperties = MyGameplayConstants.GetGameplayProperties(objectBuilder.GetObjectBuilderType(), objectBuilderId, MyMwcObjectBuilder_FactionEnum.Euroamerican); MyCommonDebugUtils.AssertDebug(inventoryItemProperties != null); MyInventoryItem item = MyInventory.InventoryItemsPool.Allocate(); item.Start(guiHelper, inventoryItemProperties, objectBuilder, amountToAdd); return(item); }
public MyMinerGame(ServiceContainer services) { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMinerGame()::constructor"); MyMwcLog.WriteLine("MyMinerGame.Constructor() - START"); MyMwcLog.IncreaseIndent(); Services = services; // we want check objectbuilders, prefab's configurations, gameplay constants and building specifications MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Checks"); MyMwcObjectBuilder_Base.Check(); MyPrefabConstants.Check(); MyGameplayConstants.Check(); MyBuildingSpecifications.Check(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("Preallocate"); Preallocate(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("IsAdmin"); WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent(); WindowsPrincipal windowsPrincipal = new WindowsPrincipal(windowsIdentity); bool IsAdmin = windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator); MyMwcLog.WriteLine("IsAdmin " + IsAdmin.ToString()); MyMwcLog.WriteLine("Game dir: " + GameDir); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyCustomGraphicsDeviceManagerDX"); #if !DEBUG try { #endif this.Exiting += MyMinerGame_Exiting; this.Activated += MyMinerGame_OnActivated; this.Deactivated += MyMinerGame_OnDeactivated; this.m_InvokeQueue = new ConcurrentQueue <Tuple <ManualResetEvent, Action> >(); this.m_MainThread = Thread.CurrentThread; GraphicsDeviceManager = new MyCustomGraphicsDeviceManagerDX(this); m_isGraphicsSupported = GraphicsDeviceManager.ChangeProfileSupport(); m_isGraphicsSupported = true; if (m_isGraphicsSupported) { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyVideoModeManager.HookEventHandlers"); MyVideoModeManager.HookEventHandlers(); //Content = new MyCustomContentManager(Services, ContentDir); // Content = new SharpDX.Toolkit.Content.ContentManager(Services); RootDirectory = Path.Combine(GameDir, "Content"); RootDirectoryDebug = Path.GetFullPath(System.IO.Path.Combine(GameDir, "..\\..\\..\\Content")); RootDirectoryEffects = RootDirectory; Static = this; MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("InitNumberOfCores"); InitNumberOfCores(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyVideoModeManager.LogApplicationInformation"); MyVideoModeManager.LogApplicationInformation(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyVideoModeManager.LogInformation"); MyVideoModeManager.LogInformation(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyVideoModeManager.LogEnvironmentInformation"); MyVideoModeManager.LogEnvironmentInformation(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyPlugins.LoadContent"); MyPlugins.LoadContent(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyConfig.Load"); MyConfig.Load(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyMath.Init"); MyMath.Init(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyTextsWrapper.Init"); MyTextsWrapper.Init(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyDialoguesWrapper.Init"); MyDialoguesWrapper.Init(); // If I don't set TargetElapsedTime, default value will be used, which is 60 times per second, and it will be more precise than if I calculate // it like below - SO I MUST BE DOING THE WRONG CALCULATION !!! // We use fixed timestep. Update() is called at this precise timesteps. If Update or Draw takes more time, Update will be called more time. Draw is called only after Update. #if RENDER_PROFILING || GPU_PROFILING IsFixedTimeStep = false; MyMinerGame.GraphicsDeviceManager.SynchronizeWithVerticalRetrace = false; #else IsFixedTimeStep = MyFakes.FIXED_TIMESTEP; #endif } MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("InitMultithreading"); InitMultithreading(); #if !DEBUG } catch (Exception ex) { // We are catching exceptions in constructor, because if error occures here, it app will start unloading // so we skip to UnloadContent and there we will get another exception (because app wasn't really loaded when unload started) // So we want original exception in log. MyMwcLog.WriteLine(ex); throw; } #endif MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); MyMwcLog.DecreaseIndent(); MyMwcLog.WriteLine("MyMinerGame.Constructor() - END"); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); }
private void AnnounceGame() { if (!Peers.IsConnectedToServer) { try { Peers.NetworkClient.RemoveCallback <MyEventLoginResponse>(); Peers.NetworkClient.RemoveCallback <MyEventCreateGameResponse>(); LastCreateGameRequest.JoinMode = JoinMode; LastCreateGameRequest.SectorName = MyGuiScreenGamePlay.Static.GetGameName(GameType, MyGameplayConstants.GetGameplayDifficulty()); Peers.SendServer(ref LastCreateGameRequest); } catch { } } }
protected override void ProgressStart() { //MyClientServer.SendMessageStartSessionRequest(m_sessionType, m_sectorIdentifier, m_difficulty); MyGameplayConstants.SetGameplayDifficulty(m_difficulty); }
/// <summary> /// Initializes a new instance of the <see cref="MySession"/> class. /// </summary> public MySinglePlayerSession(MyGameplayDifficultyEnum difficulty) { MyGameplayConstants.SetGameplayDifficulty(difficulty); }
private StringBuilder GetGameType(MyGameInfo gameInfo) { switch (gameInfo.GameType) { case MyGameTypes.Story: return(new StringBuilder(MyTextsWrapper.Get(MyTextsWrapperEnum.Story) + " (" + MyTextsWrapper.Get(MyGameplayConstants.GetGameplayDifficultyProfile(gameInfo.Difficulty).DifficultyName) + ")")); break; case MyGameTypes.Deathmatch: return(MyTextsWrapper.Get(MyTextsWrapperEnum.Deathmatch)); break; default: return(MyTextsWrapper.Get(MyTextsWrapperEnum.UNKNOWN)); break; } }
// This method realy initiates/starts the missile // IMPORTANT: Direction vector must be normalized! public void Start(Vector3 position, Vector3 initialVelocity, Vector3 directionNormalized, MyMwcObjectBuilder_SmallShip_Ammo usedAmmo, MySmallShip minerShip) { m_usedAmmo = usedAmmo; m_ammoProperties = MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType); m_gameplayProperties = MyGameplayConstants.GetGameplayProperties(m_usedAmmo, Faction); m_penetratedVoxelMap = null; m_wasPenetration = false; m_hasExplosion = false; m_isExploded = false; m_collidedEntity = null; m_collisionPoint = null; Matrix orientation = GetWorldRotation(); Vector3 pos = position; // Play missile thrust cue (looping) m_thrusterCue = MyAudio.AddCue3D(MySoundCuesEnum.WepMissileFly, pos, orientation.Forward, orientation.Up, this.Physics.LinearVelocity); m_light = MyLights.AddLight(); if (m_light != null) { m_light.Start(MyLight.LightTypeEnum.PointLight, GetPosition(), MyMissileHelperUtil.GetCannonShotLightColor(), 1, MyMissileConstants.MISSILE_LIGHT_RANGE); } m_diffuseColor = m_ammoProperties.TrailColor; switch (usedAmmo.AmmoType) { case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic: case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_High_Speed: case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Armor_Piercing_Incendiary: case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_SAPHEI: case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Proximity_Explosive: m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION; break; case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_BioChem: m_explosionType = MyExplosionTypeEnum.BIOCHEM_EXPLOSION; break; case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_EMP: m_explosionType = MyExplosionTypeEnum.EMP_EXPLOSION; break; case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster: m_explosionType = MyExplosionTypeEnum.BLASTER_EXPLOSION; break; default: throw new MyMwcExceptionApplicationShouldNotGetHere(); break; } this.Physics.Mass = m_gameplayProperties.WeightPerUnit; Vector3?correctedDirection = null; if (MyGameplayConstants.GameplayDifficultyProfile.EnableAimCorrection) { if (minerShip == MinerWars.AppCode.Game.Managers.Session.MySession.PlayerShip) { correctedDirection = MyEntities.GetDirectionFromStartPointToHitPointOfNearestObject(minerShip, position, m_ammoProperties.MaxTrajectory); } } if (correctedDirection != null) { directionNormalized = correctedDirection.Value; } base.Start(position, initialVelocity, directionNormalized, m_ammoProperties.DesiredSpeed, minerShip); if (correctedDirection != null) //override the base class behaviour, update the missile direction { Matrix ammoWorld = minerShip.WorldMatrix; ammoWorld.Translation = position; ammoWorld.Forward = correctedDirection.Value; SetWorldMatrix(ammoWorld); } m_smokeEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_CannonShot); m_smokeEffect.AutoDelete = false; m_smokeEffect.WorldMatrix = WorldMatrix; }
/// <summary> /// All weapons cheat implementation /// </summary> static void AllWeaponsEnabled(MyGameplayCheat cheat) { if (MySession.PlayerShip == null) { return; } List <MyMwcObjectBuilder_SmallShip_Weapon> weapons = new List <MyMwcObjectBuilder_SmallShip_Weapon>(); List <MyMwcObjectBuilder_AssignmentOfAmmo> ammoAssignment = new List <MyMwcObjectBuilder_AssignmentOfAmmo>(); List <MyMwcObjectBuilder_InventoryItem> inventoryItems = new List <MyMwcObjectBuilder_InventoryItem>(); // weapons foreach (MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum weapon in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum))) { weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(weapon)); // we want have 2x autocanon if (weapon == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon) { weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(weapon)); } } // ammo assignment ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic)); ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, MyMwcObjectBuilder_AmmoGroupEnum.Missile, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic)); ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Third, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherFront, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic)); ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fourth, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherBack, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart)); ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fifth, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic)); MySession.PlayerShip.Weapons.Init(weapons, ammoAssignment); foreach (MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammo in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum))) { MyMwcObjectBuilder_InventoryItem item = new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(ammo), MyGameplayConstants.GetGameplayProperties(MyMwcObjectBuilderTypeEnum.SmallShip_Ammo, (int)ammo, MySession.PlayerShip.Faction).MaxAmount); if (!MySession.PlayerShip.Inventory.IsFull) { MySession.PlayerShip.Inventory.AddInventoryItem(MyInventory.CreateInventoryItemFromInventoryItemObjectBuilder(item)); } } }