Пример #1
0
 public void OnLoadLastCheckpointClick(MyGuiControlButton sender)
 {
     MyMwcLog.WriteLine("OnLoadLastCheckpointClick - Start");
     MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);
     MySession.StartLastCheckpoint();
     MyMwcLog.WriteLine("OnLoadLastCheckpointClick - End");
 }
Пример #2
0
        private MyGuiScreenLoading JoinMultiplayerSession(MyGameTypes gameType, MyMwcObjectBuilder_Checkpoint checkpoint)
        {
            MyMultiplayerGameplay.Static.IsHost = false;
            //var checkpoint = MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.Checkpoint, null) as MyMwcObjectBuilder_Checkpoint;

            // This is just dummy ship for load
            //var ship = MyMwcObjectBuilder_SmallShip_Player.CreateDefaultShip(MyMwcObjectBuilder_SmallShip_TypesEnum.GETTYSBURG, MySession.Static.Player.Faction);
            MySession.Static.Player.Faction = checkpoint.PlayerObjectBuilder.ShipObjectBuilder.Faction;

            MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);

            MyGuiScreenGamePlayType?         gameplayType = null;
            MyMwcStartSessionRequestTypeEnum?sessionType  = null;

            switch (gameType)
            {
            case MyGameTypes.Story:
                gameplayType = MyGuiScreenGamePlayType.GAME_STORY;
                sessionType  = MyMwcStartSessionRequestTypeEnum.JOIN_FRIEND_STORY;
                break;

            case MyGameTypes.Deathmatch:
                gameplayType = MyGuiScreenGamePlayType.GAME_SANDBOX;
                sessionType  = MyMwcStartSessionRequestTypeEnum.SANDBOX_FRIENDS;
                break;

            default:
                break;
            }

            return(MyGuiScreenGamePlay.ReloadGameplayScreen(checkpoint, sessionType, gameplayType));
        }
