/// <summary> /// Check between plateau to deployment point /// </summary> /// <param name="plateau"></param> /// <param name="deploymentPoint"></param> /// <returns></returns> private void CheckDeploymentPointIsValid(Plateau plateau, DeploymentPoint deploymentPoint) { if (plateau.Width < deploymentPoint.X || plateau.Height < deploymentPoint.Y || deploymentPoint.X < 0 || deploymentPoint.Y < 0) { throw new OutOfBoundsFromPlateauException(); } }
private void OnDeploymentStateChange(DeploymentPoint deploymentPoint) { if (deploymentPoint.IsDeployed || !this.team.DetachmentManager.Detachments.Contains(deploymentPoint.DisbandedWeapon as IDetachment)) { return; } this.team.DetachmentManager.DestroyDetachment(deploymentPoint.DisbandedWeapon as IDetachment); }
public Rover SetRoverOnPlateau(Plateau plateau, DeploymentPoint deploymentPoint) { CheckDeploymentPointIsValid(plateau, deploymentPoint); CheckDirectionIsValid(deploymentPoint.Direction); return(new Rover() { DeploymentPoint = deploymentPoint }); }
private bool DeployWeaponFrom(DeploymentPoint dp) { IEnumerable <System.Type> source = dp.DeployableWeaponTypes.Where <System.Type>((Func <System.Type, bool>)(t => this.deploymentPoints.Count <DeploymentPoint>((Func <DeploymentPoint, bool>)(dep => dep.IsDeployed && SiegeWeaponCollection.GetWeaponType((ScriptComponentBehaviour)dep.DeployedWeapon) == t)) < this.weapons.GetMaxDeployableWeaponCount(t))); if (source.IsEmpty <System.Type>()) { return(false); } System.Type t1 = source.MaxBy <System.Type, float>((Func <System.Type, float>)(t => this.GetWeaponValue(t))); dp.Deploy(t1); return(true); }
private void DeployAllForDefenders() { Mission current = Mission.Current; Scene scene = current.Scene; List <ICastleKeyPosition> list1 = current.ActiveMissionObjects.Select <MissionObject, GameEntity>((Func <MissionObject, GameEntity>)(amo => amo.GameEntity)).Select <GameEntity, UsableMachine>((Func <GameEntity, UsableMachine>)(e => e.GetFirstScriptOfType <UsableMachine>())).Where <UsableMachine>((Func <UsableMachine, bool>)(um => um is ICastleKeyPosition)).Cast <ICastleKeyPosition>().Where <ICastleKeyPosition>((Func <ICastleKeyPosition, bool>)(x => { IPrimarySiegeWeapon attackerSiegeWeapon = x.AttackerSiegeWeapon; return(attackerSiegeWeapon == null || attackerSiegeWeapon.WeaponSide != FormationAI.BehaviorSide.BehaviorSideNotSet); })).ToList <ICastleKeyPosition>(); List <DeploymentPoint> list2 = this.deploymentPoints.Where <DeploymentPoint>((Func <DeploymentPoint, bool>)(dp => !dp.IsDeployed)).ToList <DeploymentPoint>(); while (!list2.IsEmpty <DeploymentPoint>()) { Threat maxThreat = ThreatSeeker.GetMaxThreat(list1); Vec3 mostDangerousThreatPosition = maxThreat.Position; DeploymentPoint dp1 = list2.MinBy <DeploymentPoint, float>((Func <DeploymentPoint, float>)(dp => dp.GameEntity.GlobalPosition.DistanceSquared(mostDangerousThreatPosition))); if (this.DeployWeaponFrom(dp1)) { maxThreat.ThreatValue *= 0.5f; } list2.Remove(dp1); } }