Exemple #1
0
        public void GroupEngagementTest()
        {
            Player player = new Player();

            player.Name             = "GoodGuy";
            player.IsComputerPlayer = true;
            GameManager.Instance.GameData.InitAllData();
            Game game = GameManager.Instance.CreateGame(player, "test game");

            GameManager.Instance.GameData.LoadGameScenario("small", game);
            Player otherPlayer = player.Enemies[0];

            Assert.IsTrue(game.Players.Count == 2, "There should be two players in game.");
            //Assert.IsTrue(otherPlayer.Units.Count == 15, "Player 1 should have 15 units.");
            BaseUnit unit = player.GetUnitById("tag:main");

            Assert.IsNotNull(unit, "Unit with tag main should exist.");
            var wp = unit.MovementOrder.GetActiveWaypoint();

            Assert.IsNotNull(wp, "Main unit waypoint should not be null.");
            BaseUnitInfo info = unit.GetBaseUnitInfo();

            Assert.IsTrue(info.IsGroupMainUnit, "Main unit should be main unit");

            //foreach (var u in player.Units)
            //{
            //    if (string.IsNullOrEmpty(u.CurrentWeaponLoadName))
            //    {
            //        GameManager.Instance.Log.LogDebug(
            //            string.Format("Unit {0} has empty CurrentWeaponLoad.", u.ToShortString()));
            //    }
            //}
            game.IsNetworkEnabled                  = false;
            game.RealTimeCompressionFactor         = 10;
            GameManager.Instance.Game.RunGameInSec = 1;
            var sentryPlane = player.GetUnitById("tag:sentry");

            Assert.IsNotNull(sentryPlane, "Sentry plane should exist and not be null.");
            sentryPlane.SetSensorsActivePassive(GameConstants.SensorType.Radar, true);

            GameManager.Instance.Game.StartGamePlay();
            var detectedGroup = player.DetectedGroups.FirstOrDefault <DetectedGroup>();

            Assert.IsNotNull(detectedGroup, "Detected group should be found");
            var result = unit.EngageDetectedGroup(detectedGroup, GameConstants.EngagementOrderType.EngageNotClose, GameConstants.EngagementStrength.DefaultAttack, true);

            Assert.IsTrue(result, "EngageDetectedGroup should respond true");
        }