Пример #3
0
        public override void OnOkClick(MyGuiControlButton sender)
        {
            base.OnOkClick(sender);

            PrefabContainer.AlarmOn = m_alarmOn.Checked;
            PrefabContainer.Activate(m_activatedCheckbox.Checked, false);

            MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);
        }
 public override void OnOkClick(MyGuiControlButton sender)
 {
     base.OnOkClick(sender);
     foreach (var v in m_waypoints)
     {
         v.IsSecret = m_secretCheckbox.Checked;
     }
     MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);
 }
        public override void OnOkClick(MyGuiControlButton sender)
        {
            base.OnOkClick(sender);

            Scanner.ReinitScanningPart();
            Scanner.Enabled = m_onCheckbox.Checked;
            Scanner.Activate(m_activatedCheckbox.Checked, false);

            // close all opened screens except gameplay
            MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);
        }
        private void LoadCheckpoint()
        {
            var item = m_listbox.GetSelectedItem();

            if (item != null)
            {
                MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);

                MySession.StartTemplateCheckpoint(GetCheckpointNameFromItem(item));
            }
        }
        public override void OnOkClick(MyGuiControlButton sender)
        {
            base.OnOkClick(sender);

            if (PrefabKinematic.CanOpen != m_on.Checked)
            {
                PrefabKinematic.CanOpen = m_on.Checked;
            }

            MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);
        }
        public override void OnOkClick(MyGuiControlButton sender)
        {
            base.OnOkClick(sender);

            if (HasEntity())
            {
                if (m_changeMaterial.Checked)
                {
                    m_entity.VoxelMaterial = ((MyMwcVoxelMaterialsEnum)m_selectVoxelMapMaterialCombobox.GetSelectedKey());
                }

                float x, y, z;
                if (float.TryParse(m_positionX.Text, out x) && float.TryParse(m_positionY.Text, out y) && float.TryParse(m_positionZ.Text, out z))
                {
                    m_entity.SetPosition(new Vector3(x, y, z));
                }
            }
            else
            {
                if (GetAsteroidType() == MyGuiAsteroidTypesEnum.VOXEL)
                {
                    MyMwcObjectBuilder_SmallShip_TypesEnum shipType = (MyMwcObjectBuilder_SmallShip_TypesEnum)
                                                                      Enum.ToObject(typeof(MyMwcObjectBuilder_SmallShip_TypesEnum), m_selectVoxelMapCombobox.GetSelectedKey());
                    MyMwcVoxelFilesEnum voxelFileEnum = (MyMwcVoxelFilesEnum)
                                                        Enum.ToObject(typeof(MyMwcVoxelFilesEnum), m_selectVoxelMapCombobox.GetSelectedKey());
                    MyMwcVoxelMaterialsEnum materialEnum = (MyMwcVoxelMaterialsEnum)
                                                           Enum.ToObject(typeof(MyMwcVoxelMaterialsEnum), m_selectVoxelMapMaterialCombobox.GetSelectedKey());

                    MyMwcObjectBuilder_VoxelMap voxelMapBuilder = MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.VoxelMap, null) as MyMwcObjectBuilder_VoxelMap;
                    voxelMapBuilder.VoxelMaterial = materialEnum;
                    voxelMapBuilder.VoxelFile     = voxelFileEnum;
                    MyEditor.Static.CreateFromObjectBuilder(voxelMapBuilder, Matrix.CreateWorld(m_newObjectPosition, Vector3.Forward, Vector3.Up), m_screenPosition);
                }
                else if (GetAsteroidType() == MyGuiAsteroidTypesEnum.STATIC)
                {
                    MyMwcObjectBuilder_StaticAsteroid_TypesEnum staticAsteroidType = (MyMwcObjectBuilder_StaticAsteroid_TypesEnum)
                                                                                     Enum.ToObject(typeof(MyMwcObjectBuilder_StaticAsteroid_TypesEnum), m_selectVoxelMapCombobox.GetSelectedKey());

                    MyMwcVoxelMaterialsEnum?materialEnum = null;
                    int materialKey = m_selectVoxelMapMaterialCombobox.GetSelectedKey();
                    if (materialKey != -1)
                    {
                        materialEnum = (MyMwcVoxelMaterialsEnum)Enum.ToObject(typeof(MyMwcVoxelMaterialsEnum), materialKey);
                    }

                    MyMwcObjectBuilder_StaticAsteroid staticAsteroidBuilder = new MyMwcObjectBuilder_StaticAsteroid(staticAsteroidType, materialEnum);
                    MyEditor.Static.CreateFromObjectBuilder(staticAsteroidBuilder, Matrix.CreateWorld(m_newObjectPosition, Vector3.Forward, Vector3.Up), m_screenPosition);
                }
            }

            MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);
        }
        public override void OnOkClick(MyGuiControlButton sender)
        {
            base.OnOkClick(sender);

            Debug.Assert(m_radiusSlider.GetValue() > 30 || m_bots.Count <= 1, "Spawnpoint radius is too small, you will probably get failed spawn attempts!");

            if (!HasEntity())
            {
                MyMwcObjectBuilder_SpawnPoint builder = MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.SpawnPoint, null) as MyMwcObjectBuilder_SpawnPoint;
                builder.BoundingRadius = m_radiusSlider.GetValue();

                float cameraDistance = builder.BoundingRadius / (float)Math.Sin(MathHelper.ToRadians(MyCamera.FieldOfViewAngle / 2)) * 1.2f;

                m_spawnPoint = MyEntities.CreateFromObjectBuilderAndAdd(null, builder, Matrix.CreateWorld(MyCamera.Position + cameraDistance * MyCamera.ForwardVector, Vector3.Forward, Vector3.Up)) as MySpawnPoint;
            }

            MyMwcObjectBuilder_FactionEnum shipFaction = (MyMwcObjectBuilder_FactionEnum)
                                                         Enum.ToObject(typeof(MyMwcObjectBuilder_FactionEnum), m_selectShipFactionCombobox.GetSelectedKey());

            List <BotTemplate> templates = new List <BotTemplate>();

            foreach (int key in m_bots.Keys)
            {
                BotTemplate btmp;
                m_bots.TryGetValue(key, out btmp);
                btmp.m_builder.Faction = shipFaction;
                templates.Add(btmp);
            }

            m_spawnPoint.SpawnInGroups   = m_spawnInGroupsCheckbox.Checked;
            m_spawnPoint.LeftToSpawn     = GetSpawnCount();
            m_spawnPoint.MaxSpawnCount   = m_spawnPoint.LeftToSpawn;
            m_spawnPoint.FirstSpawnTimer = m_firstSpawnTimeSlider.GetValue();
            m_spawnPoint.RespawnTimer    = m_respawnTimeSlider.GetValue();

            m_spawnPoint.Faction = shipFaction;
            m_spawnPoint.SetWayPointPath(m_waypointPathCombobox.GetSelectedValue().ToString());
            m_spawnPoint.PatrolMode = (MyPatrolMode)m_patrolModeCombobox.GetSelectedKey();
            m_spawnPoint.ApplyBotTemplates(templates);

            m_spawnPoint.BoundingSphereRadius = m_radiusSlider.GetValue();
            if (m_activeCheckbox.Checked && !m_spawnPoint.IsActive())
            {
                m_spawnPoint.Activate();
            }
            else if (!m_activeCheckbox.Checked && m_spawnPoint.IsActive())
            {
                m_spawnPoint.Deactivate();
            }

            MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);
        }
