Esempio n. 1
0
        public void Hack(IMyUseableEntity entityToHack)
        {
            if (entityToHack == null)
            {
                throw new ArgumentNullException("entityToHack");
            }
            if (!entityToHack.CanBeHacked(m_owner))
            {
                StopHacking(MyHackingResultEnum.CanNotBeHacked);
                return;
            }
            if (HackingLevel < 1)
            {
                StopHacking(MyHackingResultEnum.NoHackingTool);
                return;
            }
            if (entityToHack.UseProperties.HackingLevel > HackingLevel)
            {
                StopHacking(MyHackingResultEnum.NotEnoughLevel, null, new object[] { entityToHack.UseProperties.HackingLevel, HackingLevel });
                return;
            }

            m_state = MyHackingToolStateEnum.Hacking;
            m_acutalHackingEntity = entityToHack;
            //m_hackingTimeTotal = (int)((float)entityToHack.UseProperties.HackingTime * (1f - (HackingLevel - entityToHack.UseProperties.HackingLevel) * 0.25f));
            //m_hackingTimeLeft = m_hackingTimeTotal;
            NotifyHackingStart();
            int hackingTimeTotal = (int)((float)entityToHack.UseProperties.HackingTime * (1f - (HackingLevel - entityToHack.UseProperties.HackingLevel) * 0.25f));

            m_hackingProgressScreen             = new MyGuiScreenUseProgressBar(MyTextsWrapperEnum.Hacking, MyTextsWrapperEnum.HackingProgress, 0f, MySoundCuesEnum.SfxProgressHack, MySoundCuesEnum.SfxCancelHack, MyGameControlEnums.USE, 50, hackingTimeTotal, 0);
            m_hackingProgressScreen.OnCanceled += m_hackingProgressScreenCanceled;
            m_hackingProgressScreen.OnSuccess  += m_hackingProgressScreenSuccess;
            m_owner.OnDie += m_ownerDie;
            MyGuiManager.AddScreen(m_hackingProgressScreen);
        }
Esempio n. 2
0
        private void StopHacking(MyHackingResultEnum result, HackingResultAction action = null, object[] parameters = null)
        {
            MyHackingResultMessage resultMessage = m_hackingResultMessages[(int)result];

            if (resultMessage != null)
            {
                //MyGuiManager.AddScreen(new MyGuiScreenMessageBox(resultConfig.MessageBoxType, resultConfig.Text, MyTextsWrapperEnum.HackingResult, MyTextsWrapperEnum.Ok, null));
                resultMessage.Display(parameters);
            }

            if (m_hackingProgressScreen != null)
            {
                if (m_hackingProgressScreen.GetState() != MyGuiScreenState.CLOSED)
                {
                    m_hackingProgressScreen.CloseScreenNow();
                }
                m_hackingProgressScreen.OnCanceled -= m_hackingProgressScreenCanceled;
                m_hackingProgressScreen.OnSuccess  -= m_hackingProgressScreenSuccess;
                m_hackingProgressScreen             = null;
            }
            m_owner.OnDie -= m_ownerDie;
            if (action != null)
            {
                action();
            }
            NotifyHackingFinish(result);
            m_acutalHackingEntity = null;
            //m_hackingTimeLeft = 0;
            m_state = MyHackingToolStateEnum.Idle;
        }
Esempio n. 3
0
        public override void Load()
        {
            base.Load();
            if (m_realMissionEntityId.HasValue)
            {
                m_realMissionEntity = MyScriptWrapper.TryGetEntity(m_realMissionEntityId.Value);
            }

            m_notification = new MyHudNotification.MyNotification(m_notificationText, MyHudConstants.MISSION_FONT, MyHudNotification.DONT_DISAPEAR, null, new object[] { "" });
            m_startingGeneratorProgressScreen_OnCanceledHandler = new EventHandler(OnCanceledHandler);
            m_startingGeneratorProgressScreen_OnSuccessHandler  = new EventHandler(OnSuccessHandler);

            m_useProgress             = new MyGuiScreenUseProgressBar(m_useCaption, m_useText, 0f, m_progressCue, m_cancelCue, MyGameControlEnums.USE, 0, m_requiredTime, 0);
            m_useProgress.OnCanceled += m_startingGeneratorProgressScreen_OnCanceledHandler;
            m_useProgress.OnSuccess  += m_startingGeneratorProgressScreen_OnSuccessHandler;
        }
        public override void Load()
        {
            base.Load();
            m_entitiesToUse = new List <uint>();
            m_entitiesToUse.AddRange(MissionEntityIDs);
            InitSounds(m_objectiveType);
            m_totalCount   = MissionEntityIDs.Count;
            m_notification = new MyHudNotification.MyNotification(m_notificationText, MyHudConstants.MISSION_FONT, MyHudNotification.DONT_DISAPEAR, null, new object[] { "" });
            m_startingGeneratorProgressScreen_OnCanceledHandler = new EventHandler(OnCanceledHandler);
            m_startingGeneratorProgressScreen_OnSuccessHandler  = new EventHandler(OnSuccessHandler);

            m_useProgress             = new MyGuiScreenUseProgressBar(m_useCaption, m_useText, 0f, m_progressCue, m_cancelCue, MyGameControlEnums.USE, 0, m_requiredTime, 0);
            m_useProgress.OnCanceled += m_startingGeneratorProgressScreen_OnCanceledHandler;
            m_useProgress.OnSuccess  += m_startingGeneratorProgressScreen_OnSuccessHandler;


            foreach (var id in MissionEntityIDs)
            {
                SetLocationVisibility(true, MyScriptWrapper.GetEntity(id), MyGuitargetMode.Objective);
            }

            ReloadAdditionalHubInfo();
        }