예제 #1
0
        void ISensorEventListener.OnSensorChanged(SensorEvent e)
        {
            if (e.Sensor.Name == accelerometer && !lastAccelerometerSet)
            {
                e.Values.CopyTo(lastAccelerometer, 0);
                lastAccelerometerSet = true;
            }
            else if (e.Sensor.Name == magnetometer && !lastMagnetometerSet)
            {
                e.Values.CopyTo(lastMagnetometer, 0);
                lastMagnetometerSet = true;
            }

            if (lastAccelerometerSet && lastMagnetometerSet)
            {
                SensorManager.GetRotationMatrix(r, null, lastAccelerometer, lastMagnetometer);
                SensorManager.GetOrientation(r, orientation);
                var azimuthInRadians = orientation[0];
                if (Compass.ApplyLowPassFilter)
                {
                    filter.Add(azimuthInRadians);
                    azimuthInRadians = filter.Average();
                }
                var azimuthInDegress = (Java.Lang.Math.ToDegrees(azimuthInRadians) + 360.0) % 360.0;

                var data = new CompassData(azimuthInDegress);
                Compass.OnChanged(data);
                lastMagnetometerSet  = false;
                lastAccelerometerSet = false;
            }
        }
예제 #2
0
            public void Compass_Should_Change_Heading()
            {
                // Given
                var                  testScheduler = new TestScheduler();
                CompassData          reading       = new CompassData();
                MockCompassEssential compass       = new MockCompassEssentialFixture().WithScheduler(testScheduler);

                compass
                .CompassChanged
                .Subscribe(_ =>
                {
                    reading = _.Reading;
                });

                // When
                testScheduler.AdvanceToMs(TimeSpan.FromSeconds(1).TotalMilliseconds);

                // Then
                reading.HeadingMagneticNorth.Should().Be(0);

                // When
                testScheduler.AdvanceBy(TimeSpan.FromSeconds(1).Ticks);

                // Then
                reading.HeadingMagneticNorth.Should().Be(10);

                // When
                testScheduler.AdvanceBy(TimeSpan.FromSeconds(1).Ticks);

                // Then
                reading.HeadingMagneticNorth.Should().Be(20);
            }
예제 #3
0
        public void CompassData_Comparison(
            double heading1,
            double heading2,
            bool equals)
        {
            var data1 = new CompassData(heading1);
            var data2 = new CompassData(heading2);

            if (equals)
            {
                Assert.True(data1.Equals(data2));
                Assert.True(data1 == data2);
                Assert.False(data1 != data2);
                Assert.Equal(data1, data2);
                Assert.Equal(data1.GetHashCode(), data2.GetHashCode());
            }
            else
            {
                Assert.False(data1.Equals(data2));
                Assert.False(data1 == data2);
                Assert.True(data1 != data2);
                Assert.NotEqual(data1, data2);
                Assert.NotEqual(data1.GetHashCode(), data2.GetHashCode());
            }
        }
예제 #4
0
        private void UpdateEnemyFleet()
        {
            CompassData compass = KCDatabase.Instance.Battle.Compass;

            _enemyFleetCandidate = RecordManager.Instance.EnemyFleet.Record.Values.Where(
                r =>
                r.MapAreaID == compass.MapAreaID &&
                r.MapInfoID == compass.MapInfoID &&
                r.CellID == compass.Destination &&
                r.Difficulty == compass.MapInfo.EventDifficulty
                ).ToList();
            _enemyFleetCandidateIndex = -1;


            if (_enemyFleetCandidate.Count == 0)
            {
                TextEventDetail.Text    = "(敵艦隊候補なし)";
                TextEnemyFleetName.Text = "(敵艦隊情報不明)";

                TextFormation.Visible      = false;
                TextAirSuperiority.Visible = false;
                TableEnemyMember.Visible   = false;
            }
            else
            {
                NextEnemyFleetCandidate();
            }


            PanelEnemyFleet.Visible = true;
        }
예제 #5
0
        public void OnSensorChanged(SensorEvent e)
        {
            if (e.Sensor.Name == accelerometer && !lastAccelerometerSet)
            {
                CopyValues(e.Values, lastAccelerometer);
                lastAccelerometerSet = true;
            }
            else if (e.Sensor.Name == magnetometer && !lastMagnetometerSet)
            {
                CopyValues(e.Values, lastMagnetometer);
                lastMagnetometerSet = true;
            }

            if (lastAccelerometerSet && lastMagnetometerSet)
            {
                SensorManager.GetRotationMatrix(r, null, lastAccelerometer, lastMagnetometer);
                SensorManager.GetOrientation(r, orientation);
                var azimuthInRadians = orientation[0];
                var azimuthInDegress = (Java.Lang.Math.ToDegrees(azimuthInRadians) + 360.0) % 360.0;

                var data = new CompassData(azimuthInDegress);
                Compass.OnChanged(data);
                lastMagnetometerSet  = false;
                lastAccelerometerSet = false;
            }
        }
예제 #6
0
        internal void RaiseReadingChanged(CompassData data)
        {
            var args = new CompassChangedEventArgs(data);

            if (UseSyncContext)
            {
                MainThread.BeginInvokeOnMainThread(() => ReadingChanged?.Invoke(null, args));
            }
            else
            {
                ReadingChanged?.Invoke(null, args);
            }
        }
		private void UpdateEnemyFleet()
		{

			CompassData compass = KCDatabase.Instance.Battle.Compass;

			_enemyFleetCandidate = RecordManager.Instance.EnemyFleet.Record.Values.Where(
				r =>
					r.MapAreaID == compass.MapAreaID &&
					r.MapInfoID == compass.MapInfoID &&
					r.CellID == compass.Destination &&
					r.Difficulty == compass.MapInfo.EventDifficulty
				).ToList();
			_enemyFleetCandidateIndex = 0;


			if (_enemyFleetCandidate.Count == 0)
			{
				TextEventDetail.Text = "( 尚无敌舰队候选 )";
				TextEventDetail.Font = Utility.Configuration.Config.UI.MainFont;
				TextEnemyFleetName.Text = "( 敌舰队名不明 )";
				TextEnemyFleetName.Font = Utility.Configuration.Config.UI.MainFont;


				TableEnemyCandidate.Visible = false;

			}
			else
			{
				_enemyFleetCandidate.Sort((a, b) =>
				{
					for (int i = 0; i < a.FleetMember.Length; i++)
					{
						int diff = a.FleetMember[i] - b.FleetMember[i];
						if (diff != 0)
							return diff;
					}
					return a.Formation - b.Formation;
				});

				NextEnemyFleetCandidate(0);
			}


			PanelEnemyFleet.Visible = false;

		}
예제 #8
0
        private bool CheckGaugeIndex72(CompassData compass)
        {
            if (compass.MapAreaID == 7 && compass.MapInfoID == 2)
            {
                switch (compass.Destination)
                {
                case 7:
                    return(GaugeIndex == 1);

                case 15:
                    return(GaugeIndex == 2);

                default:
                    return(false);
                }
            }
            return(true);
        }
예제 #9
0
        private void UpdateEnemyFleet()
        {
            CompassData compass = KCDatabase.Instance.Battle.Compass;

            _enemyFleetCandidate = RecordManager.Instance.EnemyFleet.Record.Values.Where(
                r =>
                r.MapAreaID == compass.MapAreaID &&
                r.MapInfoID == compass.MapInfoID &&
                r.CellID == compass.Destination &&
                r.Difficulty == compass.MapInfo.EventDifficulty
                ).ToList();
            _enemyFleetCandidateIndex = 0;


            if (_enemyFleetCandidate.Count == 0)
            {
                TextEventDetail.Text    = GeneralRes.NoFleetCandidates;
                TextEnemyFleetName.Text = GeneralRes.EnemyUnknown;


                TableEnemyCandidate.Visible = false;
            }
            else
            {
                _enemyFleetCandidate.Sort((a, b) =>
                {
                    for (int i = 0; i < a.FleetMember.Length; i++)
                    {
                        int diff = a.FleetMember[i] - b.FleetMember[i];
                        if (diff != 0)
                        {
                            return(diff);
                        }
                    }
                    return(a.Formation - b.Formation);
                });

                NextEnemyFleetCandidate(0);
            }


            PanelEnemyFleet.Visible = false;
        }
예제 #10
0
        private string GetMaterialName(CompassData compass)
        {
            if (compass.GetItemID == 4)                         //"※" 大方資源専用ID

            {
                return(Constants.GetMaterialName(compass.GetItemIDMetadata));
            }
            else
            {
                UseItemMaster item = KCDatabase.Instance.MasterUseItems[compass.GetItemIDMetadata];
                if (item != null)
                {
                    return(item.Name);
                }
                else
                {
                    return("謎のアイテム");
                }
            }
        }
예제 #11
0
        private string GetMaterialInfo(CompassData compass)
        {
            var strs = new LinkedList <string>();

            foreach (var item in compass.GetItems)
            {
                string itemName;

                if (item.ItemID == 4)
                {
                    itemName = Constants.GetMaterialName(item.Metadata);
                }
                else
                {
                    var itemMaster = KCDatabase.Instance.MasterUseItems[item.Metadata];
                    if (itemMaster != null)
                    {
                        itemName = itemMaster.Name;
                    }
                    else
                    {
                        itemName = "謎のアイテム";
                    }
                }

                strs.AddLast(itemName + " x " + item.Amount);
            }

            if (!strs.Any())
            {
                return("(なし)");
            }
            else
            {
                return(string.Join(", ", strs));
            }
        }
예제 #12
0
 internal CompassChangedEventArgs(CompassData reading) => Reading = reading;
예제 #13
0
 internal static void OnChanged(CompassData reading)
 => OnChanged(new CompassChangedEventArgs(reading));
