コード例 #1
0
    private void TransferFuel()
    {
        if (this.fromTank == null || this.toTank == null)
        {
            return;
        }
        if (this.fromTank.part.vessel != Ref.mainVessel || this.toTank.part.vessel != Ref.mainVessel)
        {
            this.fromTank = null;
            this.toTank   = null;
            return;
        }
        if (this.fromTank.resourceGroup.empty)
        {
            MsgController.ShowMsg("Fuel transfer completed");
            this.fromTank = null;
            this.toTank   = null;
            return;
        }
        if (this.toTank.resourceGroup.full)
        {
            MsgController.ShowMsg("Fuel transfer completed");
            this.fromTank = null;
            this.toTank   = null;
            return;
        }
        double num            = (double)((float)this.warpSpeeds[this.timewarpPhase] * Time.deltaTime * 0.5f);
        double resourceAmount = this.fromTank.resourceGroup.resourceAmount;
        double num2           = this.toTank.resourceGroup.resourceSpace - this.toTank.resourceGroup.resourceAmount;

        if (num > resourceAmount)
        {
            num = resourceAmount;
        }
        if (num > num2)
        {
            num = num2;
        }
        this.fromTank.resourceGroup.TakeResource(num);
        this.toTank.resourceGroup.AddResource(num);
        MsgController.ShowMsg("Transfering...");
    }
コード例 #2
0
    public bool CheckConnection()
    {
        if (Application.internetReachability == NetworkReachability.NotReachable)
        {
            MsgController.ShowMsg(SFST.T.Sharing_No_Connection);
            return(false);
        }
        this.latestInfo = MasterInfo.Fetch();
        if (this.latestInfo == null)
        {
            if (Sharing.mgcache0 == null)
            {
                Sharing.mgcache0 = new Action <string>(MsgController.ShowMsg);
            }
            SyncContext.RunOnUI <string>(Sharing.mgcache0, SFST.T.STP_Request_Timeout);
            return(false);
        }
        int num  = VersionHolder.SharingVersion.CompareVersion(this.latestInfo.Version.Sharing.Client);
        int num2 = VersionHolder.ProtocolVersion.CompareVersion(this.latestInfo.Version.Sharing.Protocol);

        if (num == -1)
        {
            MsgController.ShowMsg(SFST.T.Sharing_Old_Version);
            return(false);
        }
        if (num == 1)
        {
            MsgController.ShowMsg(SFST.T.Sharing_New_Version);
            return(false);
        }
        if (num2 == -1)
        {
            MsgController.ShowMsg(SFST.T.Sharing_Old_Protocol);
            return(false);
        }
        if (num2 == 1)
        {
            MsgController.ShowMsg(SFST.T.Sharing_New_Protocol);
            return(false);
        }
        return(true);
    }
コード例 #3
0
 public void StartSaveProcess()
 {
     Ref.SceneType currentScene = Ref.currentScene;
     if (currentScene != Ref.SceneType.Build)
     {
         if (currentScene == Ref.SceneType.Game)
         {
             if (Ref.mainVessel == null)
             {
                 MsgController.ShowMsg("Cannot save while not controlling a rocket");
                 return;
             }
         }
     }
     else if (!Build.main.buildGrid.HasAnyParts())
     {
         return;
     }
     this.onOpenSaveMenu.InvokeEvenets();
 }
コード例 #4
0
ファイル: MsgControllerTest.cs プロジェクト: rog1039/crux
        public async Task MsgControllerDisplay()
        {
            var data    = new MsgApiDataHandler();
            var display = MsgData.GetFirstDisplay(false);

            data.Result.Setup(m => m.Execute(It.IsAny <MsgDisplayById>())).Returns(display);

            var controller = new MsgController(data, Cloud, Logic)
            {
                CurrentUser = AdminUser
            };
            var result = await controller.Display(MsgData.FirstId) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();

            Assert.That(result.Value, Is.DeepEqualTo(display));

            data.HasExecuted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <MsgDisplayById>()), Times.Once());
        }