Пример #10
0
        public override void OnOkClick(MyGuiControlButton sender)
        {
            if (m_respawnPoint.Checked && m_respawnPointCombo.GetSelectedKey() == (int)MyMwcObjectBuilder_FactionEnum.None)
            {
                MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.PleaseSelectValidFaction, MyTextsWrapperEnum.InvalidFaction, MyTextsWrapperEnum.Ok, null));
                return;
            }

            base.OnOkClick(sender);
            DummyPoint.Activate(m_activatedCheckbox.Checked, false);
            // close all opened screens except gameplay
            MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);
        }
 public void Run()
 {
     MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);
     try
     {
         StartNewGame();
     }
     catch (MyDataCorruptedException e)
     {
         MyMwcLog.WriteLine(e);
         MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.LocalDataCorrupted, MyTextsWrapperEnum.Error, OnErrorClose));
     }
 }
Пример #12
0
        private void LoadCheckpoint()
        {
            var item = m_listbox.GetSelectedItem();

            if (item != null && m_chapters.Count >= item.Key)
            {
                MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);

                string chapterName = m_chapters[item.Key].Item1; // TODO: dont construct the name, just take it from some array
                MinerWars.AppCode.Networking.MyLocalCache.ReplaceCurrentChapter(chapterName);
                MySession.StartLastCheckpoint();
            }
        }
Пример #13
0
 public override void OnOkClick(MyGuiControlButton sender)
 {
     base.OnOkClick(sender);
     foreach (MyPrefabLargeWeapon prefabLargeWeapon in m_prefabLargeWeapons)
     {
         prefabLargeWeapon.SearchingDistance = m_searchingDistance.GetValue();
         if (prefabLargeWeapon.Enabled != m_on.Checked)
         {
             prefabLargeWeapon.Enabled = m_on.Checked;
         }
         prefabLargeWeapon.Activate(m_activatedCheckbox.Checked, false);
     }
     MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);
 }