예제 #14
0
        public override void LoadFromResponse( string apiname, dynamic data )
        {
            //base.LoadFromResponse( apiname, data );	//不要

            switch ( apiname ) {
                case "api_req_map/start":
                case "api_req_map/next":
                    BattleDay = null;
                    BattleNight = null;
                    Result = null;
                    BattleMode = BattleModes.Undefined;
                    Compass = new CompassData();
                    Compass.LoadFromResponse( apiname, data );
                    break;

                case "api_req_sortie/battle":
                    BattleMode = BattleModes.Normal;
                    BattleDay = new BattleNormalDay();
                    BattleDay.LoadFromResponse( apiname, data );
                    break;

                case "api_req_battle_midnight/battle":
                    BattleNight = new BattleNormalNight();
                    BattleNight.TakeOverParameters( BattleDay );
                    BattleNight.LoadFromResponse( apiname, data );
                    break;

                case "api_req_battle_midnight/sp_midnight":
                    BattleMode = BattleModes.NightOnly;
                    BattleNight = new BattleNightOnly();
                    BattleNight.LoadFromResponse( apiname, data );
                    break;

                case "api_req_sortie/airbattle":
                    BattleMode = BattleModes.AirBattle;
                    BattleDay = new BattleAirBattle();
                    BattleDay.LoadFromResponse( apiname, data );
                    break;

                case "api_req_combined_battle/battle":
                    BattleMode = BattleModes.Normal | BattleModes.CombinedTaskForce;
                    BattleDay = new BattleCombinedNormalDay();
                    BattleDay.LoadFromResponse( apiname, data );
                    break;

                case "api_req_combined_battle/midnight_battle":
                    BattleNight = new BattleCombinedNormalNight();
                    //BattleNight.TakeOverParameters( BattleDay );		//checkme: 連合艦隊夜戦では昼戦での与ダメージがMVPに反映されない仕様?
                    BattleNight.LoadFromResponse( apiname, data );
                    break;

                case "api_req_combined_battle/sp_midnight":
                    BattleMode = BattleModes.NightOnly | BattleModes.CombinedMask;
                    BattleNight = new BattleCombinedNightOnly();
                    BattleNight.LoadFromResponse( apiname, data );
                    break;

                case "api_req_combined_battle/airbattle":
                    BattleMode = BattleModes.AirBattle | BattleModes.CombinedTaskForce;
                    BattleDay = new BattleCombinedAirBattle();
                    BattleDay.LoadFromResponse( apiname, data );
                    break;

                case "api_req_combined_battle/battle_water":
                    BattleMode = BattleModes.Normal | BattleModes.CombinedSurface;
                    BattleDay = new BattleCombinedWater();
                    BattleDay.LoadFromResponse( apiname, data );
                    break;

                case "api_req_practice/battle":
                    BattleMode = BattleModes.Practice;
                    BattleDay = new BattlePracticeDay();
                    BattleDay.LoadFromResponse( apiname, data );
                    break;

                case "api_req_practice/midnight_battle":
                    BattleNight = new BattlePracticeNight();
                    BattleNight.TakeOverParameters( BattleDay );
                    BattleNight.LoadFromResponse( apiname, data );
                    break;

                case "api_req_sortie/battleresult":
                case "api_req_combined_battle/battleresult":
                case "api_req_practice/battle_result":
                    Result = new BattleResultData();
                    Result.LoadFromResponse( apiname, data );
                    BattleFinished();
                    break;

                case "api_port/port":
                    Compass = null;
                    BattleDay = null;
                    BattleNight = null;
                    Result = null;
                    BattleMode = BattleModes.Undefined;
                    DroppedShipCount = DroppedEquipmentCount = 0;
                    break;

                case "api_get_member/slot_item":
                    DroppedEquipmentCount = 0;
                    break;

            }
        }
예제 #15
0
        public override void LoadFromResponse(string apiname, dynamic data)
        {
            //base.LoadFromResponse( apiname, data );	//不要

            switch (apiname)
            {
            case "api_req_map/start":
            case "api_req_map/next":
                BattleDay   = null;
                BattleNight = null;
                Result      = null;
                BattleMode  = BattleModes.Undefined;
                Compass     = new CompassData();
                Compass.LoadFromResponse(apiname, data);
                break;

            case "api_req_sortie/battle":
                BattleMode = BattleModes.Normal;
                BattleDay  = new BattleNormalDay();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_battle_midnight/battle":
                BattleNight = new BattleNormalNight();
                BattleNight.TakeOverParameters(BattleDay);
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_battle_midnight/sp_midnight":
                BattleMode  = BattleModes.NightOnly;
                BattleNight = new BattleNightOnly();
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_sortie/airbattle":
                BattleMode = BattleModes.AirBattle;
                BattleDay  = new BattleAirBattle();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_sortie/ld_airbattle":
                BattleMode = BattleModes.AirRaid;
                BattleDay  = new BattleAirRaid();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/battle":
                BattleMode = BattleModes.Normal | BattleModes.CombinedTaskForce;
                BattleDay  = new BattleCombinedNormalDay();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/midnight_battle":
                BattleNight = new BattleCombinedNormalNight();
                //BattleNight.TakeOverParameters( BattleDay );		//checkme: 連合艦隊夜戦では昼戦での与ダメージがMVPに反映されない仕様?
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/sp_midnight":
                BattleMode  = BattleModes.NightOnly | BattleModes.CombinedMask;
                BattleNight = new BattleCombinedNightOnly();
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/airbattle":
                BattleMode = BattleModes.AirBattle | BattleModes.CombinedTaskForce;
                BattleDay  = new BattleCombinedAirBattle();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/battle_water":
                BattleMode = BattleModes.Normal | BattleModes.CombinedSurface;
                BattleDay  = new BattleCombinedWater();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/ld_airbattle":
                BattleMode = BattleModes.AirRaid | BattleModes.CombinedTaskForce;
                BattleDay  = new BattleCombinedAirRaid();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/ec_battle":
                BattleMode = BattleModes.Normal | BattleModes.EnemyCombinedFleet;
                BattleDay  = new BattleEnemyCombinedDay();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/ec_midnight_battle":
                BattleNight = new BattleEnemyCombinedNight();
                //BattleNight.TakeOverParameters( BattleDay );		//undone: これで正しいかは未検証
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/each_battle":
                BattleMode = BattleModes.Normal | BattleModes.CombinedTaskForce | BattleModes.EnemyCombinedFleet;
                BattleDay  = new BattleCombinedEachDay();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/each_battle_water":
                BattleMode = BattleModes.Normal | BattleModes.CombinedSurface | BattleModes.EnemyCombinedFleet;
                BattleDay  = new BattleCombinedEachWater();
                BattleDay.LoadFromResponse(apiname, data);
                break;


            case "api_req_member/get_practice_enemyinfo":
                EnemyAdmiralName = data.api_nickname;
                EnemyAdmiralRank = Constants.GetAdmiralRank((int)data.api_rank);
                break;

            case "api_req_practice/battle":
                BattleMode = BattleModes.Practice;
                BattleDay  = new BattlePracticeDay();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_practice/midnight_battle":
                BattleNight = new BattlePracticeNight();
                BattleNight.TakeOverParameters(BattleDay);
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_sortie/battleresult":
            case "api_req_combined_battle/battleresult":
            case "api_req_practice/battle_result":
                Result = new BattleResultData();
                Result.LoadFromResponse(apiname, data);
                BattleFinished();
                break;

            case "api_port/port":
                Compass          = null;
                BattleDay        = null;
                BattleNight      = null;
                Result           = null;
                BattleMode       = BattleModes.Undefined;
                DroppedShipCount = DroppedEquipmentCount = 0;
                DroppedItemCount.Clear();
                break;

            case "api_get_member/slot_item":
                DroppedEquipmentCount = 0;
                break;
            }
        }