コード例 #5
0
    public void CompleteSaveProcess()
    {
        string text = TouchKeyboard.main.GetText("Unnamed Save");

        Ref.SceneType currentScene = Ref.currentScene;
        if (currentScene != Ref.SceneType.Build)
        {
            if (currentScene == Ref.SceneType.Game)
            {
                GameSaving.Quicksaves.AddQuicksave(GameSaving.GetGameSaveData(text));
                MsgController.ShowMsg("Game Saved");
            }
        }
        else
        {
            Build.BuildQuicksaves.AddQuicksave(new Build.BuildSave(text, Camera.main.transform.position, Build.main.buildGrid.parts, 0));
            MsgController.ShowMsg("Design Saved");
        }
        this.onCloseSaveMenu.InvokeEvenets();
        this.CloseMenus();
        this.UpdateLoadButtonColor();
    }
コード例 #6
0
    public void MainBGSceneInit(AARController aar, MsgController msg, DeviceListScene list, BthCommunicator bth)
    {
        _ClickBlock.SetActive(false);

        _AAR  = aar;
        _Msg  = msg;
        _List = list;
        _BTH  = bth;

        _DisplayGroupObject.SetActive(false);
        _LoadingObject.SetActive(false);

        int       iNum = _DojaGroup.childCount;
        Transform obj;

        for (int i = 0; i < iNum; ++i)
        {
            obj = _DojaGroup.GetChild(i);
            _DojaTexts.Add(obj.Find("LvText").GetComponent <Text>());
            _DojaTitles.Add(obj.Find("DojaName").GetComponent <Text>());
        }
    }
コード例 #7
0
 public void AccelerateTime()
 {
     Ref.inputController.instructionsTimewarp.SetActive(false);
     if (Ref.mainVesselHeight < this.loadedPlanet.minTimewarpHeightKm * 1000.0 && !Ref.timeWarping)
     {
         if (!Ref.mainVessel.OnSurface)
         {
             MsgController.ShowMsg("Cannot time warp below " + this.loadedPlanet.minTimewarpHeightKm.ToString() + "km");
             return;
         }
         if (Ref.mainVessel.GetGlobalVelocity.magnitude2d >= 0.05000000074505806)
         {
             MsgController.ShowMsg("Cannot time warp while moving on the surface");
             return;
         }
     }
     if (Ref.mainVessel.throttle.throttleOn && Ref.mainVessel.throttle.throttleRaw > 0f)
     {
         foreach (EngineModule engineModule in Ref.mainVessel.partsManager.engineModules)
         {
             if (engineModule.engineOn.boolValue)
             {
                 MsgController.ShowMsg("Cannot time warp while under acceleration");
                 return;
             }
         }
     }
     if (this.timewarpPhase == this.warpSpeeds.Length - 1)
     {
         return;
     }
     this.timewarpPhase++;
     MsgController.ShowMsg(this.warpSpeeds[this.timewarpPhase].ToString() + "x Time acceleration");
     if (!Ref.timeWarping)
     {
         this.EnterTimeWarpMode();
     }
 }
コード例 #8
0
ファイル: MsgControllerTest.cs プロジェクト: rog1039/crux
        public async Task MsgControllerPostAdd()
        {
            var data  = new MsgApiDataHandler();
            var model = MsgData.GetFirst();

            data.Result.Setup(m => m.Execute(It.IsAny <Persist <Msg> >())).Returns(model);

            var controller = new MsgController(data, Cloud, Logic)
            {
                CurrentUser = AdminUser
            };
            var viewModel = controller.Mapper.Map <MsgViewModel>(model);

            viewModel.Id         = string.Empty;
            viewModel.Files      = new List <VisibleDisplay>();
            viewModel.Recipients = new List <ResultProfile>()
            {
                UserData.GetFirstProfile(), UserData.GetSecondProfile()
            };
            viewModel.HasReply.Should().BeFalse();
            viewModel.Reply.Should().BeNull();

            var result = await controller.Post(viewModel) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();
            result.Value.Should().NotBeNull();

            var check = result.Value as ConfirmViewModel;

            check.Identity.Should().Be(model.Id);

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <Loader <Msg> >()), Times.Never);
            data.Result.Verify(s => s.Execute(It.IsAny <Persist <Msg> >()), Times.Once());
        }
