private void HandleGameUIControlInfo(IMarshallable dataReceived) { Debug.Log("GameUIControl received"); GameUiControl guc = dataReceived as GameUiControl; Vector3 position = new Vector3((float)guc.PositionX, (float)guc.PositionY, (float)guc.PositionZ); Vector3 rotation = new Vector3((float)guc.RotationX, (float)guc.RotationY, (float)guc.RotationZ); PlayerUnit unit = GameManager.Instance.UnitManager.FindUnitById(guc.Id); GameManager.Instance.CameraManager.SetCameraFocus(position, rotation, unit != null ? unit : 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; } }