private void numericUD_CheckPoint_Click(object sender, EventArgs e) { // int idx = (int)numericUD_CheckPoint.Value; LocationSystem LocSys = BrainCtrl.LocSys; LocSys.RTS.SetCheckPointIndex(idx); }
private void HandleStartGameEvent(GameStartEventInfo gameStartEventInfo) { LocationSystem.Start(); DialogueSystem.Start(); EntitySystem.Start(); ProgressSystem.Start(); loadingScreen.SetActive(false); StartGame(gameStartEventInfo.progress); }
/// <summary> /// チェックポイント削減 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonCheckPointReduction_Click(object sender, EventArgs e) { LocationSystem LocSys = BrainCtrl.LocSys; int beforPoints = LocSys.RTS.rosCheckPoint.Count; int reductedPoints = LocSys.RTS.CheckPointReduction(10.0 * Math.PI / 180.0); MessageBox.Show("チェックポイント\n 削減前:" + beforPoints.ToString() + "\n 削減後:" + reductedPoints.ToString() , "チェックポイント削減"); }
private HasLocation FindSafeLocation(LocationSystem locationSystem, Random rng) { var x = rng.Next(0, this.boundsX); var y = rng.Next(0, this.boundsY); while (locationSystem.IsEntityAt(x, y)) { x = rng.Next(0, this.boundsX); y = rng.Next(0, this.boundsY); } return(new HasLocation(x, y, this.boundsX, this.boundsY)); }
/// <summary> /// 初期化 /// </summary> public void Init(MapData mapData) { ModeCtrl = new ModeControl(); // チェックポイントへ向かう ModeCtrl.SetActionMode(ModeControl.ActionMode.CheckPoint); // Locpresump // マップ画像ファイル名、実サイズの横[mm], 実サイズ縦[mm] (北向き基準) LocSys = new LocationSystem(mapData); UpdateCnt = 0; // 現在座標リセット Reset_Rooting(true); }
/// <summary> /// LRF用のガイドライン描画 /// </summary> /// <param name="g"></param> /// <param name="LocSys"></param> /// <param name="ctrX"></param> /// <param name="ctrY"></param> /// <param name="scale"></param> public void LRF_Draw_GuideLine(Graphics g, ref LocationSystem LocSys, int ctrX, int ctrY, double scale) { // ガイド描画 // 30mを2m区切りで描画 for (int i = 1; i <= 30 / 2; i++) { int cirSize = (int)((((i * 2000) * 2) / (LocSys.MapTom * 1000.0)) * scale); g.DrawPie(Pens.LightGray, (ctrX - cirSize / 2), (ctrY - cirSize / 2), cirSize, cirSize, -135 - 90, 270); g.DrawString((i * 2).ToString("F1") + "m", fntMini, Brushes.LightGray, (ctrX - cirSize / 2), (ctrY - cirSize / 2)); } }
/// <summary> /// 自律走行モード /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cb_Autonomous_CheckedChanged(object sender, EventArgs e) { if (cb_StartAutonomous.Checked) { LocationSystem LocSys = BrainCtrl.LocSys; bRunAutonomous = true; cb_StartAutonomous.BackColor = Color.LimeGreen; } else { // 停止 bRunAutonomous = false; CersioCt.SendCommand_Stop(); cb_StartAutonomous.BackColor = SystemColors.Window; } }
private static void ShowEntity(EntityEventInfo entityEventInfo) { LocationSystem.HideNamePanel(); if (entityEventInfo.entity.Texture == null) { currentEntity = entityEventInfo.entity; APIHandler.getAPIHandler().FetchImage(entityEventInfo.entity.imagePath, FetchImageCallback); } else { entityImage.sprite = Sprite.Create( entityEventInfo.entity.Texture, new Rect(0, 0, entityEventInfo.entity.Texture.width, entityEventInfo.entity.Texture.height), new Vector2(0.5f, 0.5f)); entityImage.SetMaterialDirty(); UIHelperClass.ShowPanel(entityImageObject, true); } }
public static void TurnOver(int entity) { //Log.Message("Turn over for " + DescriptionSystem.GetNameWithID(entity)); var health = EntityManager.GetComponent <HealthComponent>(entity); // entity dead, don't do anything if (health.Amount <= 0) { return; } TurnOverEvent?.Invoke(entity); if (entity == PlayerID) { CurrentFloor.CalculateTileVisibility(); LocationSystem.UpdateDistanceMap(PlayerID); PlayerTurnOver = true; TurnCount++; } }
protected override void ResetState() { locations = null; }
/// <summary> /// PictureBox内へのワールドマップ描画 /// </summary> /// <param name="g"></param> /// <param name="CersioCt"></param> /// <param name="BrainCtrl"></param> public void AreaMap_Draw_WorldMap(Graphics g, PictureBox picbox_AreaMap, ref LocationSystem LocSys, int scrollX, int scrollY) { // 全体マップ描画 float viewScale = 1.0f;// viewScaleWorld; MapData mapData = LocSys.mapData; // マップ外カラー g.FillRectangle(Brushes.DarkGray, 0, 0, picbox_AreaMap.Width, picbox_AreaMap.Height); { float wdAspect = (float)LocSys.mapBmp.Width / (float)worldMapBmp.Width; float htAspect = (float)LocSys.mapBmp.Height / (float)worldMapBmp.Height; if (wdAspect < htAspect) { viewScale = (float)(1.0 / htAspect); } else { viewScale = (float)(1.0 / wdAspect); } } g.ResetTransform(); //g.TranslateTransform(-ctrX, -ctrY, MatrixOrder.Append); //g.RotateTransform((float)layer.wAng, MatrixOrder.Append); //g.ScaleTransform(viewScale, viewScale, MatrixOrder.Append); g.TranslateTransform((float)(-scrollX), (float)(-scrollY), MatrixOrder.Append); if (null != worldMapBmp) { g.DrawImage(worldMapBmp, 0, 0); } g.ResetTransform(); g.TranslateTransform((float)(-(mapData.MapOrign.x / mapData.Resolution) * viewScale) - scrollX, (float)(-(mapData.MapOrign.y / mapData.Resolution) * viewScale) - scrollY, MatrixOrder.Append); //g.ResetTransform(); // 各マーカーの位置を描画 //LocSys.DrawWorldMap(g, viewScale); DrawMaker(g, viewScale, Brushes.Red, new DrawMarkPoint(LocSys.R1, LocSys), 10); // チェックポイント描画 { double dir = 0; DrawMarkPoint prvPos = new DrawMarkPoint(LocSys.R1, LocSys); for (int i = LocSys.RTS.GetCheckPointIdx(); i < LocSys.RTS.GetNumCheckPoints(); i++) { Vector3 tgtPos = LocSys.RTS.GetCheckPoint(i); //BrainCtrl.RTS.getNowTargetDir(ref dir); DrawMarkPoint tgtMk = new DrawMarkPoint(new MarkPoint(tgtPos.x, tgtPos.y, dir), LocSys); // ターゲットまでのライン DrawMakerLine(g, viewScale, prvPos, tgtMk, Pens.Olive, 1); g.DrawString(i.ToString("D2"), fntMini, Brushes.Green, (int)(tgtMk.x * viewScale), (int)(tgtMk.y * viewScale)); prvPos.x = tgtMk.x; prvPos.y = tgtMk.y; } } }
/* * /// <summary> * /// エリアマップ生成 * /// </summary> * /// <param name="worldBMP"></param> * /// <param name="picbox_AreaMap"></param> * /// <returns></returns> * public Bitmap MakePictureBoxAreaMap(Bitmap worldBMP, PictureBox picbox_AreaMap, ref LocationSystem LocSys, int scrollX, int scrollY) * { * { * //int picW = (int)(viewScale * worldBMP.Width + 0.5); * //int picH = (int)(viewScale * worldBMP.Height + 0.5); * * areaMapBmp = new Bitmap(picbox_AreaMap.Width, picbox_AreaMap.Height); * Graphics g = Graphics.FromImage(areaMapBmp); * * DrawMarkPoint drawCenter = new DrawMarkPoint(LocSys.R1, LocSys); * * g.ResetTransform(); * g.TranslateTransform( (float)(-drawCenter.x - (worldBMP.Width * 0.5) + (picbox_AreaMap.Width*0.5)) - scrollX, * (float)(-drawCenter.y - (worldBMP.Height * 0.5) + (picbox_AreaMap.Height * 0.5)) - scrollY, * MatrixOrder.Append); * //g.RotateTransform((float)layer.wAng, MatrixOrder.Append); * //g.ScaleTransform(viewScale, viewScale, MatrixOrder.Append); * * g.DrawImage(worldBMP, 0, 0); * * g.Dispose(); * } * * return areaMapBmp; * } */ /// <summary> /// PictureBox内へのマップ描画(等倍) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void AreaMap_Draw_Area(Graphics g, PictureBox picbox_AreaMap, ref LocationSystem LocSys, int scrollX, int scrollY, int selCpIndex, bool bHandleTarget) { Bitmap worldBMP = LocSys.mapBmp; MapData mapData = LocSys.mapData; //Bitmap areaBMP = MakePictureBoxAreaMap(worldBMP, picbox_AreaMap, ref LocSys, scrollX, scrollY); //float viewScale = 1.0f; DrawMarkPoint drawCenter = new DrawMarkPoint(LocSys.R1, LocSys); // センターを左下にずらす Width x 0.1, Height x 0.1 double viewCenterX = GetMapWndowCenterX(picbox_AreaMap); // (picbox_AreaMap.Width * 0.5) - (picbox_AreaMap.Width * 0.1); double viewCenterY = GetMapWndowCenterY(picbox_AreaMap); //(picbox_AreaMa.pHeight * 0.5) + (picbox_AreaMap.Height * 0.1); // エリアマップ描画 g.ResetTransform(); g.TranslateTransform((float)(-drawCenter.x + (mapData.MapOrign.x / mapData.Resolution) + viewCenterX) - scrollX, (float)(-drawCenter.y + (mapData.MapOrign.y / mapData.Resolution) + viewCenterY) - scrollY, MatrixOrder.Append); //g.RotateTransform((float)layer.wAng, MatrixOrder.Append); //g.ScaleTransform(1.0f, -1.0f, MatrixOrder.Append); g.InterpolationMode = InterpolationMode.NearestNeighbor; g.DrawImage(worldBMP, 0, 0); // ------------------------ g.ResetTransform(); g.TranslateTransform((float)(-drawCenter.x + viewCenterX) - scrollX, (float)(-drawCenter.y + viewCenterY) - scrollY, MatrixOrder.Append); //g.ScaleTransform(1.0f, -1.0f, MatrixOrder.Append); // 現在位置描画 DrawMaker(g, Brushes.Red, new DrawMarkPoint(LocSys.R1, LocSys), 8); // チェックポイント描画 { double prvPosX = LocSys.R1.x; double prvPosY = LocSys.R1.y; for (int i = LocSys.RTS.GetCheckPointIdx(); i < LocSys.RTS.GetNumCheckPoints(); i++) { //Vector3 checkPnt = LocSys.RTS.GetCheckPoint(i); Vector3 checkPnt = LocSys.RTS.GetCheckPointToWayPoint(i); //BrainCtrl.RTS.getNowTargetDir(ref dir); DrawMarkPoint checkPntMk = new DrawMarkPoint(new MarkPoint(checkPnt.x, checkPnt.y, 0.0), LocSys); checkPntMk.theta = -checkPnt.z; if (selCpIndex == i) { // 選択中のチェックポイント DrawMaker(g, Brushes.Purple, checkPntMk, 8); } else { DrawMaker(g, Brushes.GreenYellow, checkPntMk, 8); } // ターゲットまでのライン DrawMakerLine(g, 1.0f, new DrawMarkPoint(new MarkPoint(prvPosX, prvPosY, 0), LocSys), checkPntMk, Pens.Olive, 1); g.DrawString(i.ToString("D2"), fntMini, Brushes.Green, checkPntMk.x, checkPntMk.y); prvPosX = checkPnt.x; prvPosY = checkPnt.y; } } // ターゲット描画(ハンドル操作がVRの場合) if (bHandleTarget) { Vector3 nowtgtPos = LocSys.RTS.GetNowTargetPositon(); DrawMarkPoint tgtMk = new DrawMarkPoint(new MarkPoint(nowtgtPos.x, nowtgtPos.y, 0.0), LocSys); DrawMakerNoDir(g, Brushes.DeepPink, tgtMk, 6); // ターゲットまでのライン DrawMakerLine(g, 1.0f, new DrawMarkPoint(LocSys.R1, LocSys), tgtMk, Pens.DeepPink, 1); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { graphics.PreferredBackBufferWidth = Util.ScreenWidth; graphics.PreferredBackBufferHeight = Util.ScreenHeight; graphics.ApplyChanges(); Util.ContentPath = Content.RootDirectory; Log.Init(AppDomain.CurrentDomain.BaseDirectory); Log.Message("Seed: " + Seed); var gameData = GameData.Instance = new GameData(); var dataPath = Util.ContentPath + "/GameData/"; gameData.LoadEntities(EntityType.Terrain, dataPath + "Entities/Terrains"); gameData.LoadEntities(EntityType.Structure, dataPath + "Entities/Structures"); gameData.LoadEntities(EntityType.Character, dataPath + "Entities/Characters"); gameData.LoadEntities(EntityType.Item, dataPath + "Entities/Items"); var herb = gameData.CreateItem("randomHerb"); var herbSubstance = EntityManager.GetComponent <SubstanceComponent>(herb); gameData.LoadTilesets(dataPath + "tilesets.json"); gameData.LoadRoomTemplates(dataPath); //Floor test = new Floor(Content.RootDirectory + "/map.txt"); Floor testFloor = new Floor(500, 500); //testFloor.GenerateSimple(); testFloor.GenerateGraphBased(); //EntityManager.Dump(); Util.CurrentFloor = testFloor; Util.CurrentFloor.CalculateTileVisibility(); // Delete entities that were removed during generation EntityManager.CleanUpEntities(); //Log.Data(DescriptionSystem.GetDebugInfoEntity(Util.PlayerID)); InputManager input = InputManager.Instance; // instantiate all the systems Log.Message("Loading Systems..."); inputSystem = new InputSystem(); movementSystem = new MovementSystem(); renderSystem = new RenderSystem(GraphicsDevice); collisionSystem = new CollisionSystem(); healthSystem = new HealthSystem(); combatSystem = new CombatSystem(); npcBehaviourSystem = new NPCBehaviourSystem(); interactionSystem = new InteractionSystem(); itemSystem = new ItemSystem(); uiSystem = new UISystem(); statSystem = new StatSystem(); craftingSystem = new CraftingSystem(); // toggle FOW renderSystem.FogOfWarEnabled = true; // hook up all events with their handlers Log.Message("Registering Event Handlers..."); input.MovementEvent += movementSystem.HandleMovementEvent; input.InventoryToggledEvent += uiSystem.HandleInventoryToggled; input.InventoryCursorMovedEvent += uiSystem.HandleInventoryCursorMoved; input.PickupItemEvent += itemSystem.PickUpItem; input.InteractionEvent += interactionSystem.HandleInteraction; input.ItemUsedEvent += itemSystem.UseItem; input.ItemConsumedEvent += itemSystem.ConsumeItem; // crafting input.AddItemAsIngredientEvent += craftingSystem.AddIngredient; input.CraftItemEvent += craftingSystem.CraftItem; input.ResetCraftingEvent += craftingSystem.ResetCrafting; interactionSystem.ItemAddedEvent += itemSystem.AddItem; itemSystem.HealthGainedEvent += healthSystem.HandleGainedHealth; itemSystem.HealthLostEvent += healthSystem.HandleLostHealth; itemSystem.StatChangedEvent += statSystem.ChangeStat; npcBehaviourSystem.EnemyMovedEvent += movementSystem.HandleMovementEvent; movementSystem.CollisionEvent += collisionSystem.HandleCollision; movementSystem.BasicAttackEvent += combatSystem.HandleBasicAttack; movementSystem.InteractionEvent += interactionSystem.HandleInteraction; craftingSystem.ItemAddedEvent += itemSystem.AddItem; Util.TurnOverEvent += healthSystem.RegenerateEntity; Util.TurnOverEvent += statSystem.TurnOver; combatSystem.HealthLostEvent += healthSystem.HandleLostHealth; Log.Message("Loading Keybindings..."); string keybindings = File.ReadAllText(Util.ContentPath + "/GameData/keybindings.json"); input.LoadKeyBindings(keybindings); input.EnterDomain(InputManager.CommandDomain.Exploring); // start out with exploring as bottom level command domain input.ControlledEntity = Util.PlayerID; base.Initialize(); Log.Message("Initialization completed!"); //CraftableComponent.foo(); int testRock = EntityManager.CreateEntity(new List <IComponent>() { new DescriptionComponent() { Name = "Rock", Description = "You can't stop the rock!" }, new ItemComponent() { MaxCount = 5, Count = 3, Value = 1, Weight = 10 } }, EntityType.Item); // fill inventory with test items itemSystem.AddItems(Util.PlayerID, new int[] { //testRock, GameData.Instance.CreateItem("healthPotion"), GameData.Instance.CreateItem("healthPotion"), GameData.Instance.CreateItem("healthPotion"), GameData.Instance.CreateItem("poisonPotion"), GameData.Instance.CreateItem("poisonPotion"), GameData.Instance.CreateItem("elementalPotion") }); //EntityManager.Dump(); //EntityManager.RemoveEntity(testBush); //EntityManager.CleanUpEntities(); //EntityManager.Dump(); //Log.Data(DescriptionSystem.GetDebugInfoEntity(Util.GetPlayerInventory().Items[0])); LocationSystem.UpdateDistanceMap(Util.PlayerID); }
/// <summary> /// 描画と親密な定期処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tm_Update_Tick(object sender, EventArgs e) { if (null != BrainCtrl && null != BrainCtrl.LocSys) { LocationSystem LocSys = BrainCtrl.LocSys; // tm_UpdateHw_Tick { // 実走行時、bServerと接続が切れたら再接続 if (updateHwCnt % 100 == 0) { // 切断状態なら、自動接続 if (!CersioCt.TCP_IsConnected()) { // //CersioCt.Connect_bServer_Async(bServerEmuAddr); CersioCt.Connect_bServer_Async(bServerAddr); } } // ロータリーエンコーダ(タイヤ回転数)情報 if (CersioCt.bhwRE) { //lbl_RErotR.Text = CersioCt.hwRErotR.ToString("f1"); //lbl_RErotL.Text = CersioCt.hwRErotL.ToString("f1"); dataGridViewReceiveData.Rows[(int)GeridRow.RE].Cells[1].Value = "L:" + CersioCt.hwRErotL.ToString("f1"); dataGridViewReceiveData.Rows[(int)GeridRow.RE].Cells[2].Value = "R:" + CersioCt.hwRErotR.ToString("f1"); } // AMCL LocSys.Input_ROSPosition(CersioCt.hwAMCL_X, CersioCt.hwAMCL_Y, CersioCt.hwAMCL_Ang); if (CersioCt.bhwTrgAMCL) { // 受信再開時の初期化 LocSys.Reset_ROSPosition(CersioCt.hwAMCL_X, CersioCt.hwAMCL_Y, CersioCt.hwAMCL_Ang); CersioCt.bhwTrgAMCL = false; } // VehicleRunner Plot { PointD wlPos = new PointD(); REncoderToMap.CalcWheelPlotXY(ref wlR, ref wlL, ref reAng, CersioCt.hwRErotR, CersioCt.hwRErotL, reOldR, reOldL); wlPos.X = (wlR.X + wlL.X) * 0.5; wlPos.Y = (wlR.Y + wlL.Y) * 0.5; LocSys.Input_REPosition(wlPos.X, wlPos.Y, -reAng); reOldR = CersioCt.hwRErotR; reOldL = CersioCt.hwRErotL; } // LED状態 画面表示 if (CersioCt.LEDCtrl.ptnHeadLED == -1) { //lbl_LED.Text = "ND"; dataGridViewReceiveData.Rows[(int)GeridRow.LED].Cells[1].Value = "None"; } else { string ledStr = CersioCt.LEDCtrl.ptnHeadLED.ToString(); if (CersioCt.LEDCtrl.ptnHeadLED >= 0 && CersioCt.LEDCtrl.ptnHeadLED < LEDControl.LEDMessage.Count()) { ledStr += "," + LEDControl.LEDMessage[CersioCt.LEDCtrl.ptnHeadLED]; } dataGridViewReceiveData.Rows[(int)GeridRow.LED].Cells[1].Value = ledStr; /* * if (!ledStr.Equals(lbl_LED.Text)) * { * lbl_LED.Text = ledStr; * }*/ } // 現在座標 表示 //lbl_REPlotX.Text = LocSys.GetResultLocationX().ToString("F2"); //lbl_REPlotY.Text = LocSys.GetResultLocationY().ToString("F2"); //lbl_REPlotDir.Text = LocSys.GetResultAngle().ToString("F2"); dataGridViewReceiveData.Rows[(int)GeridRow.Plot].Cells[1].Value = LocSys.GetResultLocationX().ToString("F2"); dataGridViewReceiveData.Rows[(int)GeridRow.Plot].Cells[2].Value = LocSys.GetResultLocationY().ToString("F2"); dataGridViewReceiveData.Rows[(int)GeridRow.Plot].Cells[3].Value = LocSys.GetResultAngle().ToString("F2"); // CheckPointIndex if (BrainCtrl.LocSys.RTS.TrgCheckPoint()) { // チェックポイント通過時に表示更新 numericUD_CheckPoint.Value = BrainCtrl.LocSys.RTS.GetCheckPointIdx(); } // BoxPC接続状態確認 if (CersioCt.TCP_IsConnected()) { // 接続OK tb_SendData.BackColor = Color.Lime; tb_ResiveData.BackColor = Color.Lime; lb_BServerConnect.Text = "bServer [" + CersioCt.TCP_GetConnectedAddr() + "] 接続OK"; lb_BServerConnect.BackColor = Color.Lime; } else { // 接続NG tb_SendData.BackColor = SystemColors.Window; tb_ResiveData.BackColor = SystemColors.Window; lb_BServerConnect.Text = "bServer 未接続"; lb_BServerConnect.BackColor = SystemColors.Window; } // 送受信文字 画面表示 if (!string.IsNullOrEmpty(CersioCt.hwResiveStr)) { tb_ResiveData.Text = CersioCt.hwResiveStr.Replace('\n', ' '); CersioCt.hwResiveStr = ""; } if (!string.IsNullOrEmpty(CersioCt.hwSendStr)) { tb_SendData.Text = CersioCt.hwSendStr.Replace('\n', ' '); CersioCt.hwSendStr = ""; } updateHwCnt++; } // マップ上の現在位置更新 // 現在位置を、AMCL,REPlotどちらを使うか LocationSystem.LOCATION_SENSOR selSensor = (rb_SelAMCL.Checked ? LocationSystem.LOCATION_SENSOR.AMCL : LocationSystem.LOCATION_SENSOR.REPlot); BrainCtrl.LocSys.update_NowLocation(selSensor); // 自律走行(緊急ブレーキ、壁よけ含む)処理 更新 double speedKmh = (double)numericUpDownCtrlSpeed.Value; BrainCtrl.AutonomousProc(bRunAutonomous, cb_MoveBaseControl.Checked, speedKmh); // 距離計 //tb_Trip.Text = (LocSys.GetResultDistance_mm() * (1.0 / 1000.0)).ToString("f2"); tb_Trip.Text = (CersioCt.nowLengthMm * (1.0 / 1000.0)).ToString("f2"); } // スピード表示 tb_RESpeed.Text = ((CersioCt.nowSpeedMmSec * 3600.0) / (1000.0 * 1000.0)).ToString("f2"); // Km/Hour //tb_RESpeed.Text = (CersioCt.SpeedMmSec).ToString("f2"); // mm/Sec // ACコマンド送信した ハンドル、アクセル値 表示 tb_AccelVal.Text = CersioCt.sendAccelValue.ToString("f2"); tb_HandleVal.Text = CersioCt.sendHandleValue.ToString("f2"); //labelMoveBaseX.Text = CersioCt.hwMVBS_X.ToString("f2"); //labelMoveBaseAng.Text = CersioCt.hwMVBS_Ang.ToString("f2"); // グリッド表示 dataGridViewReceiveData.Rows[(int)GeridRow.MoveBase].Cells[1].Value = CersioCt.hwMVBS_X.ToString("f2"); dataGridViewReceiveData.Rows[(int)GeridRow.MoveBase].Cells[2].Value = CersioCt.hwMVBS_Y.ToString("f2"); dataGridViewReceiveData.Rows[(int)GeridRow.MoveBase].Cells[3].Value = CersioCt.hwMVBS_Ang.ToString("f2"); dataGridViewReceiveData.Rows[(int)GeridRow.CmdVel].Cells[1].Value = CersioCt.nowAccValue.ToString("f2"); dataGridViewReceiveData.Rows[(int)GeridRow.CmdVel].Cells[2].Value = "0.00"; dataGridViewReceiveData.Rows[(int)GeridRow.CmdVel].Cells[3].Value = CersioCt.nowHandleValue.ToString("f2"); dataGridViewReceiveData.Rows[(int)GeridRow.ActionMode].Cells[1].Value = BrainCtrl.ModeCtrl.GetActionModeString(); dataGridViewReceiveData.Rows[(int)GeridRow.StackCnt].Cells[1].Value = BrainCtrl.noPowerTrainCnt.ToString(); dataGridViewReceiveData.Rows[(int)GeridRow.StackCnt].Cells[2].Value = BrainCtrl.noFowrdCnt.ToString(); // 自律走行情報 if (bRunAutonomous) { // 動作内容TextBox表示 lbl_ActionMode.Text = "自律走行[" + BrainCtrl.ModeCtrl.GetActionModeString() + "]"; } else { lbl_ActionMode.Text = "モニタリング モード"; } // 画面描画 PictureUpdate(); }
private void picbox_AreaMap_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { // if (bMouseMove) { viewMoveAddX = (MouseStX - e.X); viewMoveAddY = (MouseStY - e.Y); } else if (selCpIndex != -1) { LocationSystem LocSys = BrainCtrl.LocSys; int msPosX = (e.X - MouseStX); int msPosY = (e.Y - MouseStY); MarkPoint _checkPos = new MarkPoint(new DrawMarkPoint(msPosX, msPosY, 0.0), LocSys); Vector3 baseCpPos = new Vector3((moveCpPos.x + _checkPos.x) , (moveCpPos.y + _checkPos.y) , 0.0); Vector3 nowCpPos = LocSys.RTS.GetCheckPoint(selCpIndex); if (nowCpPos != baseCpPos) { LocSys.RTS.SetCheckPoint(selCpIndex, baseCpPos); } } } else if (e.Button == MouseButtons.Right) { } else { if (checkBoxCheckPointModifi.Checked) { //if (radioButtonPointMove.Checked && (Control.ModifierKeys & Keys.Control) == Keys.Control) { LocationSystem LocSys = BrainCtrl.LocSys; DrawMarkPoint drawCenter = new DrawMarkPoint(LocSys.R1, LocSys); // センターを左下にずらす Width x 0.1, Height x 0.1 double viewCenterX = (picbox_AreaMap.Width * 0.5) - (picbox_AreaMap.Width * 0.1); double viewCenterY = (picbox_AreaMap.Height * 0.5) + (picbox_AreaMap.Height * 0.1); int msPosX = e.X - (int)((-drawCenter.x + viewCenterX) - viewScrollX); int msPosY = e.Y - (int)((-drawCenter.y + viewCenterY) - viewScrollY); MarkPoint mouseRosPos = new MarkPoint(new DrawMarkPoint(msPosX, msPosY, 0.0), LocSys); { // 移動チェックポイント選択 selCpIndex = LocSys.GetCheckPointIndex(mouseRosPos.x, mouseRosPos.y); if (selCpIndex != -1) { // 移動チェックポイント取得 moveCpPos = LocSys.RTS.GetCheckPoint(selCpIndex); } } } } } }
// ----------------------------------------------------------------- // マップスクロール private void picbox_AreaMap_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left /*&& selAreaMapMode == MAP_MODE.AREA_MAP*/) { //どの修飾子キー(Shift、Ctrl、およびAlt)が押されているか /* * if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) * Console.WriteLine("Shiftキーが押されています。"); * if ((Control.ModifierKeys & Keys.Control) == Keys.Control) * Console.WriteLine("Ctrlキーが押されています。"); * if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt) * Console.WriteLine("Altキーが押されています。"); */ if (checkBoxCheckPointModifi.Checked) { LocationSystem LocSys = BrainCtrl.LocSys; DrawMarkPoint drawCenter = new DrawMarkPoint(LocSys.R1, LocSys); // センターを左下にずらす Width x 0.1, Height x 0.1 double viewCenterX = formDraw.GetMapWndowCenterX(picbox_AreaMap); // (picbox_AreaMap.Width * 0.5) - (picbox_AreaMap.Width * 0.1); double viewCenterY = formDraw.GetMapWndowCenterY(picbox_AreaMap); //(picbox_AreaMap.Height * 0.5) + (picbox_AreaMap.Height * 0.1); int msPosX = e.X - (int)((-drawCenter.x + viewCenterX) - viewScrollX); int msPosY = e.Y - (int)((-drawCenter.y + viewCenterY) - viewScrollY); MarkPoint mouseRosPos = new MarkPoint(new DrawMarkPoint(msPosX, msPosY, 0.0), LocSys); if (radioButtonPointMove.Checked && (Control.ModifierKeys & Keys.Control) == Keys.Control) { // 移動チェックポイント選択 selCpIndex = LocSys.GetCheckPointIndex(mouseRosPos.x, mouseRosPos.y); if (selCpIndex != -1) { // 移動チェックポイント取得 moveCpPos = LocSys.RTS.GetCheckPoint(selCpIndex); } else { // スクロール bMouseMove = true; } } else if (radioButtonPointAdd.Checked) { // チェックポイント新規追加 Vector3 baseCpPos = new Vector3(mouseRosPos.x, mouseRosPos.y, 0.0); LocSys.RTS.AddCheckPoint((int)numericUD_CheckPoint.Value, baseCpPos); } else if (radioButtonPointDelete.Checked) { // チェックポイント削除 Vector3 baseCpPos = new Vector3(mouseRosPos.x, mouseRosPos.y, 0.0); selCpIndex = LocSys.GetCheckPointIndex(mouseRosPos.x, mouseRosPos.y); if (selCpIndex != -1) { LocSys.RTS.RemoveCheckPoint(selCpIndex); } selCpIndex = -1; } else { // スクロール bMouseMove = true; } } else { // スクロール bMouseMove = true; } MouseStX = e.X; MouseStY = e.Y; viewMoveAddX = 0; viewMoveAddY = 0; } }
protected override void LoadState() { locations = new(ParsedFileLines(Trip.Parse)); }