コード例 #9
0
 public void ToggleEngine(bool showMsg)
 {
     if (this.IsCovered())
     {
         return;
     }
     if (this.engineOn.boolValue)
     {
         this.engineOn.boolValue = false;
         if (showMsg)
         {
             MsgController.ShowMsg("Engine Off");
         }
         if (this.nozzleMove != null)
         {
             this.nozzleMove.SetTargetTime(0f);
         }
     }
     else
     {
         for (int i = 0; i < this.resourceSources.Length; i++)
         {
             if (this.resourceSources[i].state != FlowModule.State.Flowing)
             {
                 MsgController.ShowMsg((this.resourceSources[i].state != FlowModule.State.NoSource) ? ("Out of " + Resource.GetResourceName(this.resourceSources[i].resourceType).ToLower()) : ("No " + Resource.GetResourceName(this.resourceSources[i].resourceType).ToLower() + " source"));
                 return;
             }
         }
         this.engineOn.boolValue = true;
         if (showMsg)
         {
             MsgController.ShowMsg("Engine On");
         }
     }
     this.UpdateEngineThrottle(base.transform.parent.GetComponentInParent <Vessel>().throttle);
 }
コード例 #10
0
    private void Update()
    {
        if (this.regularUpdateTime < Time.time)
        {
            this.RegularUpdate();
            this.regularUpdateTime = Time.time + 0.5f;
        }
        this.globalTime += (double)((float)this.warpSpeeds[this.timewarpPhase] * Time.deltaTime);
        bool   flag = Ref.mainVessel != null && Ref.mainVessel.orbits.Count > 0;
        double num  = (!flag) ? double.PositiveInfinity : Ref.mainVessel.orbits[0].stopTimeWarpTime;

        if (flag)
        {
            Ref.planetManager.UpdatePositionOffset(Ref.mainVessel.GetGlobalPosition.roundTo1000);
        }
        if (this.globalTime > num)
        {
            this.globalTime = num;
            Ref.planetManager.UpdatePositionOffset(Ref.mainVessel.GetGlobalPosition.roundTo1000);
            this.timewarpPhase = 1;
            this.DecelerateTime();
            MsgController.ShowMsg("Cannot time warp below: " + this.loadedPlanet.minTimewarpHeightKm.ToString() + "km");
        }
    }
コード例 #11
0
ファイル: MsgController.cs プロジェクト: h53/mine-tank
 private void Start()
 {
     instance = this;
 }
