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."); } }
public EngagementOrder(DetectedUnit targetDetectedUnit, GameConstants.EngagementOrderType engagementOrder, string weaponClassId) : this() { TargetDetectedUnit = targetDetectedUnit; EngagementOrderType = engagementOrder; WeaponClassId = weaponClassId; }
public EngagementOrder(DetectedUnit targetDetectedUnit, GameConstants.EngagementOrderType engagementOrder, GameConstants.EngagementStrength engagementStrength) : this() { TargetDetectedUnit = targetDetectedUnit; EngagementOrderType = engagementOrder; EngagementStrength = engagementStrength; }
public static UnitEngagementOrder CreateEngagePositionOrder(string unitId, PositionInfo position, string weaponClassId, GameConstants.EngagementOrderType engagementOrderType, GameConstants.EngagementStrength engagementStrength, int noOfRounds) { UnitEngagementOrder order = new UnitEngagementOrder(); order.Id = unitId; order.Position = position; order.WeaponClassID = weaponClassId; order.RoundCount = noOfRounds; order.EngagementStrength = engagementStrength; order.EngagementType = engagementOrderType; return(order); }
/// <summary> /// Creates a UnitEngagementOrder /// </summary> /// <param name="unitId">Id of unit. If isGroupAttack is true, any unitid in group will work</param> /// <param name="targetId">Id of TargetDetectedUnit</param> /// <param name="weaponClassId">Which weapon to use. If empty or null, automatic selection</param> /// <param name="engagementOrderType">CloseAndEngage or EngageNotClose</param> /// <param name="engagementStrength">MinimalAttack, DefaultAttack or OverkillAttack</param> /// <param name="isGroupAttack">If true, all units in group may participate in attack. /// <param name="isTargetAGroup">If true, targetId is interpreted as the Id of a DetectedGroup, and all units in group will be engaged. /// If false, only unit receiving order.</param> /// <returns>Well-formed order object ready for sending</returns> public static UnitEngagementOrder CreateEngagementOrder(string unitId, string targetId, string weaponClassId, GameConstants.EngagementOrderType engagementOrderType, GameConstants.EngagementStrength engagementStrength, bool isGroupAttack, bool isTargetAGroup) { UnitEngagementOrder order = new UnitEngagementOrder(); order.TargetId = targetId; order.IsGroupAttack = isGroupAttack; order.Id = unitId; order.WeaponClassID = weaponClassId; //"mk45mod4"; order.EngagementType = engagementOrderType; order.EngagementStrength = engagementStrength; order.IsTargetAGroup = isTargetAGroup; return(order); }
public override void DockableWindowFunc(int id) { DoResizing(); GUILayout.Space(GameManager.Instance.GUIManager.MinimizeButtonRect.height); if (_SelectedUnit != null) { Separator.fixedWidth = WindowRect.width - this.PaddingLeft * 2; if (Target != null) { GUILayout.Label(string.Format("Target : {0} at Position : {1}", Target.RefersToUnitName, Target.Position.ToString())); GUILayout.Label("", Separator); } GUILayout.Label("Choose weapon:"); foreach (WeaponInfo wi in _SelectedUnit.Info.Weapons) { WeaponClass wc = GameManager.Instance.GetWeaponClass(wi.WeaponClassId); if (wc != null) { if (GUILayout.Button(wc.WeaponClassName)) { _SelectedWeapon = wi; _RoundCount = 10; } } } if (_SelectedWeapon != null) { GUILayout.Label("", Separator); WeaponClass wc = GameManager.Instance.GetWeaponClass(_SelectedWeapon.WeaponClassId); GUILayout.Label(string.Format("Selected weapon : {0}. Weapon ready in {1} sec", wc.WeaponClassName, _SelectedWeapon.ReadyInSec)); GUILayout.Label(string.Format("Round count : {0}.", Mathf.Floor(_RoundCount))); GUILayout.BeginVertical(); _RoundCount = GUILayout.HorizontalSlider(_RoundCount, 1, _SelectedWeapon.AmmunitionRemaining); _EngagementOrderType = GUILayout.SelectionGrid(_EngagementOrderType, GameConstants.EngagementOrderType.GetNames(typeof(GameConstants.EngagementOrderType)), 3, EngagementOrderStyle); string eName = GameConstants.EngagementOrderType.GetName(typeof(GameConstants.EngagementOrderType), _EngagementOrderType).ToString(); GUILayout.Label(eName); if (GUILayout.Button("Give order")) { //ATTACK GameConstants.EngagementOrderType type = (GameConstants.EngagementOrderType)GameConstants.EngagementOrderType.Parse(typeof(GameConstants.EngagementOrderType), eName); GameManager.Instance.OrderManager.Attack(_SelectedUnit.Info, Target, type, _SelectedWeapon.WeaponClassId, (int)_RoundCount); this.enabled = false; } GUILayout.EndVertical(); } } else { GUILayout.Label("Not Connected"); } }
public void Attack(string attackerId, string detectedInfoId, GameConstants.EngagementOrderType engagementOrderType, WeaponInfo weaponInfo, GameConstants.EngagementStrength strength, bool isGroupAttack) { GameManager.Instance.NetworkManager.Send(OrderFactory.CreateEngagementOrder(attackerId, detectedInfoId, weaponInfo == null ? string.Empty : weaponInfo.Id, engagementOrderType, strength, isGroupAttack)); GameManager.Instance.MessageManager.AddMessage(string.Format("Attacking {0} with unit {1}", attackerId, detectedInfoId), GameManager.MessageTypes.Battle, null); }