예제 #16
0
        private void Updated(string apiname, dynamic data)
        {
            Func <int, Color> getColorFromEventKind = ( int kind ) => {
                switch (kind)
                {
                case 0:
                case 1:
                default:                                //昼夜戦・その他
                    return(SystemColors.ControlText);

                case 2:
                case 3:                                 //夜戦・夜昼戦
                    return(Color.Navy);

                case 4:                                 //航空戦
                    return(Color.DarkGreen);
                }
            };

            if (apiname == "api_port/port")
            {
                BasePanel.Visible = false;
            }
            else if (apiname == "api_req_member/get_practice_enemyinfo")
            {
                TextMapArea.Text           = GeneralRes.Practice;
                TextDestination.Text       = string.Format("{0} {1}", data.api_nickname, Constants.GetAdmiralRank((int)data.api_rank));
                TextDestination.ImageAlign = ContentAlignment.MiddleCenter;
                TextDestination.ImageIndex = -1;
                ToolTipInfo.SetToolTip(TextDestination, null);
                TextEventKind.Text         = data.api_cmt;
                TextEventKind.ForeColor    = getColorFromEventKind(0);
                TextEventDetail.Text       = string.Format("Lv. {0} / {1} exp.", data.api_level, data.api_experience[0]);
                TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
                TextEventDetail.ImageIndex = -1;
                TextEnemyFleetName.Text    = data.api_deckname;
            }
            else
            {
                CompassData compass = KCDatabase.Instance.Battle.Compass;


                BasePanel.SuspendLayout();
                PanelEnemyFleet.Visible = false;


                TextMapArea.Text = string.Format(GeneralRes.Map + ": {0}-{1}", compass.MapAreaID, compass.MapInfoID);

                TextDestination.Text = string.Format(GeneralRes.NextNode + ": {0}{1}", compass.Destination, (compass.IsEndPoint ? GeneralRes.EndNode : ""));
                if (compass.LaunchedRecon != 0)
                {
                    TextDestination.ImageAlign = ContentAlignment.MiddleRight;
                    TextDestination.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane;

                    string tiptext;
                    switch (compass.CommentID)
                    {
                    case 1:
                        tiptext = GeneralRes.EnemySighted;
                        break;

                    case 2:
                        tiptext = GeneralRes.TargetSighted;
                        break;

                    default:
                        tiptext = GeneralRes.EnemyPlaneSighted;
                        break;
                    }
                    ToolTipInfo.SetToolTip(TextDestination, tiptext);
                }
                else
                {
                    TextDestination.ImageAlign = ContentAlignment.MiddleCenter;
                    TextDestination.ImageIndex = -1;
                    ToolTipInfo.SetToolTip(TextDestination, null);
                }

                //とりあえずリセット
                TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
                TextEventDetail.ImageIndex = -1;


                TextEventKind.ForeColor = getColorFromEventKind(0);

                {
                    string eventkind = Constants.GetMapEventID(compass.EventID);

                    switch (compass.EventID)
                    {
                    case 0:                                     //初期位置
                    case 1:                                     //不明
                        TextEventDetail.Text = GeneralRes.WhyDidThisHappen;
                        break;

                    case 2:                                     //資源
                    case 8:                                     //船団護衛成功
                        TextEventDetail.Text = GetMaterialName(compass) + " x " + compass.GetItemAmount;
                        break;

                    case 3:                                     //渦潮
                    {
                        int materialmax = KCDatabase.Instance.Fleet.Fleets.Values
                                          .Where(f => f != null && f.IsInSortie)
                                          .SelectMany(f => f.MembersWithoutEscaped)
                                          .Max(s => {
                                if (s == null)
                                {
                                    return(0);
                                }
                                switch (compass.WhirlpoolItemID)
                                {
                                case 1:
                                    return(s.Fuel);

                                case 2:
                                    return(s.Ammo);

                                default:
                                    return(0);
                                }
                            });

                        TextEventDetail.Text = string.Format("{0} x {1} ({2:p0})",
                                                             Constants.GetMaterialName(compass.WhirlpoolItemID),
                                                             compass.WhirlpoolItemAmount,
                                                             (double)compass.WhirlpoolItemAmount / Math.Max(materialmax, 1));
                    }
                    break;

                    case 4:                                     //通常戦闘
                        if (compass.EventKind >= 2)
                        {
                            eventkind += "/" + Constants.GetMapEventKind(compass.EventKind);

                            TextEventKind.ForeColor = getColorFromEventKind(compass.EventKind);
                        }
                        UpdateEnemyFleet(compass.EnemyFleetID);
                        break;

                    case 5:                                     //ボス戦闘
                        TextEventKind.ForeColor = Color.Red;
                        goto case 4;

                    case 6:                                     //気のせいだった
                        switch (compass.EventKind)
                        {
                        case 0:                                                 //気のせいだった
                        default:
                            TextEventDetail.Text = "";
                            break;

                        case 1:                                                 //敵影を見ず
                            eventkind            = GeneralRes.SawNoEnemy;
                            TextEventDetail.Text = "";
                            break;

                        case 2:                                                 //能動分岐
                            eventkind            = GeneralRes.BranchChoice;
                            TextEventDetail.Text = string.Join("/", compass.RouteChoices);
                            break;
                        }
                        break;

                    case 7:                                     //航空戦or航空偵察
                        TextEventKind.ForeColor = getColorFromEventKind(compass.EventKind);

                        switch (compass.EventKind)
                        {
                        case 0:                                                 //航空偵察
                            eventkind = "航空偵察";

                            switch (compass.AirReconnaissanceResult)
                            {
                            case 0:
                            default:
                                TextEventDetail.Text = "失敗";
                                break;

                            case 1:
                                TextEventDetail.Text = "成功";
                                break;

                            case 2:
                                TextEventDetail.Text = "大成功";
                                break;
                            }

                            switch (compass.AirReconnaissancePlane)
                            {
                            case 0:
                            default:
                                TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
                                TextEventDetail.ImageIndex = -1;
                                break;

                            case 1:
                                TextEventDetail.ImageAlign = ContentAlignment.MiddleLeft;
                                TextEventDetail.ImageIndex = (int)ResourceManager.EquipmentContent.FlyingBoat;
                                break;

                            case 2:
                                TextEventDetail.ImageAlign = ContentAlignment.MiddleLeft;
                                TextEventDetail.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane;
                                break;
                            }

                            if (compass.GetItemID != -1)
                            {
                                TextEventDetail.Text += string.Format(" {0} x {1}", GetMaterialName(compass), compass.GetItemAmount);
                            }

                            break;

                        case 4:                                                 //航空戦
                        default:
                            UpdateEnemyFleet(compass.EnemyFleetID);
                            break;
                        }
                        break;


                    default:
                        TextEventDetail.Text = "";
                        break;
                    }
                    TextEventKind.Text = eventkind;
                }

                BasePanel.ResumeLayout();

                BasePanel.Visible = true;
            }
        }
예제 #17
0
        private void Updated(string apiname, dynamic data)
        {
            Color getColorFromEventKind(int kind)
            {
                switch (kind)
                {
                case 0:
                case 1:
                default:                            //昼夜戦・その他
                    return(SystemColors.ControlText);

                case 2:
                case 3:                             //夜戦・夜昼戦
                    return(Color.Navy);

                case 4:                             //航空戦
                case 6:                             //長距離空襲戦
                    return(Color.DarkGreen);

                case 5:                             // 敵連合
                    return(Color.DarkRed);

                case 7:                             // 夜昼戦(対連合艦隊)
                    return(Color.Navy);

                case 8:                             // レーダー射撃
                    return(Color.Navy);
                }
            }

            if (apiname == "api_port/port")
            {
                BasePanel.Visible = false;
            }
            else if (apiname == "api_req_member/get_practice_enemyinfo")
            {
                TextMapArea.Text           = "演習";
                TextDestination.Text       = string.Format("{0} {1}", data.api_nickname, Constants.GetAdmiralRank((int)data.api_rank));
                TextDestination.ImageAlign = ContentAlignment.MiddleCenter;
                TextDestination.ImageIndex = -1;
                ToolTipInfo.SetToolTip(TextDestination, null);
                TextEventKind.Text       = data.api_cmt;
                TextEventKind.ForeColor  = getColorFromEventKind(0);
                TextEventKind.ImageAlign = ContentAlignment.MiddleCenter;
                TextEventKind.ImageIndex = -1;
                ToolTipInfo.SetToolTip(TextEventKind, null);
                TextEventDetail.Text       = string.Format("Lv. {0} / {1} exp.", data.api_level, data.api_experience[0]);
                TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
                TextEventDetail.ImageIndex = -1;
                ToolTipInfo.SetToolTip(TextEventDetail, null);
                TextEnemyFleetName.Text = data.api_deckname;
            }
            else
            {
                CompassData compass = KCDatabase.Instance.Battle.Compass;


                BasePanel.SuspendLayout();
                PanelEnemyFleet.Visible     = false;
                PanelEnemyCandidate.Visible = false;

                _enemyFleetCandidate      = null;
                _enemyFleetCandidateIndex = -1;


                TextMapArea.Text = string.Format("出撃海域 : {0}-{1}{2}", compass.MapAreaID, compass.MapInfoID,
                                                 compass.MapInfo.EventDifficulty > 0 ? " [" + Constants.GetDifficulty(compass.MapInfo.EventDifficulty) + "]" : "");
                {
                    var mapinfo = compass.MapInfo;
                    var sb      = new StringBuilder();

                    if (mapinfo.RequiredDefeatedCount != -1 && mapinfo.CurrentDefeatedCount < mapinfo.RequiredDefeatedCount)
                    {
                        sb.AppendFormat("{0}撃破: {1} / {2} 回\r\n",
                                        mapinfo.CurrentGaugeIndex > 0 ? $"#{mapinfo.CurrentGaugeIndex} " : "",
                                        mapinfo.CurrentDefeatedCount, mapinfo.RequiredDefeatedCount);
                    }
                    else if (mapinfo.MapHPMax > 0)
                    {
                        int current = compass.MapHPCurrent > 0 ? compass.MapHPCurrent : mapinfo.MapHPCurrent;
                        int max     = compass.MapHPMax > 0 ? compass.MapHPMax : mapinfo.MapHPMax;

                        sb.AppendFormat("{0}{1}: {2} / {3}\r\n",
                                        mapinfo.CurrentGaugeIndex > 0 ? $"#{mapinfo.CurrentGaugeIndex} " : "",
                                        mapinfo.GaugeType == 3 ? "TP" : "HP", current, max);
                    }


                    foreach (var pair in KCDatabase.Instance.Battle.SpecialAttackCount)
                    {
                        sb.AppendLine($"{Constants.GetDayAttackKind((DayAttackKind)pair.Key)} : 発動済み");
                    }

                    ToolTipInfo.SetToolTip(TextMapArea, sb.Length > 0 ? sb.ToString() : null);
                }


                TextDestination.Text = string.Format("次のセル : {0}{1}", compass.Destination, (compass.IsEndPoint ? " (終点)" : ""));
                if (compass.LaunchedRecon != 0)
                {
                    TextDestination.ImageAlign = ContentAlignment.MiddleRight;
                    TextDestination.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane;

                    string tiptext;
                    switch (compass.CommentID)
                    {
                    case 1:
                        tiptext = "敵艦隊発見!";
                        break;

                    case 2:
                        tiptext = "攻撃目標発見!";
                        break;

                    case 3:
                        tiptext = "針路哨戒!";
                        break;

                    default:
                        tiptext = "索敵機発艦!";
                        break;
                    }
                    ToolTipInfo.SetToolTip(TextDestination, tiptext);
                }
                else
                {
                    TextDestination.ImageAlign = ContentAlignment.MiddleCenter;
                    TextDestination.ImageIndex = -1;
                    ToolTipInfo.SetToolTip(TextDestination, null);
                }

                //とりあえずリセット
                TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
                TextEventDetail.ImageIndex = -1;
                ToolTipInfo.SetToolTip(TextEventDetail, null);


                TextEventKind.ForeColor = getColorFromEventKind(0);

                {
                    string eventkind = Constants.GetMapEventID(compass.EventID);

                    switch (compass.EventID)
                    {
                    case 0:                                 //初期位置
                        TextEventDetail.Text = "どうしてこうなった";
                        break;

                    case 2:                                 //資源
                    case 8:                                 //船団護衛成功
                        TextEventDetail.Text = GetMaterialInfo(compass);
                        break;

                    case 3:                                 //渦潮
                    {
                        int materialmax = KCDatabase.Instance.Fleet.Fleets.Values
                                          .Where(f => f != null && f.IsInSortie)
                                          .SelectMany(f => f.MembersWithoutEscaped)
                                          .Max(s =>
                            {
                                if (s == null)
                                {
                                    return(0);
                                }
                                switch (compass.WhirlpoolItemID)
                                {
                                case 1:
                                    return(s.Fuel);

                                case 2:
                                    return(s.Ammo);

                                default:
                                    return(0);
                                }
                            });

                        TextEventDetail.Text = string.Format("{0} x {1} ({2:p0})",
                                                             Constants.GetMaterialName(compass.WhirlpoolItemID),
                                                             compass.WhirlpoolItemAmount,
                                                             (double)compass.WhirlpoolItemAmount / Math.Max(materialmax, 1));
                    }
                    break;

                    case 4:                                 //通常戦闘
                        if (compass.EventKind >= 2)
                        {
                            eventkind += "/" + Constants.GetMapEventKind(compass.EventKind);

                            TextEventKind.ForeColor = getColorFromEventKind(compass.EventKind);
                        }
                        UpdateEnemyFleet();
                        break;

                    case 5:                                 //ボス戦闘
                        TextEventKind.ForeColor = Color.Red;

                        if (compass.EventKind >= 2)
                        {
                            eventkind += "/" + Constants.GetMapEventKind(compass.EventKind);
                        }
                        UpdateEnemyFleet();
                        break;

                    case 1:                                 //イベントなし
                    case 6:                                 //気のせいだった
                        switch (compass.EventKind)
                        {
                        case 0:                                             //気のせいだった
                        default:
                            break;

                        case 1:
                            eventkind = "敵影を見ず";
                            break;

                        case 2:
                            eventkind = "能動分岐";
                            break;

                        case 3:
                            eventkind = "穏やかな海";
                            break;

                        case 4:
                            eventkind = "穏やかな海峡";
                            break;

                        case 5:
                            eventkind = "警戒が必要";
                            break;

                        case 6:
                            eventkind = "静かな海";
                            break;
                        }

                        if (compass.RouteChoices != null)
                        {
                            TextEventDetail.Text = string.Join("/", compass.RouteChoices);
                        }
                        else if (compass.FlavorTextType != -1)
                        {
                            TextEventDetail.Text = "◆";
                            ToolTipInfo.SetToolTip(TextEventDetail, compass.FlavorText);
                        }
                        else
                        {
                            TextEventDetail.Text = "";
                        }

                        break;

                    case 7:                                 //航空戦or航空偵察
                        TextEventKind.ForeColor = getColorFromEventKind(compass.EventKind);

                        switch (compass.EventKind)
                        {
                        case 0:                                             //航空偵察
                            eventkind = "航空偵察";

                            switch (compass.AirReconnaissanceResult)
                            {
                            case 0:
                            default:
                                TextEventDetail.Text = "失敗";
                                break;

                            case 1:
                                TextEventDetail.Text = "成功";
                                break;

                            case 2:
                                TextEventDetail.Text = "大成功";
                                break;
                            }

                            switch (compass.AirReconnaissancePlane)
                            {
                            case 0:
                            default:
                                TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
                                TextEventDetail.ImageIndex = -1;
                                break;

                            case 1:
                                TextEventDetail.ImageAlign = ContentAlignment.MiddleLeft;
                                TextEventDetail.ImageIndex = (int)ResourceManager.EquipmentContent.FlyingBoat;
                                break;

                            case 2:
                                TextEventDetail.ImageAlign = ContentAlignment.MiddleLeft;
                                TextEventDetail.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane;
                                break;
                            }

                            if (compass.GetItems.Any())
                            {
                                TextEventDetail.Text += " " + GetMaterialInfo(compass);
                            }

                            break;

                        case 4:                                             //航空戦
                        default:
                            UpdateEnemyFleet();
                            break;
                        }
                        break;

                    case 9:                                 //揚陸地点
                        TextEventDetail.Text = "";
                        break;

                    case 10:                                // 泊地
                        TextEventDetail.Text = compass.CanEmergencyAnchorageRepair ? "修理可能" : "";
                        break;

                    default:
                        TextEventDetail.Text = "";
                        break;
                    }
                    TextEventKind.Text = eventkind;
                }


                if (compass.HasAirRaid)
                {
                    TextEventKind.ImageAlign = ContentAlignment.MiddleRight;
                    TextEventKind.ImageIndex = (int)ResourceManager.EquipmentContent.CarrierBasedBomber;
                    ToolTipInfo.SetToolTip(TextEventKind, "空襲 - " + Constants.GetAirRaidDamage(compass.AirRaidDamageKind));
                }
                else
                {
                    TextEventKind.ImageAlign = ContentAlignment.MiddleCenter;
                    TextEventKind.ImageIndex = -1;
                    ToolTipInfo.SetToolTip(TextEventKind, null);
                }


                BasePanel.ResumeLayout();

                BasePanel.Visible = true;
            }
        }