コード例 #12
0
 private void StayTouch(int fingerId, int i, ref Double3 summedPositionDelta, ref int dragingFingerCount, ref float horizontalAxis, ref Vector2 rcsInput)
 {
     global::Touch.TouchState touchState = this.touchesInfo[fingerId].touchState;
     if (touchState != global::Touch.TouchState.OnEmpty)
     {
         if (touchState == global::Touch.TouchState.OnUI)
         {
             if (this.touchesInfo[fingerId].touchDownButton == Ref.inputController.leftArrow)
             {
                 horizontalAxis = -1f;
             }
             else if (this.touchesInfo[fingerId].touchDownButton == Ref.inputController.rightArrow)
             {
                 horizontalAxis = 1f;
             }
             else if (this.touchesInfo[fingerId].touchDownButton == Ref.inputController.up)
             {
                 rcsInput.y = 1f;
             }
             else if (this.touchesInfo[fingerId].touchDownButton == Ref.inputController.down)
             {
                 rcsInput.y = -1f;
             }
             else if (this.touchesInfo[fingerId].touchDownButton == Ref.inputController.right)
             {
                 rcsInput.x = 1f;
             }
             else if (this.touchesInfo[fingerId].touchDownButton == Ref.inputController.left)
             {
                 rcsInput.x = -1f;
             }
             if (Ref.controller != null && Ref.controller.throttlePercentUI != null && this.touchesInfo[fingerId].touchDownButton == Ref.controller.throttlePercentUI.transform.parent)
             {
                 float num = this.touchesInfo[fingerId].lastFingerPosPixel.y - Input.GetTouch(i).position.y;
                 if (num != 0f && Ref.mainVessel != null)
                 {
                     if (Ref.mainVessel.controlAuthority)
                     {
                         Ref.mainVessel.SetThrottle(new Vessel.Throttle(Ref.mainVessel.throttle.throttleOn, Mathf.Clamp01(Ref.mainVessel.throttle.throttleRaw - num / 318f)));
                         if (Ref.inputController.instructionSlideThrottleHolder.activeSelf)
                         {
                             Ref.inputController.instructionSlideThrottleHolder.SetActive(false);
                             Ref.inputController.CheckAllInstructions();
                         }
                     }
                     else if (MsgController.main.msgText.color.a < 0.6f)
                     {
                         MsgController.ShowMsg("No control");
                     }
                 }
             }
         }
     }
     else
     {
         if (Ref.currentScene == Ref.SceneType.Build)
         {
             Vector2 deltaPixel = this.touchesInfo[fingerId].lastFingerPosPixel - Input.GetTouch(i).position;
             Vector2 posWorld   = Camera.main.ScreenToWorldPoint((Vector3)Input.GetTouch(i).position + Vector3.forward * -Ref.cam.transform.position.z);
             Ref.inputController.TouchStayEmpty(posWorld, deltaPixel, fingerId);
         }
         if (Ref.currentScene == Ref.SceneType.Game)
         {
             Vector2 v = this.touchesInfo[fingerId].lastFingerPosPixel - Input.GetTouch(i).position;
             summedPositionDelta += v;
             dragingFingerCount++;
         }
     }
 }
コード例 #13
0
 private void SomeStuff()
 {
     if (Input.GetKeyDown("."))
     {
         this.AccelerateTime();
     }
     if (Input.GetKeyDown(","))
     {
         this.DecelerateTime();
     }
     if (Input.GetKeyDown("space") && !Ref.saving.savingMenuHolder.activeSelf)
     {
         if (Ref.mainVessel.controlAuthority)
         {
             this.ToggleThrottle();
         }
         else if (MsgController.main.msgText.color.a < 0.6f)
         {
             MsgController.ShowMsg("No control");
         }
     }
     if (Input.GetAxisRaw("Vertical") != 0f)
     {
         if (Ref.mainVessel.controlAuthority)
         {
             Ref.mainVessel.SetThrottle(new Vessel.Throttle(Ref.mainVessel.throttle.throttleOn, Mathf.Clamp01(Ref.mainVessel.throttle.throttleRaw + Input.GetAxisRaw("Vertical") / 2f * Time.deltaTime)));
             if (Ref.inputController.instructionSlideThrottleHolder.activeSelf)
             {
                 Ref.inputController.instructionSlideThrottleHolder.SetActive(false);
                 Ref.inputController.CheckAllInstructions();
             }
         }
         else if (MsgController.main.msgText.color.a < 0.6f)
         {
             MsgController.ShowMsg("No control");
         }
     }
     if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
     {
         if (Ref.mainVessel.controlAuthority)
         {
             Ref.mainVessel.SetThrottle(new Vessel.Throttle(Ref.mainVessel.throttle.throttleOn, Mathf.Clamp01(Ref.mainVessel.throttle.throttleRaw + 0.5f * Time.deltaTime)));
         }
         else if (MsgController.main.msgText.color.a < 0.6f)
         {
             MsgController.ShowMsg("No control");
         }
     }
     if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
     {
         if (Ref.mainVessel.controlAuthority)
         {
             Ref.mainVessel.SetThrottle(new Vessel.Throttle(Ref.mainVessel.throttle.throttleOn, Mathf.Clamp01(Ref.mainVessel.throttle.throttleRaw - 0.5f * Time.deltaTime)));
         }
         else if (MsgController.main.msgText.color.a < 0.6f)
         {
             MsgController.ShowMsg("No control");
         }
     }
     if (Input.GetKeyDown("u"))
     {
         this.topRightText.transform.parent.gameObject.SetActive(!Ref.inputController.switchToButton.transform.parent.parent.gameObject.activeSelf);
         this.bottomLeftHolder.gameObject.SetActive(!Ref.inputController.switchToButton.transform.parent.parent.gameObject.activeSelf);
         Ref.inputController.switchToButton.transform.parent.parent.gameObject.SetActive(!Ref.inputController.switchToButton.transform.parent.parent.gameObject.activeSelf);
     }
 }
