public bool AreAlliedOrEqual(NATIONALITY nationality1, NATIONALITY nationality2) { if (AllianceResult[(int)nationality1, (int)nationality2] == ALLIANCETYPE.Allied) { return(true); } return(nationality1 == nationality2); }
public void AddUnit(int Col, int Row, int unitType, NATIONALITY nationality) { _units.Add(Col, Row, unitType, nationality); if (nationality == NATIONALITY.USA) { var newUnit = _units.FindUnit(Col, Row); _terrainMap.UnmaskBoard(Col, Row, newUnit.ViewRange); _terrainMap.SetView(Col, Row, newUnit.ViewRange); } }
public void Add(int col, int row, int unitType, NATIONALITY nationality) { using (var scope = IocContainer.Container.BeginLifetimeScope()) { var unit = scope.Resolve <IUnit>(); unit.Row = row; unit.Col = col; unit.UnitType = unitType; unit.Nationality = nationality; _unitList.Add((Unit)unit); } }
public void SetTurn(NATIONALITY nationality) { CurrentTurn = nationality; foreach (var unit in _unitList) { if (unit.Nationality == nationality) { unit.NewTurn(); } } }
public bool IsTurnComplete(NATIONALITY nationality) { foreach (var unit in _unitList) { if (unit.Nationality == nationality) { if (!unit.TurnComplete) { return(false); } } } return(true); }
public Unit FindNextUnit(Unit previousUnit, NATIONALITY nationality) { if (previousUnit == null) { // find the first available unit in the units list foreach (var currentUnit in _unitList) { if (currentUnit.Nationality == nationality) { if (currentUnit.TurnComplete == false) { return(currentUnit); } } } } else { // find the next unit in the units list int currentUnit = -1; for (int i = 0; i < _unitList.Count; i++) { if (_unitList[i].UnitNumber == previousUnit.UnitNumber) { currentUnit = i; break; } } if (currentUnit > -1) { for (int i = currentUnit + 1; i < _unitList.Count; i++) { if (_unitList[i].Nationality == nationality) { if (_unitList[i].TurnComplete == false) { return(_unitList[i]); } } } } } return(null); }
public int FindClosestUnassignedUnit(int col, int row, NATIONALITY nationality) { var liDistance = double.MaxValue; // just make sure this is bigger than the map board var liClosestUnit = -1; for (var i = 0; i < _unitList.Count; i++) { if (_unitList[i].Nationality == nationality && _unitList[i].Command == UNITCOMMAND.None) { if (_unitList[i].Col != col && _unitList[i].Row != row) { var liTempDistance = BattleFieldOneCommonObjects.Distance(col, row, _unitList[i].Col, _unitList[i].Row); if (liTempDistance < liDistance) { liDistance = liTempDistance; liClosestUnit = i; } } } } return(liClosestUnit); }
public bool AreEnemies(NATIONALITY nationality1, NATIONALITY nationality2) { return(AllianceResult[(int)nationality1, (int)nationality2] == ALLIANCETYPE.Enemy); }
public bool AreAllied(NATIONALITY nationality1, NATIONALITY nationality2) { return(AllianceResult[(int)nationality1, (int)nationality2] == ALLIANCETYPE.Allied); }
public void SetEnemies(NATIONALITY nationality1, NATIONALITY nationality2) { AllianceResult[(int)nationality1, (int)nationality2] = ALLIANCETYPE.Enemy; AllianceResult[(int)nationality2, (int)nationality1] = ALLIANCETYPE.Enemy; }
/// <summary> /// set alliance between two nationalities /// </summary> /// <param name="nationality1"></param> /// <param name="nationality2"></param> public void SetAlliance(NATIONALITY nationality1, NATIONALITY nationality2) { AllianceResult[(int)nationality1, (int)nationality2] = ALLIANCETYPE.Allied; AllianceResult[(int)nationality2, (int)nationality1] = ALLIANCETYPE.Allied; }