예제 #18
0
        static void LocationManagerUpdatedHeading(object sender, CLHeadingUpdatedEventArgs e)
        {
            var data = new CompassData(e.NewHeading.MagneticHeading);

            OnChanged(data);
        }
예제 #19
0
 /// <include file="../../docs/Microsoft.Maui.Essentials/CompassChangedEventArgs.xml" path="//Member[@MemberName='.ctor']/Docs" />
 public CompassChangedEventArgs(CompassData reading) =>
예제 #20
0
        private void Updated(string apiname, dynamic data)
        {
            Color colorNormal = SystemColors.ControlText;
            Color colorNight  = Color.Navy;


            if (apiname == "api_port/port")
            {
                BasePanel.Visible = false;
            }
            else if (apiname == "api_req_member/get_practice_enemyinfo")
            {
                TextMapArea.Text        = "演習";
                TextDestination.Text    = string.Format("{0} {1}", data.api_nickname, Constants.GetAdmiralRank((int)data.api_rank));
                TextEventKind.Text      = data.api_cmt;
                TextEventKind.ForeColor = colorNormal;
                TextEventDetail.Text    = string.Format("Lv. {0} / {1} exp.", data.api_level, data.api_experience[0]);
                TextEnemyFleetName.Text = data.api_deckname;
            }
            else
            {
                CompassData compass = KCDatabase.Instance.Battle.Compass;


                BasePanel.SuspendLayout();
                PanelEnemyFleet.Visible = false;

                TextMapArea.Text        = "出撃海域 : " + compass.MapAreaID + "-" + compass.MapInfoID;
                TextDestination.Text    = "次のセル : " + compass.Destination + (compass.IsEndPoint ? " (終点)" : "");
                TextEventKind.ForeColor = colorNormal;

                {
                    string eventkind = Constants.GetMapEventID(compass.EventID);

                    switch (compass.EventID)
                    {
                    case 0:                                     //初期位置
                    case 1:                                     //不明
                        TextEventDetail.Text = "どうしてこうなった";
                        break;

                    case 2:                                     //資源
                    {
                        string materialname;
                        if (compass.GetItemID == 4)                                                     //"※" 大方資源専用ID

                        {
                            materialname = Constants.GetMaterialName(compass.GetItemIDMetadata);
                        }
                        else
                        {
                            UseItemMaster item = KCDatabase.Instance.MasterUseItems[compass.GetItemIDMetadata];
                            if (item != null)
                            {
                                materialname = item.Name;
                            }
                            else
                            {
                                materialname = "謎のアイテム";
                            }
                        }

                        TextEventDetail.Text = materialname + " x " + compass.GetItemAmount;
                    }

                    break;

                    case 3:                                     //渦潮
                    {
                        int materialmax = KCDatabase.Instance.Fleet.Fleets.Values
                                          .Where(f => f != null && f.IsInSortie)
                                          .SelectMany(f => f.MembersWithoutEscaped)
                                          .Max(s => {
                                if (s == null)
                                {
                                    return(0);
                                }
                                switch (compass.WhirlpoolItemID)
                                {
                                case 1:
                                    return(s.Fuel);

                                case 2:
                                    return(s.Ammo);

                                default:
                                    return(0);
                                }
                            });

                        TextEventDetail.Text = string.Format("{0} x {1} ({2:p0})",
                                                             Constants.GetMaterialName(compass.WhirlpoolItemID),
                                                             compass.WhirlpoolItemAmount,
                                                             (double)compass.WhirlpoolItemAmount / Math.Max(materialmax, 1));
                    }
                    break;

                    case 4:                                     //通常戦闘
                    case 5:                                     //ボス戦闘
                        if (compass.EventKind >= 2)
                        {
                            eventkind += "/" + Constants.GetMapEventKind(compass.EventKind);

                            if (compass.EventKind == 2 || compass.EventKind == 3)
                            {
                                TextEventKind.ForeColor = colorNight;
                            }
                        }
                        UpdateEnemyFleet(compass.EnemyFleetID);
                        break;

                    case 6:                                     //気のせいだった
                        TextEventDetail.Text = "";
                        break;

                    case 7:                                                   //機動部隊航空戦
                        if (compass.EventKind >= 2 && compass.EventKind != 4) //必ず"航空戦"のはずなので除外
                        {
                            eventkind += "/" + Constants.GetMapEventKind(compass.EventKind);
                        }
                        UpdateEnemyFleet(compass.EnemyFleetID);
                        break;

                    default:
                        eventkind           += "不明";
                        TextEventDetail.Text = "";
                        break;
                    }
                    TextEventKind.Text = eventkind;
                }

                BasePanel.ResumeLayout();

                BasePanel.Visible = true;
            }
        }
예제 #21
0
        public override void LoadFromResponse(string apiname, dynamic data)
        {
            //base.LoadFromResponse( apiname, data );	//不要

            switch (apiname)
            {
            case "api_req_map/start":
            case "api_req_map/next":
                BattleDay   = null;
                BattleNight = null;
                Result      = null;
                BattleMode  = BattleModes.Undefined;
                Compass     = new CompassData();
                Compass.LoadFromResponse(apiname, data);
                break;

            case "api_req_sortie/battle":
                BattleMode = BattleModes.Normal;
                BattleDay  = new BattleNormalDay();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_battle_midnight/battle":
                BattleNight = new BattleNormalNight();
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_battle_midnight/sp_midnight":
                BattleMode  = BattleModes.NightOnly;
                BattleNight = new BattleNightOnly();
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/battle":
                BattleMode = BattleModes.Normal | BattleModes.CombinedTaskForce;
                BattleDay  = new BattleCombinedNormalDay();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/midnight_battle":
                BattleNight = new BattleCombinedNormalNight();
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/sp_midnight":
                BattleMode  = BattleModes.NightOnly | BattleModes.CombinedMask;
                BattleNight = new BattleCombinedNightOnly();
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/airbattle":
                BattleMode = BattleModes.AirBattle | BattleModes.CombinedTaskForce;
                BattleDay  = new BattleCombinedAirBattle();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/battle_water":
                BattleMode = BattleModes.Normal | BattleModes.CombinedSurface;
                BattleDay  = new BattleCombinedWater();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_practice/battle":
                BattleMode = BattleModes.Practice;
                BattleDay  = new BattlePracticeDay();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_practice/midnight_battle":
                BattleNight = new BattlePracticeNight();
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_sortie/battleresult":
            case "api_req_combined_battle/battleresult":
            case "api_req_practice/battle_result":
                Result = new BattleResultData();
                Result.LoadFromResponse(apiname, data);
                BattleFinished();
                break;

            case "api_port/port":
                Compass     = null;
                BattleDay   = null;
                BattleNight = null;
                Result      = null;
                BattleMode  = BattleModes.Undefined;
                break;
            }
        }