Пример #14
0
        public override void OnOkClick(MyGuiControlButton sender)
        {
            base.OnOkClick(sender);

            Prefab.Enabled = m_on.Checked;

            int  alarmKey    = m_alarmComboBox.GetSelectedKey();
            bool?causesAlarm = null;

            if (alarmKey == 1)
            {
                causesAlarm = true;
            }
            else if (alarmKey == 2)
            {
                causesAlarm = false;
            }
            Prefab.SetCausesAlarm(causesAlarm);

            Prefab.Activate(m_activatedCheckbox.Checked, false);

            MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);
        }
 void OnTravelToAnywhere(MyMwcVector3Int sector)
 {
     MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);
     m_sectorToTravel = sector;
     MyGuiScreenMainMenu.AddLoginScreenDrmFree(new Action(TravelToSectorCallback));
 }
        void ValidateAllMissionsStartingFrom(int index)
        {
            var allMissions = MyMissions.Missions.Values.OfType <MyMission>().ToList();

            if (index >= allMissions.Count)
            {
                return;
            }

            var         mission   = allMissions[index];
            MyMissionID missionId = mission.ID;

            // each mission is automatically validated after start
            MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);

            var startSessionScreen = new MyGuiScreenStartSessionProgress(MyMwcStartSessionRequestTypeEnum.NEW_STORY,
                                                                         MyTextsWrapperEnum.StartGameInProgressPleaseWait, null, MyGameplayDifficultyEnum.EASY, null, null);

            startSessionScreen.OnSuccessEnter = new Action <MyGuiScreenGamePlayType, MyMwcStartSessionRequestTypeEnum, MyMwcObjectBuilder_Checkpoint>((screenType, sessionType, checkpoint) =>
            {
                Action <MyMwcObjectBuilder_Sector, Vector3> enterSuccessAction = new Action <MyMwcObjectBuilder_Sector, Vector3>((sector, newPosition) =>
                {
                    MyMwcVector3Int sectorPosition;
                    sectorPosition = sector.Position;

                    MyMwcSectorIdentifier newSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.STORY, MyClientServer.LoggedPlayer.GetUserId(), sectorPosition, null);
                    var newScreen          = new MyGuiScreenGamePlay(MyGuiScreenGamePlayType.GAME_STORY, null, newSectorIdentifier, sector.Version, MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT);
                    var loadScreen         = new MyGuiScreenLoading(newScreen, MyGuiScreenGamePlay.Static);
                    newScreen.OnGameReady += new ScreenHandler((screen) =>
                    {
                        ((MyMission)MyMissions.GetMissionByID(missionId)).Accept();
                        ValidateAllMissionsStartingFrom(index + 1);  // validate the next mission
                    });

                    loadScreen.AnnounceLeaveToServer = true;
                    loadScreen.LeaveSectorReason     = MyMwcLeaveSectorReasonEnum.TRAVEL;

                    // Current sector and sector object builder has changed
                    checkpoint.ActiveMissionID = -1;          // Manually deactivate mission
                    checkpoint.PlayerObjectBuilder.ShipObjectBuilder.PositionAndOrientation.Position = newPosition;
                    checkpoint.EventLogObjectBuilder.Clear(); // Or just clear mission start/finish

                    // Make prereq missions completed
                    foreach (var prereq in mission.RequiredMissions)
                    {
                        var start = new MyEventLogEntry()
                        {
                            EventType = EventTypeEnum.MissionStarted, EventTypeID = (int)prereq
                        }.GetObjectBuilder();
                        var end = new MyEventLogEntry()
                        {
                            EventType = EventTypeEnum.MissionFinished, EventTypeID = (int)prereq
                        }.GetObjectBuilder();
                        checkpoint.EventLogObjectBuilder.Add(start);
                        checkpoint.EventLogObjectBuilder.Add(end);
                    }

                    checkpoint.SectorObjectBuilder    = sector;
                    checkpoint.CurrentSector.Position = sector.Position;
                    loadScreen.AddEnterSectorResponse(checkpoint, missionId);

                    MyGuiManager.AddScreen(loadScreen);

                    if (MyMinerGame.IsPaused())
                    {
                        MyMinerGame.SwitchPause();
                    }
                });

                //  Load neighbouring sector
                MyGuiManager.AddScreen(new MyGuiScreenEnterSectorProgress(MyMwcTravelTypeEnum.SOLAR, mission.Location.Sector, Vector3.Zero, enterSuccessAction));

                //var newGameplayScreen = new MyGuiScreenGamePlay(screenType, null, checkpoint.CurrentSector, sessionType);
                //var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static);

                //loadScreen.AddEnterSectorResponse(checkpoint);
                //MyGuiManager.AddScreen(loadScreen);
            });

            MyGuiManager.AddScreen(startSessionScreen);
        }