コード例 #14
0
ファイル: FrmServer.cs プロジェクト: magic9911/CopyForex
 public FrmServer(MsgController msgCtrl) : this()
 {
     masterController = msgCtrl;
 }
コード例 #15
0
 public override void OnPartUsed()
 {
     if (Ref.timeWarping)
     {
         if (this.moveModule.targetTime.floatValue == 0f)
         {
             MsgController.ShowMsg("Cannot deploy parachute while time warping");
         }
     }
     else
     {
         Rigidbody2D componentInParent = base.GetComponentInParent <Rigidbody2D>();
         if (this.moveModule.targetTime.floatValue == 0f)
         {
             if (!Ref.controller.loadedPlanet.atmosphereData.hasAtmosphere || Ref.mainVesselHeight > Ref.controller.loadedPlanet.atmosphereData.atmosphereHeightM * 0.8)
             {
                 MsgController.ShowMsg("Cannot deploy parachute in a vacuum");
             }
             else if (Ref.mainVesselTerrainHeight > this.minDeployHeight)
             {
                 MsgController.ShowMsg("Cannot deploy parachute above " + this.minDeployHeight.ToString() + "m");
             }
             else if (componentInParent.velocity.magnitude > this.maxDeployVelocity)
             {
                 MsgController.ShowMsg("Cannot deploy parachute while moving faster than " + this.maxDeployVelocity + "m/s");
             }
             else if (componentInParent.velocity.magnitude < 3f)
             {
                 MsgController.ShowMsg("Cannot deploy parachute while moving slower than 3m/s");
             }
             else
             {
                 MsgController.ShowMsg("Parachute half deployed");
                 this.DeployParachute(1f, true);
             }
         }
         else if (this.moveModule.targetTime.floatValue == 1f)
         {
             if (Ref.mainVesselTerrainHeight > 500.0)
             {
                 MsgController.ShowMsg("Cannot fully deploy parachute above 500m");
             }
             else if (componentInParent.velocity.magnitude > this.maxDeployVelocity / 5f)
             {
                 MsgController.ShowMsg("Cannot fully deploy parachute while moving faster than " + this.maxDeployVelocity / 5f + "m/s");
             }
             else
             {
                 MsgController.ShowMsg("Parachute fully deployed");
                 this.DeployParachute(2f, false);
             }
         }
         else if (this.moveModule.targetTime.floatValue == 2f)
         {
             if (this.moveModule.time.floatValue < 2f)
             {
                 return;
             }
             MsgController.ShowMsg("Parachute cut");
             this.RelaseParachute();
         }
     }
 }
コード例 #16
0
 private void CancelFuelTranfer()
 {
     Ref.controller.fromTank = null;
     Ref.controller.toTank   = null;
     MsgController.ShowMsg("Transfer canceled");
 }
コード例 #17
0
 public static void ShowMsg(string msgText)
 {
     MsgController.ShowMsg(msgText, 3.5f, true);
 }
コード例 #18
0
 public static void ShowMsg(string msgText, bool showMsg = true)
 {
     MsgController.ShowMsg(msgText, 3.5f, showMsg);
 }
コード例 #19
0
 public FrmSlave(MsgController msgCtrl) : this()
 {
     msgController = msgCtrl;
 }