예제 #22
0
        private void Updated(string apiname, dynamic data)
        {
            Color getColorFromEventKind(int kind)
            {
                switch (kind)
                {
                case 0:
                case 1:
                default:                            //昼夜戦・その他
                    return(Utility.Configuration.Config.UI.ForeColor);

                case 2:
                case 3:                             //夜戦・夜昼戦
                    return(Utility.Configuration.Config.UI.Compass_ColorTextEventKind3);

                case 4:                             //航空戦
                case 6:                             //長距離空襲戦
                    return(Utility.Configuration.Config.UI.Compass_ColorTextEventKind6);

                case 5:                             // 敵連合
                    return(Utility.Configuration.Config.UI.Compass_ColorTextEventKind5);

                case 7:                             // 夜昼戦(対連合艦隊)
                    return(Utility.Configuration.Config.UI.Compass_ColorTextEventKind3);

                case 8:                             // レーダー射撃
                    return(Utility.Configuration.Config.UI.Compass_ColorTextEventKind3);
                }
            }

            if (apiname == "api_port/port")
            {
                BasePanel.Visible = false;
            }
            else if (apiname == "api_req_member/get_practice_enemyinfo")
            {
                TextMapArea.Text           = GeneralRes.Practice;
                TextDestination.Text       = string.Format("{0} {1}", data.api_nickname, Constants.GetAdmiralRank((int)data.api_rank));
                TextDestination.ImageAlign = ContentAlignment.MiddleCenter;
                TextDestination.ImageIndex = -1;
                ToolTipInfo.SetToolTip(TextDestination, null);
                TextEventKind.Text       = data.api_cmt;
                TextEventKind.ForeColor  = getColorFromEventKind(0);
                TextEventKind.ImageAlign = ContentAlignment.MiddleCenter;
                TextEventKind.ImageIndex = -1;
                ToolTipInfo.SetToolTip(TextEventKind, null);
                TextEventDetail.Text       = string.Format("Lv. {0} / {1} exp.", data.api_level, data.api_experience[0]);
                TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
                TextEventDetail.ImageIndex = -1;
                ToolTipInfo.SetToolTip(TextEventDetail, null);
                TextEnemyFleetName.Text = data.api_deckname;
            }
            else
            {
                CompassData compass = KCDatabase.Instance.Battle.Compass;


                BasePanel.SuspendLayout();
                PanelEnemyFleet.Visible     = false;
                PanelEnemyCandidate.Visible = false;

                _enemyFleetCandidate      = null;
                _enemyFleetCandidateIndex = -1;


                TextMapArea.Text = string.Format(GeneralRes.Map + ": {0}-{1}{2}", compass.MapAreaID, compass.MapInfoID,
                                                 compass.MapInfo.EventDifficulty > 0 ? " [" + Constants.GetDifficulty(compass.MapInfo.EventDifficulty) + "]" : "");
                {
                    var mapinfo = compass.MapInfo;
                    var sb      = new StringBuilder();

                    if (mapinfo.RequiredDefeatedCount != -1 && mapinfo.CurrentDefeatedCount < mapinfo.RequiredDefeatedCount)
                    {
                        sb.AppendFormat("{0} defeated: {1} / {2} times\r\n",
                                        mapinfo.CurrentGaugeIndex > 0 ? $"#{mapinfo.CurrentGaugeIndex} " : "",
                                        mapinfo.CurrentDefeatedCount, mapinfo.RequiredDefeatedCount);
                    }
                    else if (mapinfo.MapHPMax > 0)
                    {
                        int current = compass.MapHPCurrent > 0 ? compass.MapHPCurrent : mapinfo.MapHPCurrent;
                        int max     = compass.MapHPMax > 0 ? compass.MapHPMax : mapinfo.MapHPMax;

                        sb.AppendFormat("{0}{1}: {2} / {3}\r\n",
                                        mapinfo.CurrentGaugeIndex > 0 ? $"#{mapinfo.CurrentGaugeIndex} " : "",
                                        mapinfo.GaugeType == 3 ? "TP" : "HP", current, max);
                    }


                    foreach (var pair in KCDatabase.Instance.Battle.SpecialAttackCount)
                    {
                        sb.AppendLine($"{Constants.GetDayAttackKind((DayAttackKind)pair.Key)} : 発動済み");
                    }

                    ToolTipInfo.SetToolTip(TextMapArea, sb.Length > 0 ? sb.ToString() : null);
                }


                TextDestination.Text = string.Format(GeneralRes.NextNode + ": {0}{1}", compass.DestinationID, (compass.IsEndPoint ? GeneralRes.EndNode : ""));
                if (compass.LaunchedRecon != 0)
                {
                    TextDestination.ImageAlign = ContentAlignment.MiddleRight;
                    TextDestination.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane;

                    string tiptext;
                    switch (compass.CommentID)
                    {
                    case 1:
                        tiptext = "Enemy sighted!";
                        break;

                    case 2:
                        tiptext = "Target sighted!";
                        break;

                    case 3:
                        tiptext = "Course Patrol!";
                        break;

                    default:
                        tiptext = "Enemy plane sighted!";
                        break;
                    }
                    ToolTipInfo.SetToolTip(TextDestination, tiptext);
                }
                else
                {
                    TextDestination.ImageAlign = ContentAlignment.MiddleCenter;
                    TextDestination.ImageIndex = -1;
                    ToolTipInfo.SetToolTip(TextDestination, null);
                }

                //とりあえずリセット
                TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
                TextEventDetail.ImageIndex = -1;
                ToolTipInfo.SetToolTip(TextEventDetail, null);


                TextEventKind.ForeColor = getColorFromEventKind(0);

                {
                    string eventkind = Constants.GetMapEventID(compass.EventID);

                    switch (compass.EventID)
                    {
                    case 0:                                 //初期位置
                        TextEventDetail.Text = GeneralRes.WhyDidThisHappen;
                        break;

                    case 2:                                 //資源
                        TextEventKind.ForeColor = Utility.Configuration.Config.UI.Color_Green;
                        TextEventDetail.Text    = GetMaterialInfo(compass);
                        break;

                    case 8:                                     //船団護衛成功
                        TextEventDetail.Text = GetMaterialInfo(compass);
                        break;

                    case 3:                                 //渦潮
                    {
                        int materialmax = KCDatabase.Instance.Fleet.Fleets.Values
                                          .Where(f => f != null && f.IsInSortie)
                                          .SelectMany(f => f.MembersWithoutEscaped)
                                          .Max(s =>
                            {
                                if (s == null)
                                {
                                    return(0);
                                }
                                switch (compass.WhirlpoolItemID)
                                {
                                case 1:
                                    return(s.Fuel);

                                case 2:
                                    return(s.Ammo);

                                default:
                                    return(0);
                                }
                            });

                        TextEventDetail.Text = string.Format("{0} x {1} ({2:p0})",
                                                             Constants.GetMaterialName(compass.WhirlpoolItemID),
                                                             compass.WhirlpoolItemAmount,
                                                             (double)compass.WhirlpoolItemAmount / Math.Max(materialmax, 1));
                    }
                    break;

                    case 4:                                 //通常戦闘
                        if (compass.EventKind >= 2)
                        {
                            eventkind += "/" + Constants.GetMapEventKind(compass.EventKind);

                            TextEventKind.ForeColor = getColorFromEventKind(compass.EventKind);
                        }
                        UpdateEnemyFleet();
                        break;

                    case 5:                                     //ボス戦闘
                        TextEventKind.ForeColor = Utility.Configuration.Config.UI.Color_Red;

                        if (compass.EventKind >= 2)
                        {
                            eventkind += "/" + Constants.GetMapEventKind(compass.EventKind);
                        }
                        UpdateEnemyFleet();
                        break;

                    case 1:                                 //イベントなし
                    case 6:                                 //気のせいだった
                        switch (compass.EventKind)
                        {
                        case 0:                                             //気のせいだった
                        default:
                            break;

                        case 1:
                            eventkind = "No enemy sighted.";
                            break;

                        case 2:
                            eventkind = "Branch choice:";
                            break;

                        case 3:
                            eventkind = "It's a calm sea.";
                            break;

                        case 4:
                            eventkind = "It's a calm strait.";
                            break;

                        case 5:
                            eventkind = "I need to be careful.";
                            break;

                        case 6:
                            eventkind = "It's a calm sea.";
                            break;
                        }

                        if (compass.RouteChoices != null)
                        {
                            var nodechoices = new string[compass.RouteChoices.Count];
                            for (int i = 0; i < compass.RouteChoices.Count; i++)
                            {
                                nodechoices[i] = FormMain.Instance.Translator.GetMapNodes(compass.MapAreaID, compass.MapInfoID,
                                                                                          compass.RouteChoices[i]);
                            }
                            TextEventDetail.Text = string.Join(" or ", nodechoices);
                        }
                        else if (compass.FlavorTextType != -1)
                        {
                            TextEventDetail.Text = "◆";
                            ToolTipInfo.SetToolTip(TextEventDetail, compass.FlavorText);
                        }
                        else
                        {
                            TextEventDetail.Text = "";
                        }

                        break;

                    case 7:                                 //航空戦or航空偵察
                        TextEventKind.ForeColor = getColorFromEventKind(compass.EventKind);

                        switch (compass.EventKind)
                        {
                        case 0:                                                 //航空偵察
                            eventkind = GeneralRes.AerialRecon;

                            switch (compass.AirReconnaissanceResult)
                            {
                            case 0:
                            default:
                                TextEventDetail.Text = GeneralRes.Failure;
                                break;

                            case 1:
                                TextEventDetail.Text = GeneralRes.Success;
                                break;

                            case 2:
                                TextEventDetail.Text = GeneralRes.GreatSuccess;
                                break;
                            }

                            switch (compass.AirReconnaissancePlane)
                            {
                            case 0:
                            default:
                                TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
                                TextEventDetail.ImageIndex = -1;
                                break;

                            case 1:
                                TextEventDetail.ImageAlign = ContentAlignment.MiddleLeft;
                                TextEventDetail.ImageIndex = (int)ResourceManager.EquipmentContent.FlyingBoat;
                                break;

                            case 2:
                                TextEventDetail.ImageAlign = ContentAlignment.MiddleLeft;
                                TextEventDetail.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane;
                                break;
                            }

                            if (compass.GetItems.Any())
                            {
                                TextEventDetail.Text += " " + GetMaterialInfo(compass);
                            }

                            break;

                        case 4:                                             //航空戦
                        default:
                            UpdateEnemyFleet();
                            break;
                        }
                        break;

                    case 9:                                 //揚陸地点
                        TextEventDetail.Text = "";
                        break;

                    case 10:                                // 泊地
                        TextEventDetail.Text = compass.CanEmergencyAnchorageRepair ? "修理可能" : "";
                        break;

                    default:
                        TextEventDetail.Text = "";
                        break;
                    }
                    TextEventKind.Text = eventkind;
                }


                if (compass.HasAirRaid)
                {
                    TextEventKind.ImageAlign = ContentAlignment.MiddleRight;
                    TextEventKind.ImageIndex = (int)ResourceManager.EquipmentContent.CarrierBasedBomber;
                    ToolTipInfo.SetToolTip(TextEventKind, "Air raid - " + Constants.GetAirRaidDamage(compass.AirRaidDamageKind));
                }
                else
                {
                    TextEventKind.ImageAlign = ContentAlignment.MiddleCenter;
                    TextEventKind.ImageIndex = -1;
                    ToolTipInfo.SetToolTip(TextEventKind, null);
                }


                BasePanel.ResumeLayout();

                BasePanel.Visible = true;
            }
        }
