/// <summary> /// Initializes a new instance of the <see cref="FleetCmdStat" /> struct. /// </summary> /// <param name="name">The name.</param> /// <param name="maxHitPts">The maximum hit PTS.</param> /// <param name="maxCmdEffect">The maximum command effect.</param> /// <param name="formation">The formation.</param> public FleetCmdStat(string name, float maxHitPts, int maxCmdEffect, Formation formation) : this() { Name = name; MaxHitPoints = maxHitPts; MaxCmdEffectiveness = maxCmdEffect; UnitFormation = formation; }
public FP.Vector pos; // where to move to #endregion Fields #region Constructors public MoveCmdEvt(long timeVal, long timeCmdVal, Dictionary<int, int[]> pathsVal, FP.Vector posVal, Formation formationVal, bool autoTimeTravelVal) : base(timeVal, timeCmdVal, pathsVal) { pos = posVal; formation = formationVal; autoTimeTravel = autoTimeTravelVal; }
public static Boolean delete(Formation formation) { Boolean isDelete = false; //Connection ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["EntretienSPPPConnectionString"]; SqlConnection connection = new SqlConnection(connectionStringSettings.ToString()); String requete = @"DELETE FROM Formation WHERE Identifiant = @Identifiant ;"; SqlCommand commande = new SqlCommand(requete, connection); commande.Parameters.AddWithValue("Identifiant", formation.Identifiant); try { connection.Open(); commande.ExecuteNonQuery(); isDelete = true; } catch (Exception) { isDelete = false; } finally { connection.Close(); } return isDelete; }
public static Formation CreateFormation(Formation formation) { ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["EntretienSPPPConnectionString"]; SqlConnection connection = new SqlConnection(connectionStringSettings.ToString()); String requete = @"Insert INTO formation(organisme,Titre,Objectif,Interne,Externe) Values (@organisme,@Titre,@Objectif,@Interne,@Externe); SELECT SCOPE_IDENTITY() ;"; SqlCommand commande = new SqlCommand(requete, connection); commande.Parameters.AddWithValue("organisme",formation.organisme); commande.Parameters.AddWithValue("Titre",formation.Titre); commande.Parameters.AddWithValue("Objectif",formation.Objectif); commande.Parameters.AddWithValue("Interne",formation.Interne); commande.Parameters.AddWithValue("Externe",formation.Externe); try { connection.Open(); Decimal IDENTIFIANTDERNIERAJOUT = (Decimal)commande.ExecuteScalar(); return FormationDB.Get(Int32.Parse(IDENTIFIANTDERNIERAJOUT.ToString())); } catch (Exception) { throw; } finally { connection.Close(); } }
/// <summary> /// Initializes a new instance of the <see cref="StarbaseCmdStat" /> struct. /// </summary> /// <param name="name">The name.</param> /// <param name="maxHitPts">The maximum hit PTS.</param> /// <param name="lowOrbitDistance">The low orbit distance.</param> /// <param name="maxCmdEffect">The maximum command effect.</param> /// <param name="formation">The formation.</param> public StarbaseCmdStat(string name, float maxHitPts, float lowOrbitDistance, int maxCmdEffect, Formation formation) : this() { Name = name; MaxHitPoints = maxHitPts; LowOrbitDistance = lowOrbitDistance; MaxCmdEffectiveness = maxCmdEffect; UnitFormation = formation; }
public void MakeSphere(Formation f, float x, float y, float size) { GameObject g = new GameObject(); Transform t = g.transform; t.parent= f.transform; t.localPosition = new Vector3(0,y,-x); t.localScale = new Vector3(size,size,size); }
public BehaviorDestroySiegeWeapons(Formation formation) : base(formation) { this.BehaviorCoherence = 0.2f; this.behaviorSide = formation.AI.Side; this._allWeapons = Mission.Current.ActiveMissionObjects.FindAllWithType <SiegeWeapon>().Where <SiegeWeapon>((Func <SiegeWeapon, bool>)(sw => sw.Side != formation.Team.Side)).ToList <SiegeWeapon>(); this.DetermineTargetWeapons(); this.CurrentOrder = MovementOrder.MovementOrderCharge; }
public static void AjouterFormationDB(Formation formationNouveau) { using (var db = new DBAirAtlantiqueContext()) { db.Formations.Add(formationNouveau); db.SaveChanges(); } }
public BehaviorProtectFlank(Formation formation) : base(formation) { this._protectFlankState = BehaviorProtectFlank.BehaviourState.HoldingFlank; this.behaviorSide = formation.AI.Side; this._mainFormation = formation.Team.Formations.FirstOrDefault <Formation>((Func <Formation, bool>)(f => f.AI.IsMainFormation)); this.CalculateCurrentOrder(); this.CurrentOrder = this._movementOrder; }
public Formation LoadFormation(Enums.FormationId formationId) { string pt = Path.Combine(FilePath, formationId.ToString() + ".json"); StreamReader reader = new StreamReader(pt); string data = reader.ReadToEnd(); Formation formation = JsonConvert.DeserializeObject <Formation>(data); return(formation); }
public static Element Create(string name, Formation startFormation, params GroupAction[] actions) { return(new Element { Name = name, StartFormation = startFormation, GroupActions = actions }); }
private void AssignSergeant(Formation formationToLead, Agent sergeant) { sergeant.Formation = formationToLead; if (!sergeant.IsAIControlled) { formationToLead.PlayerOwner = sergeant; } formationToLead.Captain = sergeant; }
public LaissezUnAvisViewModel(string nomseo) { Formation formation = null; if (FormationManager.ObtenirFormation(nomseo, out formation)) { this.Formation = formation; } }
// Update is called once per frame void Update() { Formation c = ChooseFormation(); if (c != null) { armyScript.activeFormation = c; } }
static void PostfixCalculateCurrentOrder(Formation ____mainFormation, ref FacingOrder ___CurrentFacingOrder) { if (____mainFormation != null) { MethodInfo method = typeof(FacingOrder).GetMethod("FacingOrderLookAtDirection", BindingFlags.NonPublic | BindingFlags.Static); method.DeclaringType.GetMethod("FacingOrderLookAtDirection"); ___CurrentFacingOrder = (FacingOrder)method.Invoke(___CurrentFacingOrder, new object[] { ____mainFormation.Direction }); } }
// GET: Formations/Create public IActionResult Create(int id) { Formation formation = new Formation(); formation.CurriculumId = id; ViewData["TypeCoursId"] = new SelectList(_context.TypeCours, "TypeCoursId", "Type"); return(View(formation)); }
private void ArrangeDefenseFronts() { this._meleeFormations = this.Formations.Where <Formation>((Func <Formation, bool>)(f => f.QuerySystem.IsInfantryFormation || f.QuerySystem.IsCavalryFormation)).ToList <Formation>(); this._rangedFormations = this.Formations.Where <Formation>((Func <Formation, bool>)(f => f.QuerySystem.IsRangedFormation || f.QuerySystem.IsRangedCavalryFormation)).ToList <Formation>(); int count1 = Math.Min(8 - this._rangedFormations.Count, this._enemyClusters.Count); if (this._meleeFormations.Count != count1) { this.SplitFormationClassIntoGivenNumber((Func <Formation, bool>)(f => f.QuerySystem.IsInfantryFormation || f.QuerySystem.IsCavalryFormation), count1); this._meleeFormations = this.Formations.Where <Formation>((Func <Formation, bool>)(f => f.QuerySystem.IsInfantryFormation || f.QuerySystem.IsCavalryFormation)).ToList <Formation>(); } int count2 = Math.Min(8 - count1, this._enemyClusters.Count); if (this._rangedFormations.Count != count2) { this.SplitFormationClassIntoGivenNumber((Func <Formation, bool>)(f => f.QuerySystem.IsRangedFormation || f.QuerySystem.IsRangedCavalryFormation), count2); this._rangedFormations = this.Formations.Where <Formation>((Func <Formation, bool>)(f => f.QuerySystem.IsRangedFormation || f.QuerySystem.IsRangedCavalryFormation)).ToList <Formation>(); } foreach (TacticPerimeterDefense.DefenseFront defenseFront in this._defenseFronts) { defenseFront.MatchedEnemyCluster.UpdateClusterData(); BehaviorDefendKeyPosition defendKeyPosition = defenseFront.MeleeFormation.AI.SetBehaviorWeight <BehaviorDefendKeyPosition>(1f); defendKeyPosition.EnemyClusterPosition = defenseFront.MatchedEnemyCluster.MedianAggregatePosition; defendKeyPosition.EnemyClusterPosition.SetVec2(defenseFront.MatchedEnemyCluster.AggregatePosition); } IEnumerable <TacticPerimeterDefense.EnemyCluster> enemyClusters = this._enemyClusters.Where <TacticPerimeterDefense.EnemyCluster>((Func <TacticPerimeterDefense.EnemyCluster, bool>)(ec => this._defenseFronts.All <TacticPerimeterDefense.DefenseFront>((Func <TacticPerimeterDefense.DefenseFront, bool>)(df => df.MatchedEnemyCluster != ec)))); List <Formation> list1 = this._meleeFormations.Where <Formation>((Func <Formation, bool>)(mf => this._defenseFronts.All <TacticPerimeterDefense.DefenseFront>((Func <TacticPerimeterDefense.DefenseFront, bool>)(df => df.MeleeFormation != mf)))).ToList <Formation>(); List <Formation> list2 = this._rangedFormations.Where <Formation>((Func <Formation, bool>)(rf => this._defenseFronts.All <TacticPerimeterDefense.DefenseFront>((Func <TacticPerimeterDefense.DefenseFront, bool>)(df => df.RangedFormation != rf)))).ToList <Formation>(); foreach (TacticPerimeterDefense.EnemyCluster matchedEnemyCluster in enemyClusters) { if (list1.IsEmpty <Formation>()) { break; } Formation formation = list1.Last <Formation>(); TacticPerimeterDefense.DefenseFront defenseFront = new TacticPerimeterDefense.DefenseFront(matchedEnemyCluster, formation); formation.AI.ResetBehaviorWeights(); TacticComponent.SetDefaultBehaviorWeights(formation); BehaviorDefendKeyPosition defendKeyPosition = formation.AI.SetBehaviorWeight <BehaviorDefendKeyPosition>(1f); defendKeyPosition.DefensePosition = this._defendPosition; defendKeyPosition.EnemyClusterPosition = matchedEnemyCluster.MedianAggregatePosition; defendKeyPosition.EnemyClusterPosition.SetVec2(matchedEnemyCluster.AggregatePosition); list1.Remove(formation); if (!list2.IsEmpty <Formation>()) { Formation f = list2.Last <Formation>(); f.AI.ResetBehaviorWeights(); TacticComponent.SetDefaultBehaviorWeights(f); f.AI.SetBehaviorWeight <BehaviorSkirmishBehindFormation>(1f).ReferenceFormation = formation; defenseFront.RangedFormation = f; list2.Remove(f); this._defenseFronts.Add(defenseFront); } } }
void Start() { Application.runInBackground = true; ConfigFile = Application.dataPath + "/config.txt"; ConfigProperties.save(ConfigFile, "last.run", DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss")); setupLocation = (SetupLocation)Enum.Parse(enumType: typeof(SetupLocation), value: ConfigProperties.load(ConfigFile, "setup.type")); if (setupLocation == SetupLocation.LEFT) { _localPrefix = "left"; _remotePrefix = "right"; } else { _localPrefix = "right"; _remotePrefix = "left"; } formation = (Formation)Enum.Parse(enumType: typeof(Formation), value: ConfigProperties.load(ConfigFile, "start.formation")); localTrackerListenPort = int.Parse(ConfigProperties.load(ConfigFile, _localPrefix + ".tracker.listen.port")); remoteTrackerListenPort = int.Parse(ConfigProperties.load(ConfigFile, _remotePrefix + ".tracker.listen.port")); localTrackerAddress = ConfigProperties.load(ConfigFile, _localPrefix + ".setup.address"); int localTrackerBroadcastPort = int.Parse(ConfigProperties.load(ConfigFile, _localPrefix + ".tracker.broadcast.port")); localTrackerSurfaceRequestPort = int.Parse(ConfigProperties.load(ConfigFile, _localPrefix + ".tracker.surface.request.port")); localTrackerSurfaceListenerPort = int.Parse(ConfigProperties.load(ConfigFile, _localPrefix + ".tracker.surface.listener.port")); int localAvatarListenPort = int.Parse(ConfigProperties.load(ConfigFile, _localPrefix + ".client.avatar.listen.port")); remoteTrackerAddress = ConfigProperties.load(ConfigFile, _remotePrefix + ".setup.address"); int remoteTrackerBroadcastPort = int.Parse(ConfigProperties.load(ConfigFile, _remotePrefix + ".tracker.broadcast.port")); remoteTrackerSurfaceRequestPort = int.Parse(ConfigProperties.load(ConfigFile, _remotePrefix + ".tracker.surface.request.port")); remoteTrackerSurfaceListenerPort = int.Parse(ConfigProperties.load(ConfigFile, _remotePrefix + ".tracker.surface.listener.port")); int remoteAvatarListenPort = int.Parse(ConfigProperties.load(ConfigFile, _remotePrefix + ".client.avatar.listen.port")); GetComponent <CreepyTrackerSurfaceRequestListener>().StartReceive(localTrackerSurfaceListenerPort, remoteTrackerSurfaceListenerPort); GameObject eyes = GameObject.Find("Eyes"); eyes.transform.position = _getPositionFromConfig(ConfigProperties.load(ConfigFile, _localPrefix + ".eyes.localPosition")); eyes.transform.rotation = _getRotationFromConfig(ConfigProperties.load(ConfigFile, _localPrefix + ".eyes.localRotation")); //remoteWorkspaceOrigin.transform.position = _getPositionFromConfig(ConfigProperties.load(ConfigFile, _remotePrefix + ".workspaceCenter.transform.position")); //remoteWorkspaceOrigin.transform.rotation = _getRotationFromConfig(ConfigProperties.load(ConfigFile, _remotePrefix + ".workspaceCenter.transform.rotation")); if (calibrated) { leftWS_RigidBody.GetComponentInChildren <MeshRenderer>().enabled = false; rightWS_RigidBody.GetComponentInChildren <MeshRenderer>().enabled = false; leftARCameraRig_RigidBody.GetComponentInChildren <MeshRenderer>().enabled = false; rightARCameraRig_RigidBody.GetComponentInChildren <MeshRenderer>().enabled = false; } _sensors = new Dictionary <string, GameObject>(); _surfaceRequest(); }
public ActionResult Edit([Bind(Include = "Id,Nom,Url,Description,NomSeo")] Formation formation) { if (ModelState.IsValid) { db.Entry(formation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(formation)); }
protected override void LoadChildren() { base.LoadChildren(); foreach (string strFile in Directory.GetFiles(PersonnelPath, "*.Form")) { Formation formation = new Formation(strFile); base.Children.Add(new FormationViewModel(formation, this)); } }
public void SpawnSetup(Paths Path, int id, Formation newFormation) { pathToFollow = Path; enemyID = id; formation = newFormation; gameObject.SetActive(true); //GameManager.instance.activeEnemies.Add(this); // transform.SetParent(null); }
public BehaviorTacticalCharge(Formation formation) : base(formation) { this._lastTarget = (FormationQuerySystem)null; this.CurrentOrder = MovementOrder.MovementOrderCharge; this.CurrentFacingOrder = FacingOrder.FacingOrderLookAtEnemy; this._chargeState = BehaviorTacticalCharge.ChargeState.Undetermined; this.BehaviorCoherence = 0.5f; this._desiredChargeStopDistance = 20f; }
public OffensivePlay(OffensivePlayType type, Formation formation, RouteTypes[] routes) : base(formation) { if (type != OffensivePlayType.PASS) { return; } this.type = type; this.routes = routes; this.formation = formation; }
public ActionResult Delete(int id, FormCollection collection) { Formation p = MyFormationService.GetById(id); MyFormationService.Delete(p); MyFormationService.Commit(); // TODO: Add delete logic here return(RedirectToAction("Index")); }
public BehaviorAssaultWalls(Formation formation) : base(formation) { this.BehaviorCoherence = 0.0f; this.behaviorSide = formation.AI.Side; this._teamAISiegeComponent = (TeamAISiegeComponent)formation.Team.TeamAI; this._behaviourState = BehaviorAssaultWalls.BehaviorState.Deciding; this.ResetOrderPositions(); this.CurrentOrder = this._stopOrder; }
/// <summary> /// Supprimer une formation en base à partir du contexte et de son identifiant /// </summary> /// <param name="employeID">Identifiant d'une formation à supprimer</param> public void Supprimer(int formationID) { Formation delFor = _contexte.Formations.Where(frm => frm.Id == formationID).FirstOrDefault(); if (delFor != null) { _contexte.Formations.Remove(delFor); } _contexte.SaveChanges(); }
private static float GetPositionMultiplierOfFormation( Formation formation, IEnumerable <ICastleKeyPosition> referencePositions) { ICastleKeyPosition closestCastlePosition; float betweenPositions = ThreatSeeker.GetMinimumDistanceBetweenPositions(formation.GetMedianAgent(false, false, formation.GetAveragePositionOfUnits(false, false)).Position, referencePositions, out closestCastlePosition); bool flag = closestCastlePosition.AttackerSiegeWeapon != null && closestCastlePosition.AttackerSiegeWeapon.HasCompletedAction(); return(formation.IsRanged() ? (float)(((double)betweenPositions >= 20.0 ? ((double)betweenPositions >= 35.0 ? 0.600000023841858 : 0.800000011920929) : 1.0) + (flag ? 0.200000002980232 : 0.0)) : (float)(((double)betweenPositions >= 15.0 ? ((double)betweenPositions >= 40.0 ? 0.119999997317791 : 0.150000005960464) : 0.200000002980232) * (flag ? 7.5 : 1.0))); }
public override IEnumerable <Cell> GetAffectedArea(Cell targetedCell) { Formation formation = targetedCell.Formation; int file = formation.GetFile(targetedCell.Coordinate); foreach (Cell cell in formation.GetFileCells(file)) { yield return(cell); } }
public void Delete(int formationId) { Formation del = _context.Formations.FirstOrDefault(form => form.Id == formationId); if (del != null) { _context.Formations.Remove(del); } _context.SaveChanges(); }
public CharacterDetail(Character chara, IEnumerable <CharacterSkill> skills, Formation formation, bool isStopCommand) { this.Skills = skills; this.Id = chara.Id; this.Message = chara.Message; this.Money = chara.Money; this.Rice = chara.Rice; this.Formation = formation; this.IsStopCommand = isStopCommand; }
public void RemoveFromCluster(Formation formation) { this.enemyFormations.Remove(formation); float totalPower = this.totalPower; this.totalPower -= formation.QuerySystem.FormationPower; this.AggregatePosition -= formation.QuerySystem.AveragePosition * (formation.QuerySystem.FormationPower / totalPower); this.AggregatePosition *= totalPower / this.totalPower; this.UpdateMedianPosition(); }
/// <summary> /// Returns the position that a CombatEntity exists in a Formation as an integer. /// </summary> /// <param name="entity">The CombatEntity to find.</param> /// <param name="formation">The Formation to look through.</param> /// <returns></returns> private int GetTargetPosition(CombatEntity entity, Formation formation) { var coords = formation.Positions.FindIndexTwoD(entity); if (coords == null) { return(-1); } return(coords[0] + 1 + coords[1] * 3); }
public ActionResult Details(int id) { Formation f = Dal.forma.Find(id); if (f == null) { RedirectToAction("Index"); //return index } return(View(f)); //affiche dans la vue détail }
public virtual void updateDirection(float dt, Formation frm, IEnumerable <Animal> others) { if (!Game1.bInEmbrace) { Vector2 newDir = Vector2.Zero; Animal target = null; float tdist = float.MaxValue; foreach (Animal you in others) { reactTo(you, ref target, ref tdist, ref newDir); } updateColor(target, tdist); if (newDir.Length() < 0.01f) { return; } newDir.Normalize(); float rotLimit = AnimalSpec.RotationLimitation * dt; Direction = restrictRotationSpeed(Direction, newDir, rotLimit); //update Z position ZPosition += ZDirection;//*0.2f; if (ZPosition >= Game1.thickness || ZPosition <= 0.0f) { ZDirection = -ZDirection; } } else //in embrace gesture { Vector2 newDir = Vector2.Zero; Animal target = null; float tdist = float.MaxValue; foreach (Animal you in others) { reactTo(you, ref target, ref tdist, ref newDir); } updateColor(target, tdist); if (newDir.Length() < 0.01f) { return; } newDir.Normalize(); float rotLimit = AnimalSpec.RotationLimitation * dt; Direction = restrictRotationSpeed(Direction, newDir, rotLimit); Vector2 offset = new Vector2((float)randZ.NextDouble(), (float)randZ.NextDouble()); newDir = Game1.screenCenter - this.Position; newDir.Normalize(); Direction = Direction + newDir + offset; } }
public MatrixFrame GetSpawnPointFrameForPlayer( VirtualPlayer player, BattleSideEnum side, int agentVisualIndex, int totalTroopCount, bool isMounted = false) { if (agentVisualIndex == 0) { int num1 = -1; int num2 = -1; for (int index = 0; index < this._visualSpawnPointUsers.Length; ++index) { if (this._visualSpawnPointUsers[index] == player) { num1 = index; break; } if (num2 < 0 && this._visualSpawnPointUsers[index] == null) { num2 = index; } } int index1 = num1 >= 0 ? num1 : num2; if (index1 < 0) { return(MatrixFrame.Identity); } this._visualSpawnPointUsers[index1] = player; GameEntity gameEntity = (GameEntity)null; switch (side) { case BattleSideEnum.Defender: gameEntity = this._visualDefenderSpawnPoints[index1]; break; case BattleSideEnum.Attacker: gameEntity = this._visualAttackerSpawnPoints[index1]; break; } MatrixFrame matrixFrame = gameEntity != null?gameEntity.GetGlobalFrame() : this._visualSpawnPoints[index1].GetGlobalFrame(); matrixFrame.rotation.OrthonormalizeAccordingToForwardAndKeepUpAsZAxis(); return(matrixFrame); } Vec3 origin1 = this._visualSpawnPoints[3].GetGlobalFrame().origin; Vec3 origin2 = this._visualSpawnPoints[1].GetGlobalFrame().origin; Vec3 origin3 = this._visualSpawnPoints[5].GetGlobalFrame().origin; Mat3 rotation = this._visualSpawnPoints[0].GetGlobalFrame().rotation; rotation.MakeUnit(); List <WorldFrame> formationCreation = Formation.GetFormationFramesForBeforeFormationCreation(origin2.Distance(origin3), totalTroopCount, isMounted, new WorldPosition(Mission.Current.Scene, origin1), rotation); return(formationCreation.Count < agentVisualIndex ? new MatrixFrame(rotation, origin1) : formationCreation[agentVisualIndex - 1].ToGroundMatrixFrame()); }
void SelectTarget(Vector3 point) { isSelectionActive = true; if (units.Count > 1) { Formation formation = units[0].formation; bool isSame = false; if (formation != null) { isSame = true; foreach (Unit unit in units) { if (formation != unit.formation) { isSame = false; break; } } } if (isSame && formation.GetUnitCount() == units.Count) { formation.SetTargetPoint(point); formation.SetTowerTarget(currentTowerTarget); } else { foreach (Unit unit in units) { unit.GetComponent <FollowNavAgent> ().agent.obstacleAvoidanceType = ObstacleAvoidanceType.HighQualityObstacleAvoidance; if (unit.formation) { unit.formation.RemoveUnit(unit); } } CreateFormation(point); units[0].formation.SetTargetPoint(point); units[0].formation.SetTowerTarget(currentTowerTarget); } } else if (units.Count == 1) { Unit unit = units[0]; if (unit.formation /* && unit.formation.leader != unit*/) { unit.formation.RemoveUnit(unit); } unit.GetComponent <FollowNavAgent> ().SetDestination(point); unit.GetComponent <Soldier> ().SetTowerTarget(currentTowerTarget); } }
public override void OnStart() { Formation formation = FormationManager.GetAvailableFormation(); if(formation == null) { formation = FormationManager.CreateFormation(); formation.SetLeader(pilot); } else { formation.AddMember(pilot); } }
public override void Execute() { //If there is no formation for the enemy child cell to take, query the postionQuery to get which formation to get for the specific situation if(m_CurrentFormation == Formation.Empty) { m_AttackType = PositionQuery.Instance.GetMostSignificantAttack(); m_CurrentFormation = PositionQuery.Instance.GetDefensiveFormation(); FormationDatabase.Instance.RefreshDatabases(m_Main.GetComponent<EnemyMainFSM>().ECList); FormationDatabase.Instance.UpdateDatabaseFormation(m_CurrentFormation,m_fMainScale); if(m_CurrentFormation != Formation.QuickCircle){FormationDatabase.Instance.CheckOtherOverlapADRange();} } if(m_CurrentFormation == Formation.QuickCircle){m_TargetPos = FormationDatabase.Instance.CheckCircleOverlapADRange(FormationDatabase.Instance.GetTargetFormationPosition(m_CurrentFormation, m_Child));} if(m_CurrentFormation != Formation.QuickCircle){m_TargetPos = FormationDatabase.Instance.GetTargetFormationPosition(m_CurrentFormation, m_Child);} }
//Constructor public ECDefendState(GameObject _childCell, EnemyChildFSM _ecFSM) { m_Child = _childCell; m_ecFSM = _ecFSM; m_Main = _ecFSM.m_EMain; m_ECTransform = m_Child.transform; m_EMTransform = m_Main.transform; m_fMaxFormingAcceleration = 150f; m_fMaxChaseAcceleration = 500f; m_fAutoDefendRange = 7f; m_fDefendTime = 0f; m_bReturnToMain = false; m_bReachedMain = false; m_CurrentFormation = Formation.Empty; }
public void ShowFormation( Formation formation) { switch(formation){ case Formation.F323: ShowFormation(this.Formation323); break; case Formation.F332: ShowFormation(this.Formation332); break; case Formation.F422: ShowFormation(this.Formation422); break; case Formation.F431: ShowFormation(this.Formation431); break; } }
public Formation Create(string formationString) { Formation retValue = new Formation(); string[] elements = formationString.Split('='); string[] trajectoriesString = elements[0].Split('|'); string[] trajectoryString = null; int i = trajectoriesString.Length - 1; retValue.formation = new Trajectory[trajectoriesString.Length]; retValue.timer = System.Convert.ToSingle(elements[1]); for (; i >= 0; --i) { trajectoryString = trajectoriesString[i].Split('#'); retValue.formation[i] = (Trajectory) Activator.CreateInstance(Type.GetType(trajectoryString[0])); retValue.formation[i].Set(trajectoryString[1]); } return retValue; }
public void InitPlayerFormation() { _formation = new Formation(); _formation.InitPlayerFormation(); foreach (KeyValuePair<GeneralInfo, PositionPair> pair in _formation.FormationMap) { Label lb_General = new Label(); lb_General.Text = pair.Key.GeneralConfig.Name; int r = pair.Value.RowIndex; int c = pair.Value.ColumnIndex; lb_General.TextAlign = ContentAlignment.MiddleCenter; tableLayoutPanel1.Controls.Add(lb_General, c,r); //Console.WriteLine("添加了Formation table{0}{1}, 武将{2}", r,c,lb_General.Text); } LB_TeamName.Text = _formation.TeamName; LB_BattlePower.Text = _formation.TeamBattlePowerPoint.ToString(); }
public void InitLevelEnemy(int levelID,bool isElite) { IsEliteLevel = isElite; string name = DBConfigMgr.Instance.MapLevel[levelID].Name; if (isElite) name += "精英"; this.Text = name; EnemyFormation = new Formation(); EnemyFormation.InitNPCFormation(levelID,isElite); LevelID = levelID; EnemyList = EnemyFormation.NPCFormation; EnemyList.OrderBy(x => x.Key); RefreashEnemyData(); ReComputeBattlePoint(); GetReferBattlePoint(); CanReComputeBattlePoint = true; }
/// <summary> /// Repositions all the Unit elements in the formation designated by the Cmd. /// Called when 1) a fleet is first formed, 2) the desired formation has changed, 3) the HQ Element has changed, /// or 4) when another large fleet joins this one. /// <remarks>Repositioning is accomplished by calling Cmd.PositionElementInFormation().</remarks> /// </summary> /// <param name="allElements">All elements.</param> public void RepositionAllElementsInFormation(IList<IUnitElement> allElements) { Formation formation = _unitCmd.UnitFormation; if (formation != _currentFormation) { _occupiedStationSlotLookup.Clear(); float formationRadius; _availableStationSlots = GenerateFormationSlotInfo(formation, _unitCmd.transform, out formationRadius); //D.Log(ShowDebugLog, "{0} generated {1} {2}s for Formation {3} => {4}.", DebugName, _availableStationSlots.Count, typeof(FormationStationSlotInfo).Name, formation.GetValueName(), _availableStationSlots.Concatenate()); _unitCmd.UnitMaxFormationRadius = formationRadius; _currentFormation = formation; } else { ReturnAllOccupiedStationSlotsToAvailable(); } int hqCount = Constants.Zero; allElements.ForAll(e => { if (e.IsHQ) { hqCount++; } AddAndPositionElement(e); }); D.AssertEqual(Constants.One, hqCount); }
private void updateInput() { // select newly made alternate paths of selected units foreach (Path path in g.alternatePaths) { if (path.player == selPlayer) { foreach (Unit unit in path.segments[0].units) { selPaths.Add (new UnitSelection(path, unit, path.segments[0].timeStart)); } } } g.alternatePaths.Clear (); // update current unit selection curSelPaths.Clear (); foreach (SegmentUnit segmentUnit in g.segmentUnitsWhen (selSegmentUnits (), g.timeGame)) { if (!curSelPaths.ContainsKey (segmentUnit.segment.path)) curSelPaths[segmentUnit.segment.path] = new List<Unit>(); if (!curSelPaths[segmentUnit.segment.path].Contains (segmentUnit.unit)) curSelPaths[segmentUnit.segment.path].Add (segmentUnit.unit); } // handle changed mouse buttons if (Input.GetMouseButtonDown (0)) { // left button down mouseDownPos[0] = Input.mousePosition; } if (Input.GetMouseButtonDown (1)) { // right button down mouseDownPos[1] = Input.mousePosition; } if (Input.GetMouseButtonDown (2)) { // middle button down mouseDownPos[2] = Input.mousePosition; } if (Input.GetMouseButtonUp (0)) { // left button up mouseUpPos[0] = Input.mousePosition; if (mouseDownPos[0].y > uiBarTop) { if (makeUnitType != null) { // make unit FP.Vector pos = makeUnitPos(); if (pos.x != Sim.offMap) g.cmdPending.addEvt(new MakeUnitCmdEvt(g.timeSim, newCmdTime(), UnitCmdEvt.argFromPathDict (curSelPaths), makeUnitType.id, pos, enableAutoTimeTravel)); makeUnitType = null; } else { // select paths Vector3 mouseMinPos = new Vector3(Math.Min (mouseDownPos[0].x, Input.mousePosition.x), Math.Min (mouseDownPos[0].y, Input.mousePosition.y), 0); Vector3 mouseMaxPos = new Vector3(Math.Max (mouseDownPos[0].x, Input.mousePosition.x), Math.Max (mouseDownPos[0].y, Input.mousePosition.y), 0); bool deselect = false; if (!Input.GetKey (KeyCode.LeftControl) && !Input.GetKey (KeyCode.LeftShift)) { selPaths.Clear(); curSelPaths.Clear(); selFormation = Formation.Tight; } foreach (Path path in g.paths) { if (selPlayer == path.player && g.timeGame >= path.moves[0].timeStart && FP.rectIntersects (drawToSimPos (mouseMinPos), drawToSimPos (mouseMaxPos), path.selMinPos(g.timeGame), path.selMaxPos(g.timeGame))) { if (curSelPaths.ContainsKey (path) && curSelPaths[path].Count == path.segmentWhen (g.timeGame).units.Count) { curSelPaths.Remove(path); deselect = true; } else { curSelPaths[path] = new List<Unit>(path.segmentWhen(g.timeGame).units); foreach (Unit unit in curSelPaths[path]) { selPaths.Add (new UnitSelection(path, unit, g.timeGame)); } } if (selBoxMin > (Input.mousePosition - mouseDownPos[0]).sqrMagnitude) break; } } if (deselect) { selPaths.Clear (); foreach (KeyValuePair<Path, List<Unit>> path in curSelPaths) { foreach (Unit unit in path.Value) { selPaths.Add (new UnitSelection(path.Key, unit, g.timeGame)); } } } } } } if (Input.GetMouseButtonUp (1)) { // right button up mouseUpPos[1] = Input.mousePosition; if (mouseDownPos[1].y > uiBarTop) { if (makeUnitType != null) { // cancel making unit makeUnitType = null; } else { int attackPath = -1, stackPath = -1; for (int i = 0; i < g.paths.Count; i++) { if (g.timeGame >= g.paths[i].segments[0].timeStart && FP.rectContains (g.paths[i].selMinPos(g.timeGame), g.paths[i].selMaxPos(g.timeGame), drawToSimPos (Input.mousePosition))) { if (g.timeGame >= g.timeSim && g.paths[i].tileWhen (g.timeGame).playerDirectVisWhen (selPlayer, g.timeGame) && selPlayer.canAttack[g.paths[i].player.id] && g.paths[i].segmentWhen (g.timeGame).units.Where (u2 => curSelPaths.Values.Where (units => units.Where (u => u.type.damage[u2.type.id] > 0).Any ()).Any ()).Any ()) { attackPath = i; break; } if (selPlayer == g.paths[i].player && curSelPaths.Keys.Where (p => p.id != i && p.speed > 0 && p.speed == g.paths[i].speed).Any ()) { stackPath = i; break; } } } if (attackPath >= 0) { // attack clicked path g.cmdPending.addEvt (new AttackCmdEvt(g.timeSim, newCmdTime (), UnitCmdEvt.argFromPathDict (curSelPaths), attackPath)); } else if (enableStacking && stackPath >= 0) { // stack selected paths onto clicked path g.cmdPending.addEvt (new StackCmdEvt(g.timeSim, newCmdTime (), UnitCmdEvt.argFromPathDict (curSelPaths), stackPath, enableAutoTimeTravel)); } else { // move selected paths g.cmdPending.addEvt(new MoveCmdEvt(g.timeSim, newCmdTime(), UnitCmdEvt.argFromPathDict (curSelPaths), drawToSimPos (Input.mousePosition), selFormation, enableAutoTimeTravel)); } } } } if (Input.GetMouseButtonUp (2)) { // middle button up mouseUpPos[2] = Input.mousePosition; } // handle changed keys if (Input.GetKeyDown (KeyCode.Escape)) { // exit Application.Quit (); } if (Input.GetKeyDown (KeyCode.P)) { // pause/resume paused = !paused; } if (Input.GetKeyDown (KeyCode.Equals)) { // increase speed speed++; timeSpeedChg = Environment.TickCount; } if (Input.GetKeyDown (KeyCode.Minus)) { // decrease speed speed--; timeSpeedChg = Environment.TickCount; } if (Input.GetKeyDown (KeyCode.Q)) { // tight formation setFormation (Formation.Tight); } if (Input.GetKeyDown (KeyCode.W)) { // loose formation setFormation (Formation.Loose); } if (Input.GetKeyDown (KeyCode.E)) { // ring formation setFormation (Formation.Ring); } if (Input.GetKeyDown (KeyCode.U)) { // unstack unstack (); } if (Input.GetKeyDown (KeyCode.N)) { // create new paths that selected units could take makePaths (); } if (Input.GetKeyDown (KeyCode.Delete)) { if (Input.GetKey (KeyCode.LeftShift) || Input.GetKey (KeyCode.RightShift)) { // delete unselected paths of selected units deleteOtherPaths (); } else { // delete selected paths deletePaths (); } } if (Input.GetKeyDown(KeyCode.D) && Input.GetKey(KeyCode.LeftShift)) { // delete unselected paths of selected units (alternate shortcut) deleteOtherPaths(); } if (enableStacking && Input.GetKeyDown (KeyCode.S) && !Input.GetKey (KeyCode.LeftShift)) { // share selected paths sharePaths (); } /*for (KeyCode keyCode = KeyCode.Alpha1; keyCode <= KeyCode.Alpha9; keyCode++) { // set # units that other players may see on selected paths if (Input.GetKeyDown (keyCode)) { foreach (Path path in selPaths.Keys) { path.nSeeUnits = keyCode - KeyCode.Alpha1 + 1; // this doesn't sync across multiplayer } } }*/ if (Input.GetKeyDown (KeyCode.F2)) { // change selected player do { selPlayer = g.players[(selPlayer.id + 1) % g.players.Length]; } while (selPlayer.user != g.selUser); selPaths.Clear(); makeUnitType = null; } if (Input.GetKeyDown (KeyCode.F3)) { // toggle map hack g.cmdPending.addEvt (new MapHackCmdEvt(g.timeSim, selPlayer.id, !selPlayer.mapHack)); } if (Input.GetKeyDown (KeyCode.R) && Input.GetKey (KeyCode.LeftShift)) { // instant replay instantReplay (); } if (Input.GetKeyDown (KeyCode.O) && Input.GetKey (KeyCode.LeftShift)) { // open binary game file using (FileStream file = File.OpenRead (appPath + modPath + "savegame.sav")) { g = Serializer.Deserialize<Sim>(file); } loadUI (); GC.Collect (); } if (Input.GetKeyDown (KeyCode.S) && Input.GetKey (KeyCode.LeftShift)) { // save binary game file using (FileStream file = File.Create (appPath + modPath + "savegame.sav")) { Serializer.Serialize(file, g); } } // move camera if (Input.GetKey (KeyCode.LeftArrow) || (Input.mousePosition.x == 0 && Screen.fullScreen)) { g.camPos.x -= g.camSpeed * timeDelta; if (g.camPos.x < 0) g.camPos.x = 0; } if (Input.GetKey (KeyCode.RightArrow) || (Input.mousePosition.x == Screen.width - 1 && Screen.fullScreen)) { g.camPos.x += g.camSpeed * timeDelta; if (g.camPos.x > g.mapSize) g.camPos.x = g.mapSize; } if (Input.GetKey (KeyCode.DownArrow) || (Input.mousePosition.y == 0 && Screen.fullScreen)) { g.camPos.y -= g.camSpeed * timeDelta; if (g.camPos.y < 0) g.camPos.y = 0; } if (Input.GetKey (KeyCode.UpArrow) || (Input.mousePosition.y == Screen.height - 1 && Screen.fullScreen)) { g.camPos.y += g.camSpeed * timeDelta; if (g.camPos.y > g.mapSize) g.camPos.y = g.mapSize; } // zoom camera if (Input.GetKey (KeyCode.PageUp)) { g.zoom /= (float)Math.Exp (g.zoomSpeed * timeDelta); } if (Input.GetKey (KeyCode.PageDown)) { g.zoom *= (float)Math.Exp (g.zoomSpeed * timeDelta); } if (Input.mousePosition.y > uiBarTop && Input.GetAxis ("Mouse ScrollWheel") != 0) { g.zoom *= (float)Math.Exp (g.zoomMouseWheelSpeed * Input.GetAxis ("Mouse ScrollWheel")); } if (g.zoom < g.zoomMin) g.zoom = g.zoomMin; if (g.zoom > g.zoomMax) g.zoom = g.zoomMax; }
/// <summary> /// Récupère une liste de Formation à partir de la base de données /// </summary> /// <returns>Une liste de client</returns> public static List<Formation> List() { //Récupération de la chaine de connexion //Connection ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["EntretienSPPPConnectionString"]; SqlConnection connection = new SqlConnection(connectionStringSettings.ToString()); //Commande String requete = "SELECT Identifiant, IdentifiantOrganisme, Titre, Objectif, Interne, Externe FROM Formation ;"; connection.Open(); SqlCommand commande = new SqlCommand(requete, connection); //execution SqlDataReader dataReader = commande.ExecuteReader(); List<Formation> list = new List<Formation>(); while (dataReader.Read()) { //1 - Créer un Formation à partir des donner de la ligne du dataReader Formation formation = new Formation(); formation.Identifiant = dataReader.GetInt32(0); formation.organisme.Identifiant = dataReader.GetInt32(1); formation.Titre = dataReader.GetString(2); formation.Objectif = dataReader.GetString(3); formation.Interne = dataReader.GetChar(4); formation.Externe = dataReader.GetChar(5); //2 - Ajouter ce Formation à la list de client list.Add(formation); } dataReader.Close(); connection.Close(); return list; }
public void removeFormation(Formation f) { formations.Remove(f); }
public void add(Formation f) { formations.Add(f); }
/// <summary> /// Initializes a new instance of the <see cref="SettlementCmdStat"/> class. /// </summary> /// <param name="unitName">Name of the unit.</param> /// <param name="maxHitPts">The maximum hit PTS.</param> /// <param name="maxCmdEffect">The maximum command effectiveness.</param> /// <param name="formation">The formation.</param> /// <param name="population">The population.</param> public SettlementCmdStat(string unitName, float maxHitPts, float maxCmdEffect, Formation formation, int population) : base(unitName, maxHitPts, maxCmdEffect, formation) { Population = population; }
public static Boolean update(Formation formation) { Boolean isUpDAte = false ; //mettre a jour la base de donnée // retourne un boulean si l'update ses bien dérouler //Connection ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["EntretienSPPPConnectionString"]; SqlConnection connection = new SqlConnection(connectionStringSettings.ToString()); String requete = @"Update Formation set organisme = @organisme,Titre = @Titre, Objectif = @Objectif, interne = @interne, externe = @externe where identifiant = @identifiant ;"; SqlCommand commande = new SqlCommand(requete, connection); commande.Parameters.AddWithValue("organisme", formation.organisme); commande.Parameters.AddWithValue("Titre", formation.Titre); commande.Parameters.AddWithValue("Objectif", formation.Objectif); commande.Parameters.AddWithValue("interne", formation.Interne); commande.Parameters.AddWithValue("externe", formation.Externe); commande.Parameters.AddWithValue("Identifiant", formation.Identifiant); try { connection.Open(); commande.ExecuteNonQuery(); isUpDAte = true; } catch (Exception) { isUpDAte = false; } finally { connection.Close(); } return isUpDAte; }
public virtual void updatePosition(float dt, Formation frm) { if (this.AnimalType == AnimalType.Fish) { if (!Game1.bInEmbrace) { Vector2 newPos = Position + this.RadialVelocity * Direction * dt; frm.normalize(ref newPos, out newPos); frm.move(this, newPos); if (this.RadialVelocity > FishSpec.RadialVelocityOriginal) { this.RadialVelocity *= 0.999f; } } else //in embrace, gather quickly { Vector2 newPos = Position + AnimalSpec.RadialVelocity * Direction * dt * 20.0f; frm.normalize(ref newPos, out newPos); frm.move(this, newPos); } } else if (this.AnimalType == AnimalType.Whale && this.iLeftRightHand == -1) //left hand { if (Kinect.bLeftDataValid) { this.bActive = true; Vector2 leftHandPos = Kinect.leftHandWhale; leftHandPos.X += 70; leftHandPos.Y += 40; if (leftHandPos.X < 0) leftHandPos.X = 0; else if (leftHandPos.X > 100) leftHandPos.X = 100; if (leftHandPos.Y < 0) leftHandPos.Y = 0; else if (leftHandPos.Y > 100) leftHandPos.Y = 100; Vector2 newPos = new Vector2(leftHandPos.X / 100.0f * Game1.width, leftHandPos.Y / 100.0f * Game1.height); frm.normalize(ref newPos, out newPos); frm.move(this, newPos); } else { this.bActive = false; } } else if (this.AnimalType == AnimalType.Whale && this.iLeftRightHand == 1) //right hand { if (Kinect.bRightDataValid) { this.bActive = true; Vector2 rightHandPos = Kinect.rightHandWhale; rightHandPos.X += 30; rightHandPos.Y += 40; if (rightHandPos.X < 0) rightHandPos.X = 0; else if (rightHandPos.X > 100) rightHandPos.X = 100; if (rightHandPos.Y < 0) rightHandPos.Y = 0; else if (rightHandPos.Y > 100) rightHandPos.Y = 100; Vector2 newPos = new Vector2(rightHandPos.X / 100.0f * Game1.width, rightHandPos.Y / 100.0f * Game1.height); frm.normalize(ref newPos, out newPos); frm.move(this, newPos); } else { this.bActive = false; } } }
public virtual void updateDirection(float dt, Formation frm, IEnumerable<Animal> others) { if (!Game1.bInEmbrace) { Vector2 newDir = Vector2.Zero; Animal target = null; float tdist = float.MaxValue; foreach (Animal you in others) { reactTo(you, ref target, ref tdist, ref newDir); } updateColor(target, tdist); if (newDir.Length() < 0.01f) return; newDir.Normalize(); float rotLimit = AnimalSpec.RotationLimitation * dt; Direction = restrictRotationSpeed(Direction, newDir, rotLimit); //update Z position ZPosition += ZDirection;//*0.2f; if (ZPosition >= Game1.thickness || ZPosition <= 0.0f) ZDirection = -ZDirection; } else //in embrace gesture { Vector2 newDir = Vector2.Zero; Animal target = null; float tdist = float.MaxValue; foreach (Animal you in others) { reactTo(you, ref target, ref tdist, ref newDir); } updateColor(target, tdist); if (newDir.Length() < 0.01f) return; newDir.Normalize(); float rotLimit = AnimalSpec.RotationLimitation * dt; Direction = restrictRotationSpeed(Direction, newDir, rotLimit); Vector2 offset = new Vector2((float)randZ.NextDouble(), (float)randZ.NextDouble()); newDir = Game1.screenCenter - this.Position; newDir.Normalize(); Direction = Direction + newDir + offset; } }
public void update(float dt, Formation frm) { IEnumerable<Animal> others = frm.findNeighbors(this); updateDirection(dt, frm, others); updatePosition(dt, frm); }
/// <summary> /// Récupère une Formation à partir d'un identifiant de client /// </summary> /// <param name="Identifiant">Identifant de Formation</param> /// <returns>Un Formation </returns> public static Formation Get(Int32 identifiant) { //Connection ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["EntretienSPPPConnectionString"]; SqlConnection connection = new SqlConnection(connectionStringSettings.ToString()); //Commande String requete = @"SELECT Identifiant, IdentifiantOrganisme, Titre, Objectif, Interne, Externe FROM Formation WHERE Identifiant = @Identifiant ;"; SqlCommand commande = new SqlCommand(requete, connection); //Paramètres commande.Parameters.AddWithValue("Identifiant", identifiant); //Execution connection.Open(); SqlDataReader dataReader = commande.ExecuteReader(); dataReader.Read(); //1 - Création du Formation Formation formation = new Formation(); formation.Identifiant = dataReader.GetInt32(0); dataReader.Close(); connection.Close(); return formation; }
/// <summary> /// Initializes a new instance of the <see cref="UnitCmdStat" /> class. /// </summary> /// <param name="unitName">The Unit's name.</param> /// <param name="maxHitPts">The maximum hit PTS.</param> /// <param name="maxCmdEffect">The maximum command effectiveness.</param> /// <param name="formation">The formation.</param> public UnitCmdStat(string unitName, float maxHitPts, float maxCmdEffect, Formation formation) { UnitName = unitName; MaxHitPoints = maxHitPts; MaxCmdEffectiveness = maxCmdEffect; UnitFormation = formation; }
private void loadUI() { // users int nUsers = 0; foreach (Player player in g.players) { if (player.user >= nUsers) nUsers = player.user + 1; } g.users = new User[nUsers]; for (int i = 0; i < g.users.Length; i++) { g.users[i] = new User(); } // unit types texUnits = new Texture[g.unitT.Length, g.players.Length]; for (int i = 0; i < g.unitT.Length; i++) { for (int j = 0; j < g.players.Length; j++) { if (!(texUnits[i, j] = loadTexture (appPath + modPath + g.players[j].name + '.' + g.unitT[i].imgPath))) { if (!(texUnits[i, j] = loadTexture (appPath + modPath + g.unitT[i].imgPath))) { Debug.LogWarning ("Failed to load " + modPath + g.players[j].name + '.' + g.unitT[i].imgPath); } } } } // tiles texTile = new Texture2D(g.tileLen (), g.tileLen (), TextureFormat.ARGB32, false); // units if (sprUnits != null) { foreach (List<UnitSprite> sprs in sprUnits) { foreach (UnitSprite spr in sprs) { spr.dispose (); } } } sprUnits = new List<List<UnitSprite>>(); // miscellaneous Camera.main.backgroundColor = g.backCol; border.line.material.color = g.borderCol; uiBarTop = Screen.height * g.uiBarHeight; selPlayer = g.players[0]; while (selPlayer.user != g.selUser) selPlayer = g.players[(selPlayer.id + 1) % g.players.Length]; selPaths = new List<UnitSelection>(); curSelPaths = new Dictionary<Path, List<Unit>>(); selFormation = Formation.Tight; makeUnitType = null; replay = false; showDeletedUnits = false; paused = false; speed = 0; }
// methods below involve commanding selected units private void setFormation(Formation formation) { selFormation = formation; if (curSelPaths.Count > 0) { long minX = g.mapSize, maxX = 0, minY = g.mapSize, maxY = 0; foreach (KeyValuePair<Path, List<Unit>> path in curSelPaths) { if (path.Key.canMove (g.timeGame)) { FP.Vector pos = path.Key.posWhen(g.timeGame); if (pos.x < minX) minX = pos.x; if (pos.x > maxX) maxX = pos.x; if (pos.y < minY) minY = pos.y; if (pos.y > maxY) maxY = pos.y; } } g.cmdPending.addEvt(new MoveCmdEvt(g.timeSim, newCmdTime(), UnitCmdEvt.argFromPathDict (curSelPaths), new FP.Vector((minX + maxX) / 2, (minY + maxY) / 2), selFormation, enableAutoTimeTravel)); } }
private void selectLevel() { // 显示关卡的怪物 panel1.Controls.Clear(); panel2.Controls.Clear(); npcFormationControl = new UCFormation(); npcFormationControl.InitNPCFormation(currentSelectedLevelID, false); panel1.Controls.Add(npcFormationControl); teamOneFormation = npcFormationControl.CurrentFormation; npcFormationControl2 = new UCFormation(); npcFormationControl2.InitNPCFormation(currentSelectedLevelID, true); panel2.Controls.Add(npcFormationControl2); teamTwoFormation = npcFormationControl2.CurrentFormation; groupBox1.Visible = true; int reflv1 = DBConfigMgr.Instance.MapLevel[currentSelectedLevelID].RefLevel ; int reflv2 = DBConfigMgr.Instance.MapLevel[currentSelectedLevelID].EliteRefLevel; TB_LevelName.Text = DBConfigMgr.Instance.MapLevel[currentSelectedLevelID].Name; TB_RefLevel.Text = reflv1.ToString(); TB_RefEliteLevel.Text = reflv2.ToString(); TB_Enemy.Text = DBConfigMgr.Instance.MapLevel[currentSelectedLevelID].Enemy; TB_EliteEnemy.Text = DBConfigMgr.Instance.MapLevel[currentSelectedLevelID].EliteEnemy; TB_EnemyAngel.Text = DBConfigMgr.Instance.MapLevel[currentSelectedLevelID].EnemyAngel; TB_EliteEnemyAngel.Text = DBConfigMgr.Instance.MapLevel[currentSelectedLevelID].EliteEnemyAngel; LB_RefSquads1.Text = Formula.GetOnBattleSquads(reflv1).ToString(); LB_RefSquads2.Text = Formula.GetOnBattleSquads(reflv2).ToString(); // 强敌 CB_StrongEnemy.Checked = DBConfigMgr.Instance.MapLevel[currentSelectedLevelID].StrongEnemy == 1; }
protected override IList<FormationStationSlotInfo> GenerateFormationSlotInfo(Formation formation, Transform cmdTransform, out float formationRadius) { return References.FormationGenerator.GenerateFleetFormation(formation, cmdTransform, out formationRadius); }
private void AddLevelRow(int index) { Level levelConfig = DBConfigMgr.Instance.MapLevel[index]; LevelRecord record = PlayerDataMgr.Instance.GetPlayerLevelRecords()[index]; // 先计算好战斗力BattlePoint int normalRefPower = Formula.GetRefBattlePoint(levelConfig.RefLevel); int eliteRefPower = Formula.GetRefBattlePoint(levelConfig.EliteRefLevel); // 参考人数和实际人数 int normalRefSquads = Formula.GetOnBattleSquads(levelConfig.RefLevel); int eliteRefSquads = Formula.GetOnBattleSquads(levelConfig.EliteRefLevel); Formation normalFormation = new Formation(); normalFormation.InitNPCFormation(levelConfig.ID, false); int normalRealPower = normalFormation.TeamBattlePowerPoint; Formation eliteFormation = new Formation(); eliteFormation.InitNPCFormation(levelConfig.ID, true); int eliteRealPower = eliteFormation.TeamBattlePowerPoint; int normalRealSquads = normalFormation.NPCFormation.Count(); int eliteRealSquads = eliteFormation.NPCFormation.Count(); DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell textBoxID = new DataGridViewTextBoxCell(); textBoxID.Value = levelConfig.ID; row.Cells.Add(textBoxID); DataGridViewTextBoxCell textBoxName = new DataGridViewTextBoxCell(); textBoxName.Value = levelConfig.Name; row.Cells.Add(textBoxName); DataGridViewTextBoxCell textBoxNormalBattleCompare = new DataGridViewTextBoxCell(); textBoxNormalBattleCompare.Value = String.Format("{0}/{1}",normalRealPower,normalRefPower); row.Cells.Add(textBoxNormalBattleCompare); DataGridViewTextBoxCell textBoxNormalSquadsCompare = new DataGridViewTextBoxCell(); textBoxNormalSquadsCompare.Value = String.Format("{0}/{1}", normalRealSquads, normalRefSquads); if (normalRefSquads != normalRealSquads) textBoxNormalSquadsCompare.Style.BackColor = Color.Red; row.Cells.Add(textBoxNormalSquadsCompare); DataGridViewTextBoxCell textBoxEliteBattleCompare = new DataGridViewTextBoxCell(); textBoxEliteBattleCompare.Value = String.Format("{0}/{1}", eliteRealPower, eliteRefPower); row.Cells.Add(textBoxEliteBattleCompare); DataGridViewTextBoxCell textBoxEliteSquadsCompare = new DataGridViewTextBoxCell(); textBoxEliteSquadsCompare.Value = String.Format("{0}/{1}", eliteRealSquads, eliteRefSquads); if( eliteRealSquads != eliteRefSquads) textBoxEliteSquadsCompare.Style.BackColor = Color.Red; row.Cells.Add(textBoxEliteSquadsCompare); DataGridViewTextBoxCell textBoxHasPlot = new DataGridViewTextBoxCell(); string hasPlotBefore = "无"; string hasPlotIn ="无"; string hasPlotAfter ="无"; if (DBConfigMgr.Instance.MapPlot.ContainsKey(index)) { Plot p = DBConfigMgr.Instance.MapPlot[index]; if (p.BeforeBattle.Length > 0) hasPlotBefore = "有"; if (p.InBattle.Length > 0) hasPlotIn = "有"; if (p.AfterBattle.Length > 0) hasPlotAfter = "有"; textBoxHasPlot.Style.ForeColor = Color.Green; } textBoxHasPlot.Value = String.Format("{0}/{1}/{2}", hasPlotBefore, hasPlotIn, hasPlotAfter); row.Cells.Add(textBoxHasPlot); DataGridViewTextBoxCell textBoxNormalRewards = new DataGridViewTextBoxCell(); string hasRewards = "无"; if (levelConfig.ClientShowRewards.Length > 0) { hasRewards = "有"; textBoxNormalRewards.Style.ForeColor = Color.Green; } textBoxNormalRewards.Value = hasRewards; row.Cells.Add(textBoxNormalRewards); DataGridViewTextBoxCell textBoxEliteRewards = new DataGridViewTextBoxCell(); hasRewards = "无"; if (levelConfig.EliteClientShowRewards.Length > 0) { hasRewards = "有"; textBoxEliteRewards.Style.ForeColor = Color.Green; } textBoxEliteRewards.Value = hasRewards; row.Cells.Add(textBoxEliteRewards); dataGridView2.Rows.Add(row); }