public void Move(double lat, double lng, BaseUnitInfo info, bool removeWaypoints) { string Id; if (info != null) { Id = info.Id; } else { return; } UnitMovementOrder order = OrderFactory.CreateUnitMovementOrder(Id, new PositionInfo(lat, lng), removeWaypoints); //order.Id = Id; //PositionInfo pos = new PositionInfo(); //pos.Latitude = lat; //pos.Longitude = lng; //order.RemoveAllExistingWaypoints = removeWaypoints; //order.Waypoints.Add(new WaypointInfo(pos)); GameManager.Instance.NetworkManager.Send(order); //GameManager.Instance.MessageManager.AddMessage(string.Format("Move order sendt. Heading for {0}, {1}", lat, lng), GameManager.MessageTypes.Game); }
private void btnMove_Click(object sender, RoutedEventArgs e) { try { double Lat = double.Parse(txtLat.Text); double Lon = double.Parse(txtLon.Text); BaseUnitInfo info = lstUnits.SelectedItem as BaseUnitInfo; string Id; if (info != null) { Id = info.Id; } else { ShowInfo("Select a unit in ListBox first."); return; } UnitMovementOrder order = new UnitMovementOrder(); order.Id = Id; PositionInfo pos = new PositionInfo(); pos.Latitude = Lat; pos.Longitude = Lon; order.RemoveAllExistingWaypoints = (bool)chkClearWaypoints.IsChecked; order.Waypoints.Add(new WaypointInfo(pos)); order.UnitSpeedType = GameConstants.UnitSpeedType.UnchangedDefault; _gameClient.Send(order); ShowInfo("*** Movement order sent to unit " + info.UnitName); lstUnits.SelectedIndex = -1; lstDetections.SelectedIndex = -1; } catch (Exception ex) { ShowInfo("Select a unit. Use decimal points for Lat and Long. " + ex.Message); } }
public void Launch(BaseUnitInfo unit, List <CarriedUnit> unitsToLaunch, GameConstants.UnitOrderType unitOrderType, Coordinate coord) { if (unit != null) { UnitOrder order = new UnitOrder(unitOrderType, unit.Id); StringBuilder sb = new StringBuilder(); sb.AppendLine("Launcing Aircrafts:"); foreach (CarriedUnit cui in unitsToLaunch) { order.ParameterList.Add(cui.UnitInfo.Id); sb.AppendLine(cui.UnitInfo.Id); } UnitMovementOrder moveOrder = new UnitMovementOrder(); moveOrder.Waypoints.Add(new WaypointInfo(new PositionInfo(coord.Latitude, coord.Longitude))); order.UnitOrders.Add(moveOrder); GameManager.Instance.MessageManager.AddMessage(sb.ToString(), GameManager.MessageTypes.Game, unit.Position); GameManager.Instance.NetworkManager.Send(order); } }
public void Attack(BaseUnitInfo attacker, DetectedUnitInfo attackee, GameConstants.EngagementOrderType engagementOrderType, string weaponClassID, int roundCount) { if (attacker != null && attackee != null) { //~ ShowInfo(string.Format("*** Unit {0} to engage target {1}", unit.UnitName, det.DetectedUnitDescription)); UnitEngagementOrder order = OrderFactory.CreateEngagementOrder(attacker.Id, attackee.Id, weaponClassID, engagementOrderType, GameConstants.EngagementStrength.DefaultAttack, false); //order.DetectedUnitId = attackee.Id; //order.Id = attacker.Id; //if (weaponClassID != null) //{ // order.WeaponClassID = weaponClassID; //} //if (roundCount != null && roundCount > 0) //{ // order.RoundCount = roundCount; //} //order.EngagementType = engagementOrderType; GameManager.Instance.NetworkManager.Send(order); GameManager.Instance.MessageManager.AddMessage(string.Format("Attacking {0} with unit {1}", attackee.Id, attacker.Id), GameManager.MessageTypes.Battle, attackee.Position); } else { //~ ShowInfo("Select own unit and detected unit to engage."); } }
private void HandleBaseUnitInfo(IMarshallable dataReceived) { BaseUnitInfo info = dataReceived as BaseUnitInfo; if (info != null) { if (_Units.Find(u => info.Id == u.Id) != null) { _Units.RemoveAll(u => u.Id == info.Id); } else { ShowInfo("Received BaseUnitInfo: " + info.ToString()); } if (info.IsMarkedForDeletion) { //ShowInfo(string.Format("Unit [{0}] {1} has been DESTROYED.", info.Id, info.UnitName)); } else { _Units.Add(info); } ShowGameInfo(); lstUnits.Items.Refresh(); } }
public void ChangePlaneLoadoutTest() { Player player = new Player(); player.Name = "GoodGuy"; player.IsComputerPlayer = true; GameManager.Instance.GameData.InitAllData(); Game game = GameManager.Instance.CreateGame(player, "test game"); GameManager.Instance.GameData.LoadGameScenario("test", game); Player otherPlayer = player.Enemies[0]; BaseUnit Airport = player.Units.Find(u => u.UnitClass.Id == "ukairportlarge"); Assert.IsNotNull(Airport, "Airport should not be null."); AircraftUnit f22unit = (AircraftUnit)Airport.AircraftHangar.Aircraft.First <AircraftUnit>(a => a.UnitClass.Id == "f22"); game.IsGamePlayStarted = true; //a lie string desiredWeaponLoad = "Naval Strike"; f22unit.SetDirty(TTG.NavalWar.NWComms.GameConstants.DirtyStatus.Clean); Airport.SetDirty(TTG.NavalWar.NWComms.GameConstants.DirtyStatus.Clean); BaseUnitInfo info = Airport.GetBaseUnitInfo(); f22unit.SetWeaponLoad(desiredWeaponLoad); info = Airport.GetBaseUnitInfo(); Assert.IsTrue(f22unit.ReadyInSec > 500, "F22 should not be ready after loadout change."); Assert.IsTrue(f22unit.CurrentWeaponLoadName == desiredWeaponLoad, "Current loadout name should be 'Naval Strike'"); bool launchResult = Airport.LaunchAircraft(new List <AircraftUnit> { f22unit }, string.Empty, "No planes", null, ""); Assert.IsFalse(launchResult, "Air group should not be launched."); info = Airport.GetBaseUnitInfo(); }
private void btnMaxSpeed_Click(object sender, RoutedEventArgs e) { BaseUnitInfo unit = lstUnits.SelectedItem as BaseUnitInfo; if (unit != null) { var order = OrderFactory.CreateSetSpeedOrder(unit.Id, GameConstants.UnitSpeedType.Afterburner, true); _gameClient.Send(order); } }
private void btnRadar_Click(object sender, RoutedEventArgs e) { BaseUnitInfo unit = lstUnits.SelectedItem as BaseUnitInfo; if (unit != null) { var order = OrderFactory.CreateSensorActivationOrder(unit.Id, GameConstants.SensorType.Radar, true); _gameClient.Send(order); } }
public void Launch(BaseUnitInfo unit, CarriedUnitInfo unitToLaunch, GameConstants.UnitOrderType unitOrderType) { if (unit != null) { UnitOrder order = new UnitOrder(unitOrderType, unit.Id); order.ParameterList.Add(unitToLaunch.Id); GameManager.Instance.MessageManager.AddMessage(string.Format( "Launching aircraft: {0}", unit.UnitName), GameManager.MessageTypes.Game, unit.Position); GameManager.Instance.NetworkManager.Send(order); } }
public void ChangeLoadOut(BaseUnitInfo carrier, CarriedUnitInfo carriedUnit, string loadOutName) { UnitOrder order = new UnitOrder(GameConstants.UnitOrderType.ChangeAircraftLoadout, carrier.Id); order.SecondId = carriedUnit.Id; order.StringParamater = loadOutName; GameManager.Instance.MessageManager.AddMessage(string.Format( "Changing loadout for {0} to {1}", carriedUnit.UnitName, loadOutName), GameManager.MessageTypes.Game, carrier.Position); GameManager.Instance.NetworkManager.Send(order); }
private void lstUnits_SelectionChanged(object sender, SelectionChangedEventArgs e) { BaseUnitInfo unit = lstUnits.SelectedItem as BaseUnitInfo; if (unit != null) { _selectedUnitInfo = unit; UpdateUnitInfoWindow(); } else { _selectedUnitInfo = null; } }
private void btnRtb_Click(object sender, RoutedEventArgs e) { BaseUnitInfo unit = lstUnits.SelectedItem as BaseUnitInfo; if (unit != null) { var unitOrder = OrderFactory.CreateReturnToBaseOrder(unit.Id); _gameClient.Send(unitOrder); } else { ShowInfo("Select own unit"); } }
public void SetSensorPassiveActive(BaseUnitInfo unit, SensorInfo sensor, bool active) { if (unit != null) { UnitOrder order = new UnitOrder(GameConstants.UnitOrderType.SensorActivationOrder, unit.Id); order.IsParameter = active; order.SecondId = sensor.Id; GameManager.Instance.MessageManager.AddMessage(string.Format( "UnitOrder to unit {0} : Change {1} to: {2} sensoring", order.Id, sensor.Name, active == true ? "active" : "passive"), GameManager.MessageTypes.Detection, unit.Position); GameManager.Instance.NetworkManager.Send(order); } }
public void GroupEngagementTest() { Player player = new Player(); player.Name = "GoodGuy"; player.IsComputerPlayer = true; GameManager.Instance.GameData.InitAllData(); Game game = GameManager.Instance.CreateGame(player, "test game"); GameManager.Instance.GameData.LoadGameScenario("small", game); Player otherPlayer = player.Enemies[0]; Assert.IsTrue(game.Players.Count == 2, "There should be two players in game."); //Assert.IsTrue(otherPlayer.Units.Count == 15, "Player 1 should have 15 units."); BaseUnit unit = player.GetUnitById("tag:main"); Assert.IsNotNull(unit, "Unit with tag main should exist."); var wp = unit.MovementOrder.GetActiveWaypoint(); Assert.IsNotNull(wp, "Main unit waypoint should not be null."); BaseUnitInfo info = unit.GetBaseUnitInfo(); Assert.IsTrue(info.IsGroupMainUnit, "Main unit should be main unit"); //foreach (var u in player.Units) //{ // if (string.IsNullOrEmpty(u.CurrentWeaponLoadName)) // { // GameManager.Instance.Log.LogDebug( // string.Format("Unit {0} has empty CurrentWeaponLoad.", u.ToShortString())); // } //} game.IsNetworkEnabled = false; game.RealTimeCompressionFactor = 10; GameManager.Instance.Game.RunGameInSec = 1; var sentryPlane = player.GetUnitById("tag:sentry"); Assert.IsNotNull(sentryPlane, "Sentry plane should exist and not be null."); sentryPlane.SetSensorsActivePassive(GameConstants.SensorType.Radar, true); GameManager.Instance.Game.StartGamePlay(); var detectedGroup = player.DetectedGroups.FirstOrDefault <DetectedGroup>(); Assert.IsNotNull(detectedGroup, "Detected group should be found"); var result = unit.EngageDetectedGroup(detectedGroup, GameConstants.EngagementOrderType.EngageNotClose, GameConstants.EngagementStrength.DefaultAttack, true); Assert.IsTrue(result, "EngageDetectedGroup should respond true"); }
private void AddPlayer() { Debug.Log("AddPlayer..."); Player player = new Player(); BaseUnitInfo info = new BaseUnitInfo(); //TODO copy data from server and config player.Init(info); GameObject unitFrameShell = GameObject.CreatePrimitive(PrimitiveType.Cube); UnitFrameView unitFrameView = unitFrameShell.AddComponent <UnitFrameView>(); unitFrameView.myInfo = info; playerList.Add(player); unitFrameViewList.Add(unitFrameView); unitFrameViewMap.Add(info.id, unitFrameView); }
public void LaunchAttack(BaseUnitInfo unit, DetectedUnitInfo det, List <CarriedUnit> unitsToLaunch, Coordinate coord) { List <string> units = new List <string>(); foreach (CarriedUnit cui in unitsToLaunch) { units.Add(cui.UnitInfo.Id); } UnitMovementOrder moveOrder = new UnitMovementOrder(); if (coord != null) { moveOrder.Waypoints.Add(new WaypointInfo(new PositionInfo(coord.Latitude, coord.Longitude))); } GameManager.Instance.NetworkManager.Send(OrderFactory.CreateAircraftLaunchOrder(unit.Id, units, moveOrder)); GameManager.Instance.NetworkManager.Send(OrderFactory.CreateEngagementOrder(unit.Id, det.Id, string.Empty, GameConstants.EngagementOrderType.CloseAndEngage, GameConstants.EngagementStrength.DefaultAttack, true)); }
private void btnLaunchAircraft_Click(object sender, RoutedEventArgs e) { BaseUnitInfo unit = lstUnits.SelectedItem as BaseUnitInfo; if (unit != null) { UnitOrder order = new UnitOrder(GameConstants.UnitOrderType.LaunchAircraft, unit.Id); LaunchAircraft launchDialog = new LaunchAircraft(); launchDialog.AircraftList = unit.CarriedUnits; launchDialog.Init(); bool?result = launchDialog.ShowDialog(); order.ParameterList = launchDialog.GetSelectedIds(); //int unitcount = 0; //int maxUnits = 1; //string aircraftlist = string.Empty; //if(unit.UnitClassId.Contains("airport")) //{ // maxUnits = 3; //} //foreach (var c in unit.CarriedUnits) //{ // if (c.ReadyInSec < 1 && unitcount < maxUnits) // { // order.ParameterList.Add(c.Id); // aircraftlist += c.ToString() + " "; // unitcount++; // } //} ShowInfo(string.Format( "UnitOrder to unit {0} : Launch {1} aircraft.", order.Id, order.ParameterList.Count)); UnitMovementOrder moveOrder = new UnitMovementOrder(); moveOrder.Waypoints.Add(new WaypointInfo(new PositionInfo(55, 3))); order.UnitOrders.Add(moveOrder); _gameClient.Send(order); } else { ShowInfo("No unit selected!"); } }
private void btnInfo_Click(object sender, RoutedEventArgs e) { BaseUnitInfo unit = lstUnits.SelectedItem as BaseUnitInfo; if (unit != null) { string info = ""; info = unit.ToLongString(); // +"\n" + "Distance to target: " + unit.Position.MostRecentDistanceToTargetM + "\n"; foreach (var sens in unit.Sensors) { info += string.Format("\n* {0} Operational: {1}", sens.ToString(), sens.IsOperational); } foreach (var wpn in unit.Weapons) { info += string.Format("\n* {0} Ammo: {1} of {2}", wpn.ToString(), wpn.AmmunitionRemaining, wpn.MaxAmmunition); } _unitInfoWindows.ShowInfo(info); } }
private void btnCloseAndEngage_Click(object sender, RoutedEventArgs e) { BaseUnitInfo unit = lstUnits.SelectedItem as BaseUnitInfo; DetectedUnitInfo det = lstDetections.SelectedItem as DetectedUnitInfo; if (unit != null && det != null) { ShowInfo(string.Format("*** Unit {0} to close and engage target {1}", unit.UnitName, det.ToString())); UnitEngagementOrder order = new UnitEngagementOrder(); order.TargetId = det.Id; order.IsGroupAttack = true; //test that order.Id = unit.Id; //order.WeaponClassID = "mk45mod4"; order.EngagementType = GameConstants.EngagementOrderType.CloseAndEngage; _gameClient.Send(order); } else { ShowInfo("Select own unit and detected unit to engage."); } }
public void Launch(BaseUnitInfo unit, GameConstants.UnitOrderType unitOrderType) { if (unit != null) { UnitOrder order = new UnitOrder(unitOrderType, unit.Id); int unitcount = 0; string aircraftlist = string.Empty; foreach (CarriedUnitInfo c in unit.CarriedUnits) { if (c.ReadyInSec < 1 && unitcount < 1) { order.ParameterList.Add(c.Id); aircraftlist += c.ToString() + " "; unitcount++; } } GameManager.Instance.MessageManager.AddMessage(string.Format( "UnitOrder to unit {0} : Launch {1} aircraft: {2} ", order.Id, order.ParameterList.Count, aircraftlist), GameManager.MessageTypes.Game, unit.Position); GameManager.Instance.NetworkManager.Send(order); } }
public void Attack(string lat, string lng, BaseUnitInfo info) { //double Lat = double.Parse(lat); //double Lon = double.Parse(lng); //string Id; //if (info != null) //{ // Id = info.Id; //} //else //{ // //~ ShowInfo("Select a unit in ListBox first."); // return; //} //UnitMovementOrder order = new UnitMovementOrder(); //order.Id = Id; //PositionInfo pos = new PositionInfo(); //pos.Latitude = Lat; //pos.Longitude = Lon; //order.RemoveAllExistingWaypoints = true; //order.Positions.Add(pos); }
public void LoadTestScenario() { Player player = new Player(); player.Name = "GoodGuy"; player.IsComputerPlayer = true; GameManager.Instance.GameData.InitAllData(); Game game = GameManager.Instance.CreateGame(player, "test game"); GameManager.Instance.GameData.LoadGameScenario("test", game); Player otherPlayer = player.Enemies[0]; Assert.IsTrue(game.Players.Count == 2, "There should be two players in game."); //Assert.IsTrue(otherPlayer.Units.Count == 15, "Player 1 should have 15 units."); BaseUnit unit = player.GetUnitById("tag:main"); Assert.IsNotNull(unit, "Unit with tag main should exist."); var wp = unit.MovementOrder.GetActiveWaypoint(); Assert.IsNotNull(wp, "Main unit waypoint should not be null."); BaseUnitInfo info = unit.GetBaseUnitInfo(); Assert.IsTrue(info.IsGroupMainUnit, "Main unit should be main unit"); }
private void HandleGameStateInfo(IMarshallable dataReceived) { GameStateInfo gameInfo = dataReceived as GameStateInfo; if (gameInfo != null) { if (gameInfo.InfoType == GameConstants.GameStateInfoType.UnitIsDestroyed) { if (_selectedUnitInfo != null && _selectedUnitInfo.Id == gameInfo.Id) { _selectedUnitInfo = null; } _Units.RemoveAll(u => u.Id == gameInfo.Id); lstUnits.Items.Refresh(); } else if (gameInfo.InfoType == GameConstants.GameStateInfoType.DetectedContactIsLost || gameInfo.InfoType == GameConstants.GameStateInfoType.DetectedContactIsDestroyed) { _Detections.RemoveAll(d => d.Id == gameInfo.Id); lstDetections.Items.Refresh(); } else if (gameInfo.InfoType == GameConstants.GameStateInfoType.DetectedContactGroupIsLost) { _DetectedGroups.RemoveAll(d => d.Id == gameInfo.Id); } else if (gameInfo.InfoType == GameConstants.GameStateInfoType.AircraftIsLanded) { _Units.RemoveAll(u => u.Id == gameInfo.Id); lstUnits.Items.Refresh(); ShowInfo("Aircraft has landed : " + gameInfo.Id); } else if (gameInfo.InfoType == GameConstants.GameStateInfoType.MissileLaunch) { } ShowInfo("***GameStateInfo: " + gameInfo.ToString()); } }
public virtual void Destroy() { unitFrameInfo = null; myInfo = null; }
private void HandleReceivedData(IMarshallable dataReceived) { switch (dataReceived.ObjectTypeToken) { case CommsMarshaller.ObjectTokens.NoObject: break; case CommsMarshaller.ObjectTokens.Enq: break; case CommsMarshaller.ObjectTokens.Ack: break; case CommsMarshaller.ObjectTokens.ClientInfoRequest: break; case CommsMarshaller.ObjectTokens.GameControlRequest: break; case CommsMarshaller.ObjectTokens.GameStateInfo: HandleGameStateInfo(dataReceived); break; case CommsMarshaller.ObjectTokens.MessageString: MessageString str = dataReceived as MessageString; if (str != null) { if (str.Message.StartsWith("CHEAT")) { _selectedUnitInfo = null; _unitInfoWindows.ShowInfo(str.Message); } else { ShowInfo("MessageString: " + str.Message); } } break; case CommsMarshaller.ObjectTokens.BattleDamageReport: BattleDamageReport report = dataReceived as BattleDamageReport; if (report != null) { if (_playerInfo != null) { //if (string.IsNullOrEmpty(report.MessageToAttacker) || string.IsNullOrEmpty(report.MessageToAttacker)) //{ //} //if (report.PlayerInflictingDamageId == _playerInfo.Id) //{ // ShowInfo("+++" + report.MessageToAttacker); //} //else if (report.PlayerSustainingDamageId == _playerInfo.Id) //{ // ShowInfo("---" + report.MessageToAttackee); //} } //ShowInfo("***BattleDamageReport: " + report.ToString()); } break; case CommsMarshaller.ObjectTokens.GameInfo: GameInfo gameInfo = dataReceived as GameInfo; if (gameInfo != null) { _gameInfo = gameInfo; ShowInfo("*** GameInfo received.\n" + gameInfo.ToString()); //ShowInfo("GameWorldTimeSec=" + gameInfo.GameWorldTimeSec); //ShowInfo("GameEngineTimeMs=" + gameInfo.GameEngineTimeMs); } break; case CommsMarshaller.ObjectTokens.PlayerInfo: PlayerInfo playerInfo = dataReceived as PlayerInfo; HandlePlayerInfo(playerInfo); break; case CommsMarshaller.ObjectTokens.PositionInfo: HandlePositionInfo(dataReceived); break; case CommsMarshaller.ObjectTokens.BaseUnitInfo: HandleBaseUnitInfo(dataReceived); break; case CommsMarshaller.ObjectTokens.GroupInfo: HandleGroupInfo(dataReceived); break; case CommsMarshaller.ObjectTokens.DetectedUnitInfo: HandleDetectedUnitInfo(dataReceived); break; case CommsMarshaller.ObjectTokens.DetectedGroupInfo: HandleDetectedGroupInfo(dataReceived); break; case CommsMarshaller.ObjectTokens.MessageInfo: HandleMessageInfo(dataReceived); break; case CommsMarshaller.ObjectTokens.OrderInfo: break; case CommsMarshaller.ObjectTokens.UnitOrder: break; case CommsMarshaller.ObjectTokens.UnitMovementOrder: break; case CommsMarshaller.ObjectTokens.UnitEngagementOrder: break; case CommsMarshaller.ObjectTokens.UnitClass: UnitClass unitClass = dataReceived as UnitClass; if (unitClass != null) { ShowInfo("Received new UnitClass " + unitClass.Id + " " + unitClass.UnitClassShortName); } break; case CommsMarshaller.ObjectTokens.WeaponClass: break; case CommsMarshaller.ObjectTokens.SensorClass: break; case CommsMarshaller.ObjectTokens.GameScenario: var scenario = dataReceived as GameScenario; if (scenario != null) { cmbPlayers.Items.Clear(); foreach (var al in scenario.Alliences) { foreach (var pl in al.ScenarioPlayers) { if (pl.IsCompetitivePlayer) { var item = new ComboBoxItem(); item.Content = pl.ToString(); item.Tag = pl.Id; cmbPlayers.Items.Add(item); } } } if (cmbPlayers.Items.Count > 0) { cmbPlayers.SelectedIndex = 0; } } break; case CommsMarshaller.ObjectTokens.GameScenarioAlliance: break; case CommsMarshaller.ObjectTokens.GameScenarioPlayer: break; case CommsMarshaller.ObjectTokens.GameScenarioGroup: break; case CommsMarshaller.ObjectTokens.GameScenarioUnit: break; case CommsMarshaller.ObjectTokens.GameUiControl: GameUiControl control = dataReceived as GameUiControl; if (control != null) { ShowInfo("### GameUiControl received: " + control.ToString()); } break; default: break; } }
private void HandlePositionInfo(IMarshallable dataReceived) { PositionInfo posInfo = dataReceived as PositionInfo; if (posInfo == null) { return; } if (posInfo.IsDetection) { DetectedUnitInfo det = _Detections.Find(d => d.Id == posInfo.UnitId); if (det != null) { det.Position = posInfo; lstDetections.Items.Refresh(); if (_selectedDetectedUnitInfo != null && _selectedDetectedUnitInfo.Id == det.Id) { UpdateUnitInfoWindow(); } } else { ShowInfo("Received PositionInfo on Non-Existing Detection " + det.Id); } } else //refers to unit { BaseUnitInfo unit = _Units.Find(u => u.Id == posInfo.UnitId); if (unit != null) { //double oldBearingDeg = unit.Position.BearingDeg; //double newBearingDeg = posInfo.BearingDeg; //double diffBearing = Math.Abs(oldBearingDeg - newBearingDeg); if (_selectedUnitInfo != null && _selectedUnitInfo.Id == unit.Id) { UpdateUnitInfoWindow(); } unit.Position = posInfo; //if (unit.Id == "BRZ") //that darned helo //{ // txtUnitInfo.Text = string.Format("BRZ bearing: {0:F}", newBearingDeg); // if(diffBearing > 1.0) // { // ShowInfo( // string.Format("### BRZ has changed bearing: Old: {0:F} New: {1:F} Des: {2:F}\nPositionInfo: {3}", // oldBearingDeg, newBearingDeg, unit.Position.DesiredBearingDeg, posInfo)); // } //} //if (unit.Tag == "main") //{ // _log.LogDebug(string.Format("Unit {0} PositionInfo: {1}", unit.Id, posInfo.ToString())); //} //if (posInfo.IsFormationMovementOrder) //{ // _log.LogDebug(string.Format("Unit {0} PositionInfo: {1}", unit.Id, posInfo.ToString())); //} unit.ActualSpeedKph = posInfo.ActualSpeedKph; } ShowGameInfo(); lstUnits.Items.Refresh(); } }
private void HandleBaseUnitInfo(IMarshallable dataReceived) { //~ GameManager.Instance.MessageManager.AddMessage(dataReceived.ToString()); BaseUnitInfo info = dataReceived as BaseUnitInfo; if (info != null) { PlayerUnit unit = GameManager.Instance.UnitManager.FindUnitById(info.Id); if (info.IsMarkedForDeletion) { //~ ShowMessage(string.Format("Unit [{0}] {1} has been DESTROYED.", info.Id, info.UnitName)); ////////////REMOVE OBJECT/////////////////////// Debug.Log(info + " is marked for deletion"); if (unit.Info.UnitType == GameConstants.UnitType.Missile) { //Instantiate explosives unit.MyMapUnit.Explode(); } Destroy(unit.gameObject); return; } //~ ShowMessage(info.UnitName + " " + info.IsMarkedForDeletion.ToString()); GameObject go = null; if (unit != null) { unit.Info = info; return; } if (go == null) //Make new one and add to _GameUnits list { //Debug.Log(info.UnitClassId); UnitClass vesselUnitClass = GameManager.Instance.GetUnitClass(info.UnitClassId); if (vesselUnitClass == null) { Debug.Log("Unitclass is NuLLL!!!!"); } go = GetVesselByUnitClassId(vesselUnitClass.UnitModelFileName, info.Position); unit = go.AddComponent <PlayerUnit>(); unit.Size = new Vector2(32, 32); //unit.OptionalAngleTest = optionalAngle; unit.PrefabMapUnit = MapUnit; go.transform.parent = GameObject.Find("SurfaceUnits").transform; if (info.DomainType != GameConstants.DomainType.Land && info.DomainType != GameConstants.DomainType.Air) { go.transform.localScale = GameManager.Instance.GlobalScale; } go.name = info.UnitName; if (info.DomainType != GameConstants.DomainType.Air) { GameObject healthBar = Instantiate(HealthBar, Vector3.zero, Quaternion.identity) as GameObject; healthBar.transform.parent = go.transform; healthBar.transform.localPosition = Vector3.up * 10; } //~ if(map != null) //~ { //~ map.UnitInfo = unit; //~ } //~ GameObject clone = Instantiate(ABurke, GameManager.Instance.GetVectorByLatLng((float)info.Position.Latitude, (float)info.Position.Longitude), Quaternion.identity) as GameObject; //~ Debug.Log(string.Format("Adding unit {0} to list", unit.Info.Id)); } //Debug.Log(info.Id + " created"); unit.Info = info; //~ MapUnit mu = AddMapUnit(unit, GameManager.Instance.GetTextureByUnitClassId(unit.Info.UnitClassId)); //~ unit.MapUnit = mu; GameManager.Instance.UnitManager.AddUnit(unit); if (go.audio != null) { GameManager.Instance.AudioManager.AddSound(go.audio); } if (GameManager.Instance.UnitManager.SelectedUnit == null) { GameManager.Instance.UnitManager.SelectedUnit = unit; } } }
public virtual void Init(BaseUnitInfo unitInfo) { this.myInfo = unitInfo; }