예제 #23
0
        private static void CompassOnReadingChanged(object sender, CompassChangedEventArgs e)
        {
            CompassData data = e.Reading;

            heading = data.HeadingMagneticNorth * -1;
        }
예제 #24
0
        private void Updated(string apiname, dynamic data)
        {
            Func <int, Color> getColorFromEventKind = ( int kind ) => {
                switch (kind)
                {
                case 0:
                case 1:
                default:                                //昼夜戦・その他
                    return(SystemColors.ControlText);

                case 2:
                case 3:                                 //夜戦・夜昼戦
                    return(Color.Navy);

                case 4:                                 //航空戦
                    return(Color.DarkGreen);
                }
            };

            if (apiname == "api_port/port")
            {
                BasePanel.Visible = false;
            }
            else if (apiname == "api_req_member/get_practice_enemyinfo")
            {
                TextMapArea.Text        = "演習";
                TextDestination.Text    = string.Format("{0} {1}", data.api_nickname, Constants.GetAdmiralRank((int)data.api_rank));
                TextEventKind.Text      = data.api_cmt;
                TextEventKind.ForeColor = getColorFromEventKind(0);
                TextEventDetail.Text    = string.Format("Lv. {0} / {1} exp.", data.api_level, data.api_experience[0]);
                TextEnemyFleetName.Text = data.api_deckname;
            }
            else
            {
                CompassData compass = KCDatabase.Instance.Battle.Compass;


                BasePanel.SuspendLayout();
                PanelEnemyFleet.Visible = false;


                TextMapArea.Text = string.Format("出撃海域 : {0}-{1}", compass.MapAreaID, compass.MapInfoID);

                TextDestination.Text = string.Format("次のセル : {0}{1}", compass.Destination, (compass.IsEndPoint ? " (終点)" : ""));
                if (compass.LaunchedRecon != 0)
                {
                    TextDestination.ImageAlign = ContentAlignment.MiddleRight;
                    TextDestination.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane;

                    string tiptext;
                    switch (compass.CommentID)
                    {
                    case 1:
                        tiptext = "敵艦隊発見!";
                        break;

                    case 2:
                        tiptext = "攻撃目標発見!";
                        break;

                    default:
                        tiptext = "索敵機発艦!";
                        break;
                    }
                    ToolTipInfo.SetToolTip(TextDestination, tiptext);
                }
                else
                {
                    TextDestination.ImageAlign = ContentAlignment.MiddleCenter;
                    TextDestination.ImageIndex = -1;
                    ToolTipInfo.SetToolTip(TextDestination, null);
                }


                TextEventKind.ForeColor = getColorFromEventKind(0);

                {
                    string eventkind = Constants.GetMapEventID(compass.EventID);

                    switch (compass.EventID)
                    {
                    case 0:                                     //初期位置
                    case 1:                                     //不明
                        TextEventDetail.Text = "どうしてこうなった";
                        break;

                    case 2:                                     //資源
                    case 8:                                     //船団護衛成功
                    {
                        string materialname;
                        if (compass.GetItemID == 4)                                                     //"※" 大方資源専用ID

                        {
                            materialname = Constants.GetMaterialName(compass.GetItemIDMetadata);
                        }
                        else
                        {
                            UseItemMaster item = KCDatabase.Instance.MasterUseItems[compass.GetItemIDMetadata];
                            if (item != null)
                            {
                                materialname = item.Name;
                            }
                            else
                            {
                                materialname = "謎のアイテム";
                            }
                        }

                        TextEventDetail.Text = materialname + " x " + compass.GetItemAmount;
                    }

                    break;

                    case 3:                                     //渦潮
                    {
                        int materialmax = KCDatabase.Instance.Fleet.Fleets.Values
                                          .Where(f => f != null && f.IsInSortie)
                                          .SelectMany(f => f.MembersWithoutEscaped)
                                          .Max(s => {
                                if (s == null)
                                {
                                    return(0);
                                }
                                switch (compass.WhirlpoolItemID)
                                {
                                case 1:
                                    return(s.Fuel);

                                case 2:
                                    return(s.Ammo);

                                default:
                                    return(0);
                                }
                            });

                        TextEventDetail.Text = string.Format("{0} x {1} ({2:p0})",
                                                             Constants.GetMaterialName(compass.WhirlpoolItemID),
                                                             compass.WhirlpoolItemAmount,
                                                             (double)compass.WhirlpoolItemAmount / Math.Max(materialmax, 1));
                    }
                    break;

                    case 4:                                     //通常戦闘
                    case 5:                                     //ボス戦闘
                        if (compass.EventKind >= 2)
                        {
                            eventkind += "/" + Constants.GetMapEventKind(compass.EventKind);

                            TextEventKind.ForeColor = getColorFromEventKind(compass.EventKind);
                        }
                        UpdateEnemyFleet(compass.EnemyFleetID);
                        break;

                    case 6:                                     //気のせいだった
                        TextEventDetail.Text = "";
                        break;

                    case 7:                                     //航空戦(連合艦隊)
                        if (compass.EventKind >= 2)
                        {
                            if (compass.EventKind != 4)                                         //必ず"航空戦"のはずなので除外
                            {
                                eventkind += "/" + Constants.GetMapEventKind(compass.EventKind);
                            }
                            TextEventKind.ForeColor = getColorFromEventKind(compass.EventKind);
                        }
                        UpdateEnemyFleet(compass.EnemyFleetID);
                        break;


                    default:
                        eventkind           += "不明";
                        TextEventDetail.Text = "";
                        break;
                    }
                    TextEventKind.Text = eventkind;
                }

                BasePanel.ResumeLayout();

                BasePanel.Visible = true;
            }
        }
예제 #25
0
        void Compass_ReadingChanged(object sender, CompassChangedEventArgs e)
        {
            CompassData data = e.Reading;

            UpdateBindingMemberValues(data.HeadingMagneticNorth);
        }
예제 #26
0
        private void Updated(string apiname, dynamic data)
        {
            Func <int, Color> getColorFromEventKind = ( int kind ) => {
                switch (kind)
                {
                case 0:
                case 1:
                default:                                //昼夜戦・その他
                    return(SystemColors.ControlText);

                case 2:
                case 3:                                 //夜戦・夜昼戦
                    return(Color.Navy);

                case 4:                                 //航空戦
                case 6:                                 //長距離空襲戦
                    return(Color.DarkGreen);
                }
            };

            if (apiname == "api_port/port")
            {
                BasePanel.Visible = false;
            }
            else if (apiname == "api_req_member/get_practice_enemyinfo")
            {
                TextMapArea.Text           = "演習";
                TextDestination.Text       = string.Format("{0} {1}", data.api_nickname, Constants.GetAdmiralRank((int)data.api_rank));
                TextDestination.ImageAlign = ContentAlignment.MiddleCenter;
                TextDestination.ImageIndex = -1;
                ToolTipInfo.SetToolTip(TextDestination, null);
                TextEventKind.Text       = data.api_cmt;
                TextEventKind.ForeColor  = getColorFromEventKind(0);
                TextEventKind.ImageAlign = ContentAlignment.MiddleCenter;
                TextEventKind.ImageIndex = -1;
                ToolTipInfo.SetToolTip(TextEventKind, null);
                TextEventDetail.Text       = string.Format("Lv. {0} / {1} exp.", data.api_level, data.api_experience[0]);
                TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
                TextEventDetail.ImageIndex = -1;
                ToolTipInfo.SetToolTip(TextEventDetail, null);
                TextEnemyFleetName.Text = data.api_deckname;
            }
            else
            {
                CompassData compass = KCDatabase.Instance.Battle.Compass;


                BasePanel.SuspendLayout();
                PanelEnemyFleet.Visible     = false;
                PanelEnemyCandidate.Visible = false;

                _enemyFleetCandidate      = null;
                _enemyFleetCandidateIndex = -1;


                TextMapArea.Text = string.Format("出撃海域 : {0}-{1}{2}", compass.MapAreaID, compass.MapInfoID,
                                                 compass.MapInfo.EventDifficulty > 0 ? " [" + Constants.GetDifficulty(compass.MapInfo.EventDifficulty) + "]" : "");
                {
                    var mapinfo = compass.MapInfo;

                    if (mapinfo.IsCleared)
                    {
                        ToolTipInfo.SetToolTip(TextMapArea, null);
                    }
                    else if (mapinfo.RequiredDefeatedCount != -1)
                    {
                        ToolTipInfo.SetToolTip(TextMapArea, string.Format("撃破: {0} / {1} 回", mapinfo.CurrentDefeatedCount, mapinfo.RequiredDefeatedCount));
                    }
                    else if (mapinfo.MapHPMax > 0)
                    {
                        ToolTipInfo.SetToolTip(TextMapArea, string.Format("{0}: {1} / {2}", mapinfo.GaugeType == 3 ? "TP" : "HP", mapinfo.MapHPCurrent, mapinfo.MapHPMax));
                    }
                    else
                    {
                        ToolTipInfo.SetToolTip(TextMapArea, null);
                    }
                }


                TextDestination.Text = string.Format("次のセル : {0}{1}", compass.Destination, (compass.IsEndPoint ? " (終点)" : ""));
                if (compass.LaunchedRecon != 0)
                {
                    TextDestination.ImageAlign = ContentAlignment.MiddleRight;
                    TextDestination.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane;

                    string tiptext;
                    switch (compass.CommentID)
                    {
                    case 1:
                        tiptext = "敵艦隊発見!";
                        break;

                    case 2:
                        tiptext = "攻撃目標発見!";
                        break;

                    case 3:
                        tiptext = "針路哨戒!";
                        break;

                    default:
                        tiptext = "索敵機発艦!";
                        break;
                    }
                    ToolTipInfo.SetToolTip(TextDestination, tiptext);
                }
                else
                {
                    TextDestination.ImageAlign = ContentAlignment.MiddleCenter;
                    TextDestination.ImageIndex = -1;
                    ToolTipInfo.SetToolTip(TextDestination, null);
                }

                //とりあえずリセット
                TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
                TextEventDetail.ImageIndex = -1;
                ToolTipInfo.SetToolTip(TextEventDetail, null);


                TextEventKind.ForeColor = getColorFromEventKind(0);

                {
                    string eventkind = Constants.GetMapEventID(compass.EventID);

                    switch (compass.EventID)
                    {
                    case 0:                                     //初期位置
                    case 1:                                     //不明
                        TextEventDetail.Text = "どうしてこうなった";
                        break;

                    case 2:                                     //資源
                    case 8:                                     //船団護衛成功
                        TextEventDetail.Text = GetMaterialInfo(compass);
                        break;

                    case 3:                                     //渦潮
                    {
                        int materialmax = KCDatabase.Instance.Fleet.Fleets.Values
                                          .Where(f => f != null && f.IsInSortie)
                                          .SelectMany(f => f.MembersWithoutEscaped)
                                          .Max(s => {
                                if (s == null)
                                {
                                    return(0);
                                }
                                switch (compass.WhirlpoolItemID)
                                {
                                case 1:
                                    return(s.Fuel);

                                case 2:
                                    return(s.Ammo);

                                default:
                                    return(0);
                                }
                            });

                        TextEventDetail.Text = string.Format("{0} x {1} ({2:p0})",
                                                             Constants.GetMaterialName(compass.WhirlpoolItemID),
                                                             compass.WhirlpoolItemAmount,
                                                             (double)compass.WhirlpoolItemAmount / Math.Max(materialmax, 1));
                    }
                    break;

                    case 4:                                     //通常戦闘
                        if (compass.EventKind >= 2)
                        {
                            eventkind += "/" + Constants.GetMapEventKind(compass.EventKind);

                            TextEventKind.ForeColor = getColorFromEventKind(compass.EventKind);
                        }
                        UpdateEnemyFleet();
                        break;

                    case 5:                                     //ボス戦闘
                        TextEventKind.ForeColor = Color.Red;
                        goto case 4;

                    case 6:                                     //気のせいだった
                        switch (compass.EventKind)
                        {
                        case 0:                                                 //気のせいだった
                        default:
                            TextEventDetail.Text = "";
                            break;

                        case 1:                                                 //敵影を見ず
                            eventkind            = "敵影を見ず";
                            TextEventDetail.Text = "";
                            break;

                        case 2:                                                 //能動分岐
                            eventkind            = "能動分岐";
                            TextEventDetail.Text = string.Join("/", compass.RouteChoices);
                            break;
                        }
                        break;

                    case 7:                                     //航空戦or航空偵察
                        TextEventKind.ForeColor = getColorFromEventKind(compass.EventKind);

                        switch (compass.EventKind)
                        {
                        case 0:                                                 //航空偵察
                            eventkind = "航空偵察";

                            switch (compass.AirReconnaissanceResult)
                            {
                            case 0:
                            default:
                                TextEventDetail.Text = "失敗";
                                break;

                            case 1:
                                TextEventDetail.Text = "成功";
                                break;

                            case 2:
                                TextEventDetail.Text = "大成功";
                                break;
                            }

                            switch (compass.AirReconnaissancePlane)
                            {
                            case 0:
                            default:
                                TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
                                TextEventDetail.ImageIndex = -1;
                                break;

                            case 1:
                                TextEventDetail.ImageAlign = ContentAlignment.MiddleLeft;
                                TextEventDetail.ImageIndex = (int)ResourceManager.EquipmentContent.FlyingBoat;
                                break;

                            case 2:
                                TextEventDetail.ImageAlign = ContentAlignment.MiddleLeft;
                                TextEventDetail.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane;
                                break;
                            }

                            if (compass.GetItems.Any())
                            {
                                TextEventDetail.Text += " " + GetMaterialInfo(compass);
                            }

                            break;

                        case 4:                                                 //航空戦
                        default:
                            UpdateEnemyFleet();
                            break;
                        }
                        break;

                    case 9:                                     //揚陸地点
                        TextEventDetail.Text = "";
                        break;

                    default:
                        TextEventDetail.Text = "";
                        break;
                    }
                    TextEventKind.Text = eventkind;
                }


                if (compass.HasAirRaid)
                {
                    TextEventKind.ImageAlign = ContentAlignment.MiddleRight;
                    TextEventKind.ImageIndex = (int)ResourceManager.EquipmentContent.CarrierBasedBomber;
                    ToolTipInfo.SetToolTip(TextEventKind, Constants.GetAirRaidDamage(compass.AirRaidDamageKind));
                }
                else
                {
                    TextEventKind.ImageAlign = ContentAlignment.MiddleCenter;
                    TextEventKind.ImageIndex = -1;
                    ToolTipInfo.SetToolTip(TextEventKind, null);
                }


                BasePanel.ResumeLayout();

                BasePanel.Visible = true;
            }
        }
예제 #27
0
		private void Updated(string apiname, dynamic data)
		{

			Func<int, Color> getColorFromEventKind = (int kind) =>
			{
				switch (kind)
				{
					case 0:
					case 1:
					default:    //昼夜戦・その他
						return Utility.Configuration.Config.UI.ForeColor;
					case 2:
					case 3:     //夜戦・夜昼戦
						return Utility.Configuration.Config.UI.Compass_ColorTextEventKind3;
					case 4:     //航空戦
					case 6:     //長距離空襲戦
						return Utility.Configuration.Config.UI.Compass_ColorTextEventKind6;
					case 5:     // 敵連合
						return Utility.Configuration.Config.UI.Compass_ColorTextEventKind5;
					case 7:		// 夜昼戦(対連合艦隊)
						return Utility.Configuration.Config.UI.Compass_ColorTextEventKind3;
				}
			};

			if (apiname == "api_port/port")
			{

				BasePanel.Visible = false;

			}
			else if (apiname == "api_req_member/get_practice_enemyinfo")
			{

				TextMapArea.Text = "演习";
				TextDestination.Text = string.Format("{0} {1}", data.api_nickname, Constants.GetAdmiralRank((int)data.api_rank));
				TextDestination.Font = Utility.Configuration.Config.UI.JapFont;
				TextDestination.ImageAlign = ContentAlignment.MiddleCenter;
				TextDestination.ImageIndex = -1;
				ToolTipInfo.SetToolTip(TextDestination, null);
				TextEventKind.Text = data.api_cmt;
				TextEventKind.ForeColor = getColorFromEventKind(0);
				TextEventKind.ImageAlign = ContentAlignment.MiddleCenter;
				TextEventKind.ImageIndex = -1;
				TextEventKind.Font = Utility.Configuration.Config.UI.JapFont;
				ToolTipInfo.SetToolTip(TextEventKind, null);
				TextEventDetail.Text = string.Format("Lv. {0} / {1} exp.", data.api_level, data.api_experience[0]);
				TextEventDetail.Font = Utility.Configuration.Config.UI.JapFont;
				TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
				TextEventDetail.ImageIndex = -1;
				ToolTipInfo.SetToolTip(TextEventDetail, null);
				TextEnemyFleetName.Text = data.api_deckname;
				TextEnemyFleetName.Font = Utility.Configuration.Config.UI.JapFont;

			}
			else
			{

				CompassData compass = KCDatabase.Instance.Battle.Compass;


				BasePanel.SuspendLayout();
				PanelEnemyFleet.Visible = false;
				PanelEnemyCandidate.Visible = false;

				_enemyFleetCandidate = null;
				_enemyFleetCandidateIndex = -1;


				TextMapArea.Text = string.Format("出击海域 : {0}-{1}{2}", compass.MapAreaID, compass.MapInfoID,
					compass.MapInfo.EventDifficulty > 0 ? " [" + Constants.GetDifficulty(compass.MapInfo.EventDifficulty, compass.MapAreaID) + "]" : "");
				{
					var mapinfo = compass.MapInfo;

					if (mapinfo.IsCleared)
					{
						ToolTipInfo.SetToolTip(TextMapArea, null);

					}
					else if (mapinfo.RequiredDefeatedCount != -1)
					{
						ToolTipInfo.SetToolTip(TextMapArea, string.Format("击破 : {0} / {1} 次", mapinfo.CurrentDefeatedCount, mapinfo.RequiredDefeatedCount));

					}
					else if (mapinfo.MapHPMax > 0)
					{
						int current = compass.MapHPCurrent > 0 ? compass.MapHPCurrent : mapinfo.MapHPCurrent;
						int max = compass.MapHPMax > 0 ? compass.MapHPMax : mapinfo.MapHPMax;

						ToolTipInfo.SetToolTip(TextMapArea, string.Format("{0}: {1} / {2}", mapinfo.GaugeType == 3 ? "TP" : "HP", current, max));

					}
					else
					{
						ToolTipInfo.SetToolTip(TextMapArea, null);
					}
				}


				TextDestination.Text = string.Format("下一航路 : {0}{1}", compass.Destination, (compass.IsEndPoint ? " ( 终点 )" : ""));
				TextDestination.Font = Utility.Configuration.Config.UI.MainFont;
				if (compass.LaunchedRecon != 0)
				{
					TextDestination.ImageAlign = ContentAlignment.MiddleRight;
					TextDestination.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane;

					string tiptext;
					switch (compass.CommentID)
					{
						case 1:
							tiptext = "发现敌舰队!";
							break;
						case 2:
							tiptext = "发现攻击目标!";
							break;
						case 3:
							tiptext = "針路哨戒!";
							break;
						default:
							tiptext = "索敌机离舰!";
							break;
					}
					ToolTipInfo.SetToolTip(TextDestination, tiptext);

				}
				else
				{
					TextDestination.ImageAlign = ContentAlignment.MiddleCenter;
					TextDestination.ImageIndex = -1;
					ToolTipInfo.SetToolTip(TextDestination, null);
				}

				//とりあえずリセット
				TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
				TextEventDetail.ImageIndex = -1;
				ToolTipInfo.SetToolTip(TextEventDetail, null);


				TextEventKind.ForeColor = getColorFromEventKind(0);

				{
					string eventkind = Constants.GetMapEventID(compass.EventID);

					switch (compass.EventID)
					{

						case 0:     //初期位置
						case 1:     //不明
							TextEventDetail.Text = "どうしてこうなった";
							break;

						case 2:     //資源
						case 8:     //船団護衛成功
							TextEventDetail.Text = GetMaterialInfo(compass);
							TextEventDetail.Font = Utility.Configuration.Config.UI.MainFont;
							break;

						case 3:     //渦潮
							{
								int materialmax = KCDatabase.Instance.Fleet.Fleets.Values
									.Where(f => f != null && f.IsInSortie)
									.SelectMany(f => f.MembersWithoutEscaped)
									.Max(s =>
									{
										if (s == null) return 0;
										switch (compass.WhirlpoolItemID)
										{
											case 1:
												return s.Fuel;
											case 2:
												return s.Ammo;
											default:
												return 0;
										}
									});

								TextEventDetail.Text = string.Format("{0} x {1} ({2:p0})",
									Constants.GetMaterialName(compass.WhirlpoolItemID),
									compass.WhirlpoolItemAmount,
									(double)compass.WhirlpoolItemAmount / Math.Max(materialmax, 1));
								TextEventDetail.Font = Utility.Configuration.Config.UI.MainFont;

							}
							break;

						case 4:     //通常戦闘
							if (compass.EventKind >= 2)
							{
								eventkind += "/" + Constants.GetMapEventKind(compass.EventKind);

								TextEventKind.ForeColor = getColorFromEventKind(compass.EventKind);
							}
							UpdateEnemyFleet();
							break;

						case 5:     //ボス戦闘
							TextEventKind.ForeColor = Utility.Configuration.Config.UI.Color_Red;

							if (compass.EventKind >= 2)
							{
								eventkind += "/" + Constants.GetMapEventKind(compass.EventKind);
							}
							UpdateEnemyFleet();
							break;

						case 6:     //気のせいだった
							switch (compass.EventKind)
							{

								case 0:     //気のせいだった
								default:
									break;
								case 1:
									eventkind = "不见敌影";
									break;
								case 2:
									eventkind = "能动分歧";
									break;
								case 3:
									eventkind = "平稳的海面";
									break;
								case 4:
									eventkind = "平稳的海峡";
									break;
								case 5:
									eventkind = "需要提高警惕";
									break;
								case 6:
									eventkind = "安静的海洋";
									break;
								case 7:
									eventkind = "游击部队进击中";
									break;
								case 8:
									eventkind = "对潜警戒进击中";
									break;
								case 9:
									eventkind = "栗田舰队突入";
									break;
							}
							if (compass.RouteChoices != null) {
								TextEventDetail.Text = string.Join("/", compass.RouteChoices);
								TextEventDetail.Font = Utility.Configuration.Config.UI.MainFont;
							} else {
								TextEventDetail.Text = "";
							}

							break;

						case 7:     //航空戦or航空偵察
							TextEventKind.ForeColor = getColorFromEventKind(compass.EventKind);

							switch (compass.EventKind)
							{
								case 0:     //航空偵察
									eventkind = "航空侦察";

									switch (compass.AirReconnaissanceResult)
									{
										case 0:
										default:
											TextEventDetail.Text = "失败";
											TextEventDetail.Font = Utility.Configuration.Config.UI.MainFont;
											break;
										case 1:
											TextEventDetail.Text = "成功";
											TextEventDetail.Font = Utility.Configuration.Config.UI.MainFont;
											break;
										case 2:
											TextEventDetail.Text = "大成功";
											TextEventDetail.Font = Utility.Configuration.Config.UI.MainFont;
											break;
									}

									switch (compass.AirReconnaissancePlane)
									{
										case 0:
										default:
											TextEventDetail.ImageAlign = ContentAlignment.MiddleCenter;
											TextEventDetail.ImageIndex = -1;
											break;
										case 1:
											TextEventDetail.ImageAlign = ContentAlignment.MiddleLeft;
											TextEventDetail.ImageIndex = (int)ResourceManager.EquipmentContent.FlyingBoat;
											break;
										case 2:
											TextEventDetail.ImageAlign = ContentAlignment.MiddleLeft;
											TextEventDetail.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane;
											break;
									}

									if (compass.GetItems.Any())
									{
										TextEventDetail.Text += " " + GetMaterialInfo(compass);
										TextEventDetail.Font = Utility.Configuration.Config.UI.MainFont;
									}

									break;

								case 4:     //航空戦
								default:
									UpdateEnemyFleet();
									break;
							}
							break;

						case 9:     //揚陸地点
							TextEventDetail.Text = "";
							break;

						default:
							TextEventDetail.Text = "";
							break;

					}
					TextEventKind.Text = eventkind;
					TextEventKind.Font = Utility.Configuration.Config.UI.MainFont;
				}


				if (compass.HasAirRaid)
				{
					TextEventKind.ImageAlign = ContentAlignment.MiddleRight;
					TextEventKind.ImageIndex = (int)ResourceManager.EquipmentContent.CarrierBasedBomber;
					ToolTipInfo.SetToolTip(TextEventKind, "空袭 - " + Constants.GetAirRaidDamage(compass.AirRaidDamageKind));
				}
				else
				{
					TextEventKind.ImageAlign = ContentAlignment.MiddleCenter;
					TextEventKind.ImageIndex = -1;
					ToolTipInfo.SetToolTip(TextEventKind, null);
				}


				BasePanel.ResumeLayout();

				BasePanel.Visible = true;
			}


		}
예제 #28
0
파일: Compass.uwp.cs 프로젝트: hevey/maui
        static void CompassReportedInterval(object sender, CompassReadingChangedEventArgs e)
        {
            var data = new CompassData(e.Reading.HeadingMagneticNorth);

            OnChanged(data);
        }
예제 #29
0
        public override void LoadFromResponse(string apiname, dynamic data)
        {
            //base.LoadFromResponse( apiname, data );	//不要

            switch (apiname)
            {
            case "api_req_map/start":
            case "api_req_map/next":
                BattleDay   = null;
                BattleNight = null;
                Result      = null;
                BattleMode  = BattleModes.Undefined;
                Compass     = new CompassData();
                Compass.LoadFromResponse(apiname, data);
                break;

            case "api_req_sortie/battle":
                BattleMode = BattleModes.Normal;
                BattleDay  = new BattleNormalDay();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_battle_midnight/battle":
                BattleNight = new BattleNormalNight();
                BattleNight.TakeOverParameters(BattleDay);
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_battle_midnight/sp_midnight":
                BattleMode  = BattleModes.NightOnly;
                BattleNight = new BattleNightOnly();
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_sortie/airbattle":
                BattleMode = BattleModes.AirBattle;
                BattleDay  = new BattleAirBattle();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/battle":
                BattleMode = BattleModes.Normal | BattleModes.CombinedTaskForce;
                BattleDay  = new BattleCombinedNormalDay();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/midnight_battle":
                BattleNight = new BattleCombinedNormalNight();
                //BattleNight.TakeOverParameters( BattleDay );		//checkme: 連合艦隊夜戦では昼戦での与ダメージがMVPに反映されない仕様?
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/sp_midnight":
                BattleMode  = BattleModes.NightOnly | BattleModes.CombinedMask;
                BattleNight = new BattleCombinedNightOnly();
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/airbattle":
                BattleMode = BattleModes.AirBattle | BattleModes.CombinedTaskForce;
                BattleDay  = new BattleCombinedAirBattle();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_combined_battle/battle_water":
                BattleMode = BattleModes.Normal | BattleModes.CombinedSurface;
                BattleDay  = new BattleCombinedWater();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_practice/battle":
                BattleMode = BattleModes.Practice;
                BattleDay  = new BattlePracticeDay();
                BattleDay.LoadFromResponse(apiname, data);
                break;

            case "api_req_practice/midnight_battle":
                BattleNight = new BattlePracticeNight();
                BattleNight.TakeOverParameters(BattleDay);
                BattleNight.LoadFromResponse(apiname, data);
                break;

            case "api_req_sortie/battleresult":
            case "api_req_combined_battle/battleresult":
            case "api_req_practice/battle_result":
                Result = new BattleResultData();
                Result.LoadFromResponse(apiname, data);
                BattleFinished();
                break;

            case "api_port/port":
                Compass          = null;
                BattleDay        = null;
                BattleNight      = null;
                Result           = null;
                BattleMode       = BattleModes.Undefined;
                DroppedShipCount = DroppedEquipmentCount = 0;
                break;

            case "api_get_member/slot_item":
                DroppedEquipmentCount = 0;
                break;
            }
        }
예제 #30
0
        private void serialPort_dataReceived(object sender, SerialDataReceivedEventArgs e) {
            //Console.WriteLine("Compass received data!");
            if (myCompass.BytesToRead >= 4)
            {                  
                byte[] buf = new byte[4];
                myCompass.Read(buf, 0, 4);
//          make this more good later
//                if (buf[0] != (byte)motor.MotorCommands.COMMAND_START || buf[3] != (byte)motor.MotorCommands.COMMAND_STOP)
                if (buf[0] != (byte)254 || buf[3] != (byte)233)
                
                {
                    // something went wrong
                    Console.WriteLine("Error in compass serial port handler, received: " + buf.ToString());
                    return;
                }
                int angle = ((int)buf[1]) + buf[2];

                if (!(0 <= angle && angle <= 360))
                {
                    Console.WriteLine("Error in compass serial port handler, impossible angle received");
                    return;
                }

                CompassData dat = new CompassData();
                dat.angle = angle;
                CompassNotification not = new CompassNotification(dat);

                _mainPort.Post(not);
            }
        }
예제 #31
0
 private void Compass_ReadingChanged(object sender, CompassChangedEventArgs e)
 {
     this.CompassData = e.Reading;
 }